private void Students_Blacklist_Load(object sender, EventArgs e) { ctr.ColorDataGridView(dgv_blacklist); string mysql = "SELECT * FROM [Tutors] WHERE 是否黑名单='是' ORDER BY 教员编号 DESC"; DataSet mydataset = mydb.ExecuteQuery(mysql, "Tutors"); dgv_blacklist.DataSource = mydataset.Tables["Tutors"]; dgv_blacklist.Columns[0].Visible = false; dgv_blacklist.Columns[10].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; }
private void Today_Form_Load(object sender, EventArgs e) { CCTRS ctr = new CCTRS(); ctr.ColorDataGridView(dgv_form); string mysql = "SELECT 打印编号,学员性别,年级科目,家教地址简单 as 家教地址,家教时间,concat((CASE WHEN 教员要求性别='' THEN NULL ELSE concat(教员要求性别,' ') END)," + "(CASE WHEN 教员要求地域 = '' THEN '' ELSE concat(教员要求地域, ' ') END)," + "(CASE WHEN 教员要求年级 = '' THEN '' ELSE concat(教员要求年级, ' ') END)," + "(CASE WHEN 教员要求专业 = '' THEN '' ELSE concat(教员要求专业, ' ') END)," + "(CASE WHEN 教员要求其他 = '' THEN '' ELSE concat(教员要求其他, ' ') END)) as 教员要求 FROM [Parents] WHERE 家教状态='接入' OR 家教状态='换人' OR 家教状态='重请' " + "ORDER BY 打印编号 DESC"; DataSet mydataset = mydb.ExecuteQuery(mysql, "Parents"); dgv_form.DataSource = mydataset.Tables["Parents"]; dgv_form.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; }
public void bind(DataGridView dgv, string mystr, string tb)//绑定数据的自定义方法 { CommDB mydb = new CommDB(); DataSet mydataset = mydb.ExecuteQuery(mystr, tb); dgv.DataSource = mydataset.Tables[tb]; }
private void inquire() { if (txt_student_num.Text == "" && txt_tutors_name.Text == "" && txt_tutors_num.Text == "" && txt_phone.Text == "") { CmbDataGridview cmbd = new CmbDataGridview(); cmbd.bind(dgv_inquire, mystr, "Tutors"); return; } CommDB mydb = new CommDB(); string mysql = "", tempstr = ""; if (txt_tutors_num.Text != "") { tempstr = "教员编号 Like '%" + txt_tutors_num.Text.Trim() + "%'"; } if (txt_tutors_name.Text != "") { if (tempstr == "") { tempstr = "姓名 Like '%" + txt_tutors_name.Text.Trim() + "%'"; } else { tempstr += " AND 姓名 Like '%" + txt_tutors_name.Text.Trim() + "%'"; } } if (txt_student_num.Text != "") { if (tempstr == "") { tempstr = "学号 Like '%" + txt_student_num.Text.Trim() + "%'"; } else { tempstr += " AND 学号 Like '%" + txt_student_num.Text.Trim() + "%'"; } } if (txt_phone.Text != "") { if (tempstr == "") { tempstr = "联系方式 Like '%" + txt_phone.Text.Trim() + "%'"; } else { tempstr += " AND 联系方式 Like '%" + txt_phone.Text.Trim() + "%'"; } } if (tempstr == "") { mysql = "SELECT * FROM [Tutors] ORDER BY 教员编号"; } else { mysql += "SELECT * FROM [Tutors] WHERE " + tempstr + " ORDER BY 教员编号 DESC"; } DataSet mydataset = mydb.ExecuteQuery(mysql, "Tutors"); dgv_inquire.DataSource = mydataset.Tables["Tutors"]; }
private void btn_prepared_Click(object sender, EventArgs e) { CommDB mydb = new CommDB(); string mysql = "SELECT ID,家长编号,打印编号,家长称呼,联系方式," + "年级科目,学员性别,家教状态,经办时间,家教价格,家教时间,家教地址详细,重要备注,缴费状态,缴费时间 FROM [Parents] WHERE 家教状态='待接' ORDER BY 经办时间 DESC"; DataSet mydataset = mydb.ExecuteQuery(mysql, "Parents"); dgv_track.DataSource = mydataset.Tables["Parents"]; }
public void cboDataBind(ComboBox cbo, string cmdText, string tb, string DisplayFied) { CommDB mydb = new CommDB(); DataSet mydataset; // string mystr = "SELECT distinct 接待人 FROM [Table]"; mydataset = mydb.ExecuteQuery(cmdText, tb); cbo.DataSource = mydataset.Tables[tb]; cbo.DisplayMember = DisplayFied; }
private void btn_check_Click(object sender, EventArgs e) { if (txt_parentnum.Text.Trim() == "" && txt_print_num.Text.Trim() == "" && txt_time.Text.Trim() == "") { CmbDataGridview cmbd = new CmbDataGridview(); cmbd.bind(dgv_responsibility, mystr, "Responsibility"); return; } string mysql = "", tempstr = ""; if (txt_parentnum.Text != "") { tempstr = "家长编号 Like '%" + txt_parentnum.Text.Trim() + "%'"; } if (txt_print_num.Text != "") { if (tempstr == "") { tempstr = "打印编号 Like '%" + txt_print_num.Text.Trim() + "%'"; } else { tempstr += " AND 打印编号 Like '%" + txt_print_num.Text.Trim() + "%'"; } } if (txt_time.Text != "") { if (tempstr == "") { tempstr = "经办时间 Like '%" + txt_time.Text.Trim() + "%'"; } else { tempstr += " AND 经办时间 Like '%" + txt_time.Text.Trim() + "%'"; } } if (tempstr == "") { mysql = "SELECT 家长编号,打印编号,经办状态,经办时间,经办人,处理备注 FROM [Responsibility] ORDER BY 经办时间 DESC"; } else { mysql += "SELECT 家长编号,打印编号,经办状态,经办时间,经办人,处理备注 FROM [Responsibility] WHERE " + tempstr + " ORDER BY 经办时间 DESC"; } DataSet mydataset = mydb.ExecuteQuery(mysql, "Responsibility"); dgv_responsibility.DataSource = mydataset.Tables["Responsibility"]; }
private void inquire() { if (txt_parentnum.Text == "" && txt_printnum.Text == "" && txt_adr.Text == "" && txt_phone.Text == "") { CmbDataGridview cmbd = new CmbDataGridview(); cmbd.bind(dgv_inquire, mystr, "Parents"); return; } CommDB mydb = new CommDB(); string mysql = "", tempstr = ""; if (txt_parentnum.Text != "") { tempstr = "家长编号 Like '%" + txt_parentnum.Text.Trim() + "%'"; } if (txt_printnum.Text != "") { if (tempstr == "") { tempstr = "打印编号 Like '%" + txt_printnum.Text.Trim() + "%'"; } else { tempstr += " AND 打印编号 Like '%" + txt_printnum.Text.Trim() + "%'"; } } if (txt_adr.Text != "") { if (tempstr == "") { tempstr = "家教地址详细 Like '%" + txt_adr.Text.Trim() + "%'"; } else { tempstr += " AND 家教地址详细 Like '%" + txt_adr.Text.Trim() + "%'"; } } if (txt_phone.Text != "") { if (tempstr == "") { tempstr = "联系方式 Like '%" + txt_phone.Text.Trim() + "%'"; } else { tempstr += " AND 联系方式 Like '%" + txt_phone.Text.Trim() + "%'"; } } if (tempstr == "") { mysql = "SELECT ID,家长编号,打印编号,家长称呼,联系方式," + "年级科目,学员性别,家教状态,经办时间,家教价格,家教时间,家教地址详细,重要备注,缴费状态,缴费时间 FROM [Parents] ORDER BY 打印编号"; } else { mysql += "SELECT ID,家长编号,打印编号,家长称呼,联系方式," + "年级科目,学员性别,家教状态,经办时间,家教价格,家教时间,家教地址详细,重要备注,缴费状态,缴费时间 FROM [Parents] WHERE " + tempstr + " ORDER BY 打印编号 DESC"; } DataSet mydataset = mydb.ExecuteQuery(mysql, "Parents"); dgv_inquire.DataSource = mydataset.Tables["Parents"]; }