private void ChangePatientBtn_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { MessageBox.Show("请选择一行"); return; } Intent.dict["ADD_OR_CHANGE"] = "CHANGE"; PatientEdit pe = new PatientEdit(); Patient p = new Patient(); p.SetValue( listView1.SelectedItems[0].SubItems[0].Text, listView1.SelectedItems[0].SubItems[1].Text, listView1.SelectedItems[0].SubItems[2].Text, listView1.SelectedItems[0].SubItems[3].Text ); pe.p = p; Intent.dict["OLD_ID"] = p.PID; if (pe.ShowDialog() == DialogResult.OK) { sqlString = @"" + " UPDATE [Patient]" + " SET" + " [PID]='" + p.PID + "'," + " [PName]='" + p.PName + "'," + " [Date]='" + p.Date + "'," + " [GroupNo]=" + p.GroupNo + " WHERE [PID]='" + Intent.dict["OLD_ID"] + "'"; db.SetBySQL(sqlString); } UpdateListView(); }
/* ################ Tab1 ################ */ private void AddPatientBtn_Click(object sender, EventArgs e) { Intent.dict["ADD_OR_CHANGE"] = "ADD"; PatientEdit pe = new PatientEdit(); if (pe.ShowDialog() == DialogResult.OK) { Patient p = pe.p; sqlString = @"" + " INSERT INTO [Patient]" + " VALUES" + " (" + " '" + p.PID + "'," + " '" + p.PName + "'," + " '" + p.Date + "'," + " " + p.GroupNo + "" + " )"; db.SetBySQL(sqlString); } UpdateListView(); }