/// <summary> /// /// This method will iterate through a list of Products and apply the default value to every instance /// of an empty Attribute (i.e., in every DataRow of its Group). /// /// <param name="poProducts">The product list that we are iterating through</param> /// <param name="poDefaultValues">The default values for Attributes</param> /// <returns>None</returns> /// </summary> public static void ApplyDefaults(List <WonkaProduct> poProducts, Dictionary <int, string> poDefaultValues) { foreach (WonkaProduct TempProduct in poProducts) { var iDefaultValEnumerator = poDefaultValues.GetEnumerator(); while (iDefaultValEnumerator.MoveNext()) { int nDefaultAttrId = iDefaultValEnumerator.Current.Key; string sDefaultAttrValue = iDefaultValEnumerator.Current.Value; WonkaRefAttr TempAttr = WonkaRefEnvironment.GetInstance().GetAttributeByAttrId(nDefaultAttrId); WonkaPrdGroup TargetGroup = TempProduct.GetProductGroup(TempAttr.GroupId); foreach (WonkaPrdGroupDataRow TempDataRow in TargetGroup) { string sTempValue = TempDataRow[TempAttr.AttrId]; if (String.IsNullOrEmpty(sTempValue)) { TempDataRow.SetData(TempAttr.AttrId, sDefaultAttrValue); } } } } }
public void TempProductRematchTest(int resolveID, int reResolveID, int amount) { // Creating temp product int old_id = TempProduct.GetNextID(); TempProduct TestProd = new TempProduct("Test", 10m); POS.AddSaleTransaction(TestProd, amount); // Check if price on receipt is correct bool priceCheck = POS.PlacerholderReceipt.TotalPrice == TestProd.SalePrice * amount; // execute receipt, without printing it POS.ExecuteReceipt(false); // Check if the tempproduct can be found in the TempProductDictionary bool DictionaryContains = SC.TempProductDictionary.ContainsKey(old_id); int new_id = TempProduct.GetNextID(); bool ID_Check = new_id > old_id; // download tempproduct form DB TempProduct TestProd_DB = new TempProduct(old_id); // Match temp product SC.MatchTempProduct(TestProd_DB, resolveID); // Getting the TempProduct from DB after merge to see if it has been resolved TempProduct TestProd_DB_AfterMatch = new TempProduct(old_id); bool CheckResolved = TestProd_DB_AfterMatch.Resolved; bool CheckResolvedProdID = TestProd_DB.ResolvedProductID == resolveID; bool CheckResolvedProdID_DB = TestProd_DB_AfterMatch.ResolvedProductID == resolveID; SC.RematchTempProduct(TestProd_DB_AfterMatch, reResolveID); TempProduct TestProd_DB_AfterRematch = new TempProduct(old_id); bool CheckRematchdTempProduct = TestProd_DB_AfterRematch.ResolvedProductID == reResolveID; Assert.IsTrue(ID_Check && CheckResolvedProdID && CheckResolvedProdID_DB && CheckRematchdTempProduct && priceCheck && CheckResolved); }
public TempProduct CreateTempTempProduct(string description, decimal salePrice, int ID) { TempProduct newTempProduct = new TempProduct(description, salePrice); newTempProduct.ID = ID; TempTempProductList.Add(newTempProduct); return(newTempProduct); }
public TempProduct CreateTempProduct(string description, decimal salePrice, int ID) { TempProduct newTempProduct = new TempProduct(description, salePrice); newTempProduct.ID = ID; TempProductDictionary.TryAdd(ID, newTempProduct); return(newTempProduct); }
public void CreateTempProduct() { int old_id = TempProduct.GetNextID(); TempProduct TestProd = new TempProduct("Testing", 10m); TestProd.UploadToDatabase(); int new_id = TempProduct.GetNextID(); Assert.IsTrue(new_id > old_id); }
public void RematchTempProduct(TempProduct tempProductToMatch, int matchedProductID) { Product PreviouslyMatchdProduct = ProductDictionary[tempProductToMatch.ResolvedProductID]; KeyValuePair <int, int> StorageRoomStatus = PreviouslyMatchdProduct.StorageWithAmount.Where(x => x.Key != 0).First(); PreviouslyMatchdProduct.StorageWithAmount[StorageRoomStatus.Key] = StorageRoomStatus.Value + tempProductToMatch.GetTempProductsSaleTransaction().Amount; PreviouslyMatchdProduct.UpdateInDatabase(); MatchTempProduct(tempProductToMatch, matchedProductID); }
private void AddDiscountTable(TempProduct tempProduct, Product product) { // add discount table if (_entities.TempProductDiscounts.Any(a => a.ProductID == tempProduct.ID)) { TempProductDiscount tempProductDiscount = _entities.TempProductDiscounts.FirstOrDefault(a => a.ID == tempProduct.ID); ProductDiscount productDiscount = new ProductDiscount(); productDiscount.DateFrom = tempProductDiscount.DateFrom; productDiscount.DateTo = tempProductDiscount.DateTo; productDiscount.Discount = tempProductDiscount.Discount; product.ProductDiscounts.Add(productDiscount); } }
private void HandleFirstPool() { Row Data; while (!FirstPoolDone()) { while (_serviceProductQueue.TryDequeue(out Data)) { ServiceProduct NewServiceProduct = new ServiceProduct(Data); ServiceProductDictionary.TryAdd(NewServiceProduct.ID, NewServiceProduct); Interlocked.Increment(ref _doneServiceProductCount); } while (_tempProductQueue.TryDequeue(out Data)) { TempProduct NewTempProduct = new TempProduct(Data); TempProductDictionary.TryAdd(NewTempProduct.ID, NewTempProduct); Interlocked.Increment(ref _doneTempProductCount); } while (_storageRoomQueue.TryDequeue(out Data)) { StorageRoom NewStorageRoom = new StorageRoom(Data); StorageRoomDictionary.TryAdd(NewStorageRoom.ID, NewStorageRoom); Interlocked.Increment(ref _doneStorageRoomsCount); } while (_groupsQueue.TryDequeue(out Data)) { Group NewGroup = new Group(Data); GroupDictionary.TryAdd(NewGroup.ID, NewGroup); Interlocked.Increment(ref _doneGroupsCount); } while (_productQueue.TryDequeue(out Data)) { Product NewProduct = new Product(Data); ProductDictionary.TryAdd(NewProduct.ID, NewProduct); Interlocked.Increment(ref _doneProductsCount); } while (_disabledProductsQueue.TryDequeue(out Data)) { Product NewProduct = new Product(Data); DisabledProducts.TryAdd(NewProduct.ID, NewProduct); Interlocked.Increment(ref _doneDisabledProductsCount); } while (_disabledServiceProductsQueue.TryDequeue(out Data)) { ServiceProduct NewProduct = new ServiceProduct(Data); DisabledServiceProducts.TryAdd(NewProduct.ID, NewProduct); Interlocked.Increment(ref _doneDisabledServiceProductsCount); } } }
public ActionResult RemoveTemp(int?id) { TempProduct temp = db.TempProducts.Find(id); db.TempProducts.Remove(temp); db.SaveChanges(); AllClassViewModel viewModel = new AllClassViewModel { TempProducts = db.TempProducts.ToList() }; ModelState.Clear(); return(View("GenerateBill", viewModel)); }
public void price() { InfoFormPrice.CurrentProgressBar = 0; InfoFormPrice.MaxProgressBar = links.Count(); foreach (string link in links) { browserFirst.Navigate().GoToUrl(link); while (true) { IWebElement[] boxs = browserFirst.FindElementsByClassName("list").ToArray(); foreach (IWebElement box in boxs) { try { string quantity = "", name = "", priceTag = "", image = "", category = ""; if (box.Text == "") { continue; } name = box.FindElement(By.TagName("h5")).Text; priceTag = box.FindElement(By.ClassName("price-tag")).Text; quantity = box.FindElement(By.ClassName("select")).FindElement(By.TagName("label")).Text; image = box.FindElement(By.TagName("img")).GetAttribute("src"); category = box.FindElements(By.XPath("//ul[@class='breadcrumb']/li"))[1].Text; InfoFormPrice.CurrentTitle = name + "--" + priceTag + "--" + quantity + "--" + category; TempProduct pro = addTempProduct(name, image, 1, "", true); } catch { continue; } } if (browserFirst.FindElementsByClassName("pag-next").Count != 0) { browserFirst.FindElementByClassName("pag-next").Click(); } else { break; } delay(2); } InfoFormPrice.CurrentProgressBar++; } }
/* User has already found the matching product ID. * First line findes the store storage * Second line subtracts the amount sold from Shop storage*/ public void MatchTempProduct(TempProduct tempProductToMatch, int matchedProductID) { Product MatchedProduct = ProductDictionary[matchedProductID]; tempProductToMatch.Resolve(MatchedProduct); SaleTransaction tempProductsTransaction = tempProductToMatch.GetTempProductsSaleTransaction(); //Gets the Shop storage room, which has = 1, but if it doesn't exist, gets the next one if (MatchedProduct.StorageWithAmount.Count == 0) { MatchedProduct.StorageWithAmount.TryAdd(1, 0); } KeyValuePair <int, int> StorageRoomStatus = MatchedProduct.StorageWithAmount.First(); MatchedProduct.StorageWithAmount[StorageRoomStatus.Key] = StorageRoomStatus.Value - tempProductsTransaction.Amount; MatchedProduct.UpdateInDatabase(); }
private void btn_AddTempProduct_Click(object sender, RoutedEventArgs e) { if (decimal.TryParse(textbox_Price.Text, out price) && price > 0 && textbox_Description != null) { string description = textbox_Description.Text; price = decimal.Parse(textbox_Price.Text); int amount = int.Parse(textBox_ProductAmount.Text); TempProduct NewTemp = _storageController.CreateTempTempProduct(description, price, _tempID); _storageController.TempTempProductList.Add(NewTemp); _posController.AddSaleTransaction(NewTemp, amount); UpdateReceiptEventHandler?.Invoke(this, null); this.Close(); } else { textbox_Description.BorderBrush = Brushes.Red; textbox_Price.BorderBrush = Brushes.Red; } }
protected TempProduct addTempProduct(string Name, string ImageUrl, int CategoryId, string Barcode, bool Status) { TempProduct product = new TempProduct(); product.Name = Name; product.ImageUrl = ImageUrl; product.CategoryId = CategoryId; product.Barcode = Barcode; product.Status = Status; TempProduct returnProduct = tempProductRepository.getMatch(Barcode); if (returnProduct == null) { TempProduct temp = tempProductRepository.Add(product); return(temp); } return(returnProduct); }
public void TestStatisticsTempProduct(decimal price, int Amount, PaymentMethod_Enum PaymentMethod, decimal PaidAmount) { DateTime Start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); DateTime Stop = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);; StatCon.RequestTodayReceipts(); StatCon.CalculatePayments(); StatCon.RequestStatistics(false, 0, false, 0, false, "", Start, Stop); StatCon.GenerateProductSalesAndTotalRevenue(); decimal Kontant_old = Math.Round(StatCon.Payments[0], 2); decimal Dankort_old = Math.Round(StatCon.Payments[1], 2); decimal MobilePay_old = Math.Round(StatCon.Payments[2], 2); int TestProdID = TempProduct.GetNextID(); SC.CreateTempProduct("Test", price, TestProdID); BaseProduct TestProd = SC.TempProductDictionary[TestProdID]; POS.AddSaleTransaction(TestProd, Amount); Payment TestPay = new Payment(Receipt.GetNextID(), PaidAmount, PaymentMethod); POS.PlacerholderReceipt.Payments.Add(TestPay); POS.ExecuteReceipt(false); StatCon.RequestTodayReceipts(); StatCon.CalculatePayments(); StatCon.GenerateProductSalesAndTotalRevenue(); decimal Kontant_new = Math.Round(StatCon.Payments[0], 2); decimal Dankort_new = Math.Round(StatCon.Payments[1], 2); decimal MobilePay_new = Math.Round(StatCon.Payments[2], 2); if (PaymentMethod == PaymentMethod_Enum.Cash) { Assert.IsTrue(Kontant_new == Kontant_old + TestPay.Amount && Dankort_old == Dankort_new && MobilePay_old == MobilePay_new); } else if (PaymentMethod == PaymentMethod_Enum.Card) { Assert.IsTrue((Kontant_new + (PaidAmount - (TestProd.SalePrice * Amount))) == Kontant_old && Dankort_new == Dankort_old + TestPay.Amount && MobilePay_old == MobilePay_new); } else if (PaymentMethod == PaymentMethod_Enum.MobilePay) { Assert.IsTrue(Kontant_new == Kontant_old && Dankort_old == Dankort_new && MobilePay_new == MobilePay_old + TestPay.Amount); } }
public ActionResult RemItem(int?id) { TempProduct temp = db.TempProducts.Find(id); temp.QtyPurchased = temp.QtyPurchased - 1; temp.Quantity = temp.Quantity + 1; if (temp.QtyPurchased <= 1) { temp.QtyPurchased = 1; } db.Entry(temp).State = EntityState.Modified; db.SaveChanges(); AllClassViewModel viewModel = new AllClassViewModel { TempProducts = db.TempProducts.ToList() }; ModelState.Clear(); return(View("GenerateBill", viewModel)); }
public void price() { InfoFormPrice.CurrentProgressBar = 0; InfoFormPrice.MaxProgressBar = links.Count(); foreach (string link in links) { browserFirst.Navigate().GoToUrl(link); IWebElement[] boxs = browserFirst.FindElementByClassName("product-listing").FindElements(By.TagName("li")).ToArray(); foreach (IWebElement box in boxs) { try { string quantity = "", name = "", priceTag = "", image = "", category = ""; if (box.Text == "") { continue; } name = box.FindElement(By.ClassName("item-name")).Text; priceTag = box.FindElement(By.ClassName("item-price")).Text; if (box.FindElements(By.ClassName("productUnit")).Count != 0) { quantity = box.FindElement(By.ClassName("productUnit")).Text; } image = box.FindElement(By.TagName("img")).GetAttribute("src"); category = box.FindElement(By.XPath("//ol[@class='breadcrumb']/li[@class='active']")).Text; InfoFormPrice.CurrentTitle = name + "--" + priceTag + "--" + quantity + "--" + category; TempProduct pro = addTempProduct(name, image, 1, "", true); } catch (Exception ex) { continue; } } InfoFormPrice.CurrentProgressBar++; } }
public ActionResult AddItem(int?id) { TempProduct temp = db.TempProducts.Find(id); if (temp.Quantity >= 1) { temp.QtyPurchased = temp.QtyPurchased + 1; temp.Quantity = temp.Quantity - 1; db.Entry(temp).State = EntityState.Modified; db.SaveChanges(); } else { ViewBag.Message = "Insufficient Quntity"; } AllClassViewModel viewModel = new AllClassViewModel { TempProducts = db.TempProducts.ToList() }; ModelState.Clear(); return(View("GenerateBill", viewModel)); }
public TempProduct Add(TempProduct product) { FoodEntities.TempProducts.Add(product); FoodEntities.SaveChanges(); return(product); }
public ActionResult GenerateBill(TempProduct tempProduct) { string barcode = tempProduct.BarCodeId.ToString(); IEnumerable <Product> products = db.Products.ToList(); bool flag = false; foreach (var item in products) { if (item.BarCodeId.Equals(barcode)) { flag = true; tempProduct.BarCodeId = item.BarCodeId; tempProduct.Brand = item.Brand; tempProduct.Category = item.Category; tempProduct.Colour = item.Colour; tempProduct.Price = item.Price; tempProduct.Quantity = item.Quantity; tempProduct.Size = item.Size; tempProduct.QtyPurchased = 0; } } if (flag) { bool fl = false; foreach (var item in db.TempProducts.ToList()) { if (tempProduct.BarCodeId == item.BarCodeId) { item.QtyPurchased = item.QtyPurchased + 1; item.Quantity = item.Quantity - 1; db.Entry(item).State = EntityState.Modified; fl = true; if (item.Quantity >= 1) { db.SaveChanges(); } else { ViewBag.Message = "Insufficient Quantity"; } break; } } if (!fl) { if (tempProduct.Quantity >= 1) { tempProduct.Quantity = tempProduct.Quantity - 1; tempProduct.QtyPurchased = tempProduct.QtyPurchased + 1; db.TempProducts.Add(tempProduct); db.SaveChanges(); } else { ViewBag.Message = "Insufficient Quantity"; } } } else { ViewBag.Message = "Incorrect Product"; } AllClassViewModel viewModel = new AllClassViewModel { TempProducts = db.TempProducts.ToList() }; ModelState.Clear(); return(View(viewModel)); }
public void CreateTempProduct(string description, decimal salePrice) { TempProduct newTempProduct = new TempProduct(description, salePrice); TempProductList.Add(newTempProduct); }
public TempProduct getMatch(string Name) { TempProduct temp = FoodEntities.TempProducts.SqlQuery("Select * from Product where Name='" + Name + "'").FirstOrDefault(); return(temp); }