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); } }
public void TechnicianIdExistanceCheck() { IdChecker idChecker = new IdChecker(); List <Technician> allTechnicians = new List <Technician>(); allTechnicians.Add(new Technician(1, "Jan", "Nowak", 2800)); ITechnician technician = new ComputerService.Fakes.StubITechnician() { GetAllTechnicians = () => allTechnicians }; int idToCheck = 2; bool result = idChecker.CheckTechnicianIdExistance(technician, idToCheck); Assert.IsFalse(result); }
public void ClientIdExistanceCheck() { IdChecker idChecker = new IdChecker(); List <Client> allClients = new List <Client>(); allClients.Add(new Client(1, "Jan", "Kowalski", "214412412421", "24241241242")); IClient client = new ComputerService.Fakes.StubIClient() { GetAllClients = () => allClients }; int idToCheck = 1; bool result = idChecker.CheckClientIdExistance(client, idToCheck); Assert.IsTrue(result); }
private bool checkValidate() { if (viewModel == null) { return(false); } if (viewModel.Sd_idtp_pat == PiDictCodeConst.SD_IDTP_IDCARD) { if (string.IsNullOrEmpty(viewModel.Idno_pat) || !IdChecker.CheckIDCard(viewModel.Idno_pat)) { this.ShowInfo("请录入正确的患者身份证号!"); (this.xapFormControl.GetUserRender("pat_card", "idno_pat") as XLabelBaseUserRender).UserRender.Focus(); return(false); } } if (viewModel.Sd_idtp_agent == PiDictCodeConst.SD_IDTP_IDCARD) { if (string.IsNullOrEmpty(viewModel.Idno_agent) || !IdChecker.CheckIDCard(viewModel.Idno_agent)) // (^\d{18}$)|(^\d{15}$)<= 错误, 在 18位身份证号码最后一位允许一位字母, { this.ShowInfo("请录入正确的代办人身份证号!"); (this.xapFormControl.GetUserRender("pat_card", "idno_agent") as XLabelBaseUserRender).UserRender.Focus(); return(false); } } if (viewModel.Age_agent != null && (viewModel.Age_agent < 0 || viewModel.Age_agent > 200)) { this.ShowAlert("年龄输入在0-200岁之间!"); return(false); } if (!String.IsNullOrWhiteSpace(viewModel.Id_idtp_agent) && !String.IsNullOrWhiteSpace(viewModel.Id_idtp_pat) && !String.IsNullOrWhiteSpace(viewModel.Idno_pat) && !String.IsNullOrWhiteSpace(viewModel.Idno_agent) && viewModel.Id_idtp_agent.Equals(viewModel.Id_idtp_pat) && viewModel.Idno_pat.Equals(viewModel.Idno_agent)) { this.ShowInfo("患者证件号码不能与代办人证件号码相同!"); return(false); } return(true); }
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); } }
public async Task <IActionResult> Check(IdChecker idChecker) { if (idChecker.type == 1) { ClanOrgOdb model = await _context.ClanOrgOdbora .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 2) { Festival model = await _context.Festivali .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 3) { Forma model = await _context.Forme .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 4) { Glumac model = await _context.Glumci .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 5) { Nagrada model = await _context.Nagrade .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 6) { OrgOdb model = await _context.OrgOdbori .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 7) { Pozoriste model = await _context.Pozorista .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 8) { Predstava model = await _context.Predstave .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 9) { PropDeoFest model = await _context.PropDeoFesta .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 10) { Radnik model = await _context.Radnici .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 11) { Reditelj model = await _context.Reditelji .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 12) { Sala model = await _context.Sale .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 13) { Selektor model = await _context.Selektori .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } if (idChecker.type == 14) { Ugovor model = await _context.Ugovori .FirstOrDefaultAsync(i => i.id == idChecker.idChecker); if (model == null) { return(Ok()); } } return(BadRequest()); }