private void button_OnOK_Click(object sender, EventArgs e) { if (this.myDataTable == null) { this.DialogResult = DialogResult.None; this.label_ErrMessage.Text = "没有添加焊工!"; return; } string str_ErrMessage; Class_KindofEmployerStudent myClass_KindofEmployerStudent; foreach (DataRow myDataRow in this.myDataTable.Rows) { myDataRow["WelderRemark"] = ""; myClass_KindofEmployerStudent = new Class_KindofEmployerStudent(); myClass_KindofEmployerStudent.KindofEmployerIssueID = this.int_KindofEmployerIssueID; myClass_KindofEmployerStudent.KindofEmployerWelderID = (int)myDataRow["KindofEmployerWelderID"]; myClass_KindofEmployerStudent.ExamSubjectID = this.TextBox_SubjectID.Text; if (Class_KindofEmployerStudent.ExistSecond(myClass_KindofEmployerStudent.KindofEmployerIssueID, myClass_KindofEmployerStudent.KindofEmployerWelderID, 0, Enum_zwjKindofUpdate.Add)) { myDataRow["WelderRemark"] = "学员不能重复!"; } else { str_ErrMessage = myClass_KindofEmployerStudent.CheckField(); if (string.IsNullOrEmpty(str_ErrMessage)) { myClass_KindofEmployerStudent.AddAndModify(Enum_zwjKindofUpdate.Add); this.bool_Updated = true; } else { myDataRow["WelderRemark"] = str_ErrMessage; } } } DataRow[] myDataRowRange = this.myDataTable.Select("WelderRemark = '' or WelderRemark is null"); if (myDataRowRange.Length < this.myDataTable.Rows.Count) { this.label_ErrMessage.Text = "有数据不合法!请查看备注信息"; this.DialogResult = DialogResult.None; } foreach (DataRow myDataRow in myDataRowRange) { myDataRow.Delete(); } this.myDataTable.AcceptChanges(); }