// delete from temptable public JsonResult DeleteTemp(int id) { // int getId = int.Parse(id); tempBill tnv = new tempBill(); tnv = db.tempBills.Where(x => x.Id == id).FirstOrDefault(); db.tempBills.Remove(tnv); db.SaveChanges(); var itmlst = from itm in db.Items join bls in db.tempBills on itm.ItemId equals bls.ItemId join cst in db.Customers on bls.CustId equals cst.CustId select new TempBillsDetails { Id = bls.Id, CustId = bls.CustId, CustName = cst.CustName, ItemId = bls.ItemId, ItemName = itm.ItemName, Qyt = bls.Qyt, Cost = bls.Cost, Date = bls.Date }; return(Json(itmlst.ToList(), JsonRequestBehavior.AllowGet)); }
//Add Temprory Bills public ActionResult AddTemp(int custId, int itemId, int qyt, decimal cost, int MId, int SId) { try { ////TODO:Save the data to Bills //int maxBillNo = db.Bills.Max(x => x.BillNo); // Get the Maximum BillNo // Bill bill=new Bill(); // bill.CustId = custId; // bill.ItemId = itemId; // bill.Date = DateTime.Now; // bill.Qyt = qyt; // bill.Cost = cost; ////bill.BillNo = maxBillNo + 1; // Increasing the BillNo by 1 // db.Bills.Add(bill); // db.SaveChanges(); // TODO: Save Data to tempBill tempBill tb = new tempBill(); tb.CustId = custId; tb.ItemId = itemId; tb.Date = DateTime.Now; tb.Qyt = qyt; tb.Cost = cost; tb.MId = MId; tb.SId = SId; db.tempBills.Add(tb); db.SaveChanges(); var itmlst = (from itm in db.Items join bls in db.tempBills on itm.ItemId equals bls.ItemId join cst in db.Customers on bls.CustId equals cst.CustId select new TempBillsDetails { Id = bls.Id, CustId = bls.CustId, CustName = cst.CustName, ItemId = bls.ItemId, ItemName = itm.ItemName, Qyt = bls.Qyt, Cost = bls.Cost, Date = bls.Date }).ToList(); return(Json(itmlst, JsonRequestBehavior.AllowGet)); } catch (Exception) { return(RedirectToAction("Create")); } }