public async Task <IActionResult> Edit(int id, [Bind("ID,ProductID,QuantityPurchased,SubTotal,DatePurchased,SalesID")] SalesDetail salesDetail) { if (id != salesDetail.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(salesDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalesDetailExists(salesDetail.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["SalesID"] = new SelectList(_context.Sales, "ID", "ID");//salesDetail.SalesID return(View(salesDetail)); }
private static void SalesDetailPocos(IEnumerable <DataRow> details, DataRow r, SalesHeader i) { foreach (var d in details) { var detail = new SalesDetail { SalesOrderDetailId = (int)d["SalesOrderDetailID"], OrderQty = (short)d["OrderQty"], ProductId = (int)d["ProductID"], SpecialOfferId = (int)d["SpecialOfferID"], UnitPrice = (decimal)d["UnitPrice"], UnitPriceDiscount = (decimal)d["UnitPriceDiscount"], LineTotal = (decimal)d["LineTotal"], Rowguid = r["rowguid"].ToString(), ModifiedDate = (DateTime)r["ModifiedDate"] }; if (!d.IsNull("CarrierTrackingNumber")) { detail.CarrierTrackingNumber = (string)d["CarrierTrackingNumber"]; } if (i.Details == null) { i.Details = new List <SalesDetail>(); } i.Details.Add(detail); } }
public async Task <IActionResult> Edit(int id, [Bind("SalesDetailID,Quantity,Amount")] SalesDetail salesDetail) { if (id != salesDetail.SalesDetailID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(salesDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalesDetailExists(salesDetail.SalesDetailID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(salesDetail)); }
public async Task <IActionResult> Create([Bind("SalesDetailId,SalesId,ProdId,Quantity,Amount")] SalesDetail salesDetail) { if (ModelState.IsValid) { var stock = await _context.Stock.Where(x => x.ProdId == salesDetail.ProdId).FirstOrDefaultAsync(); if (stock.Quantity < salesDetail.Quantity) { String error = "Stock available for this Product is " + stock.Quantity + " units."; ModelState.AddModelError("Quantity", error); return(View(salesDetail)); } else { stock.Quantity -= salesDetail.Quantity; _context.Update(stock); } _context.Add(salesDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProdId"] = new SelectList(_context.Product, "ProdId", "ProdName", salesDetail.ProdId); ViewData["SalesId"] = new SelectList(_context.Sales, "SalesId", "BillNo", salesDetail.SalesId); return(View(salesDetail)); }
public async Task <IActionResult> Edit(int id, [Bind("SalesDetailId,SalesId,ProdId,Quantity,Amount")] SalesDetail salesDetail) { if (id != salesDetail.SalesDetailId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(salesDetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalesDetailExists(salesDetail.SalesDetailId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProdId"] = new SelectList(_context.Product, "ProdId", "ProdName", salesDetail.ProdId); ViewData["SalesId"] = new SelectList(_context.Sales, "SalesId", "BillNo", salesDetail.SalesId); return(View(salesDetail)); }
public bool DeleteSalesDetail(SalesDetail salesDetails) { SalesDetails.Remove(salesDetails); BindSalesDetail(); return(true); }
public void StockMaintain(DateTime dateTime, SalesDetail salesDetail) { List <Stock> stocks = _context.Stocks.Where(x => x.ProductId == salesDetail.ProductId).ToList(); Stock lastEntry = stocks.OrderByDescending(x => x.StockDate).FirstOrDefault(); if (lastEntry.StockDate.ToString("dd/MM/yyyy") == dateTime.ToString("dd/MM/yyyy")) { lastEntry.Quantity -= salesDetail.Quantity; _context.Stocks.Update(lastEntry); _context.SaveChanges(); } else { Stock newEntry = new Stock { ProductId = salesDetail.ProductId, Quantity = lastEntry.Quantity - salesDetail.Quantity, StockDate = dateTime, UOM = lastEntry.UOM }; _context.Add(newEntry); _context.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { SalesDetail salesDetail = db.SaleDetails.Find(id); db.SaleDetails.Remove(salesDetail); db.SaveChanges(); return(RedirectToAction("Index")); }
List <SalesDetail> IntialgvProducts() { List <SalesDetail> list = new List <SalesDetail>(); SalesDetail objSalesDetail = new SalesDetail(); list.Add(objSalesDetail); return(list); }
private void Balance_Click(object sender, RoutedEventArgs e) { //double sum = 0; //for (int i = 0; i < AddSalesGrid.Items.Count; i++) //{ //sum += (double.Parse((AddSalesGrid.Columns[5].GetCellContent(AddSalesGrid.Items[i]) as TextBlock).Text)); //} //gridTotal.Text = sum.ToString(); //var totall = gridTotal.Text; ///double amount_2 = Convert.ToDouble(amountPaid.Text); //double balan = amount_2 - sum; //balance.Text = balan.ToString(); //var sel3 = new Sales //{ // Amount = amount_2, // Balance = balan, // GrandTotal = sum //}; //shopManager.AddSale(sel3); //shopManager.BindSales(); //shopManager.BindProducts(); //balance.Text = balan.ToString(); decimal Balance = 0; if (amountPaid.Text != "" && gridTotal.Text != "") { decimal AmtDue = Convert.ToDecimal(gridTotal.Text); decimal AmtPaid = Convert.ToDecimal(amountPaid.Text); balance.Text = (AmtPaid - AmtDue).ToString(); } Balance = Convert.ToDecimal(balance.Text); SaleDetailsID += 1; var newSalesDate = date.ToString("F"); //SalesDetailsCustomerName = shopManager.Products.Where(p => p.ProductName == d.ProductName); var saleDetails = new SalesDetail { SalesDetailsID = SaleDetailsID, SalesID = SaleId, SalesDetailCustomerName = customerNameCombo.Text, SalesProductName = productNameCombo.Text, AmountPaid = Convert.ToDecimal(amountPaid.Text), Balance = Balance, Total = TotalQtyPurchased, SalesDetailDates = Convert.ToDateTime(newSalesDate), }; shopManager.AddSalesDetail(saleDetails); shopManager.BindSalesDetail(); }
public void GetListSalesDetail <T>(T objFilter, ref List <T> listData) where T : class, IModel, new() { string sQuery = "GetListSalesDetail"; SalesDetail objData = objFilter as SalesDetail; List <DbParameter> list = new List <DbParameter>(); list.Add(SqlConnManager.GetConnParameters("RecNo", "RecNo", 8, GenericDataType.Long, ParameterDirection.Input, objData.RecNo)); SqlConnManager.GetList <T>(sQuery, CommandType.StoredProcedure, list.ToArray(), FillSalesDetailDataFromReader, ref listData); }
private void StockControl(SalesDetail salesDetail) { var product = _productManager.GetById(salesDetail.ProductId); if (salesDetail.SalesDetailQuantity > product.UnitInStock) { throw new Exception("Stok Yetersiz"); } }
private void FillSalesDetailDataFromReader <T>(DbDataReader DbReader, ref List <T> listData) where T : class, IModel, new() { while (DbReader.Read()) { T obj = new T(); SalesDetail objData = obj as SalesDetail; obj.FillDataFromDB(DbReader); listData.Add(obj); } }
public static SalesDetail Update(SalesDetail model) { model.UpdateDate = DateTime.Now; using (ApplicationDbContext db = new ApplicationDbContext()) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); } return(model); }
public static SalesDetail GetById(int id) { var data = new SalesDetail(); using (ApplicationDbContext db = new ApplicationDbContext()) { data = db.SalesDetails.FirstOrDefault(x => x.Id == id); } return(data); }
private void DropOffStock(SalesDetail salesDetail) { var product = _productManager.GetById(salesDetail.ProductId); if (product.UnitInStock >= 0) { product.UnitInStock -= salesDetail.SalesDetailQuantity; _productManager.Update(product); } }
public JsonResult SaveSalesDetails([FromBody] SalesDetail salesDetails) { var newsales = _context.SalesDetails; newsales.Add(salesDetails); _context.SaveChanges(); //var product = _context.Products.Where(p => p.ID == value.ProductID); return(Json(salesDetails)); }
public void Add(SalesDetail salesDetail) { StockControl(salesDetail); DropOffStock(salesDetail); SalasDetailDate(salesDetail); MultiplyQuantityAndPrice(salesDetail); _salesDetailDal.Add(salesDetail); }
public async Task <IActionResult> Create([Bind("SalesDetailID,Quantity,Amount")] SalesDetail salesDetail) { if (ModelState.IsValid) { _context.Add(salesDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(salesDetail)); }
public static SalesDetail Add(SalesDetail model) { model.CreateDate = DateTime.Now; model.IsDelete = false; using (ApplicationDbContext db = new ApplicationDbContext()) { db.SalesDetails.Add(model); db.SaveChanges(); } return(model); }
public ActionResult Edit([Bind(Include = "Id,SaleId,ProductId,Quantity,rate")] SalesDetail salesDetail) { if (ModelState.IsValid) { db.Entry(salesDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", salesDetail.ProductId); ViewBag.SaleId = new SelectList(db.Sales, "Id", "SaleCode", salesDetail.SaleId); return(View(salesDetail)); }
private void Button_Click(object sender, RoutedEventArgs e) { var selecteditem = salesDetailsGrid.SelectedItem; if (selecteditem != null) { salesDetailsGrid.Items.Remove(selecteditem); SalesDetail delstud = selecteditem as SalesDetail; // shopManager.DeleteSalesDetails(delstud); MessageBox.Show("Sales Detail deleted successfully"); } }
public void EnviarItem(SalesDetail DetalleVenta) { if (ListaArticulos.Count == 0) { ListaArticulos.Add(DetalleVenta); } else { List <SalesDetail> ListaUpdate = new List <SalesDetail>(); bool swobj = false; foreach (var item in ListaArticulos) { SalesDetail ObjLista = new SalesDetail(); if (item.Codigo == DetalleVenta.Codigo) { ObjLista.Codigo = item.Codigo; ObjLista.Description = item.Description; ObjLista.Quantity = item.Quantity + DetalleVenta.Quantity; ObjLista.Price = item.Price; ObjLista.Total = item.Total + DetalleVenta.Total; ListaUpdate.Add(ObjLista); swobj = true; } else { ObjLista.Codigo = item.Codigo; ObjLista.Description = item.Description; ObjLista.Quantity = item.Quantity; ObjLista.Price = item.Price; ObjLista.Total = item.Total; ListaUpdate.Add(ObjLista); } } if (swobj == true) { ListaArticulos.Clear(); ListaArticulos.AddRange(ListaUpdate); } else { ListaUpdate.Add(DetalleVenta); ListaArticulos.Clear(); ListaArticulos.AddRange(ListaUpdate); } } }
public async Task <IActionResult> Create([Bind("ID,ProductID,QuantityPurchased,SubTotal,DatePurchased,SalesID")] SalesDetail salesDetail) { if (ModelState.IsValid) { _context.Add(salesDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SalesID"] = new SelectList(_context.Sales, "ID", "ID");//salesDetail.SalesID return(View(salesDetail)); }
public async Task <IActionResult> Create([Bind("SalesDetailID,SalesID,ProductID,Quantity,Amount")] SalesDetail salesDetail) { if (ModelState.IsValid) { _context.Add(salesDetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProductID"] = new SelectList(_context.Product, "ProductID", "ProductID", salesDetail.ProductID); return(View(salesDetail)); }
private void CreateSalesDetails(SalesDetail salesDetail, int salesId) { string salesDetailQuery = "Insert into Sales_Product (SalesId,ProductId,Quantity,UnitPrice) values (@salesid,@productid," + "@quantity,@unitprice);"; _sqliteDataProvider.AddParameter("@salesid", salesId); var productId = new ProductDataService().GetProductByCode(salesDetail.ProductCode).Id; _sqliteDataProvider.AddParameter("@productid", productId); _sqliteDataProvider.AddParameter("@quantity", salesDetail.Quantity); _sqliteDataProvider.AddParameter("@unitprice", salesDetail.UnitPrice); _sqliteDataProvider.ExecuteScalar(salesDetailQuery); }
// GET: SalesDetail/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SalesDetail salesDetail = db.SaleDetails.Find(id); if (salesDetail == null) { return(HttpNotFound()); } return(View(salesDetail)); }
public bool insertNewEitity(SalesDetail b) { int rowsAffected = 0; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@SalesOrderID", SqlDbType.NVarChar), new SqlParameter("@ProductsID", SqlDbType.Int), new SqlParameter("@Quantity", SqlDbType.Int), new SqlParameter("@Price", SqlDbType.Money), new SqlParameter("@DiscountRate", SqlDbType.Float), new SqlParameter("@Description", SqlDbType.NVarChar) }; parameters[0].Value = b.SalesOrderID; parameters[1].Value = b.ProductsID; parameters[2].Value = b.Quantity; parameters[3].Value = b.Price; parameters[4].Value = b.DiscountRate; parameters[5].Value = b.Description; SQLHelper.RunProcedure("p_SalesDetail_insertNewEntity", parameters, out rowsAffected); return(1 == rowsAffected); }
private List <SalesDetail> GetChildOnCreate(Sales master, SalesComplex source) { List <SalesDetail> infos = new List <SalesDetail>(); var wanted = source.ChildList.Where(x => x.IsDirty == true); foreach (var item in wanted) { SalesDetail temp = Mapper.Map <SalesDetail>(item); temp.SalesID = master.SalesID; temp.LastPerson = IdentityService.GetUserData().UserID; temp.LastUpdate = DateTime.Now; infos.Add(temp); } return(infos); }
public ActionResult UpdateSalesDetail(SalesDetail salesDetail) { var customerListItems = new CustomerListViewModel().GetCustomerListItems(); ViewBag.customerListItems = customerListItems; var employeeListItems = new EmployeeListViewModel().GetEmployeeListItems(); ViewBag.employeeListItems = employeeListItems; if (!ModelState.IsValid) { return(View("UpdateSalesDetail")); } _salesDetailManager.Update(salesDetail); return(RedirectToAction("Index")); }
private void detach_SalesDetails(SalesDetail entity) { this.SendPropertyChanging("SalesDetails"); entity.PartInfo = null; }
private void detach_SalesDetails(SalesDetail entity) { this.SendPropertyChanging("SalesDetails"); entity.SalesHeader = null; }