private void OdAdd() { try { if (!IdChecker.IdCheck(oorderdetailList, ShowOrderdetail)) { oorderdetailService.Insert(new Orderdetail() { priceEach = ShowOrderdetail.priceEach, productId = ShowOrderdetail.productId, quantityOrdered = ShowOrderdetail.quantityOrdered }); } else { oorderdetailService.Edit(new Orderdetail() { orderId = ShowOrderdetail.orderId, priceEach = ShowOrderdetail.priceEach, productId = ShowOrderdetail.productId, quantityOrdered = ShowOrderdetail.quantityOrdered }); } } catch (ArgumentException e) { MessageBox.Show("Identical object already exists in the database!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void ODDelete() { try { if (IdChecker.IdCheck(orderdetailList, ShowOrderdetail)) { if (MessageBox.Show("You are about to delete a modified item. \nAre you sure you want to continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No) == MessageBoxResult.Yes) { odService.Delete(odService.GetById(ShowOrderdetail.orderId, ShowOrderdetail.productId)); ODNew(); RefreshTab(); } } else { ODNew(); RefreshTab(); } } catch (ArgumentException) { if (MessageBox.Show("You are about to delete a product from the database. \nAre you sure you want to continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No) == MessageBoxResult.Yes) { odService.Delete(odService.GetById(ShowOrderdetail.orderId, ShowOrderdetail.productId)); ODNew(); RefreshTab(); } } //SelectedProductlineI = SelectedProductlineI; }
private void PLDelete() { try { if (IdChecker.IdCheck(cproductlineList, ShowProductline)) { if (MessageBox.Show("You are about to delete a modified item. \nAre you sure you want to continue?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No) == MessageBoxResult.Yes) { plineService.Delete(plineService.GetById(ShowProductline.id)); PLNew(); } } else { PLNew(); } } catch (ArgumentException) { if (MessageBox.Show("You are about to delete a productline from the database. \nAre you sure you want to continue? \n(all existing products & orders belonging to this productline will be deleted)", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No) == MessageBoxResult.Yes) { plineService.Delete(plineService.GetById(ShowProductline.id)); PLNew(); } } SelectedProductlineI = -1; }
private void ODAdd() { try { ShowOrderdetail.productId = SelectedPProductI; if (SelectedPProductI >= 1) { if ((ShowOrderdetail.priceEach == null || ShowOrderdetail.priceEach > 0) && (ShowOrderdetail.quantityOrdered == null || ShowOrderdetail.quantityOrdered >= 0)) { if (ShowOrderdetail.productId != 0)//null) { if (!IdChecker.IdCheck(orderdetailList, ShowOrderdetail)) { odService.Insert(new Orderdetail() { productId = ShowOrderdetail.productId, quantityOrdered = ShowOrderdetail.quantityOrdered, priceEach = ShowOrderdetail.priceEach }); } else { odService.Edit(new Orderdetail() { productId = ShowOrderdetail.productId, quantityOrdered = ShowOrderdetail.quantityOrdered, priceEach = ShowOrderdetail.priceEach }); } SelectedPProductI = SelectedPProductI; } else { MessageBox.Show("Invalid product name!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("Invalid Quantities/price!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("No product selected for your order!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } catch (ArgumentException) { MessageBox.Show("Identical object already exists in the database!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void PLAdd() { try { if (!IdChecker.IdCheck(cproductlineList, ShowProductline)) { if (!string.IsNullOrEmpty(ShowProductline.name) && !string.IsNullOrWhiteSpace(ShowProductline.name)) { plineService.Insert(new Productline() { name = ShowProductline.name, description = ShowProductline.description, }); } else { MessageBox.Show("Invalid productline name!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { plineService.Edit(new Productline() { id = ShowProductline.id, name = ShowProductline.name, description = ShowProductline.description, }); } cproductlineList = plineService.GetAll("products").ToList(); PProductlineList = plineService.GetAll("products").ToList(); RefreshTab(); var ProductlineList = new List <Productline>() { new Productline() { id = -1, name = "All" } }; ProductlineList.AddRange(cproductlineList); this.ProductlineList = ProductlineList; SelectedProductlineI = -1; } catch (ArgumentException) { MessageBox.Show("Identical object already exists in the database!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void CAdd() { try { if (!IdChecker.IdCheck(ccustomerList, ShowCustomer)) { cService.Insert(new Customer() { name = ShowCustomer.name, city = ShowCustomer.city, countryId = SelectedCCountryI, postalCode = ShowCustomer.postalCode, state = ShowCustomer.state, streetAndNumber = ShowCustomer.streetAndNumber, email = ShowCustomer.email }); SelectedCCountryI = SelectedCCountryI; //ProductList.Add(ShowProduct); } else { cService.Edit(new Customer() { id = ShowCustomer.id, name = ShowCustomer.name, city = ShowCustomer.city, countryId = SelectedCCountryI, postalCode = ShowCustomer.postalCode, state = ShowCustomer.state, streetAndNumber = ShowCustomer.streetAndNumber, email = ShowCustomer.email }); SelectedCCountryI = SelectedCCountryI; } } catch (ArgumentException e) { MessageBox.Show("Identical object already exists in the database!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void OAdd() { try { //if (ShowOrder.shippedDate != null) //{ if (SelectedOStatus != null) { ShowOrder.status = SelectedOStatus; if (IdChecker.IdCheck(oorderList, ShowOrder)) { oService.Edit(new Order() { id = ShowOrder.id, customerId = SelectedCCustomerI, //ShowOrder.customerId, orderDate = ShowOrder.orderDate, requiredDate = ShowOrder.requiredDate, shippedDate = ShowOrder.shippedDate, status = ShowOrder.status, comments = ShowOrder.comments }); OrderList = oService.GetAll("customer").ToList(); oorderList = oService.GetAll("customer").ToList(); } } else { MessageBox.Show("Invalid Status!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } // } //else // MessageBox.Show("Invalid Shipdate!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (ArgumentException e) { MessageBox.Show("Identical object already exists in the database!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void PAdd() { //bool b = false; //foreach (Product product in ProductList) //{ // if (ShowProduct.id == product.id) // { // MessageBox.Show("Product ID already exists in database!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); // b = true; // break; // } //} try { ShowProduct.productlineId = SelectedPProductlineI; Regex reg = new Regex("^1:[0-9]+(?:[.]{1}[0-9]+)?$"); if (SelectedPProductlineI >= 1) { if ((ShowProduct.buyPrice == null || ShowProduct.buyPrice > 0) && (ShowProduct.quantityInOrder == null || ShowProduct.quantityInOrder >= 0) && (ShowProduct.quantityInStock == null || ShowProduct.quantityInStock >= 0)) { if (ShowProduct.name != null) { var m = reg.Match(ShowProduct.scale); if (ShowProduct.scale != null && m.Success) { if (!IdChecker.IdCheck(cproductList, ShowProduct)) { pService.Insert(new Product() { name = ShowProduct.name, description = ShowProduct.description, productlineId = ShowProduct.productlineId, scale = ShowProduct.scale, quantityInStock = ShowProduct.quantityInStock, quantityInOrder = ShowProduct.quantityInOrder, buyPrice = ShowProduct.buyPrice }); } else { pService.Edit(new Product() { id = ShowProduct.id, name = ShowProduct.name, description = ShowProduct.description, productlineId = SelectedPProductlineI, scale = ShowProduct.scale, quantityInStock = ShowProduct.quantityInStock, quantityInOrder = ShowProduct.quantityInOrder, buyPrice = ShowProduct.buyPrice }); } SelectedProductlineI = SelectedProductlineI; } else { MessageBox.Show("Invalid scale!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("Invalid product name!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("Invalid Quantities/price!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("No productline selected for your product!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } catch (ArgumentException) { MessageBox.Show("Identical object already exists in the database!", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }