双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

combox条件选中的问题

bulls5988 bulls5988 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
FORM1用来修改DataGridView里选中的ID内容,里面有几个文本框和一个combox1,表(staff_card)是存放卡资料的,其中有一个字段(card_type)是卡类型;比如“会员卡”,FORM1_LOAD的时候遍历了一张专门存放卡类型的表(feecard_type),里面有“金卡”、“会员卡”、“员工卡”等。我在FORM1_Load的时候已经把feecard_type里的所有卡类型遍历进combox1里了。

要在FORM1_LOAD的时候,如果被修改的这条记录中卡类型,为“会员卡”,那么combox1中的"会员卡"同时被选中。 //我修改的记录中卡类型内容和combox1中内容相同时,combox1中的这个条记录被选中。


//已经把所有feecard_type中所有的卡类型遍历进了combox1了
string card_class_sql = "select * from feecard_type_card order by card_id asc";
SqlConnection class_conn = new SqlConnection(fee_conn.sql_conn());
DataSet combox = new DataSet();
class_conn.Open();
SqlDataAdapter mycmd = new SqlDataAdapter(card_class_sql, class_conn);
mycmd.Fill(combox, "ds");
class_conn.Close();

comboBox1.DataSource = combox.Tables[0];
comboBox1.DisplayMember = "card_name";
comboBox1.ValueMember = "card_fee";
comboBox1.SelectedIndex = 0;

fee_id = int.Parse(park_fee_staffeditcard.staff_id);
string e_sql = "select * from staff_card where
staff_value_id = '" + fee_id + "'";
//在staff_card表中根据上一个窗体传递的ID查找卡资料
SqlConnection e_conn = new SqlConnection(fee_conn.sql_conn());
SqlCommand e_select = new SqlCommand(e_sql, e_conn);
try
{
e_conn.Open();
}
catch (System.Exception)
{
MessageBox.Show( MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
SqlDataReader e_rs = e_select.ExecuteReader();
{
if (e_rs.Read())
{
//

}
}


...全文
评论 8
收藏 已收藏
分享
返回顶部
bulls5988
C# 111,129 成员 642,540 内容