关于一个类与类之间变更传递值的问题
public void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)//下拉列表事件读取值
{
string order_byid;
if (this.DropDownList1.Text == "")
{
order_byid = "791000";//下拉列表为空,赋值791000
}
else
{
order_byid = this.DropDownList1.SelectedValue;//下拉列表不为空,赋下拉列表值
}
}
public void Button1_Click(object sender, EventArgs e)
{
if (this.r2.Checked == false && this.r1.Checked == false)
{
this.Label2.Text = "请选择机构类型";
this.Label2.Visible = true;
}
else if (this.order_id.Text == "")
{
this.Label2.Text = "请填入机构号";
this.Label2.Visible = true;
}
else if (this.order_name.Text == "")
{
this.Label2.Text = "请填入机构名称";
this.Label2.Visible = true;
}
else
{
string order_id = this.order_id.Text;
string order_name = this.order_name.Text;
string order_flag;
string conn = ConfigurationManager.AppSettings["strconn"];
OdbcConnection myconn = new OdbcConnection(conn);
myconn.Open();
string sql_add = "select * from orders where order_id='"+order_id+"'OR order_name='"+order_name+"'";
OdbcCommand myadd = new OdbcCommand(sql_add, myconn);
OdbcDataReader myaddread = myadd.ExecuteReader();
if (myaddread.HasRows)
{
this.Label2.Text = "有重复的机构号或机构名称";
this.Label2.Visible = true;
myaddread.Close();
myconn.Close();
}
else
{
DataSet ds = new DataSet();
OdbcDataAdapter da = new OdbcDataAdapter(sql_add, myconn);
OdbcCommandBuilder builder = new OdbcCommandBuilder(da);
da.Fill(ds,"orders");
DataRow tempr = ds.Tables["orders"].NewRow();
tempr["order_id"] =order_id;
tempr["order_name"] = order_name;
ds.Tables["orders"].Rows.Add(tempr);
da.Update(ds,"orders");
da.Dispose();
myaddread.Close(); //能正常运行
string sql="select * from orders where order_id='"+order_byid+"'";//这里读取的order_byid值是空值
OdbcCommand my=new OdbcCommand(sql,myconn);
OdbcDataReader myread=my.ExecuteReader();
order_byid = myread["order_byid"].ToString();//报错myread读取不存在此列/行
order_byname = myread["order_byname"].ToString();
string sql_update="update orders set order_byid='"+order_byid+"',order_byname='"+order_byname+"'where order_id='"+order_id+"'";
OdbcCommand myopen = new OdbcCommand(sql_update, myconn);
myop