private void dataGridView_student_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { Form_Student_appendModify form_Student_appendModify = new Form_Student_appendModify { isAppend = false, Text = "学员修改", name = dataGridView_student.Rows[e.RowIndex].Cells["姓名"].Value.ToString(), gender = dataGridView_student.Rows[e.RowIndex].Cells["性别"].Value.ToString(), idType = dataGridView_student.Rows[e.RowIndex].Cells["身份证明类型"].Value.ToString(), idNo = dataGridView_student.Rows[e.RowIndex].Cells["身份证明号码"].Value.ToString(), driverType = dataGridView_student.Rows[e.RowIndex].Cells["驾驶证类型"].Value.ToString(), schoolName = dataGridView_student.Rows[e.RowIndex].Cells["驾校名称"].Value.ToString() }; form_Student_appendModify.photoBytes[0] = null; form_Student_appendModify.photoBytes[1] = null; if (form_Student_appendModify.ShowDialog() == DialogResult.OK) { dataGridView_student.DataSource = mDBM.Select(__StudentViewSQL).Tables[0]; } } }
private void button_search_Click(object sender, EventArgs e) { string studentSQL = ""; if (!String.IsNullOrEmpty(textBox_name.Text)) { studentSQL += studentSQL == "" ? "" : " and "; studentSQL += "NAME='" + textBox_name.Text + "'"; } if (!string.IsNullOrEmpty(comboBox_gender.Text)) { studentSQL += studentSQL == "" ? "" : " and "; studentSQL += "GENDER_DICT_NAME='" + comboBox_gender.Text + "'"; } if (!string.IsNullOrEmpty(comboBox_idType.Text)) { studentSQL += studentSQL == "" ? "" : " and "; studentSQL += "IDTYPE_DICT_NAME='" + comboBox_idType.Text + "'"; } if (!string.IsNullOrEmpty(textBox_idNumber.Text)) { studentSQL += studentSQL == "" ? "" : " and "; studentSQL += "IDNUMBER='" + textBox_idNumber.Text + "'"; } if (!string.IsNullOrEmpty(comboBox_schoolName.Text)) { studentSQL += studentSQL == "" ? "" : " and "; studentSQL += "SCHOOL_NAME='" + comboBox_schoolName.Text + "'"; } if (!string.IsNullOrEmpty(comboBox_driverLicenseType.Text)) { studentSQL += studentSQL == "" ? "" : " and "; studentSQL += "DRIVER_LICENSE_TYPE='" + comboBox_driverLicenseType.Text + "'"; } studentSQL = __StudentViewSQL + (studentSQL == "" ? "" : " where " + studentSQL); dataGridView_student.DataSource = mDBM.Select(studentSQL).Tables[0]; //if (TrainingModeEnum.ByTime == TrainingMode) //{ // dataGridView_student.Columns["预约次数"].Visible = false; // dataGridView_student.Columns["剩余次数"].Visible = false; // dataGridView_student.Columns["预约时间"].Visible = true; // dataGridView_student.Columns["剩余时间"].Visible = true; //} //else //{ // dataGridView_student.Columns["预约次数"].Visible = true; // dataGridView_student.Columns["剩余次数"].Visible = true; // dataGridView_student.Columns["预约时间"].Visible = false; // dataGridView_student.Columns["剩余时间"].Visible = false; //} string[] names = mDBM.SelectArray(studentSQL); // 学员注册 if (names.Length == 0) { if (DialogResult.Yes == MessageBox.Show("学员不存在,是否注册", "提示", MessageBoxButtons.YesNo)) { Form_Student_appendModify form_Student_appendModify = new Form_Student_appendModify { isAppend = true, Text = "学员添加", name = textBox_name.Text, gender = comboBox_gender.Text, idType = comboBox_idType.Text, idNo = textBox_idNumber.Text, driverType = comboBox_driverLicenseType.Text, schoolName = comboBox_schoolName.Text }; form_Student_appendModify.photoBytes[0] = null; form_Student_appendModify.photoBytes[1] = null; if (form_Student_appendModify.ShowDialog() == DialogResult.OK) { dataGridView_student.DataSource = mDBM.Select(__StudentViewSQL).Tables[0]; } } else { return; } } }