private void buttonEditCustomerAddressCustomerPage_Click(object sender, RoutedEventArgs e) { if (listViewCustomerPageCustomerAddressTable.SelectedItem != null) { int i = listViewCustomerPageCustomerAddressTable.SelectedIndex; int j = listViewCustomersPageCustomerTable.SelectedIndex; Address = listViewCustomerPageCustomerAddressTable.SelectedItem as Address; EditCustomerAddress editCustomerAddress = new EditCustomerAddress(); editCustomerAddress.DataContext = listViewCustomerPageCustomerAddressTable.SelectedItem; editCustomerAddress.ShowDialog(); if (editCustomerAddress.SaveButtonPressed == true) { jackyDigitalXDBEntities.SaveChanges(); jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewCustomersPageCustomerTable.ItemsSource = jackyDigitalXDBEntities.Customers.ToList(); listViewCustomersPageCustomerTable.SelectedIndex = j; listViewCustomerPageCustomerAddressTable.SelectedIndex = i; Helper.ShowMessage1(); } else { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewCustomersPageCustomerTable.ItemsSource = jackyDigitalXDBEntities.Customers.ToList(); listViewCustomersPageCustomerTable.SelectedIndex = j; listViewCustomerPageCustomerAddressTable.SelectedIndex = i; } } else { MessageBox.Show("Please select an address first!"); } }
private void buttonNewAddressEmployeePage_Click(object sender, RoutedEventArgs e) { if (listViewEmployeePageEmployeeTable.SelectedItem != null) { int i = listViewEmployeePageEmployeeTable.SelectedIndex; Emp = listViewEmployeePageEmployeeTable.SelectedItem as Employee; Address = new Address(); AddNewEmployeeAddress addNewEmployeeAddress = new AddNewEmployeeAddress(); addNewEmployeeAddress.DataContext = Address; addNewEmployeeAddress.ShowDialog(); if (addNewEmployeeAddress.SaveButtonPressed == true) { JackyDigitalXDBEntities.Addresses.Add(Address); Emp.Addresses.Add(Address); JackyDigitalXDBEntities.SaveChanges(); listViewEmployeePageEmployeeTable.ItemsSource = null; listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; } } else { MessageBox.Show("Please select an Employee first!"); } }
public RetailerInformation() { InitializeComponent(); jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); RetailerList.ItemsSource = jackyDigitalXDBEntities.Retailers.ToList(); }
private void buttonEditCustomerBasicInformationCustomerPage_Click(object sender, RoutedEventArgs e) { if (listViewCustomersPageCustomerTable.SelectedItem != null) { int i = listViewCustomersPageCustomerTable.SelectedIndex; Customer = listViewCustomersPageCustomerTable.SelectedItem as Customer; OriginalCustomerUserName = Customer.UserName; EditCustomerBasicInformation editCustomerBasicInformation = new EditCustomerBasicInformation(); editCustomerBasicInformation.DataContext = listViewCustomersPageCustomerTable.SelectedItem; editCustomerBasicInformation.ShowDialog(); if (editCustomerBasicInformation.SaveButtonPressed == true) { jackyDigitalXDBEntities.SaveChanges(); Helper.ShowMessage1(); } else { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewCustomersPageCustomerTable.ItemsSource = jackyDigitalXDBEntities.Customers.ToList(); listViewCustomersPageCustomerTable.SelectedIndex = i; } } else { MessageBox.Show("Please select a customer first!"); } }
private void buttonEditCategoryProductPage_Click(object sender, RoutedEventArgs e) { if (listViewProductPageCategoryTable.SelectedItem != null) { int i = listViewProductPageCategoryTable.SelectedIndex; EditCategory editCategory = new EditCategory(); ProductCategory = listViewProductPageCategoryTable.SelectedItem as ProductCategory; editCategory.DataContext = listViewProductPageCategoryTable.SelectedItem; OriginalCategoryName = ProductCategory.Category; editCategory.ShowDialog(); if (editCategory.SaveButtonPressed == true) { jackyDigitalXDBEntities.SaveChanges(); Helper.ShowMessage1(); } else { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewProductPageCategoryTable.ItemsSource = jackyDigitalXDBEntities.ProductCategories.ToList(); listViewProductPageCategoryTable.SelectedIndex = i; } } else { Helper.ShowMessage2(); } }
private void ButtonEditEmployeeAddressEmployeePage_Click(object sender, RoutedEventArgs e) { if (listViewEmployeeAddressEmployeePage.SelectedItem != null) { int i = listViewEmployeePageEmployeeTable.SelectedIndex; int j = listViewEmployeeAddressEmployeePage.SelectedIndex; Address = listViewEmployeeAddressEmployeePage.SelectedItem as Address; EditEmployeeAddress editEmployeeAddress = new EditEmployeeAddress(); editEmployeeAddress.DataContext = listViewEmployeeAddressEmployeePage.SelectedItem; editEmployeeAddress.ShowDialog(); if (editEmployeeAddress.SaveButtonPressed == true) { JackyDigitalXDBEntities.SaveChanges(); listViewEmployeePageEmployeeTable.ItemsSource = null; listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; listViewEmployeeAddressEmployeePage.SelectedIndex = j; } else { listViewEmployeePageEmployeeTable.ItemsSource = null; JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; listViewEmployeeAddressEmployeePage.SelectedIndex = j; } } else { MessageBox.Show("Please selecte an address first!"); } }
public AddInvoiceWindow() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); textBlockInvoicedDateAddInvoiceWindow.Text = System.DateTime.Now.ToString(); textBlockInvoicedByEmployeeID.Text = GetEmployeeID().ToString(); }
private void despatchFinaliseOrderButton_Click(object sender, RoutedEventArgs e) { if (listViewOrderPageOrderTable.SelectedItem != null) { Order = listViewOrderPageOrderTable.SelectedItem as Order; int i = listViewOrderPageOrderTable.SelectedIndex; if (Order.Complete == false) { var orderDetails = from ods in jackyDigitalXDBEntities.OrderDetails where ods.OrderID.Equals(Order.OrderID) select ods; var unpackageds = from us in jackyDigitalXDBEntities.OrderDetails where us.OrderID.Equals(Order.OrderID) where us.Packaged.Equals(false) select us; var invoices = from ins in jackyDigitalXDBEntities.Invoiceds where ins.OrderID.Equals(Order.OrderID) select ins; if ((orderDetails.Count() != 0 && invoices.Count() != 0) && unpackageds.Count() == 0) { Order.Complete = true; jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; MessageBox.Show("Order Completed!"); } else { listViewOrderPageOrderTable.ItemsSource = null; jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; MessageBox.Show("Action Falied! This order cannot be completed becasue essential information is missing. Please verify all information, for instance, Invoice infromation, Order Detailed informaiton, Order Packaged status, and try again."); } } else { Helper.ShowMessage6(); } } else { Helper.ShowMessage4(); } }
private void buttonNewCustomerBasicInformationCustomerPage_Click(object sender, RoutedEventArgs e) { Customer = new Customer(); AddNewCustomerBasicInformation addNewCustomerBasicInformation = new AddNewCustomerBasicInformation(); addNewCustomerBasicInformation.DataContext = Customer; addNewCustomerBasicInformation.ShowDialog(); if (addNewCustomerBasicInformation.SaveButtonPressed == true) { jackyDigitalXDBEntities.Customers.Add(Customer); jackyDigitalXDBEntities.SaveChanges(); listViewCustomersPageCustomerTable.ItemsSource = null; listViewCustomersPageCustomerTable.ItemsSource = jackyDigitalXDBEntities.Customers.ToList(); Helper.ShowMessage1(); } else { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewCustomersPageCustomerTable.ItemsSource = jackyDigitalXDBEntities.Customers.ToList(); } }
private void buttonNewEmployeeBasicInformationEmployeePage_Click(object sender, RoutedEventArgs e) { Emp = new Employee(); AddNewEmployeeBasicInformation addnewEmployeeBasicInformation = new AddNewEmployeeBasicInformation(); addnewEmployeeBasicInformation.DataContext = Emp; addnewEmployeeBasicInformation.passwordBoxAddNewEmployeeBasicInformation.Visibility = Visibility.Collapsed; addnewEmployeeBasicInformation.passwordBoxConfirmNewEmployeeBasicInformation.Visibility = Visibility.Collapsed; addnewEmployeeBasicInformation.ShowDialog(); if (addnewEmployeeBasicInformation.SaveButtonPressed == true) { JackyDigitalXDBEntities.Employees.Add(Emp); JackyDigitalXDBEntities.SaveChanges(); listViewEmployeePageEmployeeTable.ItemsSource = null; listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); Helper.ShowMessage1(); } else { return; } }
private void buttonOrderPageEditBasicOrderInformation_Click(object sender, RoutedEventArgs e) { if (listViewOrderPageOrderTable.SelectedItem != null) { Order = listViewOrderPageOrderTable.SelectedItem as Order; if (Order.Complete == false) { int i = listViewOrderPageOrderTable.SelectedIndex; EditBasicOrderInformationWindow editBasicOrderInformationWindow = new EditBasicOrderInformationWindow(); editBasicOrderInformationWindow.DataContext = listViewOrderPageOrderTable.SelectedItem; editBasicOrderInformationWindow.ShowDialog(); if (editBasicOrderInformationWindow.SaveButtonPressed == true) { jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; Helper.ShowMessage1(); } else { listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewOrderPageOrderTable.SelectedIndex = i; } } else { MessageBox.Show("This 'Order Information' cannot be modified because the status of this order is 'Completed'."); } } else { Helper.ShowMessage2(); } }
private void buttonEditProductProductPage_Click(object sender, RoutedEventArgs e) { if (listViewProductPageProductTable.SelectedItem != null) { int i = listViewProductPageProductTable.SelectedIndex; int j = listViewProductPageSubCategoryTable.SelectedIndex; int k = listViewProductPageCategoryTable.SelectedIndex; EditProduct editProduct = new EditProduct(); editProduct.DataContext = listViewProductPageProductTable.SelectedItem; Product = listViewProductPageProductTable.SelectedItem as Product; OriginalPicture = Product.Picture; OriginalProductName = Product.ProductName; editProduct.ShowDialog(); if (editProduct.SaveButtonPressed == true) { jackyDigitalXDBEntities.SaveChanges(); jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewProductPageCategoryTable.ItemsSource = jackyDigitalXDBEntities.ProductCategories.ToList(); listViewProductPageProductTable.SelectedIndex = i; listViewProductPageSubCategoryTable.SelectedIndex = j; listViewProductPageCategoryTable.SelectedIndex = k; } else { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewProductPageCategoryTable.ItemsSource = jackyDigitalXDBEntities.ProductCategories.ToList(); listViewProductPageProductTable.SelectedIndex = i; listViewProductPageSubCategoryTable.SelectedIndex = j; listViewProductPageCategoryTable.SelectedIndex = k; } } else { Helper.ShowMessage2(); } }
public EmployeesPage() { JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); loadEmployeeTable(); }
private void ButtonEditEmployeeBasicInformationEmployeePage_Click(object sender, RoutedEventArgs e) { if (listViewEmployeePageEmployeeTable.SelectedItem != null) { int i = listViewEmployeePageEmployeeTable.SelectedIndex; Emp = listViewEmployeePageEmployeeTable.SelectedItem as Employee; Employee employee = (from emp in JackyDigitalXDBEntities.Employees where emp.Username == MainWindow.Username select emp).FirstOrDefault(); int employeeID = employee.EmployeeID; var thisEmployeeRoles = JackyDigitalXDBEntities.selectEmployeeRoles(employeeID); Verification verification = new Verification(); if (thisEmployeeRoles.Contains(verification.Administrator)) { OriginalEmployeeUsername = Emp.Username; OriginalPassword = Emp.Password; OriginalPicture = Emp.EmployeeImage; EditEmployeeBasicInformation editEmployeeBasicInformation = new EditEmployeeBasicInformation(); editEmployeeBasicInformation.DataContext = listViewEmployeePageEmployeeTable.SelectedItem; editEmployeeBasicInformation.passwordBoxEditEmployeeBasicInformation.Visibility = Visibility.Collapsed; editEmployeeBasicInformation.passwordBoxConfirmEditEmployeeBasicInformation.Visibility = Visibility.Collapsed; editEmployeeBasicInformation.ShowDialog(); if (editEmployeeBasicInformation.SaveButtonPressed == true) { JackyDigitalXDBEntities.SaveChanges(); JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; Helper.ShowMessage1(); } else { JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; } } else { verification = new Verification(); var selectedEmployeeRoles = JackyDigitalXDBEntities.selectEmployeeRoles(Emp.EmployeeID); if (selectedEmployeeRoles.Contains(verification.Administrator)) { MessageBox.Show("You do NOT have permission to modify this user"); } else { OriginalEmployeeUsername = Emp.Username; OriginalPassword = Emp.Password; OriginalPicture = Emp.EmployeeImage; EditEmployeeBasicInformation editEmployeeBasicInformation = new EditEmployeeBasicInformation(); editEmployeeBasicInformation.DataContext = listViewEmployeePageEmployeeTable.SelectedItem; editEmployeeBasicInformation.passwordBoxEditEmployeeBasicInformation.Visibility = Visibility.Collapsed; editEmployeeBasicInformation.passwordBoxConfirmEditEmployeeBasicInformation.Visibility = Visibility.Collapsed; editEmployeeBasicInformation.ShowDialog(); if (editEmployeeBasicInformation.SaveButtonPressed == true) { JackyDigitalXDBEntities.SaveChanges(); JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; Helper.ShowMessage1(); } else { JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; } } } } else { MessageBox.Show("Please select an employee first!"); } }
public AddBasicOrderInformationWindow() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); textBlockOrderDateAddBasicOrderInformationWindow.Text = DateTime.Now.ToString(); }
public EditCustomerBasicInformation() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); }
public SearchProduct() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); loadCategoryTable(); }
public AddressInformation() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); listViewAddressInformationAddressInformationWindow.ItemsSource = jackyDigitalXDBEntities.AddressTypes.ToList(); }
private void buttonOrderPageEditDetailedOrderInformation_Click(object sender, RoutedEventArgs e) { if (listViewOrderPageOrderDetailedTable.SelectedItem != null) { Order = listViewOrderPageOrderTable.SelectedItem as Order; OrderDetail = listViewOrderPageOrderDetailedTable.SelectedItem as OrderDetail; int originalQuantity = OrderDetail.Quantity; int i = listViewOrderPageOrderTable.SelectedIndex; int j = listViewOrderPageOrderDetailedTable.SelectedIndex; if (Order.Complete == false && OrderDetail.Packaged == false) { EditDetatiledOrderInformationWindow editDetailedOrderInformationWindow = new EditDetatiledOrderInformationWindow(); editDetailedOrderInformationWindow.DataContext = listViewOrderPageOrderDetailedTable.SelectedItem; if (OrderDetail.Packaged == true) { editDetailedOrderInformationWindow.textBlockPackaged.Visibility = Visibility.Visible; editDetailedOrderInformationWindow.textBlockUnpackaged.Visibility = Visibility.Collapsed; editDetailedOrderInformationWindow.Packaged = true; } else { editDetailedOrderInformationWindow.textBlockPackaged.Visibility = Visibility.Collapsed; editDetailedOrderInformationWindow.textBlockUnpackaged.Visibility = Visibility.Visible; editDetailedOrderInformationWindow.Packaged = false; } editDetailedOrderInformationWindow.ShowDialog(); if (editDetailedOrderInformationWindow.SaveButtonPressed == true) { if (originalQuantity != Convert.ToInt32(editDetailedOrderInformationWindow.textBoxQuantityEditDetailedOrderInformationWindow.Text.ToString())) { if (EditDetatiledOrderInformationWindow.ButtonFindPressed == true) { if (OrderDetail.Quantity <= EditDetatiledOrderInformationWindow.ProductStockUnits) { Order.OrderDetails.Add(OrderDetail); int stockRemaining = EditDetatiledOrderInformationWindow.ProductStockUnits - OrderDetail.Quantity; jackyDigitalXDBEntities.updateProduct(EditDetatiledOrderInformationWindow.ProductSelected.ProductID, EditDetatiledOrderInformationWindow.ProductSelected.RetailerID, EditDetatiledOrderInformationWindow.ProductSelected.SubCategoryID, EditDetatiledOrderInformationWindow.ProductSelected.ProductName, EditDetatiledOrderInformationWindow.ProductSelected.ProductDescription, EditDetatiledOrderInformationWindow.ProductSelected.Price, stockRemaining, EditDetatiledOrderInformationWindow.ProductSelected.Picture); jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; Helper.ShowMessage1(); } else if ((OrderDetail.Quantity > EditDetatiledOrderInformationWindow.ProductStockUnits) && EditDetatiledOrderInformationWindow.ProductStockUnits != 0) { int backOrders = OrderDetail.Quantity - EditDetatiledOrderInformationWindow.ProductStockUnits; MessageBox.Show("The order quantity is greater thant the units in stock. A second order will be generated automatically."); OrderDetail.Quantity = EditDetatiledOrderInformationWindow.ProductStockUnits; Order.OrderDetails.Add(OrderDetail); int stockRemaining = 0; jackyDigitalXDBEntities.updateProduct(EditDetatiledOrderInformationWindow.ProductSelected.ProductID, EditDetatiledOrderInformationWindow.ProductSelected.RetailerID, EditDetatiledOrderInformationWindow.ProductSelected.SubCategoryID, EditDetatiledOrderInformationWindow.ProductSelected.ProductName, EditDetatiledOrderInformationWindow.ProductSelected.ProductDescription, EditDetatiledOrderInformationWindow.ProductSelected.Price, stockRemaining, EditDetatiledOrderInformationWindow.ProductSelected.Picture); jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; Order Order2 = new Order(); Order2.OrderID = 0; Order2.CustomerID = Order.CustomerID; Order2.AddressID = Order.AddressID; Order2.OrderDate = Order.OrderDate; Order2.Complete = false; jackyDigitalXDBEntities.Orders.Add(Order2); OrderDetail OrderDetail2 = new OrderDetail(); OrderDetail2.DetailID = 0; OrderDetail2.OrderID = Order2.OrderID; OrderDetail2.ProductID = OrderDetail.ProductID; OrderDetail2.Quantity = backOrders; OrderDetail2.Packaged = false; OrderDetail2.PackagedBy = null; Order2.OrderDetails.Add(OrderDetail2); jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; } else if ((OrderDetail.Quantity > EditDetatiledOrderInformationWindow.ProductStockUnits) && EditDetatiledOrderInformationWindow.ProductStockUnits == 0) { MessageBox.Show("Please not that the unit in stock for this product is 0 (zero). An order will still be generated, however, please purchase more products in order to finalise this order."); Order.OrderDetails.Add(OrderDetail); OrderDetail.Packaged = false; OrderDetail.PackagedBy = null; jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; } } else { Product thisProduct = (from tp in jackyDigitalXDBEntities.Products where tp.ProductID == OrderDetail.ProductID select tp).FirstOrDefault(); int currentStocks = thisProduct.UnitsInStock; if (OrderDetail.Quantity <= currentStocks) { Order.OrderDetails.Add(OrderDetail); int stockRemaining = currentStocks - OrderDetail.Quantity; jackyDigitalXDBEntities.updateProduct(thisProduct.ProductID, thisProduct.RetailerID, thisProduct.SubCategoryID, thisProduct.ProductName, thisProduct.ProductDescription, thisProduct.Price, stockRemaining, thisProduct.Picture); jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; Helper.ShowMessage1(); } else if ((OrderDetail.Quantity > currentStocks) && currentStocks != 0) { int backOrders = OrderDetail.Quantity - currentStocks; MessageBox.Show("The order quantity is greater thant the units in stock. A second order will be generated automatically."); OrderDetail.Quantity = currentStocks; Order.OrderDetails.Add(OrderDetail); int stockRemaining = 0; jackyDigitalXDBEntities.updateProduct(thisProduct.ProductID, thisProduct.RetailerID, thisProduct.SubCategoryID, thisProduct.ProductName, thisProduct.ProductDescription, thisProduct.Price, stockRemaining, thisProduct.Picture); jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; Order Order2 = new Order(); Order2.OrderID = 0; Order2.CustomerID = Order.CustomerID; Order2.AddressID = Order.AddressID; Order2.OrderDate = Order.OrderDate; Order2.Complete = false; jackyDigitalXDBEntities.Orders.Add(Order2); OrderDetail OrderDetail2 = new OrderDetail(); OrderDetail2.DetailID = 0; OrderDetail2.OrderID = Order2.OrderID; OrderDetail2.ProductID = OrderDetail.ProductID; OrderDetail2.Quantity = backOrders; OrderDetail2.Packaged = false; OrderDetail2.PackagedBy = null; Order2.OrderDetails.Add(OrderDetail2); jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; } else if ((OrderDetail.Quantity > currentStocks) && currentStocks == 0) { MessageBox.Show("Please not that the unit in stock for this product is 0 (zero). An order will still be generated, however, please purchase more products in order to finalise this order."); Order.OrderDetails.Add(OrderDetail); OrderDetail.Packaged = false; OrderDetail.PackagedBy = null; jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; } } } else { jackyDigitalXDBEntities.SaveChanges(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; } } else { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewOrderPageOrderTable.ItemsSource = null; listViewOrderPageOrderTable.ItemsSource = jackyDigitalXDBEntities.Orders.ToList(); listViewOrderPageOrderTable.SelectedIndex = i; listViewOrderPageOrderDetailedTable.SelectedIndex = j; } } else { MessageBox.Show("This 'Detailed Order Information' cannot be modified because EITHER the status of this order is 'Completed' OR the order was already 'Packaged'."); } } else { Helper.ShowMessage2(); } }
public AddNewEmployeeBasicInformation() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); }
public CustomersPage() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); loadCustomerTable(); }
public EmployeeRoleManagementWindow() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); }
public EditCategory() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); }
public OrdersPage() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); LoadListView(); }
private void editRoleButtonEmployeePage_Click(object sender, RoutedEventArgs e) { if (listViewEmployeePageEmployeeTable.SelectedItem != null) { Employee employee = (from emp in JackyDigitalXDBEntities.Employees where emp.Username == MainWindow.Username select emp).FirstOrDefault(); int employeeID = employee.EmployeeID; var thisEmployeeRoles = JackyDigitalXDBEntities.selectEmployeeRoles(employeeID); Verification verification = new Verification(); if (thisEmployeeRoles.Contains(verification.Administrator)) { int i = listViewEmployeePageEmployeeTable.SelectedIndex; Emp = listViewEmployeePageEmployeeTable.SelectedItem as Employee; EmployeeRoleManagementWindow employeeRoleManagementWindow = new EmployeeRoleManagementWindow(); employeeRoleManagementWindow.rightLB.ItemsSource = Emp.Roles.ToList(); employeeRoleManagementWindow.leftLB.ItemsSource = JackyDigitalXDBEntities.Roles.ToList(); employeeRoleManagementWindow.ShowDialog(); if (employeeRoleManagementWindow.NewAdminNeeded == false) { JackyDigitalXDBEntities.SaveChanges(); listViewEditEmployeePageRoleTable.ItemsSource = null; JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; Binding binding = new Binding("SelectedItem.Roles"); binding.Source = listViewEmployeePageEmployeeTable; listViewEditEmployeePageRoleTable.SetBinding(ListView.ItemsSourceProperty, binding); } else { AddNewAdmin addNewAdmin = new AddNewAdmin(); addNewAdmin.listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); addNewAdmin.ShowDialog(); while (addNewAdmin.IsSelected == false) { MessageBox.Show("A new Administrator is required because the system must have ONE (and only one) Administrator at any time. Please choose a new Administrator in the new dialog box."); addNewAdmin = new AddNewAdmin(); addNewAdmin.listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); addNewAdmin.ShowDialog(); } Role adminRole = (from ar in JackyDigitalXDBEntities.Roles where ar.Role1 == verification.Administrator select ar).FirstOrDefault(); Emp.Roles.Remove(adminRole); addNewAdmin.NewAdmin.Roles.Add(adminRole); JackyDigitalXDBEntities.SaveChanges(); listViewEmployeePageEmployeeTable.ItemsSource = null; listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; MessageBox.Show(string.Format("You successfully assigned Administrator role to {0} {1}", addNewAdmin.NewAdmin.FirstName, addNewAdmin.NewAdmin.LastName)); } } else { int i = listViewEmployeePageEmployeeTable.SelectedIndex; Emp = listViewEmployeePageEmployeeTable.SelectedItem as Employee; verification = new Verification(); var selectedEmployeeRoles = JackyDigitalXDBEntities.selectEmployeeRoles(Emp.EmployeeID); if (selectedEmployeeRoles.Contains(verification.Administrator)) { MessageBox.Show("You do NOT have permission to modify this user"); } else { var rolesWithoutAdmin = from rwa in JackyDigitalXDBEntities.Roles where rwa.Role1 != verification.Administrator select rwa; EmployeeRoleManagementWindow employeeRoleManagementWindow = new EmployeeRoleManagementWindow(); employeeRoleManagementWindow.rightLB.ItemsSource = Emp.Roles.ToList(); employeeRoleManagementWindow.leftLB.ItemsSource = rolesWithoutAdmin.ToList(); employeeRoleManagementWindow.ShowDialog(); JackyDigitalXDBEntities.SaveChanges(); listViewEditEmployeePageRoleTable.ItemsSource = null; JackyDigitalXDBEntities = new JackyDigitalXDBEntities(); listViewEmployeePageEmployeeTable.ItemsSource = JackyDigitalXDBEntities.Employees.ToList(); listViewEmployeePageEmployeeTable.SelectedIndex = i; Binding binding = new Binding("SelectedItem.Roles"); binding.Source = listViewEmployeePageEmployeeTable; listViewEditEmployeePageRoleTable.SetBinding(ListView.ItemsSourceProperty, binding); } } } else { MessageBox.Show("Please select an employee first!"); } }
public SearchCustomer() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); listViewCustomerInfoSearchCustomer.ItemsSource = jackyDigitalXDBEntities.Customers.ToList(); }
public AddProduct() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); }
public EditDetatiledOrderInformationWindow() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); }
public EditCustomerAddress() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); }
public SearchEmployee() { jackyDigitalXDBEntities = new JackyDigitalXDBEntities(); InitializeComponent(); listViewEmployeePageEmployeeTable.ItemsSource = jackyDigitalXDBEntities.Employees.ToList(); }