예제 #1
0
파일: EditUser.cs 프로젝트: SariSultan/RMS
        private void UpdateInfoBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (UserNameComboBox.Text != "")
                {
                    if (UsersMgmt.SelectUserInfoByID(int.Parse(UserNameComboBox.SelectedValue.ToString()))["IsAdmin"].ToString() == "1")
                    {
                        MessageBox.Show(UiText.CannotEditAdminsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        Users aUser = new Users();
                        aUser.User_Name        = NameTxtBox.Text;
                        aUser.User_Address     = AddressTxtBox.Text;
                        aUser.User_Phone1      = Phone1TxtBox.Text;
                        aUser.User_Phone2      = Phone2TxtBox.Text;
                        aUser.User_Password    = PasswordTxtBox.Text;
                        aUser.User_Description = DescriptionTxtBox.Text;
                        aUser.User_ID          = int.Parse(UserNameComboBox.SelectedValue.ToString());

                        if (UsersMgmt.UpdateUser(aUser))
                        {
                            foreach (TextBox aTextBox in this.UserInfoGB.Controls.OfType <TextBox>())
                            {
                                aTextBox.Text = "";
                            }
                            MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            UserNameComboBox.Text = "";
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.UnexpectedError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + " " + MsgTxt.UserTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateInfoBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
예제 #2
0
 private void UpdateInfoBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (UserNameComboBox.SelectedValue != null && UserNameComboBox.Text != "")
         {
             UserNameComboBox.BackColor = UserBGColor;
             if (Validators.TxtBoxNotEmpty(PasswordTxtBox.Text))
             {
                 PasswordTxtBox.BackColor = PasswordBGColor;
                 Users aUser = new Users();
                 aUser.User_Name        = NameTxtBox.Text;
                 aUser.User_Address     = AddressTxtBox.Text;
                 aUser.User_Phone1      = Phone1TxtBox.Text;
                 aUser.User_Phone2      = Phone2TxtBox.Text;
                 aUser.User_Password    = PasswordTxtBox.Text;
                 aUser.User_Description = DescriptionTxtBox.Text;
                 aUser.User_ID          = int.Parse(UserNameComboBox.SelectedValue.ToString());
                 UsersMgmt.UpdateUser(aUser);
                 foreach (TextBox aTextBox in this.UserInfoGB.Controls.OfType <TextBox>())
                 {
                     aTextBox.Text = "";
                 }
                 MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 UserNameComboBox.Text = "";
             }
             else
             {
                 MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 PasswordTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                 PasswordTxtBox.Focus();
             }
         }
         else
         {
             MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             UserNameComboBox.BackColor = SharedVariables.TxtBoxRequiredColor;
             UserNameComboBox.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateInfoBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }