private void txtClass_KeyPress(object sender, KeyPressEventArgs e) { if (EmptyUI.IsChinese(e.KeyChar.ToString()) == false && e.KeyChar != (char)8 && !(char.IsNumber(e.KeyChar))) { MessageBox.Show("请输入文字或数字!", "提示"); e.Handled = true; } }
private void txtStudentName_KeyPress(object sender, KeyPressEventArgs e) { if (EmptyUI.IsChinese(e.KeyChar.ToString()) == false && e.KeyChar != (char)8) { MessageBox.Show("请输入文字!", "提示"); e.Handled = true; } }
private void txtUserID_KeyPress(object sender, KeyPressEventArgs e) { if (!(char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8 && EmptyUI.isEnlish(e.KeyChar.ToString()) == false) { MessageBox.Show("请输入数字或英文字符!", "提示"); e.Handled = true; } }
private void txtContext3_KeyPress(object sender, KeyPressEventArgs e) { if (cmbFields3.Text == "年级" || cmbFields3.Text == "班级") { if (EmptyUI.IsChinese(e.KeyChar.ToString()) == false && e.KeyChar != (char)8 && !(char.IsNumber(e.KeyChar))) { MessageBox.Show("请输入文字或数字!", "提示"); e.Handled = true; } } else { if (cmbFields3.Text == "卡号" || cmbFields3.Text == "学号" || cmbFields3.Text == "消费金额" || cmbFields3.Text == "余额") { if (!(char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8) { MessageBox.Show("请输入数字!", "提示"); e.Handled = true; } } } }
private void btOk_Click(object sender, EventArgs e) { //每次点击按钮前先清空dgv dataGridView1.DataSource = null; //1 没有组合的查询判空 //限制输入不能为空 if (cmbRelation1.Text == "") { Control[] arrcontrol = new Control[3]; arrcontrol[0] = cmbFields1; arrcontrol[1] = cmbOperator1; arrcontrol[2] = txtContext1; //调用函数判断控件中的内容是否为空 //EmptyUI.ISsomeEmpty(arrcontrol); bool falg; falg = EmptyUI.ISsomeEmpty(arrcontrol); if (falg == true) { MessageBox.Show("内容填写不完整,请核对后再查询!"); enGroupQuery = null; return; } } else { if (cmbRelation2.Text == "") { //2 开始第一个组合的查询判空 Control[] arrcontrol2 = new Control[6]; arrcontrol2[0] = cmbFields1; arrcontrol2[1] = cmbOperator1; arrcontrol2[2] = txtContext1; arrcontrol2[3] = cmbFields2; arrcontrol2[4] = cmbOperator2; arrcontrol2[5] = txtContext2; bool falg; falg = EmptyUI.ISsomeEmpty(arrcontrol2); if (falg == true) { MessageBox.Show("内容填写不完整,请核对后再查询!"); enGroupQuery = null; return; } } else { //开始第三个条件的组合查询 Control[] arrcontrol3 = new Control[9]; arrcontrol3[0] = cmbFields1; arrcontrol3[1] = cmbOperator1; arrcontrol3[2] = txtContext1; arrcontrol3[3] = cmbFields2; arrcontrol3[4] = cmbOperator2; arrcontrol3[5] = txtContext2; arrcontrol3[6] = cmbFields3; arrcontrol3[7] = cmbOperator3; arrcontrol3[8] = txtContext3; //EmptyUI.ISsomeEmpty(arrcontrol3); bool falg; falg = EmptyUI.ISsomeEmpty(arrcontrol3); if (falg == true) { MessageBox.Show("内容填写不完整,请核对后再查询!"); enGroupQuery = null; return; } } } //将参数传递给实体 //Entity.GroupQuery enGroupQuery = new Entity.GroupQuery(); enGroupQuery = new Entity.GroupQuery(); enGroupQuery.fileds1 = ToName(cmbFields1.Text); enGroupQuery.fileds2 = ToName(cmbFields2.Text); enGroupQuery.fileds3 = ToName(cmbFields3.Text); enGroupQuery.Operator1 = cmbOperator1.Text; enGroupQuery.Operator2 = cmbOperator2.Text; enGroupQuery.Operator3 = cmbOperator3.Text; enGroupQuery.Context1 = txtContext1.Text.Trim(); enGroupQuery.Context2 = txtContext2.Text.Trim(); enGroupQuery.Context3 = txtContext3.Text.Trim(); enGroupQuery.Relation1 = ToName(cmbRelation1.Text); enGroupQuery.Relation2 = ToName(cmbRelation2.Text); enGroupQuery.table = Getdbtable(); ////调用子类的查询,返回不同的查询结果 ////IList<Entity.GroupQuery> LgroupQuery = new BindingList<Entity.GroupQuery>(); //DataTable LgroupQuery = new DataTable(); //Facade.GroupQueryFacade GroupQuery = new Facade.GroupQueryFacade(); //LgroupQuery = GroupQuery.GroupQuery(enGroupQuery); ////dataGridView1.AutoGenerateColumns = false; //if (LgroupQuery.Rows.Count > 0) //{ // dataGridView1.DataSource = LgroupQuery; //} }