public void InitializeWithGeneralNumber(int RefNumber) { SEMAPHORE = true; aAdjustGeneralList = AdjustInventoryGeneralMgmt.SelectAllAdjustsGeneral(RefNumber, string.Empty, string.Empty); aItemsTable = AdjustInventoryDetailedMgmt.SelectAllAdjustsDetailed(RefNumber, -1); AllItemsTable = ItemsMgmt.SelectAllItems(); aUserRow = UsersMgmt.SelectUserInfoByID(int.Parse(aAdjustGeneralList.Rows[0]["TellerID"].ToString())); if (aItemsTable.Rows.Count > 0) { aItemsTable.Columns.Add("PhysicalCountColumn", typeof(double)); aItemsTable.Columns.Add("DifferencesColumn", typeof(double)); aItemsTable.Columns.Add("DiffValueColumn", typeof(double)); page(1); } else { MatchLbl.Visible = true; } AdjDatePicker.Text = aAdjustGeneralList.Rows[0]["Date"].ToString(); ReferenceNumberTxtBox.Text = aAdjustGeneralList.Rows[0]["Number"].ToString(); SEMAPHORE = false; }
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; } }
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; } }
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; } }
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(); } }