/// <summary> /// 学生编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { if (dataGridView1.SelectedCells.Count < 1) { return; } var sub = studentManage.GetInfo((string)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[1].Value); var frm = new FrmStudentManage(sub); frm.ShowDialog(); button1_Click(null, null); }
private void button1_Click(object sender, EventArgs e) { if (Decimal.TryParse(textBox5.Text.Trim(), out decimal Achievement) == false) { MessageBox.Show("成绩 必须为数字"); return; } var Studentinfo = StudentManange.GetInfo(textBox1.Text.Trim()); if (Studentinfo == null) { MessageBox.Show("查无此人"); return; } StuSub info; if (Student == null) { info = new StuSub(); } else { //编辑 info = StudentManange.GetStuSubInfo(Student.id); } info.Sno = textBox1.Text; info.Batch = textBox4.Text; info.Achievement = Achievement; info.Code = comboBox1.SelectedValue.ToString(); try { StudentManange.SaveStuSub(info); MessageBox.Show("保存成功"); this.Close(); } catch (Exception ex) { MessageBox.Show("请检查输入内容。是否超长\n" + ex.Message); } }