private void LoginScreen_BtnSale_Click(object sender, RoutedEventArgs e) { bool checkResult = loginScreen.CheckPassword(); if (checkResult) { tblockUsername.Text = loginScreen.txtBoxAccount.Text; BUS_Employees busEmp = new BUS_Employees(); currentEmpID = tblockUsername.Text; currentEmpType = busEmp.GetEmpTypeByID(tblockUsername.Text); BUS_AccessPermissionGroup busAccPerGr = new BUS_AccessPermissionGroup(); bool isHavePermission = busAccPerGr.IsHavePermission(currentEmpType, "AP001"); if (isHavePermission) { gridLogin.Children.Clear(); var screen = new Cashier(this, currentEmpID); gridLogin.Children.Add(screen); } else { MessageBox.Show("Bạn không có quyền sử dụng chức năng này!"); } } }
private void ListViewItemMenu_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // if(sender.Equals(Cashier)) ItemMenu item = (ItemMenu)((ListBoxItem)sender).DataContext; string perID = item.APID; bool isHavePermission = true; if (perID.Length == 5) { BUS_AccessPermissionGroup busAccPerGr = new BUS_AccessPermissionGroup(); isHavePermission = busAccPerGr.IsHavePermission(_context.GetCurrentEmpType(), perID); } if (isHavePermission) { if (item._Cashier != null) { _context.SwitchWindow(item._Cashier, 1); } else { _context.SwitchWindow(item.Screen); } } else { MessageBox.Show("Bạn không có quyền sử dụng chức năng này!"); } }
private void ReceiptButton_Click(object sender, RoutedEventArgs e) { BUS_Employees busEmp = new BUS_Employees(); string typeEmp = busEmp.GetEmpTypeByID(user); BUS_AccessPermissionGroup busAccPerGr = new BUS_AccessPermissionGroup(); bool isHavePermission = busAccPerGr.IsHavePermission(typeEmp, "AP001"); if (isHavePermission) { _context.SwitchToReceipt(); PrintScreen.Children.Clear(); } else { MessageBox.Show("Bạn không có quyền sử dụng chức năng này!"); } }
private void ListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { SubItem item = (SubItem)((ListView)sender).SelectedItem; if (ListViewMenu.IsMouseCaptured) { string perID = item.APID; BUS_AccessPermissionGroup busAccPerGr = new BUS_AccessPermissionGroup(); bool isHavePermission = busAccPerGr.IsHavePermission(_context.GetCurrentEmpType(), perID); if (isHavePermission) { _context.SwitchScreen(item.Screen); } else { MessageBox.Show("Bạn không có quyền sử dụng chức năng này!"); } } }
private void btSave_Click(object sender, RoutedEventArgs e) { tbGroupAccountValidation.Text = ""; if (tbName.Text == "") { // Name of Employee Type is empty tbGroupAccountValidation.Text = "Tên nhóm tài khoản không dược để trống."; return; } DTO_EmployeeType newEmpType = new DTO_EmployeeType("id", tbName.Text); BUS_EmployeeType busEmpType = new BUS_EmployeeType(); string newID = busEmpType.CreateEmployeeTypes(newEmpType); if (newID == "") { tbGroupAccountValidation.Text = "Tên nhóm tài khoản này đã được tạo trước đây."; } else { BUS_AccessPermissionGroup busAccPerGr = new BUS_AccessPermissionGroup(); foreach (AccessPermissionName item in dgSelectedList) { foreach (DataRow row in AccPersData.Rows) { if (item.name == row[1].ToString()) { busAccPerGr.CreateAccessPermissionGroup(new DTO_AccessPermissionGroup(row[0].ToString(), newID)); break; } } } MessageBox.Show($"Nhóm tài khoản {newEmpType.EmployeeTypeName} đã được tạo."); Window.GetWindow(this).Close(); } }
private void btSave_Click(object sender, RoutedEventArgs e) { tbGroupAccountValidation.Text = ""; if (tbName.Text == "") { // Name of Employee Type is empty tbGroupAccountValidation.Text = "Tên nhóm tài khoản không dược để trống."; return; } BUS_EmployeeType busEmpType = new BUS_EmployeeType(); string editID = busEmpType.GetIDByName(editGrAccInfo.name); bool result = busEmpType.EditEmployeeType(new DTO_EmployeeType(editID, tbName.Text)); if (!result) { tbGroupAccountValidation.Text = "Tên nhóm tài khoản bị trùng với một nhóm tài khoản khác."; return; } BUS_AccessPermissionGroup busAccPerGr = new BUS_AccessPermissionGroup(); #region Get List Permission List <AccessPermissionName> oldPerList = new List <AccessPermissionName>(); if (editGrAccInfo.cashier) { oldPerList.Add(new AccessPermissionName(Constants.CASHIER)); } if (editGrAccInfo.account) { oldPerList.Add(new AccessPermissionName(Constants.ACCOUNT)); } if (editGrAccInfo.accountType) { oldPerList.Add(new AccessPermissionName(Constants.ACCOUNTTYPE)); } if (editGrAccInfo.inventory) { oldPerList.Add(new AccessPermissionName(Constants.INVENTORY)); } if (editGrAccInfo.cost) { oldPerList.Add(new AccessPermissionName(Constants.COST)); } if (editGrAccInfo.menu) { oldPerList.Add(new AccessPermissionName(Constants.MENU)); } if (editGrAccInfo.discount) { oldPerList.Add(new AccessPermissionName(Constants.DISCOUNT)); } if (editGrAccInfo.report) { oldPerList.Add(new AccessPermissionName(Constants.REPORT)); } if (editGrAccInfo.rule) { oldPerList.Add(new AccessPermissionName(Constants.REPORT)); } #endregion // per deleted foreach (AccessPermissionName name in oldPerList) { if (!dgSelectedList.Contains(name)) { foreach (DataRow row in AccPersData.Rows) { if (name.name == row[1].ToString()) { result = busAccPerGr.DeleteAccessPermissionGroup(new DTO_AccessPermissionGroup(row[0].ToString(), editID)); if (!result) { MessageBox.Show($"Đã xảy ra lỗi do quyền bị xóa đi trong quá trình sửa nhóm tài khoản {editGrAccInfo.name}."); } break; } } } } // per added foreach (AccessPermissionName item in dgSelectedList) { if (!oldPerList.Contains(item)) { foreach (DataRow row in AccPersData.Rows) { if (item.name == row[1].ToString()) { result = busAccPerGr.CreateAccessPermissionGroup(new DTO_AccessPermissionGroup(row[0].ToString(), editID)); if (!result) { MessageBox.Show($"Đã xảy ra lỗi do quyền được thêm vào trong quá trình sửa nhóm tài khoản {editGrAccInfo.name}."); } break; } } } } MessageBox.Show($"Đã sửa thành công nhóm tài khoản {editGrAccInfo.name}."); Window.GetWindow(this).Close(); }
private void btSave_Click(object sender, RoutedEventArgs e) { BUS_Employees busEmp = new BUS_Employees(); switch (this.type) { case 1: /// Delete Account if (busEmp.IsDoingAnything(deleteid)) { MessageBox.Show($"Không thể xóa tài khoản {deleteid} do tài khoản này đã lập hóa đơn/lập phiếu chi/nhập hàng/xuất hàng."); return; } bool result1 = busEmp.DeleteEmployee(deleteid); if (result1) { MessageBox.Show($"Đã xóa tài khoản {deleteid}."); Window.GetWindow(this).Close(); } else { MessageBox.Show($"Đã xảy ra lỗi trong quá trình xóa tài khoản."); } break; case 2: /// Delete Account type BUS_AccessPermissionGroup busAccPerGr = new BUS_AccessPermissionGroup(); BUS_EmployeeType busEmpType = new BUS_EmployeeType(); if (!busAccPerGr.DeleteByEmpTypeID(busEmpType.GetIDByName(deleteid))) { MessageBox.Show($"Đã xảy ra lỗi trong quá trình xóa nhóm tài khoản."); } int result2 = busEmpType.DeleteEmployeeType(busEmpType.GetIDByName(deleteid)); if (result2 == 0) { MessageBox.Show($"Không thể xóa do vẫn còn tài khoản có nhóm tài khoản này."); } else { MessageBox.Show($"Đã xóa nhóm tài khoản {deleteid}."); Window.GetWindow(this).Close(); } break; case 3: /// Active Account bool result3 = busEmp.SetState(deleteid, true); if (result3) { MessageBox.Show($"Đã kích hoạt tài khoản {deleteid}."); Window.GetWindow(this).Close(); } else { MessageBox.Show($"Đã xảy ra lỗi trong quá trình kích hoạt tài khoản."); } break; case 4: /// Disable Account bool result4 = busEmp.SetState(deleteid, false); if (result4) { MessageBox.Show($"Đã vô hiệu hóa tài khoản {deleteid}."); Window.GetWindow(this).Close(); } else { MessageBox.Show($"Đã xảy ra lỗi trong quá trình vô hiệu hóa tài khoản."); } break; } }