Example #1
0
        private void ModifyUserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sysguard.SysguardWS.UserInfo user = dataLayer.User;

            UpdateUser updateUser = new UpdateUser(this);

            mainForm.CurrentOpenChildForm = updateUser;
            if (this.dataGridView1.SelectedRows.Count > 1)
            {
                MessageBox.Show("只能选择一行修改!");
            }
            else if (this.dataGridView1.SelectedRows.Count == 1)
            {
                if (user.roleId == 2 && (int)this.dataGridView1.SelectedRows[0].Cells[0].Value != user.userId)
                {
                    MessageBox.Show("你只能更改自己的信息!");
                }
                else
                {
                    updateUser.ShowDialg(this.dataGridView1.SelectedRows[0]);
                    if (updateUser.DialogResult == DialogResult.OK)
                    {
                        Flush();
                    }
                }
            }
            else
            {
                MessageBox.Show("请选择一行然后在修改!");
            }
        }
Example #2
0
        public MainForm()
        {
            InitializeComponent();

            IDataLayer dataLayer = (IDataLayer)Settings.Default.Context["datalayer"];

            sysguard.SysguardWS.UserInfo user = dataLayer.User;

            if (user.roleId == 2)
            {
                this.SetTheEnable(false);
            }
        }
Example #3
0
        private void DeleteUserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sysguard.SysguardWS.UserInfo user = dataLayer.User;

            if (user.roleId > 0)
            {
                MessageBox.Show("您没有用户管理的权限!");
            }
            else
            {
                //判断是否包含自己
                bool del = true;
                foreach (DataGridViewRow dgvrow in this.dataGridView1.SelectedRows)
                {
                    if (user.userId.ToString().Equals(dgvrow.Cells[0].Value.ToString()))
                    {
                        del = false;
                        break;
                    }
                }
                if (del)
                {
                    DialogResult result = MessageBox.Show("是否删除该用户?", "是否删除用户!", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        dataLayer = (IDataLayer)Settings.Default.Context["datalayer"];

                        int success = 0;

                        foreach (DataGridViewRow dgvrow in this.dataGridView1.SelectedRows)
                        {
                            int             userid     = (int)dgvrow.Cells[0].Value;
                            DataLayerResult dataResult = dataLayer.DeleteUserByUserId(userid);
                            if (dataResult == DataLayerResult.Success)
                            {
                                success++;
                            }
                        }
                        if (success == this.dataGridView1.SelectedRows.Count)
                        {
                            MessageBox.Show("删除成功!");
                            Flush();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("删除的用户中包含自己,不能删除!");
                }
            }
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            //处理手顺
            if (this.textBox1.Text.Trim().Equals(""))
            {
                MessageBox.Show("处理手顺不能为空!");
                return;
            }
            //错误描述
            if (this.textBox2.Text.Trim().Equals(""))
            {
                MessageBox.Show("错误描述不能为空!");
                return;
            }

            IDataLayer dataLayer = (IDataLayer)Settings.Default.Context["datalayer"];

            sysguard.SysguardWS.OperationInfo operation = new sysguard.SysguardWS.OperationInfo();

            operation.errorDesp = this.textBox2.Text;

            operation.operContent = this.textBox1.Text;

            operation.inputTime = DateTime.Now;

            sysguard.SysguardWS.UserInfo user = dataLayer.User;

            operation.userId = user.userId;

            DataLayerResult result = dataLayer.AddOperationInfo(operation);

            if (result == DataLayerResult.Success)
            {
                DialogResult resultDialo = MessageBox.Show("新的手顺添加成功,是否退出?", "添加成功!", MessageBoxButtons.YesNo);
                if (resultDialo == DialogResult.Yes)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    reset();
                    explainControl.Flush();
                }
            }
        }
Example #5
0
        private void NewUser_Click(object sender, EventArgs e)
        {
            sysguard.SysguardWS.UserInfo user = dataLayer.User;

            if (user.roleId > 0)
            {
                MessageBox.Show("您没有用户管理的权限!");
            }
            else
            {
                NewUser newUser = new NewUser(this);
                mainForm.CurrentOpenChildForm = newUser;
                newUser.ShowDialog();
                if (newUser.DialogResult == DialogResult.OK)
                {
                    Flush();
                }
            }
        }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            //处理手顺
            if (this.textBox1.Text.Trim().Equals(""))
            {
                MessageBox.Show("处理手顺不能为空!");
                return;
            }
            //错误描述
            if (this.textBox2.Text.Trim().Equals(""))
            {
                MessageBox.Show("错误描述不能为空!");
                return;
            }
            //
            sysguard.SysguardWS.OperationInfo operationInfo = new sysguard.SysguardWS.OperationInfo();
            //
            sysguard.SysguardWS.UserInfo user = dataLayer.User;
            //
            operationInfo.operId      = explain_id;
            operationInfo.errorDesp   = this.textBox1.Text;
            operationInfo.operContent = this.textBox2.Text;
            operationInfo.userId      = user.userId;

            DataLayerResult result2 = dataLayer.ModifyOperationInfo(operationInfo);

            if (result2 == DataLayerResult.Success)
            {
                DialogResult resultDialo = MessageBox.Show("手顺修改成功,是否退出?", "修改成功", MessageBoxButtons.YesNo);
                if (resultDialo == DialogResult.Yes)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    explainControl.Flush();
                    GetData();
                }
            }
        }
