//public JsonResult IndormedicinesalesDelete(IndorMedicineSalesVoucher tbv, IndorMedicineSalesDetails tbvd, string IndorMedicenSaleseVocherNo, int IndorMedicenSaleseId, decimal GrandTotalAmount) //{ // tbvd = db.IndorMedicineSalesDetails.FirstOrDefault(x => x.IndorMedicenSaleseId == IndorMedicenSaleseId); // db.IndorMedicineSalesDetails.Remove(tbvd); // db.SaveChanges(); // tbv = db.IndorMedicineSalesVouchers.FirstOrDefault(x => x.IndorMedicenSaleseVocherNo == IndorMedicenSaleseVocherNo); // tbv.GrandTotalAmount = tbv.GrandTotalAmount - GrandTotalAmount; // tbv.PayAmount = 0; // tbv.DueAmount = tbv.GrandTotalAmount; // db.SaveChanges(); // var jsonData = new { success = true, message = "Successfully Deleted." }; // return Json(jsonData, JsonRequestBehavior.AllowGet); //} //....................Delete....................... public ActionResult Delete(tbl_IndorMedicineSalesVoucher tbv, tbl_IndorMedicineSalesDetails tbvd, string IndorMedicenSaleseVocherNo) { var info = (from item in db.tbl_IndorMedicineSalesDetails where item.IndorMedicenSaleseVocherNo == IndorMedicenSaleseVocherNo select item).ToList(); if (info.Count > 1) { foreach (var vp in info) { db.tbl_IndorMedicineSalesDetails.Remove(vp); } } else { if (IndorMedicenSaleseVocherNo != null) { tbvd = db.tbl_IndorMedicineSalesDetails.FirstOrDefault(x => x.IndorMedicenSaleseVocherNo == IndorMedicenSaleseVocherNo); db.tbl_IndorMedicineSalesDetails.Remove(tbvd); } } db.SaveChanges(); tbv = db.tbl_IndorMedicineSalesVoucher.FirstOrDefault(x => x.IndorMedicenSaleseVocherNo == IndorMedicenSaleseVocherNo); db.tbl_IndorMedicineSalesVoucher.Remove(tbv); db.SaveChanges(); return(RedirectToAction("IndormedicineSaleList")); }
public JsonResult IndorMedicineSalesUpdate(tbl_IndorMedicineSalesVoucher tbv, tbl_IndorMedicineSalesDetails tbvd, string IndorMedicenSaleseVocherNo, int PatientID, decimal TotalAmount, decimal VatAmount, decimal DiscountAmount, decimal GrandTotalAmount, decimal PayAmount, decimal DueAmount, int IndorMedicenSaleseId, int MediInfoID, decimal Rate, int Quantity, decimal Amount) { tbv = db.tbl_IndorMedicineSalesVoucher.FirstOrDefault(x => x.IndorMedicenSaleseVocherNo == IndorMedicenSaleseVocherNo); tbv.PatientID = PatientID; tbv.TotalAmount = TotalAmount; tbv.VatAmount = VatAmount; tbv.DiscountAmount = DiscountAmount; tbv.GrandTotalAmount = GrandTotalAmount; tbv.PayAmount = PayAmount; tbv.DueAmount = DueAmount; db.SaveChanges(); tbvd = db.tbl_IndorMedicineSalesDetails.FirstOrDefault(x => x.IndorMedicenSaleseId == IndorMedicenSaleseId); tbvd.MediInfoID = MediInfoID; tbvd.Rate = Rate; tbvd.Quantity = Quantity; tbvd.Amount = Amount; db.SaveChanges(); var jsonData = new { success = true, message = "Successfully Updated" }; return(Json(jsonData, JsonRequestBehavior.AllowGet)); }