private void btnOk_Click(object sender, EventArgs e) { #region 验证 if (this.comboBoxRole.SelectedIndex == 0) { MessageBox.Show("请选择角色!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion DBUtil dbUtil = new DBUtil(); string userId = this.userId; string roleId = dbUtil.Get_Single_val("T_Roles", "RoleId", "RoleName", this.comboBoxRole.Text.Trim()); //插入之前判断是否又该记录 string strSqlSel = "select * from T_User_Role where UserId='{0}' and RoleId='{1}'"; strSqlSel = string.Format(strSqlSel, userId, roleId); bool isExist = dbUtil.yn_exist_data(strSqlSel); if (isExist) { MessageBox.Show("已存在该对应关系!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string strSql = "insert into T_User_Role(UserId, RoleId) values('{0}','{1}')"; strSql = string.Format(strSql, userId, roleId); (new SqlDBConnect()).ExecuteNonQuery(strSql); MessageBox.Show("添加成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); //初始化DataGridView InitDataGridView(); }
public void Pubmetheod(TextBox ID, string IDName, TextBox EN, string Name, Panel Panelname, string Table) { try { bool isExist; String sql_ = "", sqle_ = ""; DBUtil dbUtil = new DBUtil(); if (ID.ReadOnly) { string strSqlWhere = "where " + IDName + "='" + ID.Text.Trim() + "'"; sql_ = String.Format("select * from " + Table + " where Ltrim(Rtrim(" + Name + ")) like '{0}' and Ltrim(Rtrim(" + IDName + ")) not like '{1}'", EN.Text.Trim(), ID.Text.Trim()); sqle_ = (new InitFuncs()).Build_Update_Sql(Panelname, Table, strSqlWhere); } else { sql_ = String.Format("select * from " + Table + " where Ltrim(Rtrim(" + Name + ")) like '{0}' ", EN.Text.Trim()); sqle_ = (new InitFuncs()).Build_Insert_Sql(Panelname, Table); } isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该条信息已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); EN.Focus(); return; } (new SqlDBConnect()).ExecuteNonQuery(sqle_); InitDataGridView(Table); } catch //(Exception ex) { //MessageBox.Show(ex.ToString()); MessageBox.Show("不能插入重复键!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void button1_Click(object sender, EventArgs e) { DBUtil dbUtil = new DBUtil(); if (Util.ControlTextIsNUll(this.n_Imoney)) { MessageBox.Show("请输入发票金额!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.n_Imoney.Focus(); return; } this.DialogResult = DialogResult.OK; }
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_CustomerInvoice where Custid='" + this.custid + "' and Ititle='" + this.s_Ititle.Text.Trim() + "'"; //isExist = dbUtil.yn_exist_data(sql_); //if (isExist) //{ // MessageBox.Show("该类发票已存在!"); // return; //} sqlexe = inf.Build_Insert_Sql(this.panel1, "T_CustomerInvoice"); } else { //bool isExist = false; //sql_ = "select Ititle from T_CustomerInvoice where Custid='" + this.custid + "' and Ititle='" + this.s_Ititle.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_CustomerInvoice", swhere); } try { (new SqlDBConnect()).ExecuteNonQuery(sqlexe); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); customerfpFormChange(); } 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 btnFind_Click(object sender, EventArgs e) { WFilter wf = new WFilter(1, "CustName", true); wf.tableName = "T_CustomerInf"; //表名 wf.strSql = "select CustID as 客户编号, CustName as 客户名称, CustType as 类别,City as 城市地区,communicateAddr as 通信地址, CredDegree as 信用等级,T_CustomerImp.importance as 客户重要度 " + " from T_CustomerInf left join T_CustomerImp " + " on T_CustomerInf.ImportanceDegreeId= T_CustomerImp.Iid"; wf.s_items.Add("客户编号,CustID,C"); wf.s_items.Add("客户名称,CustName,C"); wf.s_items.Add("类别,CustType,C"); wf.s_items.Add("城市地区,City,C"); wf.s_items.Add("重要度,importance,C"); wf.ShowDialog(); if (wf.DialogResult == DialogResult.OK) { //插入 List<string> sqls = new List<string>(); DBUtil dbUtil = new DBUtil(); string custId = this.custid ; foreach (string CustName in wf.Return_Items) { string parentcustId = dbUtil.Get_Single_val("T_CustomerInf", "CustID", "CustName", CustName.Trim()); if (parentcustId == "") return; //插入前判断 string strSqlSel = "select * from T_Customer_Rela where CustID='{0}' and ParentID='{1}'"; strSqlSel = string.Format(strSqlSel, custId, parentcustId); bool isExit = dbUtil.yn_exist_data(strSqlSel); if (isExit == true) return; string strSql = "insert into T_Customer_Rela(CustID,ParentID) values('{0}','{1}')"; strSql = string.Format(strSql, custId, parentcustId); sqls.Add(strSql); } (new SqlDBConnect()).Exec_Tansaction(sqls); InitDataGridView(); } }
private void btnFind_Click(object sender, EventArgs e) { WFilter wf = new WFilter(1, "UserName", true); wf.tableName = "T_users"; //表名 wf.strSql = "select UserId as 用户编码, UserName as 用户名, ynAdmin as 是否系统管理员,BranchId as 部门编码," + "JobPosition as 职位, atGroup as 组别, DefaultUserType as 类别,SmsTel as 接收短信电话号码 " + "from [T_Users] "; wf.s_items.Add("用户编码,UserId,C"); wf.s_items.Add("用户名,UserName,C"); wf.s_items.Add("部门编码,BranchId,N"); wf.s_items.Add("职位,JobPosition,C"); wf.s_items.Add("组别,atGroup,C"); wf.ShowDialog(); if (wf.DialogResult == DialogResult.OK) { //插入 List<string> sqls = new List<string>(); DBUtil dbUtil = new DBUtil(); string curUserId = this.userId; foreach (string userName in wf.Return_Items) { string userId = dbUtil.Get_Single_val("T_Users", "UserId", "UserName", userName.Trim()); if (userId == "") continue; //插入前判断 string strSqlSel = "select * from T_UserRelation where ParentPId='{0}' and Pid='{1}'"; strSqlSel = string.Format(strSqlSel, curUserId, userId); bool isExit = dbUtil.yn_exist_data(strSqlSel); if (isExit == true) continue; string strSql = "insert into T_UserRelation(ParentPId,Pid) values('{0}','{1}')"; strSql = string.Format(strSql, curUserId, userId); sqls.Add(strSql); } (new SqlDBConnect()).Exec_Tansaction(sqls); InitDataGridView(); } }
private void btnOK_Click(object sender, EventArgs e) { #region 验证 if (this.txtReceiptId.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 DBUtil dbUtil = new DBUtil(); if (this.dataGridView1.SelectedRows.Count <= 0 || this.dataGridView1.SelectedRows[0].Cells["子物料"].Value == null) { MessageBox.Show("请正确选择一条记录!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string strMatChildName = this.dataGridView1.SelectedRows[0].Cells["子物料"].Value.ToString().Trim(); if (strMatChildName == "") { MessageBox.Show("请正确选择一条记录!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string ChildMatID = dbUtil.Get_Single_val("T_MatInf", "MatID", "MatName", strMatChildName); string strWhere = "where ReceiptId='{0}' and ChildMatID='{1}'"; strWhere = string.Format(strWhere, this.txtReceiptId.Text.Trim(), ChildMatID); string strSqlUpdate = (new InitFuncs()).Build_Update_Sql(this.panel1, "T_MatSplit_Child", strWhere); (new SqlDBConnect()).ExecuteNonQuery(strSqlUpdate); MessageBox.Show("修改成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); InitDataGridView(); }
private void button9_Click(object sender, EventArgs e) { #region 输入验证 if (((comboBoxUserName.SelectedIndex == 0) && (comboBoxArea.SelectedIndex == 0)) || ((comboBoxUserName.SelectedIndex != 0) && (comboBoxArea.SelectedIndex == 0)) || ((comboBoxUserName.SelectedIndex == 0) && (comboBoxArea.SelectedIndex != 0))) { MessageBox.Show("请输入完整的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion try { bool isExist; String sql_ = "", sqle_ = ""; DBUtil dbUtil = new DBUtil(); isExist = dbUtil.Is_Exist_Data("T_User_Area", "UAid", this.T_UAid.Text.Trim()); if (T_UAid.ReadOnly) { string strSqlWhere = "where UAid='" + T_UAid.Text.Trim() + "'"; sql_ = String.Format("select * from T_User_Area where (Ltrim(Rtrim(userid)) like '{0}' and Ltrim(Rtrim(uAreaid)) like '{1}') and Ltrim(Rtrim(UAid)) not like '{2}'", s_userid.Text.Trim(), s_UAreaid.Text.Trim(), T_UAid.Text.Trim()); sqle_ = (new InitFuncs()).Build_Update_Sql(this.panelUserArea, "T_User_Area", strSqlWhere); } else { sql_ = String.Format("select * from T_User_Area where (Ltrim(Rtrim(userid)) like '{0}' and Ltrim(Rtrim(uAreaid)) like '{1}')", s_userid.Text.Trim(), s_UAreaid.Text.Trim()); sqle_ = (new InitFuncs()).Build_Insert_Sql(this.panelUserArea, "T_User_Area"); } isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该记录已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } (new SqlDBConnect()).ExecuteNonQuery(sqle_); InitDataGridView("T_User_Area"); } catch //(Exception ex) { MessageBox.Show("不能插入重复键!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void tabParent_SelectedIndexChanged(object sender, EventArgs e) { if (this.tabParent.SelectedIndex == 0) { DBUtil dbUtil = new DBUtil(); ////在窗口中初始化T_SysConfig InitFuncs inf = new InitFuncs(); string sel_sql = "select * from T_SysConfig "; inf.ShowDatas(this.panelSysConfig, sel_sql); // 特殊字段处理 string siteId = dbUtil.Get_Single_val("T_SysConfig", "DefaStoreHouseId", "SiteCode", this.s_SiteCode.Text.Trim()); comboBoxstore.Text = dbUtil.Get_Single_val("T_StoreHouse", "SHName", "SHId", siteId); //if (s_SiteCode.Text.Trim() != "") //{ // s_SiteCode.ReadOnly = true; //} this.dataGridView1.DataSource = null; } else if (this.tabParent.SelectedIndex == 2) { //在窗口中初始化T_SelItems InitDataGridView("T_SelItems"); //升序排序 string sql = "select distinct ItemType from T_SelItems order by 1"; DataTable dt = (new SqlDBConnect()).Get_Dt(sql); return; } }
private void 删除该关系ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要删除吗?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { try { int selectedCellRowIndex = this.dataGridViewcustrela.SelectedCells[0].RowIndex; string strParentName = this.dataGridViewcustrela.Rows[selectedCellRowIndex].Cells["下级客户名称"].Value.ToString().Trim(); DBUtil dbUtil = new DBUtil(); string strParentId = dbUtil.Get_Single_val("T_CustomerInf", "CustID", "CustName", strParentName); string strSqlDel = "delete from T_Customer_Rela where CustID='{0}' and ParentID='{1}'"; strSqlDel = string.Format(strSqlDel, this.custid, strParentId); (new SqlDBConnect()).ExecuteNonQuery(strSqlDel); //初始化DataGridView InitDataGridView(); Util.ClearControlText(this.groupBox1); } catch { } } }
private void button36_Click(object sender, EventArgs e) { #region 输入验证 if (Util.ControlTextIsNUll(this.s_Pmachlctcode)) { MessageBox.Show("编码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!Util.IsContainCharNumber(this.s_Pmachlctcode, 5)) { MessageBox.Show("编码位数不能超出五位!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_machlctname)) { MessageBox.Show("部位名称为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion //Pubmetheod(s_machlctcode, "machlctcode", s_machlctname, "machlctname", this.panelMachLocate, "T_MachLocate"); try { bool isExist; String sql_ = "", sqle_ = ""; DBUtil dbUtil = new DBUtil(); if (s_Pmachlctcode.ReadOnly) { string strSqlWhere = "where machlctcode ='" + s_Pmachlctcode.Text.Trim() + "'"; sql_ = String.Format("select * from T_MachLocate where Ltrim(Rtrim(machlctname)) like '{0}' and Ltrim(Rtrim(machlctcode)) not like '{1}'", s_machlctname.Text.Trim(), s_Pmachlctcode.Text.Trim()); sqle_ = "update T_MachLocate set machlctname='" + s_machlctname.Text.Trim() + "',memo='" + s_Macmemo.Text.Trim() + "'" + " where machlctcode='" + s_Pmachlctcode.Text.Trim() + "'"; } else { sql_ = String.Format("select * from T_MachLocate where Ltrim(Rtrim(machlctname)) like '{0}' ", s_machlctname.Text.Trim()); sqle_ = "insert into T_MachLocate(machlctcode,machlctname,memo)values('" + s_Pmachlctcode.Text.Trim() + "','" + s_machlctname.Text.Trim() + "','" + s_Macmemo.Text.Trim() + "')"; } isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该条信息已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); s_machlctname.Focus(); return; } (new SqlDBConnect()).ExecuteNonQuery(sqle_); InitDataGridView("T_MachLocate"); } catch //(Exception ex) { //MessageBox.Show(ex.ToString()); MessageBox.Show("不能插入重复键!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnOK_Click(object sender, EventArgs e) { #region 验证 if (this.comboBoxMatType.SelectedIndex == 0 || this.comboBoxMatType.Text.Trim() == "") { MessageBox.Show("请选择零件类型!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.textBoxChildMatName.Text.Trim() == "") { MessageBox.Show("请输入零件名称!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (this.s_ChildManuCode.Text.Trim() == "") { MessageBox.Show("请输入零件制造编号!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endregion List<string> sqls = new List<string>(); DBUtil dbUtil = new DBUtil(); string sql = ""; string sql_ = ""; bool isExist=false; if (this.Type == "add") { //构造添加sql this.s_ChildMatID.Text = dbUtil.Get_Single_val("T_MatInf", "MatID", "MatName", this.textBoxChildMatName.Text.Trim()); this.n_ChildMatType.Text = (Util.GetMatType(this.comboBoxMatType.Text.Trim())).ToString(); sql = (new InitFuncs()).Build_Insert_Sql(this.panel1, "T_MatSplit_Child"); sqls.Add(sql); //构造判断sql sql_ = "select * from T_MatSplit_Child where ReceiptId='{0}' and ChildMatID='{1}'"; sql_ = string.Format(sql_, this.strReceiptId, this.s_ChildMatID.Text.ToString().Trim()); } else if (this.Type == "edit") { //构造更新sql string strMatChildName = this.dataGridView1.SelectedRows[0].Cells["零件"].Value.ToString().Trim(); string ChildMatID = dbUtil.Get_Single_val("T_MatInf", "MatID", "MatName", strMatChildName); string strWhere = "where ReceiptId='{0}' and ChildMatID='{1}'"; strWhere = string.Format(strWhere, this.s_ReceiptId.Text.Trim(), ChildMatID); sql = (new InitFuncs()).Build_Update_Sql(this.panel1, "T_MatSplit_Child", strWhere); //构造判断sql string select_sysid = "select sysid from T_MatSplit_Child where ReceiptId='{0}' and ChildMatID='{1}'"; select_sysid = string.Format(select_sysid, this.strReceiptId, this.s_ChildMatID.Text.ToString().Trim()); string sysid = dbUtil.Get_Single_val(select_sysid); sql_ = "select ChildMatID from T_MatSplit_Child where LTRIM(RTRIM(sysid)) not like {0} and LTRIM(RTRIM(ChildMatID)) like '{1}' and LTRIM(RTRIM(ReceiptId)) like '{2}'"; sql_ = string.Format(sql_, sysid, this.s_ChildMatID.Text.Trim(),this.strReceiptId); } isExist=dbUtil.yn_exist_data(sql_); if (isExist == false) { (new SqlDBConnect()).ExecuteNonQuery(sql); InitDataGridView(); MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("该零件信息已存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void button45_Click(object sender, EventArgs e) { #region 输入验证 if (Util.ControlTextIsNUll(this.s_trbcodedtl)) { MessageBox.Show("编码不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_trbcodename)) { MessageBox.Show("故障类别名称不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion //Pubmetheod(s_trbcodedtl, "trbcodedtl", s_trbcodename, "trbcodename", this.panelTrbTypeDtl, "T_TrbTypeDtl"); try { bool isExist; String sql_ = "", sqle_ = ""; DBUtil dbUtil = new DBUtil(); if (s_trbcodedtl.ReadOnly) { string strSqlWhere = "where trbcodedtl ='" + s_trbcodedtl.Text.Trim() + "'"; sql_ = String.Format("select * from T_TrbTypeDtl where Ltrim(Rtrim(trbcodename)) like '{0}' and Ltrim(Rtrim(trbcodedtl)) not like '{1}'", s_trbcodename.Text.Trim(), s_trbcodedtl.Text.Trim()); sqle_ = "update T_TrbTypeDtl set trbcodename='" + s_trbcodename.Text.Trim() + "',trbcode='" + s_Dtrbcode.Text.Trim() + "'" + " where trbcodedtl='" + s_trbcodedtl.Text.Trim() + "'"; } else { sql_ = String.Format("select * from T_TrbTypeDtl where Ltrim(Rtrim(trbcodename)) like '{0}' ", s_trbcodename.Text.Trim()); sqle_ = "insert into T_TrbTypeDtl(trbcodedtl,trbcodename,trbcode)values('" + s_trbcodedtl.Text.Trim() + "','" + s_trbcodename.Text.Trim() + "','" + s_Dtrbcode.Text.Trim() + "')"; } isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该条信息已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); s_trbcodename.Focus(); return; } (new SqlDBConnect()).ExecuteNonQuery(sqle_); InitDataGridView("T_TrbTypeDtl"); } catch //(Exception ex) { //MessageBox.Show(ex.ToString()); MessageBox.Show("不能插入重复键!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
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 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 buttonok_Click(object sender, EventArgs e) { if (this.dataGridViewcustrela.SelectedRows.Count <= 0) return; InitFuncs initFuncs = new InitFuncs(); string strcustID=(new SqlDBConnect ()).Ret_Single_val_Sql ("select CustID from T_CustomerInf where CustName='"+ this .c_CustID .Text .Trim ()+"'"); string strParentName = this.dataGridViewcustrela.SelectedRows [0].Cells["下级客户名称"].Value.ToString().Trim(); DBUtil dbUtil = new DBUtil(); string strParentId = dbUtil.Get_Single_val("T_CustomerInf", "CustID", "CustName", strParentName); string strSqlUpdate = "update T_Customer_Rela set InvoiceTitle='" + this.s_InvoiceTitle.Text.Trim() + "' , Memo='" + this.s_Memo.Text.Trim() + "' where CustID='" + strcustID + "' and ParentID='" + strParentId + "'"; (new SqlDBConnect()).ExecuteNonQuery (strSqlUpdate ); //MessageBox.Show("更新成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); InitDataGridView(); }
private void button51_Click(object sender, EventArgs e) { try { bool isExist; String sql_ = "", sqle_ = ""; DBUtil dbUtil = new DBUtil(); isExist = dbUtil.Is_Exist_Data("T_machproblem", "probcodeid", this.T_probcodeid.Text.Trim()); if (T_probcodeid.ReadOnly) { string strSqlWhere = "where probcodeid='" + T_probcodeid.Text.Trim() + "'"; sql_ = String.Format("select * from T_machproblem where Ltrim(Rtrim(probname)) like '{0}'and Ltrim(Rtrim(probcodeid)) not like '{1}'", s_probname.Text.Trim(), T_probcodeid.Text.Trim()); sqle_ = "update T_machproblem set probname='" + s_probname.Text.Trim() + "'," + "telcode ='" + s_Ptelcode.Text.Trim() + "' where probcodeid='" + T_probcodeid.Text.Trim() + "'"; } else { sql_ = String.Format("select * from T_machproblem where (Ltrim(Rtrim(probname)) like '{0}')", s_probname.Text.Trim()); sqle_ = "insert into T_machproblem(telcode,probname)values('" + s_Ptelcode.Text.Trim() + "','" + s_probname.Text.Trim() + "')"; } isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该记录已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } (new SqlDBConnect()).ExecuteNonQuery(sqle_); InitDataGridView("T_machproblem"); } catch //(Exception ex) { MessageBox.Show("不能插入重复键!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void ShowDatas() { string strSql = "select * from T_MatSplit_Main where ReceiptId='{0}'"; strSql = string.Format(strSql, strReceiptId); (new InitFuncs()).ShowDatas(this.panel1, strSql); DBUtil dbUtil = new DBUtil(); string matName = dbUtil.Get_Single_val("T_MatInf", "MatName", "MatID", this.s_MatID.Text.Trim()); this.comboBoxMatName.Items.Add("--请选择--"); this.comboBoxMatName.Items.Add(matName); this.comboBoxMatName.Text = matName; this.comboBoxMatType.Text = Util.GetMatTypeName(Convert.ToInt32(this.n_MatType.Text.ToString().Trim())); this.txtCurUserName.Text = dbUtil.Get_Single_val("T_Users", "UserName", "UserID", this.s_OpaUser.Text.Trim()); }
private void buttonsave_Click(object sender, EventArgs e) { bool isExist; String sql_ = "", sqle_ = ""; DBUtil dbUtil = new DBUtil(); sql_ = (new InitFuncs()).Build_Insert_Sql(this.panelHolidays, "T_Holidays"); sqle_ = String.Format("select * from T_Holidays where Ltrim(Rtrim(Holiday)) like '{0}'", s_Holiday.Text.Trim()); isExist = dbUtil.yn_exist_data(sqle_); if (isExist) { MessageBox.Show("该记录已经存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } (new SqlDBConnect()).ExecuteNonQuery(sql_); InitDataGridView("T_Holidays"); }
private void buttonOK_Click(object sender, EventArgs e) { string sql_ = ""; string sqlExe_ = ""; bool ynExistName = false; DBUtil dbUtil = new DBUtil(); #region//必填项验证 if (Util.ControlTextIsNUll(this.s_MatID)) { MessageBox.Show("请输入物料编号!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Util.ControlTextIsNUll(this.s_MatName) == true) { MessageBox.Show("请输入物料名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion try { if (this.type == "add") { #region// 判断物料ID和//名称是否存在 string sql = "select * from t_matinf where matid='" + this.s_MatID.Text.Trim() + "'"; bool ynExistID = dbUtil.yn_exist_data(sql); if (ynExistID == true) { MessageBox.Show("该物料编号已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //sql_ = "select Matid from T_MatInf where MatName='" + s_MatName.Text.Trim() + "'"; //ynExistName = dbUtil.yn_exist_data(sql_); //if (ynExistName == true) //{ // MessageBox.Show("该物料名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); // s_MatName.Focus(); // return; //} #endregion sqlExe_ = (new InitFuncs()).Build_Insert_Sql(this.panel1, "T_MatInf"); try { (new SqlDBConnect()).ExecuteNonQuery(sqlExe_); MessageBox.Show("添加成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (this.matId == "") //单据模块新增代码 materialInfoFormChange(); this.DialogResult = DialogResult.OK; this.matId = this.s_MatID.Text.Trim();//单据模块新增代码 } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } else if (this.type == "edit") { //判断新物料名称存在否 sql_ = "select Matid from T_MatInf where MatName='" + s_MatName.Text.Trim() + "' and matid<>'"+this.matId+"'"; ynExistName = dbUtil.yn_exist_data(sql_); string swhere = " where MatId='" + this.matId + "'"; sqlExe_ = (new InitFuncs()).Build_Update_Sql(this.panel1, "T_MatInf", swhere); if (!ynExistName) { sqlExe_ = (new InitFuncs()).Build_Update_Sql(this.panel1, "T_MatInf", " where MatId='" + this.s_MatID.Text.Trim() + "'"); //执行 (new SqlDBConnect()).ExecuteNonQuery(sqlExe_); materialInfoFormChange(); MessageBox.Show("更新成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("该物料名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } catch { } }
/// <summary> /// 单击dataGridView1显示于不同的Tab /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { DBUtil dbUtil = new DBUtil(); try { switch (this.TabAdd.SelectedTab.Name) { case "BranchAdd": { s_BId.ReadOnly = true; BD.Data_ToTab("部门编号", "T_Branch", "BId", panelBranch, dataGridView1); comboxLeader.Text = this.dataGridView1.SelectedRows[0].Cells["部门主管"].Value.ToString().Trim(); break; } case "Roles": { s_RoleId.ReadOnly = true; BD.Data_ToTab("角色编号", "T_Roles", "RoleId", panelRoles, dataGridView1); break; } case "AreaInf": { s_Areaid.ReadOnly = true; BD.Data_ToTab("系统编号", "T_AreaInf", "Areaid", panelAear, dataGridView1); break; } case "UserType": { n_TypeId.ReadOnly = true; BD.Data_ToTab("操作员类别编号", "T_UserType", "TypeId", panelUser, dataGridView1); break; } case "User_Area": { T_UAid.ReadOnly = true; BD.Data_ToTab("序列号", "T_User_Area", "UAid", panelUserArea, dataGridView1); T_UAid.Text = this.dataGridView1.SelectedRows[0].Cells["序列号"].Value.ToString().Trim(); comboBoxUserName.Text = this.dataGridView1.SelectedRows[0].Cells["用户名"].Value.ToString().Trim(); comboBoxArea.Text = this.dataGridView1.SelectedRows[0].Cells["地区"].Value.ToString().Trim(); break; } case "UserGrade": { s_GId.ReadOnly = true; BD.Data_ToTab("系统等级编码", "T_UserGrade", "GId", panelUserGrade, dataGridView1); comboxUtype.Text = this.dataGridView1.SelectedRows[0].Cells["类型"].Value.ToString().Trim(); break; } case "StoreHouse": { s_SHId.ReadOnly = true; BD.Data_ToTab("仓库编号", "T_StoreHouse", "SHId", panelStoreHouse, dataGridView1); comboBoxSHKeeper.Text = this.dataGridView1.SelectedRows[0].Cells["库管员"].Value.ToString().Trim(); comboBoxSort.Text = this.dataGridView1.SelectedRows[0].Cells["组织类别"].Value.ToString().Trim(); break; } case "Invoice": { s_ITCode.ReadOnly = true; BD.Data_ToTab("发票类型编号", "T_Invoice", "ITCode", panelInvoice, dataGridView1); break; } case "Material_Sort": { s_SortId.ReadOnly = true; BD.Data_ToTab("物料分类编号", "T_Material_Sort", "SortId", panelMaterial, dataGridView1); break; } case "CustomerImp": { s_Iid.ReadOnly = true; BD.Data_ToTab("重要度编码", "T_CustomerImp", "Iid", panelCustomerImp, dataGridView1); break; } case "PayMethod": { s_PMid.ReadOnly = true; BD.Data_ToTab("支付编号", "T_PayMethod", "PMid", panelPayMethod, dataGridView1); break; } case "ServiceType": { s_scid.ReadOnly = true; BD.Data_ToTab("维修类别编码", "T_ServiceType", "scid", panelServiceType, dataGridView1); break; } case "WorkType": { s_wcid.ReadOnly = true; BD.Data_ToTab("工作类别编码", "T_WorkType", "wcid", panelWorkType, dataGridView1); break; } case "MachLocate": { s_Pmachlctcode.ReadOnly = true; //BD.Data_ToTab("部位编码", "T_MachLocate", "machlctcode", panelMachLocate, dataGridView1); s_Pmachlctcode.Text = dataGridView1.SelectedRows[0].Cells["部位编码"].Value.ToString(); s_machlctname.Text = dataGridView1.SelectedRows[0].Cells["部位名称"].Value.ToString(); s_Macmemo.Text = dataGridView1.SelectedRows[0].Cells["备注"].Value.ToString(); break; } case "machlocatepart": { s_machlctpartcode.ReadOnly = true; BD.Data_ToTab("部件编码", "T_Machlocatepart", "machlctpartcode", panelmachlocatepart, dataGridView1); combPmachlctcode.Text = this.dataGridView1.SelectedRows[0].Cells["所属部位名称"].Value.ToString().Trim(); break; } case "TrbType": { s_trbcode.ReadOnly = true; BD.Data_ToTab("故障类别代码", "T_TrbType", "trbcode", panelTrbType, dataGridView1); break; } case "TrbTypeDtl": { s_trbcodedtl.ReadOnly = true; // BD.Data_ToTab("故障类别明细代码", "T_TrbTypeDtl", "trbcodedtl", panelTrbTypeDtl, dataGridView1); s_trbcodedtl.Text = dataGridView1.SelectedRows[0].Cells["故障类别明细代码"].Value.ToString(); s_trbcodename.Text = dataGridView1.SelectedRows[0].Cells["故障类别名称"].Value.ToString(); comboDtrbcode.Text = this.dataGridView1.SelectedRows[0].Cells["故障类别名称"].Value.ToString().Trim(); break; } case "TelTrbType": { s_telcode.ReadOnly = true; BD.Data_ToTab("故障代码", "T_TelTrbType", "telcode", panelTelTrbType, dataGridView1); break; } case "machproblem": { T_probcodeid.ReadOnly = true; BD.Data_ToTab("系统编号", "T_Machproblem", "probcodeid", panelmachproblem, dataGridView1); T_probcodeid.Text = this.dataGridView1.SelectedRows[0].Cells["系统编号"].Value.ToString().Trim(); comboPtelcode.Text = this.dataGridView1.SelectedRows[0].Cells["故障现象"].Value.ToString().Trim(); break; } default: break; } } catch { return; } }
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_CustContacts where Custid='" + this.custid + "' and Cname='" + this.s_CName.Text.Trim() + "'"; isExist = dbUtil.yn_exist_data(sql_); if (isExist) { MessageBox.Show("该联系人已存在!"); return; } sqlexe = inf.Build_Insert_Sql(this.panel1, "T_CustContacts"); } else { bool isExist = false; sql_ = "select CName from T_CustContacts where Custid='" + this.custid + "' and Cname='" + this.s_CName.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_CustContacts", swhere); } try { (new SqlDBConnect()).ExecuteNonQuery(sqlexe); MessageBox.Show("保存成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); customerContactFormChange(); } catch (Exception w) { MessageBox.Show(w.ToString()); } }
private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e) { SqlDBConnect SDB = new SqlDBConnect(); DBUtil dbUtil = new DBUtil(); try { s_ItemVal.Clear(); string strSql = "select * from T_SelItems where ItemType='{0}'"; strSql = string.Format(strSql, s_ItemType.Text.Trim()); DataSet ds = SDB.Get_Ds(strSql); int Lins = ds.Tables[0].Rows.Count; string[] match = new string[ds.Tables[0].Rows.Count]; for (int i = 0; i < match.Length; i++) { s_ItemVal.Text += ds.Tables[0].Rows[i]["ItemVal"].ToString() + "\r\n";//回车换行 } } catch { MessageBox.Show("当前行不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 插入 (没有使用) /// </summary> private void Insert(Panel panel, ref List<string> sqls, string strRTypeID) { DBUtil dbUtil = new DBUtil(); foreach (Control o in panel.Controls) { if (o is CheckBox && (o as CheckBox).Checked == true) { string strSql = "insert into T_ReceiptModCfg(RTypeID,ShowItem) values('{0}','{1}')"; strSql = string.Format(strSql, strRTypeID, (o as CheckBox).Text.Trim()); sqls.Add(strSql); } } }
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 删除ToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("删除操作会导致删除所有关联的数据,确定要删除吗?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel) return; string strRoleName = (((sender as ToolStripMenuItem).Owner as ContextMenuStrip).SourceControl as DataGridView).SelectedRows[0].Cells["角色名"].Value.ToString().Trim(); DBUtil dbUtil = new DBUtil(); string strRoleId = dbUtil.Get_Single_val("T_Roles", "RoleId", "RoleName", strRoleName); string strSqlDel = "delete from T_User_Role where UserId='{0}' and RoleId='{1}'"; strSqlDel = string.Format(strSqlDel, this.userId, strRoleId); (new SqlDBConnect()).ExecuteNonQuery(strSqlDel); //初始化DataGridView InitDataGridView(); }
private void CustomerInfAdd_Load(object sender, EventArgs e) { //初始化ComboBox InitFuncs inf = new InitFuncs(); inf.InitComboBox(this.s_CustType, "[客户]类别"); inf.InitComboBox(this.s_Degree, "[客户]等级"); inf.InitComboBox(this.s_whichTrade, "[客户]所在行业"); inf.InitComboBox(this.s_Country, "[客户]国家"); inf.InitComboBox(this.s_Province, "[客户]省"); inf.InitComboBox(this.s_City, "[客户]城市"); inf.InitComboBox(this.t_AreaCode, "T_AreaInf", "Area"); inf.InitComboBox(this.t_ImportanceDegreeId, "T_CustomerImp", "importance"); if (custid.Trim() == "") { tabControl1.Enabled = false; } else { tabControl1.Enabled = true ; } s_InputTime.Text = DBUtil.getServerTime().ToString(); if (this.type == "edit") { this.s_CustID.ReadOnly = true; string strsql = "select * from T_CustomerInf where CustID='{0}'"; strsql = string.Format(strsql, this.custid); inf.ShowDatas(this.panelcustomer, strsql); //以下两行必须在ShowDatas后 DBUtil dbUtil = new DBUtil(); t_AreaCode.Text = (new DBUtil()).Get_Single_val("T_AreaInf", "Area", "areaId", S_AreaCode.Text.Trim()); t_ImportanceDegreeId.Text = (new DBUtil()).Get_Single_val("T_CustomerImp", "importance", "Iid", S_ImportanceDegreeId.Text.Trim()); //初始化抬头 SqlDBConnect SDB = new SqlDBConnect(); s_BillHead.Clear(); string strSql = "select BillHead as 发票抬头 from T_CustomerTitle where CustID='{0}'";//"select * from T_SelItems where ItemType='{0}'"; strSql = string.Format(strSql, s_CustID.Text.Trim()); DataSet ds = SDB.Get_Ds(strSql); int Lins = ds.Tables[0].Rows.Count; string[] match = new string[ds.Tables[0].Rows.Count]; for (int i = 0; i < match.Length; i++) { s_BillHead.Text += ds.Tables[0].Rows[i]["发票抬头"].ToString() + "\r\n";//回车换行 } } if (this.custid!="") {//初始化联系人; init_lxr(); //初始化发票 init_fp(); //初始化多地址 init_muladd(); } //限制值类型文本框的输入 (new InitFuncs()).Num_limited(this.panelcustomer); }
/// <summary> /// 保存 /// </summary> private void btnSave_Click(object sender, EventArgs e) { //输入数据有效性验证 if (s_AttachName.Text.Trim() == "") { MessageBox.Show("附件名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string strSqlSel = ""; string strSql = ""; DBUtil dbUtil = new DBUtil(); SqlDBConnect db = new SqlDBConnect(); if (this.Type == "add") { //判断该资料原件记录是否已存在 strSqlSel = "select * from T_BargAttach where barsysid={0} and AttachName='{1}'"; strSqlSel = string.Format(strSqlSel, this.barsysid, this.s_AttachName.Text.Trim()); strSql = (new InitFuncs()).Build_Insert_Sql(this.panel1, "T_BargAttach"); } else if (this.Type == "edit") { int SysId = Convert.ToInt32(this.dataGridView1.SelectedRows[0].Cells["附件编号"].Value.ToString().Trim()); strSqlSel = "select * from T_BargAttach where BarSysId like {0} and Ltrim(Rtrim(AttachName)) like '{1}' and Ltrim(Rtrim(SysId)) not like {2}"; strSqlSel = string.Format(strSqlSel, this.barsysid, this.s_AttachName.Text.Trim(), SysId); string strWhere = "where SysId=" + SysId; strSql = (new InitFuncs()).Build_Update_Sql(this.panel1, "T_BargAttach", strWhere); } bool isExist = dbUtil.yn_exist_data(strSqlSel); if (isExist) { MessageBox.Show("当前合同已存在该附件名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } db.ExecuteNonQuery(strSql); //MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); initdataGridview(); }
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(); }