Example #7
0
        private void commitButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.userNameTextBox.Text))
            {
                MessageBox.Show("请填写用户名!");
                this.userNameTextBox.Focus();
                return;
            }
            if (!VerifyUtil.VerifyName(this.userNameTextBox.Text))
            {
                MessageBox.Show("用户名格式不正确请重新输入!,正确的格式应该是长度4-10,可以是数字或英文字母.");
                this.userNameTextBox.Text = string.Empty;
                this.userNameTextBox.Focus();
                return;
            }
            string userName = this.userNameTextBox.Text;


            if (string.IsNullOrEmpty(this.oldPasswdTextBox.Text))
            {
                MessageBox.Show("请填写旧密码!");
                this.oldPasswdTextBox.Focus();
                return;
            }
            if (!VerifyUtil.VerifyPwd(this.oldPasswdTextBox.Text))
            {
                MessageBox.Show("旧密码格式不正确请重新输入!,正确的格式应该是长度6-20,可以是数字或英文字母.");
                this.oldPasswdTextBox.Text = string.Empty;
                this.oldPasswdTextBox.Focus();
                return;
            }
            string oldPasswd = this.oldPasswdTextBox.Text;

            string newPasswd = this.newPasswdTextBox.Text;


            string verifyPasswd = this.verifyTextBox.Text;

            if (!string.IsNullOrEmpty(newPasswd))
            {
                if (!VerifyUtil.VerifyPwd(newPasswd))
                {
                    MessageBox.Show("新密码格式不正确请重新输入!,正确的格式应该是长度6-20,可以是数字或英文字母.");
                    this.newPasswdTextBox.Text = string.Empty;
                    this.newPasswdTextBox.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(verifyPasswd))
                {
                    MessageBox.Show("请填写确认密码!");
                    this.verifyTextBox.Focus();
                    return;
                }
            }
            else
            {
                newPasswd    = oldPasswd;
                verifyPasswd = oldPasswd;
            }


            if (string.IsNullOrEmpty(mailTextBox.Text))
            {
                MessageBox.Show("请填写邮件地址!");
                this.mailTextBox.Focus();
                return;
            }
            string mail = this.mailTextBox.Text;

            if (!VerifyUtil.VerifyMailInput(mail))
            {
                MessageBox.Show("邮件地址格式错误,请填写正确的邮件地址!");
                this.mailTextBox.Focus();
                return;
            }
            if (string.IsNullOrEmpty(roleComboBox.Text))
            {
                MessageBox.Show("请选择角色!");
                this.roleComboBox.Focus();
                return;
            }
            int roleID = (int)this.roleComboBox.SelectedValue;


            if (newPasswd != verifyPasswd)
            {
                MessageBox.Show("两次输入的密码不符,请重新输入!");
                this.newPasswdTextBox.Text = string.Empty;
                this.verifyTextBox.Text    = string.Empty;
                this.newPasswdTextBox.Focus();
            }
            else
            {
                IDataLayer          dataLayer = (IDataLayer)Settings.Default.Context["datalayer"];
                SysguardWS.UserInfo info      = new sysguard.SysguardWS.UserInfo();


                userInfo.name                = userName;
                userInfo.realName            = realNameTextBox.Text;
                userInfo.passwd              = newPasswd;
                userInfo.mail                = mail;
                userInfo.msn                 = this.msnTextBox.Text;
                userInfo.skype               = this.skypeTextBox.Text;
                userInfo.roleId              = roleID;
                userInfo.updateTime          = DateTime.Now;
                userInfo.updateTimeSpecified = true;


                this.cancelButton.Enabled = false;
                DataLayerResult result = dataLayer.ModifyUserInfo(userInfo, oldPasswd);

                if (result == DataLayerResult.Success)
                {
                    DialogResult dialoResult = MessageBox.Show("更新成功是否退出?", "是否退出", MessageBoxButtons.YesNo);
                    if (dialoResult == DialogResult.Yes)
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else
                    {
                        this.cancelButton.Enabled = true;
                        userControl.Flush();
                    }
                }

                else if (result == DataLayerResult.OldPasswdError)
                {
                    MessageBox.Show("旧密码无效,请重新输入!");
                    this.oldPasswdTextBox.Text = string.Empty;
                    this.oldPasswdTextBox.Focus();
                }
            }
        }