Пример #1
0
        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());
            }
        }
Пример #2
0
 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());
     }
 }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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());
            }
        }
Пример #5
0
        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());
            }
        }
Пример #6
0
        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 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();
        }
Пример #8
0
        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());
            }
        }
Пример #9
0
        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());
            }
        }
Пример #10
0
        /// <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();
        }
Пример #11
0
        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);
            }
        }
Пример #12
0
        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();
        }