private void button_OnOK_Click(object sender, EventArgs e) { this.userControl_QCBase1.FillClass(); String str_ErrMessage; str_ErrMessage = this.myClass_QC.CheckField(); if (str_ErrMessage != null) { this.DialogResult = DialogResult.None; this.label_ErrMessage.Text = str_ErrMessage; return; } if (this.bool_Add) { if (Class_QC.ExistAndCanDeleteAndDelete(this.myClass_QC.ExaminingNo, Enum_zwjKindofUpdate.Exist)) { this.label_ErrMessage.Text = "证书已添加!"; this.DialogResult = DialogResult.None; return; } if ((!string.IsNullOrEmpty(this.myClass_QC.CertificateNo)) && Class_QC.ExistSecond(this.myClass_QC.CertificateNo, null, Enum_zwjKindofUpdate.Exist)) { this.label_ErrMessage.Text = "证号不能重复!"; this.DialogResult = DialogResult.None; return; } if (!this.myClass_QC.AddAndModify(Enum_zwjKindofUpdate.Add)) { this.label_ErrMessage.Text = "添加不成功,可能是证号重复!"; this.DialogResult = DialogResult.None; return; } } else { if (Class_QC.ExistSecond(this.myClass_QC.CertificateNo, this.myClass_QC.ExaminingNo, Enum_zwjKindofUpdate.Modify)) { this.DialogResult = DialogResult.None; this.label_ErrMessage.Text = "证号不能重复!"; return; } this.myClass_QC.AddAndModify(Enum_zwjKindofUpdate.Modify); } }
private void InitDataGridView2015() { OpenFileDialog myForm = new OpenFileDialog(); myForm.Filter = "data files (*.data)|*.data|All files (*.*)|*.*"; myForm.RestoreDirectory = true; if (myForm.ShowDialog() != DialogResult.OK) { return; } DataTable myDataTable_Temp = new DataTable(); ADODB.Recordset rs = new ADODB.Recordset(); rs.Open(myForm.FileName, Type.Missing, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, 0); OleDbDataAdapter myAdapter = new OleDbDataAdapter(); myAdapter.Fill(myDataTable_Temp, rs); rs.Close(); this.myDataTable = myDataTable_Temp.Clone(); this.myDataTable_NotValid = myDataTable_Temp.Clone(); bool bool_Valid; foreach (DataRow myDataRow in myDataTable_Temp.Rows) { bool_Valid = true; if (string.IsNullOrEmpty(myDataRow["CerNo"].ToString())) { bool_Valid = false; } if (!Class_Student.ExistAndCanDeleteAndDelete(myDataRow["WelderMarkNo"].ToString(), Enum_zwjKindofUpdate.Exist)) { bool_Valid = false; } else { if (Class_QC.ExistAndCanDeleteAndDelete(myDataRow["WelderMarkNo"].ToString(), Enum_zwjKindofUpdate.Exist)) { bool_Valid = false; } else { if (Class_QC.ExistSecond(myDataRow["CerNo"].ToString(), null, Enum_zwjKindofUpdate.Add)) { bool_Valid = false; } else { } } } if (bool_Valid) { this.myDataTable.ImportRow(myDataRow); } else { this.myDataTable_NotValid.ImportRow(myDataRow); } } this.dataGridView_Data.DataSource = this.myDataTable; this.dataGridView_NotValid.DataSource = this.myDataTable_NotValid; this.label_Data.Text = string.Format("可以导入的数据,{0}", this.dataGridView_Data.RowCount); this.label_NotValid.Text = string.Format("不能导入的数据,{0}", this.dataGridView_NotValid.RowCount); }
private void InitDataGridView() { OpenFileDialog myForm = new OpenFileDialog(); myForm.Filter = "Access files (*.mdb)|*.mdb"; myForm.RestoreDirectory = true; if (myForm.ShowDialog() != DialogResult.OK) { return; } string str_Conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + myForm.FileName + ";Persist Security Info=True"; string str_SQL; str_SQL = "Select * From TB_Certificate_Info"; DataTable myDataTable_Temp = new DataTable(); OleDbDataAdapter myAdapter = new OleDbDataAdapter(str_SQL, str_Conn); myAdapter.Fill(myDataTable_Temp); this.myDataTable = myDataTable_Temp.Clone(); this.myDataTable_NotValid = myDataTable_Temp.Clone(); bool bool_Valid; foreach (DataRow myDataRow in myDataTable_Temp.Rows) { bool_Valid = true; if (string.IsNullOrEmpty(myDataRow["CerNo"].ToString())) { bool_Valid = false; } if (!Class_Student.ExistAndCanDeleteAndDelete(myDataRow["WelderMarkNo"].ToString(), Enum_zwjKindofUpdate.Exist)) { bool_Valid = false; } else { if (Class_QC.ExistAndCanDeleteAndDelete(myDataRow["WelderMarkNo"].ToString(), Enum_zwjKindofUpdate.Exist)) { bool_Valid = false; } else { if (Class_QC.ExistSecond(myDataRow["CerNo"].ToString(), null, Enum_zwjKindofUpdate.Add)) { bool_Valid = false; } else { } } } if (bool_Valid) { this.myDataTable.ImportRow(myDataRow); } else { this.myDataTable_NotValid.ImportRow(myDataRow); } } this.dataGridView_Data.DataSource = this.myDataTable; this.dataGridView_NotValid.DataSource = this.myDataTable_NotValid; this.label_Data.Text = string.Format("可以导入的数据,{0}", this.dataGridView_Data.RowCount); this.label_NotValid.Text = string.Format("不能导入的数据,{0}", this.dataGridView_NotValid.RowCount); }
private void button_Modify_Click(object sender, EventArgs e) { if (this.myDataTable_Modified.Rows.Count > 0) { MessageBox.Show("请先重置后再进行填充操作!"); return; } if (string.IsNullOrEmpty(this.MaskedTextBox_NextCertificateNo.Text)) { MessageBox.Show("证号起始不能为空!"); return; } if (string.IsNullOrEmpty(this.TextBox_SupervisionPlace.Text)) { MessageBox.Show("考察地点不能为空!"); return; } Class_Issue myClass_Issue = new Class_Issue(this.str_IssueNo); Class_ShipClassification myClass_ShipClassification = new Class_ShipClassification(myClass_Issue.ShipClassificationAb); Class_Ship myClass_Ship = new Class_Ship(); if (myClass_ShipClassification.ShipRestrict) { myClass_Ship = new Class_Ship(myClass_Issue.ShipboardNo); } DataRow myDataRow; DataRow myNewRow; DataView myDataView_Temp = new DataView(this.myDataTable_Origin); myDataView_Temp.RowFilter = "Checked = true and ((TheoryResultNeed=true and (TheoryResult>=PassScore or TheoryMakeupResult>=PassScore)) or TheoryResultNeed=false) and ((SkillResultNeed=true and (SkillResult Or SkillMakeupResult)) or SkillResultNeed=false) And CertificateNo is Null"; myDataView_Temp.Sort = "ExaminingNo"; foreach (DataRowView myDataRowView in myDataView_Temp) { //if (Class_QC.ExistAndCanDeleteAndDelete (this.MaskedTextBox_NextCertificateNo.Text, Enum_zwjKindofUpdate.Exist)) //{ // MessageBox.Show("该证号已使用!"); // return; //} if (Class_QC.ExistSecond(this.MaskedTextBox_NextCertificateNo.Text, null, Enum_zwjKindofUpdate.Add)) { MessageBox.Show("该证号已使用!"); return; } myDataRow = myDataTable_Origin.Rows.Find(myDataRowView["ExaminingNo"].ToString()); this.myDataTable_Modified.ImportRow(myDataRow); myNewRow = myDataTable_Modified.Rows.Find(myDataRowView["ExaminingNo"].ToString()); myNewRow["CertificateNo"] = this.MaskedTextBox_NextCertificateNo.Text; myNewRow["SupervisionPlace"] = this.TextBox_SupervisionPlace.Text; myNewRow["OriginalPeriod"] = this.NumericUpDown_OriginalPeriod.Value; myNewRow["PeriodofValidity"] = this.NumericUpDown_OriginalPeriod.Value; myNewRow["IssuedOn"] = this.DateTimePicker_IssuedOn.Value; if (myClass_ShipClassification.ShipRestrict) { this.MaskedTextBox_NextCertificateNo.Text = Class_Tools.GetNextSequence(this.MaskedTextBox_NextCertificateNo.Text, myClass_Ship.CertificateNoSignificantDigit); } else { this.MaskedTextBox_NextCertificateNo.Text = Class_Tools.GetNextSequence(this.MaskedTextBox_NextCertificateNo.Text, myClass_ShipClassification.CertificateNoSignificantDigit); } } this.label_Modified.Text = string.Format("新证书:({0})", this.dataGridView_Modified.RowCount); MessageBox.Show("填充完毕!"); }