Ejemplo n.º 1
0
        //............................Delete.........................
        public ActionResult Delete(tbl_IndorMedicenPurshaseVoucher tbv, tbl_IndorMedicinePurchaseDetails tbvd, string MedicinePurchaseVoucherNo)
        {
            var info = (from item in db.tbl_IndorMedicinePurchaseDetails where item.MedicinePurchaseVoucherNo == MedicinePurchaseVoucherNo select item).ToList();

            if (info.Count > 1)
            {
                foreach (var vp in info)
                {
                    db.tbl_IndorMedicinePurchaseDetails.Remove(vp);
                }
            }
            else
            {
                if (MedicinePurchaseVoucherNo != null)
                {
                    tbvd = db.tbl_IndorMedicinePurchaseDetails.FirstOrDefault(x => x.MedicinePurchaseVoucherNo == MedicinePurchaseVoucherNo);
                    db.tbl_IndorMedicinePurchaseDetails.Remove(tbvd);
                }
            }
            db.SaveChanges();

            tbv = db.tbl_IndorMedicenPurshaseVoucher.FirstOrDefault(x => x.MedicinePurchaseVoucherNo == MedicinePurchaseVoucherNo);
            db.tbl_IndorMedicenPurshaseVoucher.Remove(tbv);
            db.SaveChanges();

            return(RedirectToAction("IndorMedicinePurchaseList"));
        }
Ejemplo n.º 2
0
        public JsonResult IndormedicinePurchaseDelete(tbl_IndorMedicenPurshaseVoucher tbv, tbl_IndorMedicinePurchaseDetails tbvd, string MedicinePurchaseVoucherNo, int MedicinePurchaseId, decimal GrandTotalAmount)
        {
            tbvd = db.tbl_IndorMedicinePurchaseDetails.FirstOrDefault(x => x.MedicinePurchaseId == MedicinePurchaseId);
            db.tbl_IndorMedicinePurchaseDetails.Remove(tbvd);
            db.SaveChanges();

            tbv = db.tbl_IndorMedicenPurshaseVoucher.FirstOrDefault(x => x.MedicinePurchaseVoucherNo == MedicinePurchaseVoucherNo);
            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));
        }
Ejemplo n.º 3
0
        public JsonResult IndorMedicinePurchaseUpdate(tbl_IndorMedicenPurshaseVoucher tbv, tbl_IndorMedicinePurchaseDetails tbvd, string MedicinePurchaseVoucherNo, int MediSupplyerID, DateTime PurchaseDate, decimal GrandTotalAmount, decimal PayAmount, decimal DueAmount, int MedicinePurchaseId, int MediInfoID, decimal Rate, int Quantity, decimal Amount)
        {
            tbv = db.tbl_IndorMedicenPurshaseVoucher.FirstOrDefault(x => x.MedicinePurchaseVoucherNo == MedicinePurchaseVoucherNo);
            tbv.MediSupplyerID   = MediSupplyerID;
            tbv.PurchaseDate     = PurchaseDate;
            tbv.GrandTotalAmount = GrandTotalAmount;
            tbv.PayAmount        = PayAmount;
            tbv.DueAmount        = DueAmount;
            db.SaveChanges();

            tbvd            = db.tbl_IndorMedicinePurchaseDetails.FirstOrDefault(x => x.MedicinePurchaseId == MedicinePurchaseId);
            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));
        }