//填报志愿按钮 private void button5_Click(object sender, EventArgs e) { BLL.wish Wish = new BLL.wish(); Model.wish model = new Model.wish(); model.First = comboBox6.Text; model.Second = comboBox5.Text; model.Third = comboBox4.Text; if (Wish.update(model, UserName) == true) { MessageBox.Show("更新成功!"); } }
public Model.wish select(string UserName) { string str = "select tb_first,tb_second,tb_third,tb_result from tb_wish where username=@UserName"; MySqlParameter[] parameters = { new MySqlParameter("@UserName", MySqlDbType.VarChar, 50) }; parameters[0].Value = UserName; Model.wish model = new Model.wish(); model.First = ""; model.Second = ""; model.Third = ""; model.Result = ""; DataTable dt = SqlDbHelper.ExecuteDataTable(str, CommandType.Text, parameters); if (dt.Rows.Count > 0) { if (dt.Rows[0]["tb_first"] != null && dt.Rows[0]["tb_first"].ToString() != "") { model.First = dt.Rows[0]["tb_first"].ToString(); } if (dt.Rows[0]["tb_second"] != null && dt.Rows[0]["tb_second"].ToString() != "") { model.Second = dt.Rows[0]["tb_second"].ToString(); } if (dt.Rows[0]["tb_third"] != null && dt.Rows[0]["tb_third"].ToString() != "") { model.Third = dt.Rows[0]["tb_third"].ToString(); } if (dt.Rows[0]["tb_result"] != null && dt.Rows[0]["tb_result"].ToString() != "") { model.Result = dt.Rows[0]["tb_result"].ToString(); } } return(model); }
public bool update(Model.wish model, string username) { string str = "update tb_wish set tb_first=@First,tb_second=@Second,tb_third=@Third,tb_result='' where username='******'"; MySqlParameter[] parameters = { new MySqlParameter("@First", MySqlDbType.VarChar, 50), new MySqlParameter("@Second", MySqlDbType.VarChar, 50), new MySqlParameter("@Third", MySqlDbType.VarChar, 50), }; parameters[0].Value = model.First; parameters[1].Value = model.Second; parameters[2].Value = model.Third; int rows = SqlDbHelper.ExecuteNonQuery(str, CommandType.Text, parameters); if (rows > 0) { return(true); } else { return(false); } }
//上方第四个按钮,结果查询 private void button4_Click(object sender, EventArgs e) { panel1.Visible = false; panel2.Visible = false; panel5.Visible = false; panel6.Visible = true; panel1.Size = panel6.Size; BLL.Stumes stumes = new BLL.Stumes(); Model.Stumes model = stumes.select(UserName); textBox12.Text = model.Name; textBox11.Text = model.Number; textBox10.Text = model.Major; textBox9.Text = model.Stuclass; BLL.wish Wish = new BLL.wish(); Model.wish wishModel = Wish.select(UserName); textBox5.Text = wishModel.First; textBox6.Text = wishModel.Second; textBox7.Text = wishModel.Third; textBox8.Text = wishModel.Result; }
public bool update(Model.wish model, string username) { return(Wish.update(model, username)); }