public ActionResult DeleteConfirmed(int id) { Sales_Header sales_Header = db.Sales_Header.Find(id); db.Sales_Header.Remove(sales_Header); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Document_Date,Customer,Vat_Reg_No,Service_Date")] Sales_Header sales_Header) { if (ModelState.IsValid) { db.Entry(sales_Header).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sales_Header)); }
public ActionResult Create([Bind(Include = "ID,Document_Date,Customer,Vat_Reg_No,Service_Date")] Sales_Header sales_Header) { if (ModelState.IsValid) { db.Sales_Header.Add(sales_Header); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sales_Header)); }
public ActionResult NewSale(FormCollection form) { var user = User.Identity; var a = 0; var salesHead = new Sales_Header(); var sellerName = context.Users.Find(user.GetUserId()).UserName; var buyerName = context.Users.Find(user.GetUserId()).UserName; salesHead.Sale_Date = DateTime.Now; salesHead.Seller_Id = user.GetUserId(); salesHead.Seller_Name = sellerName; salesHead.Buyer_Name = buyerName; context.Sales_Headers.Add(salesHead); context.SaveChanges(); a = 1; //Sale Detail Process string[] itemNamesArr, itemPrcsArr, itemQtyArr, itemIdArr; itemNamesArr = form["ItemName"].Split(','); itemPrcsArr = form["ItemPrice"].Split(','); itemQtyArr = form["QtyRqstd"].Split(','); itemIdArr = form["ItemId"].Split(','); var itemCount = itemNamesArr.Count(); var saleDetail = new Sales_Detail(); var saleDetailList = new List <Sales_Detail>(); for (int i = 0; i < itemCount; i++) { saleDetail.ItemName = itemNamesArr[i]; saleDetail.Qty = Convert.ToInt32(itemQtyArr[i]); saleDetail.Price = Convert.ToDecimal(itemPrcsArr[i]); saleDetail.Sales_Header_id = salesHead.Id; saleDetail.Item_id = Convert.ToInt32(itemIdArr[i]); context.Sales_Details.Add(saleDetail); context.SaveChanges(); } a = 2; return(RedirectToAction("Index", "Users")); }
// GET: Sales_Header/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Sales_Header sales_Header = db.Sales_Header.Find(id); if (sales_Header == null) { return(HttpNotFound()); } return(View(sales_Header)); }