//................Delete.................... //public JsonResult OBSalesDelete(OutdorBloodSalesVoucher tbv, OutdorBloodSalesDetails tbvd, string OutdorBloodSalesVoucherNo, int OutdorBloodSalesID) //{ // tbvd = db.OutdorBloodSalesDetails.FirstOrDefault(x => x.OutdorBloodSalesID == OutdorBloodSalesID); // db.OutdorBloodSalesDetails.Remove(tbvd); // db.SaveChanges(); // tbv = db.OutdorBloodSalesVouchers.FirstOrDefault(x => x.OutdorBloodSalesVoucherNo == OutdorBloodSalesVoucherNo); // db.OutdorBloodSalesVouchers.Remove(tbv); // db.SaveChanges(); // var jsonData = new { success = true, message = "Successfully Deleted." }; // return Json(jsonData, JsonRequestBehavior.AllowGet); // return Json(true, JsonRequestBehavior.AllowGet); //} //........................Delete............. public ActionResult Delete(tbl_OutdorBloodSalesVoucher tbv, tbl_OutdorBloodSalesDetails tbvd, string OutdorBloodSalesVoucherNo) { var info = (from item in db.tbl_OutdorBloodSalesDetails where item.OutdorBloodSalesVoucherNo == OutdorBloodSalesVoucherNo select item).ToList(); if (info.Count > 1) { foreach (var vp in info) { db.tbl_OutdorBloodSalesDetails.Remove(vp); } } else { if (OutdorBloodSalesVoucherNo != null) { tbvd = db.tbl_OutdorBloodSalesDetails.FirstOrDefault(x => x.OutdorBloodSalesVoucherNo == OutdorBloodSalesVoucherNo); db.tbl_OutdorBloodSalesDetails.Remove(tbvd); } } db.SaveChanges(); tbv = db.tbl_OutdorBloodSalesVoucher.FirstOrDefault(x => x.OutdorBloodSalesVoucherNo == OutdorBloodSalesVoucherNo); db.tbl_OutdorBloodSalesVoucher.Remove(tbv); db.SaveChanges(); return(RedirectToAction("OutdoorBloodSalesList")); }
public JsonResult OutdoorBloodSalesDelete(tbl_OutdorBloodSalesVoucher tbv, tbl_OutdorBloodSalesDetails tbvd, string OutdorBloodSalesVoucherNo, int OutdorBloodSalesID, decimal GrandTotalAmount) { tbvd = db.tbl_OutdorBloodSalesDetails.FirstOrDefault(x => x.OutdorBloodSalesID == OutdorBloodSalesID); db.tbl_OutdorBloodSalesDetails.Remove(tbvd); db.SaveChanges(); tbv = db.tbl_OutdorBloodSalesVoucher.FirstOrDefault(x => x.OutdorBloodSalesVoucherNo == OutdorBloodSalesVoucherNo); tbv.GrandTotalAmount = tbv.GrandTotalAmount - GrandTotalAmount; tbv.PayAmount = 0; tbv.DeuAmount = tbv.GrandTotalAmount; db.SaveChanges(); var jsonData = new { success = true, message = "Successfully Deleted." }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }
public JsonResult OutDoorBloodSalesUpdate(tbl_OutdorBloodSalesVoucher tbv, tbl_OutdorBloodSalesDetails tbvd, string OutdorBloodSalesVoucherNo, string OutdorBuyerName, string OutdorBuyerPnoneNo, decimal GrandTotalAmount, decimal PayAmount, decimal DeuAmount, int OutdorBloodSalesID, int BloodID, int Quantity, decimal Rate, int MediUnitID, decimal TotalAmount) { tbv = db.tbl_OutdorBloodSalesVoucher.FirstOrDefault(x => x.OutdorBloodSalesVoucherNo == OutdorBloodSalesVoucherNo); tbv.OutdorBuyerName = OutdorBuyerName; tbv.OutdorBuyerPnoneNo = OutdorBuyerPnoneNo; tbv.GrandTotalAmount = GrandTotalAmount; tbv.PayAmount = PayAmount; tbv.DeuAmount = DeuAmount; db.SaveChanges(); tbvd = db.tbl_OutdorBloodSalesDetails.FirstOrDefault(x => x.OutdorBloodSalesID == OutdorBloodSalesID); tbvd.BloodID = BloodID; tbvd.Quantity = Quantity; tbvd.Rate = Rate; tbvd.MediUnitID = MediUnitID; tbvd.TotalAmount = TotalAmount; db.SaveChanges(); var jsonData = new { success = true, message = "Successfully Updated" }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }