Exemplo n.º 1
0
        private void FillUserNameComboBox()
        {
            DataTable UsersDataTable = VSWebBL.SecurityBL.UsersBL.Ins.GetAllData();

            UserNameComboBox.DataSource = UsersDataTable;
            UserNameComboBox.TextField  = "FullName";
            UserNameComboBox.ValueField = "FullName";
            UserNameComboBox.DataBind();
        }
Exemplo n.º 2
0
        private void UpdatePrivBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (UserNameComboBox.SelectedValue != null && UserNameComboBox.Text != "")
                {
                    UserNameComboBox.BackColor = UserBGColor;
                    if (UserNameComboBox.Text.ToLower() != "admin")
                    {
                        int UserID = int.Parse(UserNameComboBox.SelectedValue.ToString());
                        if (EditAdminsCheckBox.Checked)
                        {
                            if (!PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins")))
                            {
                                PriviligesMgmt.AddPrivilige(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins"));
                            }
                        }
                        else
                        {
                            if (PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins")))
                            {
                                PriviligesMgmt.RemovePrivilige(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins"));
                            }
                        }
                        if (AdminCheckBox.Checked == true)
                        {
                            UsersMgmt.MakeUserAdmin(UserID, 1);
                        }
                        else
                        {
                            UsersMgmt.MakeUserAdmin(UserID, 0);
                        }

                        MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        UserNameComboBox.Text = "";
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.CannotChangeAdminTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                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 [UpdatePrivBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();;
            }
        }
Exemplo n.º 3
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();
     }
 }