Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text == Code.Common.CacheStrategy.Instance.GetObject(Code.Common.CacheKey.UserName).ToString())
            {
                if (txtPassword.Text != adminPWD)
                {
                    MessageBox.Show("不允许修改当前用户的密码,请在更换密码中修改!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                if (txtPassword.Text != txtPassword2.Text)
                {
                    MessageBox.Show("两次密码输入不一致,请重新输入!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            Code.Services.OperatorService service = new Code.Services.OperatorService();
            if (service.CheckUserName(txtUserName.Text.Trim(), _id))
            {
                MessageBox.Show("对不起,您输入的登录帐号已经存在,请重新输入!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (_id != 0)
            {
                if (service.UpdateOperator(txtUserName.Text.Trim(), txtPassword.Text, txtRealName.Text.Trim(), cbbRole.Text, txtPhone.Text.Trim(), txtID.Text.Trim()))
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                }
            }
            else
            {
                if (service.AddOperator(txtUserName.Text.Trim(), txtPassword.Text, txtRealName.Text.Trim(), cbbRole.Text, txtPhone.Text.Trim(), txtID.Text.Trim()))
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                }
            }
        }
Пример #2
0
        private void fmOperatorEdit_Load(object sender, EventArgs e)
        {
            BindRole();
            if (_id != 0)
            {
                Code.Services.OperatorService service = new Code.Services.OperatorService();
                DataRow row = service.GetRole(_id);
                if (row == null)
                {
                    MessageBox.Show("记录不存在!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    txtUserName.ReadOnly  = true;
                    txtID.Text            = _id.ToString();
                    txtPassword.Text      = row["Password2"].ToString();
                    adminPWD              = row["Password2"].ToString();
                    txtPhone.Text         = row["Phone"].ToString();
                    txtRealName.Text      = row["RealName"].ToString();
                    txtPassword2.Text     = row["Password2"].ToString();
                    txtUserName.Text      = row["Name"].ToString();
                    cbbRole.SelectedValue = row["Role"].ToString();
                }
            }

            if (name != "")
            {
                Code.Services.OperatorService service = new Code.Services.OperatorService();
                DataRow row = service.GetRole(name);
                if (row == null)
                {
                    MessageBox.Show("记录不存在!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    txtUserName.ReadOnly = true;
                    _id                   = Convert.ToInt32(row["ID"]);
                    txtID.Text            = row["ID"].ToString();
                    txtPassword.Text      = row["Password2"].ToString();
                    adminPWD              = row["Password2"].ToString();
                    txtPhone.Text         = row["Phone"].ToString();
                    txtRealName.Text      = row["RealName"].ToString();
                    txtPassword2.Text     = row["Password2"].ToString();
                    txtUserName.Text      = row["Name"].ToString();
                    cbbRole.SelectedValue = row["Role"].ToString();
                }
            }
        }
Пример #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text != txtPassword2.Text)
            {
                MessageBox.Show("两次输入新密码不一致,请重新输入!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPassword2.Focus();
                return;
            }
            Code.Services.OperatorService service = new Code.Services.OperatorService();

            Code.Common.Result result = service.ChangePassword(CacheStrategy.Instance.GetObject(CacheKey.UserName).ToString(), txtOldPwd.Text, txtPassword.Text);
            if (result.Status == ResultStatus.Success)
            {
                MessageBox.Show("更换成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                MessageBox.Show("更换失败," + result.Message + "!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #4
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择需要删除的记录!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (dataGridView1[1, dataGridView1.SelectedRows[0].Index].Value.ToString().ToLower() == "admin")
            {
                MessageBox.Show("admin用户不能删除!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string userName = dataGridView1[1, dataGridView1.SelectedRows[0].Index].Value.ToString();

            Code.Services.OperatorService service = new Code.Services.OperatorService();
            if (service.DelOperator(userName))
            {
                BindGridDataSource();
            }
        }
Пример #5
0
 public void BindGridDataSource()
 {
     Code.Services.OperatorService service = new Code.Services.OperatorService();
     dataGridView1.DataSource = service.GetOperatorList();
     //dataGridView1.SelectedRows[0].Selected = false;
 }