private void button2_Click(object sender, EventArgs e) { //必须选中一行 if (pageCtrl.dg.CurrentRow == null) { MessageBox.Show("请选择一条记录"); } else { //获取选中行的信息 填充到对象中 Examination exam = new Examination(); exam.ExamCat = Convert.ToString(pageCtrl.dg.CurrentRow.Cells[2].Value.ToString()); exam.ExamName = pageCtrl.dg.CurrentRow.Cells[1].Value.ToString(); exam.StartTime = pageCtrl.dg.CurrentRow.Cells[3].Value.ToString(); exam.TotalMins = Convert.ToInt32(pageCtrl.dg.CurrentRow.Cells[4].Value.ToString()); exam.ExType = "1"; exam.ExaminationId = Convert.ToInt32(pageCtrl.dg.CurrentRow.Cells[0].Value.ToString()); exam.Num = Convert.ToInt32(pageCtrl.dg.CurrentRow.Cells[6].Value.ToString()); exam.ExType_lx = Convert.ToString(pageCtrl.dg.CurrentRow.Cells[7].Value.ToString()); AddExam addExam = new AddExam(exam); addExam.bodyExam = this; addExam.ShowDialog(); } }
private void button1_Click(object sender, EventArgs e) { AddExam addExam = new AddExam(null); addExam.bodyExam = this; addExam.ShowDialog(); }