private void p_sale_Leave(object sender, EventArgs e) { if (this.s_psale.Text.Trim() == "") { return; } if (!InitFuncs.isRightValue(s_psale, "T_users", "username")) { MessageBox.Show("该人员不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_psale.Focus(); this.s_psale.Clear(); return; } }
private void s_Techuser_Leave(object sender, EventArgs e) { if (this.s_Techuser.Text.Trim() == "") { return; } if (!InitFuncs.isRightValue(s_Techuser, "T_Users", "userName")) { MessageBox.Show("该技术员不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_Techuser.Focus(); this.s_Techuser.Clear(); return; } }
private void T_CustID_Leave(object sender, EventArgs e) { if (this.T_CustID.Text.Trim() == "") { return; } if (!InitFuncs.isRightValue(T_CustID, "T_customerinf", "custName")) { MessageBox.Show("该客户名称不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.T_CustID.Focus(); this.s_CustID.Clear(); return; } s_CustID.Text = (new DBUtil()).Get_Single_val("T_CustomerInf", "custid", "custname", T_CustID.Text.Trim()); }
/// <summary> /// 检查控件中输入的“物料名称”是否存在数据库中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void MatName_Leave(object sender, EventArgs e) { Control control = sender as Control; string controlText = control.Text.Trim(); if (controlText == "") { return; } if (!InitFuncs.isRightValue(controlText, "T_MatInf", "MatName")) { MessageBox.Show("该物料名称不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); control.Focus(); control.Text = ""; return; } }
private void button1_Click(object sender, EventArgs e) { if (this.t_CustCode.Text.Trim() == "") { return; } if (!InitFuncs.isRightValue(t_CustCode, "T_customerinf", "custName")) { MessageBox.Show("该客户名称不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.t_CustCode.Focus(); return; } string bcustid_ = (new DBUtil()).Get_Single_val("T_CustomerInf", "custid", "custname", t_CustCode.Text.Trim()); string sql_ = "select Custid1 from T_CustBrotherRela where " + "(Custid1='" + bcustid_ + "' and Custid2='" + this.custid + "')" + " or (Custid2='" + bcustid_ + "' and Custid1='" + this.custid + "')"; bool isexist = (new DBUtil()).yn_exist_data(sql_); if (isexist) { MessageBox.Show("该关系已经存在!"); return; } else { sql_ = "insert into T_CustBrotherRela values('" + bcustid_ + "','" + this.custid + "')"; try { (new SqlDBConnect()).ExecuteNonQuery(sql_); show_dgv(); } catch { } } }
private void button1_Click(object sender, EventArgs e) { if (Util.ControlTextIsNUll(this.T_CustID)) { MessageBox.Show("客户名称不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.T_CustID.Focus(); return; } T_CustID_Leave(sender, e); T_Puser_Leave(sender, e); if (Util.ControlTextIsNUll(this.s_Mtype)) { MessageBox.Show("机型不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_Mtype.Focus(); return; } if (!InitFuncs.isRightValue(this.s_Mtype, "T_Model", "ModelName")) { MessageBox.Show("输入的机型不存在,请重新录入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_Mtype.Focus(); return; } if (Util.ControlTextIsNUll(this.s_Manufactcode)) { MessageBox.Show("机号不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_Manufactcode.Focus(); return; } //数据处理 InitFuncs inf = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string sqlexe = ""; string sql_ = ""; if (type == "add") { bool isExist = false; sql_ = "select CustID from T_CustomerMac where CustID='" + this.custid + "' and Mtype='" + this.s_Mtype.Text.Trim() + "' and Manufactcode='" + this.s_Manufactcode.Text.Trim() + "'"; isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该客户已存在该机号!"); this.s_Manufactcode.Focus(); return; } sqlexe = inf.Build_Insert_Sql(this.panel1, "T_CustomerMac"); } else { bool isExist = false; sql_ = "select CustID from T_CustomerMac where CustID='" + this.custid + "' and Mtype='" + this.s_Mtype.Text.Trim() + "' and Manufactcode='" + this.s_Manufactcode.Text.Trim() + "' and Sysid!=" + Cmsysid; isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该客户已存在该机号!"); this.s_Manufactcode.Focus(); return; } string swhere = " where Sysid=" + this.Cmsysid; sqlexe = inf.Build_Update_Sql(this.panel1, "T_CustomerMac", swhere); } try { (new SqlDBConnect()).ExecuteNonQuery(sqlexe); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); custmatFormChange(); //新增成功后让联系人和发票类型可操作 if (this.type == "add") { sql_ = "select sysid from T_CustomerMac " + "where custid='" + this.s_CustID.Text.Trim() + "' and mtype='" + this.s_Mtype.Text.Trim() + "' and Manufactcode='" + this.s_Manufactcode.Text.Trim() + "'"; try { string sysid_ = (new DBUtil()).Get_Single_val(sql_); this.type = "edit"; this.Cmsysid = sysid_; this.tabControl_CustomerMaInvoice.Enabled = true; } catch { this.Close(); } } } catch (Exception w) { MessageBox.Show(w.ToString()); } }