Example #1
0
        private void Form_WelderBelong_ImportFromExcel_Load(object sender, EventArgs e)
        {
            string str_ErrMessage;

            str_ErrMessage = this.CheckSchema_DataTable();
            if (!string.IsNullOrEmpty(this.CheckSchema_DataTable()))
            {
                MessageBox.Show(str_ErrMessage);
                this.Close();
                return;
            }
            DataRow[] myDataRow_Range;
            //myDataRow_Range = this.myDataTable.Select("(len(IdentificationCard)=15 or len(IdentificationCard)=18) and len(WelderName)>0 and (Sex='男' or Sex='女') and len(Schooling)>0 and len(WelderBelongEmployer)>0");
            myDataRow_Range = this.myDataTable.Select("len(IdentificationCard)>0 and len(WelderName)>0 and len(Schooling)>0 and len(WelderBelongEmployer)>0");
            DataTable myDataTable_Temp = this.myDataTable.Clone();

            foreach (DataRow myDataRow in myDataRow_Range)
            {
                myDataTable_Temp.ImportRow(myDataRow);
            }
            this.myDataTable = myDataTable_Temp;

            if (Class_Data.GetDistinctField(this.myDataTable, "IdentificationCard").Rows.Count != this.myDataTable.Rows.Count)
            {
                MessageBox.Show("数据表中有重复的身份证号码!");
                this.Close();
            }
            DataColumn[] keys = new DataColumn[1];
            keys[0] = this.myDataTable.Columns["IdentificationCard"];
            this.myDataTable.PrimaryKey       = keys;
            this.dataGridView_Data.DataSource = new DataView(this.myDataTable);
            this.label_Data.Text = string.Format("焊工信息,({0}):", this.dataGridView_Data.RowCount);
        }
        private void Form_StudentQC_ImportFromExcel_Load(object sender, EventArgs e)
        {
            string str_ErrMessage;

            str_ErrMessage = this.CheckSchema_DataTable();
            if (!string.IsNullOrEmpty(this.CheckSchema_DataTable()))
            {
                MessageBox.Show(str_ErrMessage);
                this.Close();
                return;
            }
            DataRow[] myDataRow_Range;
            //myDataRow_Range = this.myDataTable.Select("(len(IdentificationCard)=15 or len(IdentificationCard)=18) and len(WelderName)>0 and (Sex='男' or Sex='女') and len(Schooling)>0 and len(WelderEmployer)>0 and len(ExamSubjectID)=4");
            myDataRow_Range = this.myDataTable.Select("len(IdentificationCard)>0 and len(WelderName)>0 and len(Schooling)>0 and len(WelderEmployer)>0");
            DataTable myDataTable_Temp = this.myDataTable.Clone();

            foreach (DataRow myDataRow in myDataRow_Range)
            {
                myDataTable_Temp.ImportRow(myDataRow);
            }
            this.myDataTable = myDataTable_Temp;

            string[] str_fieldNameArray = new string [2];
            str_fieldNameArray[0] = "IssueNo";
            str_fieldNameArray[1] = "IdentificationCard";
            if (Class_Data.GetDistinctField(this.myDataTable, str_fieldNameArray).Rows.Count != this.myDataTable.Rows.Count)
            {
                MessageBox.Show("数据表中同一班级编号下有重复的身份证号码!");
                this.Close();
            }
            this.dataGridView_Data.DataSource = new DataView(this.myDataTable);
            this.label_Data.Text = string.Format("报名学员,({0}):", this.dataGridView_Data.RowCount);
        }