Beispiel #1
0
 public static void FillTemplate(int UserID, bool isTemp = false)
 {
     if (IsCurrentUserAdmin && !isTemp)
     {
         CurrentActiveTemplate = AdminTemplate;
         CurrentActiveTemplate.ClearPermittedEvents();
         DataTable dtEvets = PriviligesMgmt.SelectEventIDbyUserID(UserID);
         foreach (DataRow dr in dtEvets.Rows)
         {
             CurrentActiveTemplate.AddPermittedEvent((Events)dr[0]);
         }
     }
     else if (!isTemp)
     {
         CurrentActiveTemplate = CurrentUserTemplate;
         CurrentActiveTemplate.ClearPermittedEvents();
         DataTable dtEvets = PriviligesMgmt.SelectEventIDbyUserID(UserID);
         foreach (DataRow dr in dtEvets.Rows)
         {
             CurrentActiveTemplate.AddPermittedEvent((Events)dr[0]);
         }
     }
     else
     {
         CurrentActiveTemplate = TempUserTemplate;
         CurrentActiveTemplate.ClearPermittedEvents();
         DataTable dtEvets = PriviligesMgmt.SelectEventIDbyUserID(UserID);
         foreach (DataRow dr in dtEvets.Rows)
         {
             CurrentActiveTemplate.AddPermittedEvent((Events)dr[0]);
         }
     }
 }
Beispiel #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();;
            }
        }
Beispiel #3
0
 private void UserNameComboBox_SelectedValueChanged(object sender, EventArgs e)
 {
     try
     {
         if (UserNameComboBox.SelectedValue != null && !isloading)
         {
             //ControlHelper.SuspendDrawing(this);
             int  UserID = int.Parse(UserNameComboBox.SelectedValue.ToString());
             bool isenabled;
             if (UsersMgmt.SelectUserInfoByID(UserID)["IsAdmin"].ToString() == "1")
             {
                 PasswordTxtBox.UseSystemPasswordChar = true;
                 isenabled = false;
                 CannotEditAdminLbl.Visible = true;
             }
             else
             {
                 PasswordTxtBox.UseSystemPasswordChar = false;
                 isenabled = true;
                 CannotEditAdminLbl.Visible = false;
             }
             DataRow UserInfo = UsersMgmt.SelectUserInfoByID(UserID);
             foreach (var aGroupBox in this.Controls.OfType <GroupBox>())
             {
                 foreach (TextBox aTextBox in aGroupBox.Controls.OfType <TextBox>())
                 {
                     aTextBox.Text    = UserInfo[aTextBox.Name.ToString().Substring(0, aTextBox.Name.Length - 6)].ToString();
                     aTextBox.Enabled = isenabled;
                 }
                 foreach (CheckBox aCheckBox in aGroupBox.Controls.OfType <CheckBox>())
                 {
                     aCheckBox.Checked = PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString()));
                     aCheckBox.Enabled = isenabled;
                 }
             }
             UpdateInfoBtn.Enabled = isenabled;
             UpdatePrivBtn.Enabled = isenabled;
             //  ControlHelper.ResumeDrawing(this);
         }
     }
     catch (Exception ex)
     {
         //ControlHelper.ResumeDrawing(this);
         MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UserNameComboBox_SelectedValueChanged] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Beispiel #4
0
 private void UpdatePrivBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (Validators.TxtBoxNotEmpty(UserNameComboBox.Text))
         {
             int UserID = int.Parse(UserNameComboBox.SelectedValue.ToString());
             if (UsersMgmt.SelectUserInfoByID(UserID)["IsAdmin"].ToString() == "1")
             {
                 MessageBox.Show(UiText.CannotEditAdminsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 foreach (CheckBox aCheckBox in PriviligesGB.Controls.OfType <CheckBox>())
                 {
                     if (aCheckBox.Checked == true)
                     {
                         if (!PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString())))
                         {
                             PriviligesMgmt.AddPrivilige(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString()));
                         }
                     }
                     else
                     {
                         if (PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString())))
                         {
                             PriviligesMgmt.RemovePrivilige(UserID, EventsMgmt.SelectEventIDbyName(aCheckBox.Tag.ToString()));
                         }
                     }
                 }
                 MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show(MsgTxt.PleaseSelectTxt + " " + MsgTxt.UserTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     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);
         throw;
     }
 }
Beispiel #5
0
        private void UserNameComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            try
            {
                if (UserNameComboBox.SelectedValue != null && !isloading)
                {
                    int     UserID   = int.Parse(UserNameComboBox.SelectedValue.ToString());
                    DataRow UserInfo = UsersMgmt.SelectUserInfoByID(UserID);

                    foreach (TextBox aTextBox in UserInfoGB.Controls.OfType <TextBox>())
                    {
                        aTextBox.Text = UserInfo[aTextBox.Name.ToString().Substring(0, aTextBox.Name.Length - 6)].ToString();
                    }
                    EditAdminsCheckBox.Checked = PriviligesMgmt.IsPriviligeExist(UserID, EventsMgmt.SelectEventIDbyName("EditAdmins"));
                    AdminCheckBox.Checked      = UsersMgmt.IsUserAdmin(UserID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UserNameComboBox_SelectedValueChanged] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }