internal bool updatePackPrice() { bool b = false; try { bool isOkay = true; if (sellingPriceManager.textBox_packPrice.IsNull()) { sellingPriceManager.textBox_packPrice.ErrorMode(true); isOkay = false; } if (isOkay) { if (isDublicatePrice(sellingPriceManager.textBox_selectedItemId.IntValue, "p", sellingPriceManager.textBox_packPrice.DoubleValue, sellingPriceManager.PackPrice.Id)) { ShowMessage.error(Common.Messages.Error.Error007); } else { SellingPrice sellingPrice = sellingPriceManager.PackPrice; sellingPrice.Price = sellingPriceManager.textBox_packPrice.DoubleValue; CommonMethods.setCDMDForUpdate(sellingPrice); upd(sellingPrice); b = true; } } } catch (Exception) { } return(b); }
internal bool addUnitPrice() { bool b = false; try { bool isOkay = true; if (sellingPriceManager.textBox_unitPrice.IsNull()) { sellingPriceManager.textBox_unitPrice.ErrorMode(true); isOkay = false; } if (isOkay) { if (isDublicatePrice(sellingPriceManager.textBox_selectedItemId.IntValue, "u", sellingPriceManager.textBox_unitPrice.DoubleValue, 0)) { ShowMessage.error(Common.Messages.Error.Error007); } else { SellingPrice sellingPrice = new SellingPrice(); sellingPrice.ItemId = sellingPriceManager.textBox_selectedItemId.IntValue; sellingPrice.Mode = "u"; sellingPrice.Price = sellingPriceManager.textBox_unitPrice.DoubleValue; CommonMethods.setCDMDForAdd(sellingPrice); if (add(sellingPrice) > 0) { b = true; } } } } catch (Exception) { } return(b); }
/// ********************************************************************************************************* /// internal bool addPriceFromAddSellingPrice() { bool b = false; try { if (addSellingPrice.textBox_price.DoubleValue == 0) { ShowMessage.error(Common.Messages.Error.Error006); } else if (isDublicatePrice(addSellingPrice.ItemId, addSellingPrice.Mode, addSellingPrice.textBox_price.DoubleValue, 0)) { ShowMessage.error(Common.Messages.Error.Error007); } else { SellingPrice sellingPrice = new SellingPrice(); sellingPrice.ItemId = addSellingPrice.ItemId; sellingPrice.Mode = addSellingPrice.Mode; sellingPrice.Price = addSellingPrice.textBox_price.DoubleValue; CommonMethods.setCDMDForAdd(sellingPrice); int id = add(sellingPrice); UIComboBox.sellingPriceForItemAndMode(addSellingPrice.ComboBox, addSellingPrice.ItemId, addSellingPrice.Mode, addSellingPrice); addSellingPrice.ComboBox.SelectedValue = id; b = true; } } catch (Exception) { } return(b); }
public bool deleteSellingPriceById(int id) { bool b = false; try { SellingPrice sellingPrice = new SellingPrice(); sellingPrice.Id = id; b = del(sellingPrice); } catch (Exception) { } return(b); }
public SellingPrice getSellingPriceById(int id) { SellingPrice sellingPrice = null; try { SellingPrice p = new SellingPrice(); p.Id = id; sellingPrice = get(p)[0]; } catch (Exception) { } return(sellingPrice); }
public List <SellingPrice> getSellingPriceByItemId(int itemId) { List <SellingPrice> list = null; try { SellingPrice sellingPrice = new SellingPrice(); sellingPrice.ItemId = itemId; list = get(sellingPrice); } catch (Exception) { } return(list); }
//[ProducesResponseType(201)] //[ProducesResponseType(400)] public IActionResult CreateAsync([FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (_context.Products.Any(p => p.Name.Contains(product.Name))) { return(BadRequest("Product already exists")); } product.Created = DateTime.Now; _context.Products.Add(product); _context.SaveChanges(); //update new price double currentPrice = _context.SellingPrices.Where(x => x.ProductId == product.Id).OrderByDescending(x => x.PriceDate).Select(x => x.Price).FirstOrDefault(); if (currentPrice != product.Price) { SellingPrice sp = new SellingPrice(); sp.Price = product.Price; sp.ProductId = product.Id; sp.PriceDate = DateTime.Now; sp.QuantityFrom = 1; _context.SellingPrices.Add(sp); _context.SaveChanges(); } //update import price double importPrice = _context.BuyingPrices.Where(x => x.ProductId == product.Id).OrderByDescending(x => x.PriceDate).Select(x => x.Price).FirstOrDefault(); if (importPrice != product.BuyingPrice) { BuyingPrice bp = new BuyingPrice(); bp.Price = product.BuyingPrice; bp.PriceDate = DateTime.Now; bp.ProductId = product.Id; if (product.SupplierID > 0) { bp.SupplierId = product.SupplierID; } _context.BuyingPrices.Add(bp); _context.SaveChanges(); } return(CreatedAtAction(nameof(GetById), new { id = product.Id }, product)); }
public List <SellingPrice> getSellingPriceByItemAndMode(int itemId, String mode) { List <SellingPrice> list = null; try { SellingPrice sellingPrice = new SellingPrice(); sellingPrice.ItemId = itemId; sellingPrice.Mode = mode; sellingPrice.OrderBy = "price DESC"; list = get(sellingPrice); } catch (Exception) { } return(list); }
internal void deletePrice(String mode) { try { SellingPrice sellingPrice = null; if (mode == "u") { sellingPrice = getSellingPriceById(sellingPriceManager.dataGrid_unitPrice.SelectedItemID); } else { sellingPrice = getSellingPriceById(sellingPriceManager.dataGrid_packPrice.SelectedItemID); } del(sellingPrice); } catch (Exception) { } }
private void btnSave_Click(object sender, EventArgs e) { PriceRepository priceRepository = new PriceRepository(); SellingPrice cost = new SellingPrice(); cost.ProdCd = txtProdCd.Text; cost.Old = product1.Sp; cost.New = Convert.ToDecimal(txtNewPrice.Text); if (priceRepository.ChangeSP(cost)) { MessageBox.Show("Selling price Update successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Error on Saving. Please Contact System Admin For more help.", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal void switchToUpdateMode(String mode) { try { SellingPrice sellingPrice = getSellingPriceById((mode == "u") ? sellingPriceManager.dataGrid_unitPrice.SelectedItemID : sellingPriceManager.dataGrid_packPrice.SelectedItemID); if (mode == "u") { sellingPriceManager.IsUnitUpdateMode = true; sellingPriceManager.UnitPrice = sellingPrice; sellingPriceManager.textBox_unitPrice.Text = sellingPrice.Price.ToString("#,##0.00"); sellingPriceManager.button_addUnitPrice.Content = "Update"; } else { sellingPriceManager.IsPackUpdateMode = true; sellingPriceManager.PackPrice = sellingPrice; sellingPriceManager.textBox_packPrice.Text = sellingPrice.Price.ToString("#,##0.00"); sellingPriceManager.button_addPackPrice.Content = "Update"; } } catch (Exception) { } }
public bool isDublicatePrice(int itemId, String mode, double price, int id) { bool b = false; try { SellingPrice sellingPrice = new SellingPrice(); sellingPrice.ItemId = itemId; sellingPrice.Mode = mode; //sellingPrice.Price = price; List <SellingPrice> list = get(sellingPrice); if (id < 1) { foreach (SellingPrice p in list) { if (price == p.Price) { b = true; return(b); } } } else if (list.Count > 0) { foreach (SellingPrice p in list) { if (p.Price == price && p.Id != id) { b = true; return(b); } } } } catch (Exception) { } return(b); }
public async Task <IActionResult> Put([FromRoute] int id, [FromBody] Product product) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); //update new price double currentPrice = _context.SellingPrices.Where(x => x.ProductId == product.Id).OrderByDescending(x => x.PriceDate).Select(x => x.Price).FirstOrDefault(); if (product.Price > 0 && currentPrice != product.Price) { SellingPrice sp = new SellingPrice(); sp.Price = product.Price; sp.ProductId = product.Id; sp.PriceDate = DateTime.Now; sp.QuantityFrom = 1; _context.SellingPrices.Add(sp); _context.SaveChanges(); } //update import price double importPrice = _context.BuyingPrices.Where(x => x.ProductId == product.Id).OrderByDescending(x => x.PriceDate).Select(x => x.Price).FirstOrDefault(); if (product.BuyingPrice > 0 && importPrice != product.BuyingPrice) { BuyingPrice bp = new BuyingPrice(); bp.Price = product.BuyingPrice; bp.PriceDate = DateTime.Now; bp.ProductId = product.Id; if (product.SupplierID > 0) { bp.SupplierId = product.SupplierID; } _context.BuyingPrices.Add(bp); _context.SaveChanges(); } } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }