private void Form_Student_Update_Load(object sender, EventArgs e) { if (!(this.bool_Add || Class_Student.ExistAndCanDeleteAndDelete(myClass_Student.ExaminingNo, Enum_zwjKindofUpdate.Exist))) { MessageBox.Show("不存在该项,可能已删除!"); this.DialogResult = DialogResult.Cancel; this.Close(); return; } this.label_ErrMessage.Text = ""; if (!Class_zwjPublic.myBackColor.IsEmpty) { this.BackColor = Class_zwjPublic.myBackColor; } this.checkBox_Continuous.Visible = this.bool_Add; this.userControl_StudentBase1.InitControl(this.myClass_Student, this.bool_Add); }
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); }