private void load() { if (BOOL == choose.student) { button1.Text = "修改"; foreach (studentMessage ss in studentList.selectAllStudent()) { if (ss.id.Equals(s)) { show(); this.dgv.Columns.Add("电话", null); this.dgv.Columns.Add("宿舍号", null); this.dgv.Columns.Add("项目", null); this.dgv.Columns.Add("状态", null); this.dgv.Rows.Add(ss.phone, ss.dorms, ss.project, ss.states); stu = ss; } } } else { button1.Text = "修改报修状态"; MySqlConnection myConnection; myConnection = database.open(); MySqlDataAdapter ada = new MySqlDataAdapter("select *from student", myConnection); myConnection.Open(); DataSet ds = new DataSet(); ada.Fill(ds, "student"); //ds.Tables.Add(Get("https://localhost:44396/api/students/getStudent")); dgv.DataSource = ds; dgv.DataMember = "student"; myConnection.Close(); } }
private void button1_Click(object sender, EventArgs e) { int i; if (BOOL == choose.drom) { i = dgv.CurrentRow.Index; s = dgv.Rows[i].Cells["xuehao"].Value.ToString(); MessageBox.Show(s); foreach (studentMessage ss in studentList.selectAllStudent()) { if (ss.id.Equals(s)) { stu = ss; } } } alter a = new alter(stu, BOOL); a.Show(); }
public static List <studentMessage> selectAllStudent() { MySqlConnection myConnection; myConnection = database.open(); myConnection.Open(); MySqlCommand myCommand = new MySqlCommand("select *from student", myConnection); MySqlDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); while (myReader.Read()) { studentMessage sm = new studentMessage(); sm.id = myReader["xuehao"].ToString(); sm.name = myReader["name"].ToString(); sm.phone = myReader["phone"].ToString(); sm.dorms = myReader["sushehao"].ToString(); sm.project = myReader["xiangmu"].ToString(); sm.states = myReader["states"].ToString(); stu.Add(sm); } myConnection.Close(); return(stu); }
public alter(studentMessage s, int i) { this.s = s; this.i = i; InitializeComponent(); }