客房管理系统_1._0.Register.buttonRegisterOK_Click C# (CSharp) Method

buttonRegisterOK_Click() private method

private buttonRegisterOK_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void buttonRegisterOK_Click(object sender, EventArgs e)
        {
            if (this.Text == "注册新用户")
            {
                //创建User实体
                newUser.Name = this.textBoxRegisterName.Text;
                if (this.textBoxRegisterPwd1.Text == this.textBoxRegisterPwd2.Text)
                    newUser.Password = this.textBoxRegisterPwd1.Text;
                else
                    newUser.Password = null;
                newUser.Position = this.textBoxRegisterPosition.Text;
                newUser.Privilege = Convert.ToInt32(this.comboBoxRegisterPrivilege.SelectedItem.ToString());
                newUser.Sex = this.comboBoxRegisterSex.SelectedText;
                newUser.Telephone = this.textBoxRegisterTele.Text;

                //创建业务对象,添加实体
                if (new UserManager().Check(newUser))
                {
                    if (newUser.Privilege > MainForm.LoadedUser.Privilege)
                    {
                        if (new UserManager().AddUser(newUser))
                        {
                            MessageBox.Show("注册新用户成功!", "提示");
                        }
                        else
                        {
                            MessageBox.Show("注册没有成功,请重新注册新用户!", "提示");
                        }
                    }
                    else
                    {
                        MessageBox.Show("您没有权限注册该新用户!","提示");
                    }
                }
                else
                {
                    MessageBox.Show("注册信息填写有误,请重新注册新用户!", "提示");
                }
            }
            else if(this.Text =="修改信息")
            {
                UserInformation.CurrentUser.Name =this.textBoxRegisterName.Text ;
                if (this.textBoxRegisterPwd1.Text == this.textBoxRegisterPwd2.Text)
                {
                    UserInformation.CurrentUser.Password = this.textBoxRegisterPwd1.Text;
                }
                else
                {
                    UserInformation.CurrentUser.Password = null;
                }
                UserInformation.CurrentUser.Position =this.textBoxRegisterPosition.Text ;
                UserInformation.CurrentUser.Privilege = Convert.ToInt32(this.comboBoxRegisterPrivilege.SelectedItem.ToString());
                UserInformation.CurrentUser.RegisteredName =this.textBoxRegisterRegisteredName.Text;
                UserInformation.CurrentUser.Sex =this.comboBoxRegisterSex.SelectedText ;
                UserInformation.CurrentUser.Telephone =this.textBoxRegisterTele.Text;
            }
        }