Esempio n. 1
0
        private void sbtnAdd_Click(object sender, System.EventArgs e)
        {
            if (cmbLimit.Items.Count == 0)
            {
                MessageBox.Show("权限参数有误,请与管理员联系!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }

            err = null;
            CMSMData.CMSMStruct.OperStruct ops1 = new CMSMData.CMSMStruct.OperStruct();
            if (txtOperID.Text.Trim() == "" || txtOperID.Text.Trim().Length > 10)
            {
                MessageBox.Show("操作员编号不能为空且小于10位!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                txtOperID.Focus();
                return;
            }
            else if (!cs.ChkOperIDDup(txtOperID.Text.Trim(), out err))
            {
                ops1.strOperID = txtOperID.Text.Trim();
            }
            else
            {
                MessageBox.Show("该操作员编号已经存在!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                if (err != null)
                {
                    clog.WriteLine(err);
                }
                return;
            }

            err = null;
            if (txtOperName.Text.Trim() == "" || txtOperName.Text.Trim().Length > 5)
            {
                MessageBox.Show("操作员名称不能为空且小于5个字!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                txtOperName.Focus();
                return;
            }
            else if (!cs.ChkOperNameDup(txtOperName.Text.Trim(), out err))
            {
                ops1.strOperName = txtOperName.Text.Trim();
            }
            else
            {
                MessageBox.Show("该操作员名称已经存在!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                if (err != null)
                {
                    clog.WriteLine(err);
                }
                return;
            }

            if (txtPwd.Text.Trim() == "" || txtPwd.Text.Trim().Length > 6)
            {
                MessageBox.Show("密码小于等于6位字符!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                txtPwd.Focus();
                return;
            }
            else
            {
                ops1.strPwd = txtPwd.Text.Trim();
            }
            ops1.strLimit  = this.GetColEn(cmbLimit.Text.Trim(), "LM");
            ops1.strDeptID = SysInitial.LocalDept;
            err            = null;
            cs.InsertOper(ops1, out err);
            if (err != null)
            {
                MessageBox.Show("添加操作员失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                clog.WriteLine(err);
            }
            else
            {
                DataRow dr = SysInitial.dsSys.Tables["Oper"].NewRow();
                dr["vcOperID"]   = ops1.strOperID;
                dr["vcOperName"] = ops1.strOperName;
                dr["vcLimit"]    = ops1.strLimit;
                dr["vcPwd"]      = ops1.strPwd;
                dr["vcDeptID"]   = ops1.strDeptID;
                SysInitial.dsSys.Tables["Oper"].Rows.Add(dr);

                MessageBox.Show("添加操作员成功!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                this.Close();
            }
        }