private void btnSave_Click(object sender, EventArgs e) { #region //验证 if (this.s_MainMenu.Text.Trim() == "") { MessageBox.Show("主菜单项不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.n_OrderIndex.Text.Trim() != "" && !Util.IsNumberic(this.n_OrderIndex)) { MessageBox.Show("主顺序号输入有误,请输入数值!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.LessOneNumber(this.n_OrderIndex, this.menuStripMain.Items.Count) == false) { MessageBox.Show("主顺序号只能输入小于等于" + this.menuStripMain.Items.Count + "的数字!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion SqlDBConnect db = new SqlDBConnect(); InitFuncs initFuncs = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string strSql = ""; string strSql_ = ""; if (this.isAdd == true) //新增 { strSql_ = "select * from T_MenuCfgMain where Ltrim(Rtrim(MainMenu))='{0}'"; strSql_ = string.Format(strSql_, this.s_MainMenu.Text.Trim()); //插入 strSql = initFuncs.Build_Insert_Sql(this.panelMenuMain, "T_MenuCfgMain"); } else //修改 { //更新 string strSqlWhere = "where Sysid='" + this.n_Sysid.Text.Trim() + "'"; strSql = initFuncs.Build_Update_Sql(this.panelMenuMain, "T_MenuCfgMain", strSqlWhere); strSql_ = "select * from T_MenuCfgMain where Ltrim(Rtrim(Sysid)) != {0} and Ltrim(Rtrim(MainMenu))='{1}'"; strSql_ = string.Format(strSql_, this.n_Sysid.Text.Trim(), this.s_MainMenu.Text.Trim()); } if (dbUtil.yn_exist_data(strSql_)) { MessageBox.Show("该主菜单项已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } db.ExecuteNonQuery(strSql); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); InitDataGridView(); }
private void button1_Click(object sender, EventArgs e) { string sql_ = ""; InitFuncs inf = new InitFuncs(); if (this.type == "add") { sql_ = "select * from t_errors where errorcode='" + S_errorCode.Text.Trim() + "'"; bool isExist = (new DBUtil()).yn_exist_data(sql_); if (isExist) { MessageBox.Show("该故障编码已经存在!"); S_errorCode.Focus(); return; } sql_ = inf.Build_Insert_Sql(panel1, "T_errors"); } else { sql_ = "select * from t_errors where errorcode='" + S_errorCode.Text.Trim() + "' and sysid!=" + this.sysid_; bool isExist = (new DBUtil()).yn_exist_data(sql_); if (isExist) { MessageBox.Show("该故障编码已经存在!"); S_errorCode.Focus(); return; } string swhere_ = " where sysid=" + this.sysid_; sql_ = inf.Build_Update_Sql(panel1, "t_errors", swhere_); } try { (new SqlDBConnect()).ExecuteNonQuery(sql_); if (this.type == "add") { S_errorCode.Text = ""; S_errorApperance.Text = ""; s_ErrorPlace.SelectedIndex = -1; ErrInfoFormChange_(); //激活代理事件,在UserForm中处理 } else { ErrInfoFormChange_(); //激活代理事件,在UserForm中处理 this.DialogResult = DialogResult.OK; } } catch (Exception ex) { } }
private void button1_Click(object sender, EventArgs e) { if (Util.ControlTextIsNUll(this.s_Addr)) { MessageBox.Show("联系人地址不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_Addr.Focus(); return; } //数据处理 InitFuncs inf = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string sqlexe = ""; string sql_ = ""; if (type == "add") { bool isExist = false; sql_ = "select Addr from T_CustomerAdd where Custid='" + this.custid + "' and Addr='" + this.s_Addr.Text.Trim() + "'"; isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该地址已存在!"); return; } sqlexe = inf.Build_Insert_Sql(this.panel1, "T_CustomerAdd"); } else { bool isExist = false; sql_ = "select Addr from T_CustomerAdd where Custid='" + this.custid + "' and Addr='" + this.s_Addr.Text.Trim() + "' and sysid!=" + this.sysid_; isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该地址已存在!"); return; } string swhere = " where custid='" + this.custid + "' and sysid=" + this.sysid_; sqlexe = inf.Build_Update_Sql(this.panel1, "T_CustomerAdd", swhere); } try { (new SqlDBConnect()).ExecuteNonQuery(sqlexe); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); customeraddFormChange(); } catch (Exception w) { MessageBox.Show(w.ToString()); } }
private void button1_Click(object sender, EventArgs e) { if (Util.ControlTextIsNUll(this.s_ModelName)) { MessageBox.Show("机型名称不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_ModelName.Focus(); return; } //数据处理 InitFuncs inf = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string sqlexe = ""; string sql_ = ""; if (this.type == "add") { sql_ = "select ModelName from T_Model where ModelName='" + this.s_ModelName.Text.Trim() + "'"; if (dbUtil.yn_exist_data(sql_)) { MessageBox.Show("该机器名称已存在!"); this.s_ModelName.Focus(); return; } sqlexe = inf.Build_Insert_Sql(this.panelmodel, "T_Model"); } else { sql_ = "select ModelName from T_Model where ModelName='" + this.s_ModelName.Text.Trim() + "'" + " and SysID!=" + this.ID; if (dbUtil.yn_exist_data(sql_)) { MessageBox.Show("该机器名称已存在!"); this.s_ModelName.Focus(); return; } string swhere = " where SysID=" + this.ID; sqlexe = inf.Build_Update_Sql(this.panelmodel, "T_Model", swhere); } try { (new SqlDBConnect()).ExecuteNonQuery(sqlexe); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); macmodelchange(); } catch (Exception w) { MessageBox.Show(w.ToString()); } }
private void buttonOK_Click(object sender, EventArgs e) { if (Util.ControlTextIsNUll(s_AssName)) { MessageBox.Show("请输入配套名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { InitFuncs initFuncs = new InitFuncs(); bool isExist; string sql = ""; string sql_ = ""; if (this.Type == "add") { sql = initFuncs.Build_Insert_Sql(this.panel1, "T_MatAssemblyMain"); sql_ = "select AssName from T_MatAssemblyMain where Ltrim(Rtrim(assname)) like '" + this.s_AssName.Text.Trim() + "'"; } else if (this.Type == "edit") { sql_ = "select AssName from T_MatAssemblyMain where Ltrim(Rtrim(assname)) like '{0}' and Ltrim(Rtrim(sysid)) not like {1}"; sql_ = string.Format(sql_, this.s_AssName.Text.Trim(), this.Sysid); string sqlwhere = "where sysid=" + this.Sysid; sql = initFuncs.Build_Update_Sql(this.panel1, "T_MatAssemblyMain", sqlwhere); } //验证修改的名称是否已存在 isExist = (new DBUtil()).yn_exist_data(sql_); if (isExist == false) { (new SqlDBConnect()).ExecuteNonQuery(sql); matAssemblyMainFormChange(); MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } else { MessageBox.Show("该配套名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void buttonok_Click(object sender, EventArgs e) { //受理单不一定有合同,但一定要有客户 if (Util.ControlTextIsNUll(this.s_CustCode)) { MessageBox.Show("未选择客户!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } t_Technician2_Leave(null, null); t_Technician1_Leave(null, null); //数据处理 string strSql = ""; InitFuncs initFuncs = new InitFuncs(); try { if (this.type == "add") { strSql = initFuncs.Build_Insert_Sql(this.panelCustCall, "T_CustomerCall"); } else if (this.type == "edit") { strSql = initFuncs.Build_Update_Sql(this.panelCustCall, "T_CustomerCall", " where Sysid=" + this.CallId); } try { //执行SQL (new SqlDBConnect()).ExecuteNonQuery(strSql); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); customerCallFormChange_(); //激活代理事件 this.DialogResult = DialogResult.OK; } catch { } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button1_Click(object sender, EventArgs e) { if (Util.ControlTextIsNUll(this.s_Ititle)) { MessageBox.Show("发票抬头不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_Ititle.Focus(); return; } //数据处理 InitFuncs inf = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string sqlexe = ""; string sql_ = ""; if (type == "add") { //bool isExist = false; //sql_ = "select Ititle from T_CustomerMaInvoice where CmSysId='" + this.Cmsysid + "' and Ititle='" + this.s_Ititle.Text.Trim() + "'"; //isExist = dbUtil.yn_exist_data(sql_); //if (isExist) //{ // MessageBox.Show("该类发票已存在!"); // return; //} sqlexe = inf.Build_Insert_Sql(this.panelkp, "T_CustomerMaInvoice"); } else { string swhere = " where CmSysId='" + this.Cmsysid + "'and sysid=" + this.sysid; sqlexe = inf.Build_Update_Sql(this.panelkp, "T_CustomerMaInvoice", swhere); } try { (new SqlDBConnect()).ExecuteNonQuery(sqlexe); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); customerfpmatFormChange(); } catch (Exception w) { MessageBox.Show(w.ToString()); } }
private void button1_Click(object sender, EventArgs e) { #region//输入数据有效性验证 if (Util.ControlTextIsNUll(CmatnametextBox) == true) { MessageBox.Show("请选择添加子物料", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion //建立事务 List <string> strsqls = new List <string>(); InitFuncs inifuncs = new InitFuncs(); if (this.Type == "add") { string insert_sql = inifuncs.Build_Insert_Sql(this.panelMatRela, "T_Mat_Rela"); strsqls.Add(insert_sql); //判断数据是否已存在 bool isExsit = (new DBUtil()).Is_Exist_Data("T_Mat_Rela", "ParentMatID", this.s_ParentMatID.Text.ToString().Trim(), "ChildMatID", this.s_ChildMatID.Text.ToString().Trim()); //插入一条 if (isExsit == false) { (new SqlDBConnect()).Exec_Tansaction(strsqls); MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("该机型耗材对照记录已存在"); } initdataGridview(); } if (this.Type == "edit") { string parentMatCode = this.s_ParentMatID.Text.ToString().Trim(); string childMatCode = this.s_ChildMatID.Text.ToString().Trim(); string swhere = "where ParentMatID='" + parentMatCode + "' and ChildMatID='" + childMatCode + "'"; string update_sql = inifuncs.Build_Update_Sql(this.panelMatRela, "T_Mat_Rela", swhere); (new SqlDBConnect()).ExecuteNonQuery(update_sql); initdataGridview(); MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnOK_Click(object sender, EventArgs e) { #region 验证 if (this.s_ReceiptId.Text.Trim() == "") { MessageBox.Show("请输入拆件单据编号!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.comboBoxMatName.SelectedIndex == 0 || this.comboBoxMatName.Text.Trim() == "") { MessageBox.Show("请选择被拆物料!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.comboBoxMatType.SelectedIndex == 0 || this.comboBoxMatType.Text.Trim() == "") { MessageBox.Show("请选择被拆物料类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion SqlDBConnect db = new SqlDBConnect(); InitFuncs initFuncs = new InitFuncs(); DBUtil dbUtil = new DBUtil(); this.s_OccurTime.Format = DateTimePickerFormat.Short; this.s_OccurTime.Value = DBUtil.getServerTime(); if (this.type == "add") { //插入之前判断 string strSqlSel = "select * from T_MatSplit_Main where ReceiptId='{0}'"; strSqlSel = string.Format(strSqlSel, this.s_ReceiptId.Text.Trim()); bool isExist = dbUtil.yn_exist_data(strSqlSel); if (isExist) { MessageBox.Show("已存在该拆件单据!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { List <string> sqls = new List <string>(); //插入拆件管理主表 string strSqlInsert = initFuncs.Build_Insert_Sql(this.panel1, "T_MatSplit_Main"); sqls.Add(strSqlInsert); db.Exec_Tansaction(sqls); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); matSplitMainFormChange(); //激活代理事件,在MatSplitForm中处理 this.Close(); } } else if (this.type == "edit") { //更新 string strWhere = "where ReceiptId='{0}'"; strWhere = string.Format(strWhere, this.s_ReceiptId.Text.Trim()); string strSqlUpdate = initFuncs.Build_Update_Sql(this.panel1, "T_MatSplit_Main", strWhere); db.ExecuteNonQuery(strSqlUpdate); MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); matSplitMainFormChange(); //激活代理事件,在MatSplitForm中处理 this.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { #region //验证 if (Util.ControlTextIsNUll(this.s_RoleId)) { MessageBox.Show("角色编号不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Util.IsContainCharNumber(this.s_RoleId, 4)) { MessageBox.Show("角色编号不能大于4位!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_RoleName)) { MessageBox.Show("角色名不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion InitFuncs initFuncs = new InitFuncs(); string strSqlInsert = initFuncs.Build_Insert_Sql(this.panelRoles, "T_Roles"); //插入之前首先判断是否存在该角色 DBUtil dbUtil = new DBUtil(); bool isExist = false; if (this.s_RoleId.Text.Trim() != "") { isExist = dbUtil.Is_Exist_Data("T_Roles", "RoleId", this.s_RoleId.Text.Trim()); } SqlDBConnect db = new SqlDBConnect(); if (isExist == true) { if (this.s_RoleId.ReadOnly == false) { MessageBox.Show("已存在该角色!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //更新 List <string> sqls = new List <string>(); string strSqlWhere = "where RoleId='" + this.s_RoleId.Text.ToString().Trim() + "'"; string strSqlUpdate = initFuncs.Build_Update_Sql(this.panelRoles, "T_Roles", strSqlWhere); sqls.Add(strSqlUpdate); //更新权限 string strRoleId = this.s_RoleId.Text.Trim(); //先删除 string strSqlDelete = "delete from T_Role_Rights where RoleId='{0}'"; strSqlDelete = string.Format(strSqlDelete, strRoleId); sqls.Add(strSqlDelete); List <TreeNode> checkedNodes = new List <TreeNode>();//存储所有的选中的叶子菜单项 UserPermission(this.treeViewMenus, checkedNodes); foreach (TreeNode treeNode in checkedNodes) { string strSql = "insert into T_Role_Rights([RoleId],[Function]) values('{0}','{1}')"; strSql = string.Format(strSql, strRoleId, treeNode.Text.Trim()); sqls.Add(strSql); } db.Exec_Tansaction(sqls); MessageBox.Show("更新成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); InitDataGridView(this.curSelectRowIndex); //btnCancel_Click(null, null); } else { //插入 string strSql_ = "select * from T_Roles where Ltrim(Rtrim(RoleName))='{0}'"; strSql_ = string.Format(strSql_, this.s_RoleName.Text.Trim()); if (dbUtil.yn_exist_data(strSql_)) { MessageBox.Show("该角色名已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } db.ExecuteNonQuery(strSqlInsert); //分配权限 string strRoleId = this.s_RoleId.Text.Trim(); if (strRoleId != "") { List <string> sqls = new List <string>(); List <TreeNode> checkedNodes = new List <TreeNode>();//存储所有的选中的叶子菜单项 UserPermission(this.treeViewMenus, checkedNodes); foreach (TreeNode treeNode in checkedNodes) { string strSql = "insert into T_Role_Rights([RoleId],[Function]) values('{0}','{1}')"; strSql = string.Format(strSql, strRoleId, treeNode.Text.Trim()); sqls.Add(strSql); } db.Exec_Tansaction(sqls); } MessageBox.Show("添加成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); InitDataGridView(0); btnCancel_Click(null, null); } }
private void butsave_Click(object sender, EventArgs e) { if (Util.ControlTextIsNUll(this.s_wsCode)) { MessageBox.Show("请输入工单编号!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DBUtil dbUtil = new DBUtil(); List <string> SqlLst = new List <string>(); //数据处理 string strSql = ""; InitFuncs initFuncs = new InitFuncs(); try { if (this.type == "add") { string sql = "select * from T_worksheet where wsCode='" + this.s_wsCode.Text.Trim() + "'"; bool ynExistID = dbUtil.yn_exist_data(sql); if (ynExistID == true) { MessageBox.Show("该工单号已存在!"); s_wsCode.Focus(); return; } strSql = initFuncs.Build_Insert_Sql(this.panel1, "T_worksheet"); } else if (this.type == "edit") { strSql = initFuncs.Build_Update_Sql(this.panel1, "T_worksheet", " where Sysid=" + this.sysid_); } //执行SQL try { //保存工单 SqlLst.Add(strSql); //有对应召唤单的情况下,修改召唤单的状态为返回 if (this.n_CallBillSysId.Text.Trim() != "") { strSql = "update T_CustomerCall set endflag='2' where sysid=" + this.n_CallBillSysId.Text; SqlLst.Add(strSql); } // (new SqlDBConnect()).Exec_Tansaction(SqlLst); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); addWorkFormChange_(); this.DialogResult = DialogResult.OK; } catch (Exception ew) { // MessageBox.Show(ew.ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button1_Click(object sender, EventArgs e) { #region 输入验证 if (Util.ControlTextIsNUll(this.s_CName)) { MessageBox.Show("联系人姓名不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_CName.Focus(); return; } if (this.s_Tel.Text.Trim() != "" && Util.IsNumberic(this.s_Tel) == false) { MessageBox.Show("输入电话错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.s_Tel.Focus(); return; } #endregion //数据处理 InitFuncs inf = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string sqlexe = ""; string sql_ = ""; if (type == "add") { bool isExist = false; sql_ = "select CName from T_CustMaContacts where CmSysId='" + this.Cmsysid + "' and Cname='" + this.s_CName.Text.Trim() + "'"; isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该联系人已存在!"); return; } sqlexe = inf.Build_Insert_Sql(this.panellx, "T_CustMaContacts"); } else { //bool isExist = false; //sql_ = "select CName from T_CustMaContacts where CmSysId='" + this.Cmsysid + "' and Cname='" + this.s_CName.Text.Trim() + "' and sysid!=" + this.Cmsysid; //isExist = dbUtil.yn_exist_data(sql_); //if (isExist) //{ // MessageBox.Show("该联系人已存在!"); // return; //} string swhere = " where CmSysId='{0}'and sysid='{1}'"; swhere = string.Format(swhere, this.Cmsysid, this.sysid); sqlexe = inf.Build_Update_Sql(this.panellx, "T_CustMaContacts", swhere); } try { (new SqlDBConnect()).ExecuteNonQuery(sqlexe); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); customermacontact(); } catch (Exception w) { MessageBox.Show(w.ToString()); } }
private void btnSave_Click(object sender, EventArgs e) { #region //验证 if (this.s_ReceTypeID.Text == "") { MessageBox.Show("模板编号不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.s_ReceName.Text.Trim() == "") { MessageBox.Show("模板名不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.n_DetailRows.Text.Trim() != "" && !Util.IsNumberic(this.n_DetailRows)) { MessageBox.Show("子表行数输入有误,请输入数值型数据!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion InitFuncs initFuncs = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string strSql = ""; string strSql_ = ""; if (this.type == "add") { //插入之前的判断 bool isExistKey = dbUtil.Is_Exist_Data("T_ReceiptModal", "ReceTypeID", this.s_ReceTypeID.Text.Trim()); if (isExistKey) { MessageBox.Show("该单据模板已定义!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } strSql_ = "select * from T_ReceiptModal where Ltrim(Rtrim(ReceName))='{0}'"; strSql_ = string.Format(strSql_, this.s_ReceName.Text.Trim()); //插入 strSql = initFuncs.Build_Insert_Sql(this.panelReceiptModal, "T_ReceiptModal"); } else if (this.type == "edit") { //更新 strSql_ = "select * from T_ReceiptModal where Ltrim(Rtrim(ReceTypeID)) != '{0}' and Ltrim(Rtrim(ReceName))='{1}'"; strSql_ = string.Format(strSql_, this.s_ReceTypeID.Text.Trim(), this.s_ReceName.Text.Trim()); string strSqlWhere = "where ReceTypeID='" + this.s_ReceTypeID.Text.Trim() + "'"; strSql = initFuncs.Build_Update_Sql(this.panelReceiptModal, "T_ReceiptModal", strSqlWhere); } if (dbUtil.yn_exist_data(strSql_)) { MessageBox.Show("该模板名已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } (new SqlDBConnect()).ExecuteNonQuery(strSql); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); receiptModalDefineChange(); //激活代理事件,在父窗体中处理 this.Close(); }
private void btnOk_Click(object sender, EventArgs e) { #region 输入验证 if (Util.ControlTextIsNUll(this.s_UserId)) { MessageBox.Show("用户编码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Util.IsContainCharNumber(this.s_UserId, 10)) { MessageBox.Show("用户编码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_UserName)) { MessageBox.Show("用户名不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //if (Util.ControlTextIsNUll(this.s_SmsTel)) //{ // MessageBox.Show("接收短信电话号码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} //if (Util.IsPhoneNumber(this.s_SmsTel,11) == false) //{ // MessageBox.Show("接收短信电话号码输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); // return; //} if (this.s_OfficeTel.Text.Trim() != "" && Util.IsNumberic(this.s_OfficeTel) == false) { MessageBox.Show("办公电话输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); s_OfficeTel.Focus(); return; } if (this.s_MobileTel.Text.Trim() != "" && Util.IsNumberic(this.s_MobileTel) == false) { MessageBox.Show("移动电话输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); s_MobileTel.Focus(); return; } if (this.s_Email.Text.Trim() != "" && Util.IsEmail(this.s_Email.Text.Trim()) == false) { MessageBox.Show("Email输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); s_Email.Focus(); return; } if (this.s_PassWord.Text.Trim() != "" && this.s_PassWord.Text.Trim() != this.txtPasswordCheck.Text.Trim()) { MessageBox.Show("您两次输入的密码不一致,请重新输入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); s_PassWord.Focus(); return; } #endregion //数据处理 SqlDBConnect db = new SqlDBConnect(); InitFuncs initFuncs = new InitFuncs(); DBUtil dbUtil = new DBUtil(); string strSql = ""; string strSql_ = ""; if (this.type == "add") { string strSqlInsert = initFuncs.Build_Insert_Sql(this.panelUser, "T_Users"); //插入之前首先判断是否存在该用户 bool isExist = dbUtil.Is_Exist_Data("T_Users", "UserId", this.s_UserId.Text.Trim()); if (isExist == true) //该用户名已存在 { MessageBox.Show("该用户已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } strSql_ = "select * from T_Users where Ltrim(Rtrim(UserName))='{0}'"; strSql_ = string.Format(strSql_, this.s_UserName.Text.Trim()); //插入 strSql = initFuncs.Build_Insert_Sql(this.panelUser, "T_Users"); } else if (this.type == "edit") { //更新 strSql_ = "select * from T_Users where Ltrim(Rtrim(UserId)) != '{0}' and Ltrim(Rtrim(UserName))='{1}'"; strSql_ = string.Format(strSql_, this.s_UserId.Text.Trim(), this.s_UserName.Text.Trim()); string strSqlWhere = "where UserId='" + this.s_UserId.Text.Trim() + "'"; strSql = initFuncs.Build_Update_Sql(this.panelUser, "T_Users", strSqlWhere); } if (dbUtil.yn_exist_data(strSql_)) { MessageBox.Show("该用户已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } db.ExecuteNonQuery(strSql); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); userInfoFormChange(); //激活代理事件,在UserForm中处理 this.Close(); }
private void button1_Click(object sender, EventArgs e) { #region 输入验证 if (Util.ControlTextIsNUll(this.s_CustID)) { MessageBox.Show("客户编号不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_CustName)) { MessageBox.Show("客户名称不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_CustType)) { MessageBox.Show("请选择类别!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_whichTrade)) { MessageBox.Show("请选择所在行业!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.s_PostCode.Text != "" && Util.IsPhoneNumber(this.s_PostCode, 6) == false) { MessageBox.Show("邮编输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.s_Fax.Text.Trim() != "" && Util.IsNumberic(this.s_Fax) == false) { MessageBox.Show("传真输入错误!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion //数据处理 InitFuncs initFuncs = new InitFuncs(); DBUtil dbUtil = new DBUtil(); try { #region 添加 if (this.type == "add") { // 判断客户ID是否存在 string sql = "select * from T_CustomerInf where CustID='" + this.s_CustID.Text.Trim() + "'"; bool ynExistID = dbUtil.yn_exist_data(sql); if (ynExistID == true) { MessageBox.Show("该客户已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); s_CustID.Focus(); return; } string strSqlInsert = initFuncs.Build_Insert_Sql(this.panelcustomer, "T_CustomerInf"); //插入之前首先判断是否存在该客户 bool isExist = dbUtil.Is_Exist_Data("T_CustomerInf", "CustName", this.s_CustName.Text.Trim()); if (isExist == false) //插入一条 { try { (new SqlDBConnect()).ExecuteNonQuery(strSqlInsert); MessageBox.Show("添加成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); //this.DialogResult = DialogResult.OK; this.custid = s_CustID.Text.Trim(); this.type = "edit"; tabControl1.Enabled = true; } catch { this.DialogResult = DialogResult.OK; } } else //该客名已存在 { MessageBox.Show("该客户已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } customerInfoFormChange(); } #endregion #region 编辑 else if (this.type == "edit") { //插入之前首先判断是否存在该客户 string sql_ = "select CustName from T_CustomerInf where CustName='" + this.s_CustName.Text.Trim() + "' and CustID not like '" + custid + "'"; bool isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该客户名已存在,请重新输入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string strSqlUpdate = initFuncs.Build_Update_Sql(this.panelcustomer, "T_CustomerInf", " where CustID='" + this.s_CustID.Text.Trim() + "'"); //执行 (new SqlDBConnect()).ExecuteNonQuery(strSqlUpdate); MessageBox.Show("更新成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); customerInfoFormChange(); //激活代理事件,在UserForm中处理 this.DialogResult = DialogResult.OK; } #endregion } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
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()); } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { DBUtil dbUtil = new DBUtil(); int intMainMenuOrderIndex; string strMainMenuOrderIndex = dbUtil.Get_Single_val("T_MenuCfgMain", "OrderIndex", "MainMenu", this.comboBoxMainMenu.Text.Trim()); if (strMainMenuOrderIndex != "") { intMainMenuOrderIndex = Convert.ToInt32(strMainMenuOrderIndex); } else { intMainMenuOrderIndex = this.menuStipMain.Items.Count - 1;//空值时,默认为最后一个位置 } int intSubMenuOrderIndex = (this.menuStipMain.Items[intMainMenuOrderIndex] as ToolStripMenuItem).DropDownItems.Count + 1; #region 验证 if (this.comboBoxMainMenu.SelectedIndex == 0) { MessageBox.Show("主菜单项不能为空,请选择!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.comboBoxReceName.SelectedIndex == 0) { MessageBox.Show("子菜单项不能为空,请选择!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.n_OrderIndex.Text.Trim() != "" && !Util.IsNumberic(this.n_OrderIndex)) { MessageBox.Show("顺序号输入有误,请输入数值!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.LessOneNumber(this.n_OrderIndex, intSubMenuOrderIndex) == false) { MessageBox.Show("顺序号只能输入大于0,小于等于" + intSubMenuOrderIndex + "的整数,请输入数值!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (this.n_OrderIndex.Text.Trim() != "" && Convert.ToInt32(this.n_OrderIndex.Text.Trim()) <= 0) { MessageBox.Show("顺序号只能输入大于0,小于等于" + intSubMenuOrderIndex + "的整数,请输入数值!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion SqlDBConnect db = new SqlDBConnect(); InitFuncs initFuncs = new InitFuncs(); int intMainMenuId = -1; string strMainMenuId = dbUtil.Get_Single_val("T_MenuCfgMain", "Sysid", "MainMenu", this.comboBoxMainMenu.Text.Trim()); if (strMainMenuId != "") { intMainMenuId = Convert.ToInt32(strMainMenuId); } string strSubMenu = dbUtil.Get_Single_val("T_ReceiptModal", "ReceTypeID", "ReceName", this.comboBoxReceName.Text.Trim()); MenuCfgChild menuCfgChild = new MenuCfgChild(); menuCfgChild.MainMenuId = intMainMenuId; menuCfgChild.SubMenu = strSubMenu; menuCfgChild.ShortCut = this.s_ShortCut.Text.Trim(); menuCfgChild.OrderIndex = Convert.ToInt32(this.n_OrderIndex.Text.Trim()); string strSql = ""; string strSql_ = ""; if (this.isAdd == true) //新增 { //插入之前的判断 strSql_ = "select * from T_MenuCfgChild where MainMenuId={0} and SubMenu='{1}'"; strSql_ = string.Format(strSql_, intMainMenuId, strSubMenu); //插入 strSql = initFuncs.Build_Insert_Sql(this.panelMenuChild, "T_MenuCfgChild"); } else //修改 { if (this.txtSysid.Text.Trim() == "") { return; } int intSysIdMenuChild = Convert.ToInt32(this.txtSysid.Text.Trim()); strSql_ = "select * from T_MenuCfgChild where SysId!={0} and MainMenuId={1} and SubMenu='{2}'"; strSql_ = string.Format(strSql_, intSysIdMenuChild, intMainMenuId, strSubMenu); //更新 string strWhere = string.Format("where SysId={0}", intSysIdMenuChild); strSql = initFuncs.Build_Update_Sql(this.panelMenuChild, "T_MenuCfgChild", strWhere); } bool isExist = dbUtil.yn_exist_data(strSql_); if (isExist == true) { MessageBox.Show("该记录已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } (new SqlDBConnect()).ExecuteNonQuery(strSql); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); InitDataGridView(); }