public ActionResult UpdateCashMR(MoneyReceiptVM MrVM) { using (var transaction = new TransactionScope()) { try { RBACUser rUser = new RBACUser(Session["UserName"].ToString()); if (!rUser.HasPermission("MoneyReceiptCash_Update")) { return(Json("U", JsonRequestBehavior.AllowGet)); } var VchrExist = _pVchrmainService.All().FirstOrDefault(s => s.VchrNo == MrVM.VchrNo); if (VchrExist == null) { return(Json("3", JsonRequestBehavior.AllowGet)); } var MR = _moneyReceiptService.All().Where(x => x.MRSL == MrVM.MRSL && x.MRNo == MrVM.MRNo && MrVM.Posted == false).FirstOrDefault(); var CR = _CashReceiptService.All().Where(s => s.RefNo == MrVM.MRSL).FirstOrDefault(); var CRSD = _CashReceiptSubDetailsAppService.All().Where(s => s.CashReceiptNo == CR.ReceiptNo).FirstOrDefault(); if (MR != null && CR != null && CRSD != null) { //var cabkop = _defACService.All().ToList().FirstOrDefault().CashAc; var GCa = _AcBrService.All().Where(s => s.BranchCode == MR.BranchCode && s.Ca_Ba == "Ca").Select(x => x.Accode).FirstOrDefault(); if (GCa == null) { var gset = _gsetService.All().LastOrDefault(); GCa = gset.GCa; } //For MR MR.MRSL = MrVM.MRSL; MR.BranchCode = (MrVM.BranchCode == null) ? Session["BranchCode"].ToString() : MrVM.BranchCode; MR.ProjCode = (MrVM.ProjCode == null) ? Session["ProjCode"].ToString() : MrVM.ProjCode; MR.MRNo = MrVM.MRNo; MR.MRDate = MrVM.MRDate; MR.MRAgainst = MrVM.MRAgainst; MR.VchrNo = MrVM.VchrNo; MR.Posted = MrVM.Posted; MR.AdjWithBill = MrVM.AdjWithBill; MR.MRAmount = MrVM.Amount; MR.Accode = MrVM.Accode; MR.CustCode = MrVM.CustCode; MR.FinYear = Session["FinYear"].ToString(); MR.JobNo = MrVM.JobNo; MR.Remarks = MrVM.Remarks; MR.Ca_Bk = GCa; CR.ReceiptDate = (DateTime)MrVM.MRDate; CR.purAccode = MrVM.MRAgainst;// "1.2.004"; CR.RefNo = MrVM.MRSL; CR.Amount = (Double)MrVM.Amount; CR.Remarks = MrVM.Remarks; CR.VoucherNo = MrVM.VchrNo; CRSD.SubCode = MrVM.CustCode; CRSD.Accode = MrVM.MRAgainst; CRSD.Amount = (Double)MrVM.Amount; _moneyReceiptService.Update(MR); _CashReceiptService.Update(CR); _CashReceiptSubDetailsAppService.Update(CRSD); _CashReceiptService.Save(); _CashReceiptSubDetailsAppService.Save(); _moneyReceiptService.Save(); TransactionLogService.SaveTransactionLog(_transactionLogService, "Cash MR", "Update", MR.MRSL, Session["UserName"].ToString()); LoadDropDown.journalVoucherRemoval("CR", MrVM.MRNo, MrVM.VchrNo, Session["FinYear"].ToString()); LoadDropDown.journalVoucherSave("CR", "I", MrVM.MRNo, MrVM.VchrNo, Session["FinYear"].ToString(), Session["ProjCode"].ToString(), Session["BranchCode"].ToString(), Convert.ToDateTime(MrVM.MRDate), GCa, Session["UserName"].ToString()); transaction.Complete(); return(Json("1", JsonRequestBehavior.AllowGet)); } else { transaction.Dispose(); return(Json("3", JsonRequestBehavior.AllowGet)); } } catch (Exception) { transaction.Dispose(); return(Json("0", JsonRequestBehavior.AllowGet)); } } }
public ActionResult UpdateOnlineMR(MROnlineVM MrVM) { using (var transaction = new TransactionScope()) { try { RBACUser rUser = new RBACUser(Session["UserName"].ToString()); if (!rUser.HasPermission("MoneyReceiptOnline_Update")) { return(Json("U", JsonRequestBehavior.AllowGet)); } var MR = _moneyReceiptService.All().Where(x => x.MRSL == MrVM.MRSL && x.MRNo == MrVM.MRNo && MrVM.Posted == false).FirstOrDefault(); if (MR != null) { //For MR MR.MRSL = MrVM.MRSL; MR.BranchCode = (MrVM.BranchCode == null) ? Session["BranchCode"].ToString() : MrVM.BranchCode; MR.ProjCode = (MrVM.ProjCode == null) ? Session["ProjCode"].ToString() : MrVM.ProjCode; MR.MRNo = MrVM.MRNo; MR.MRDate = MrVM.MRDate; MR.MRAgainst = MrVM.MRAgainst; MR.VchrNo = MrVM.VchrNo; //MR.Posted = MrVM.Posted; //MR.AdjWithBill = MrVM.AdjWithBill; MR.MRAmount = MrVM.MRAmount; MR.Accode = MrVM.Accode; if (MrVM.Accode == "0" || MrVM.Accode == null) { MR.Accode = _defACService.All().ToList().FirstOrDefault().CashAc; } MR.CustCode = MrVM.CustCode; MR.FinYear = Session["FinYear"].ToString(); MR.JobNo = MrVM.JobNo; MR.Remarks = MrVM.Remarks; MR.DepositBank = MrVM.DepositBank; MR.EncashDate = MrVM.DepositDate; _moneyReceiptService.Update(MR); _moneyReceiptService.Save(); var GCa = _AcBrService.All().Where(s => s.BranchCode == MR.BranchCode && s.Ca_Ba == "Ca").Select(x => x.Accode).FirstOrDefault(); if (GCa == null) { var gset = _gsetService.All().LastOrDefault(); GCa = gset.GCa; } TransactionLogService.SaveTransactionLog(_transactionLogService, "Online MR", "Update", MR.MRSL, Session["UserName"].ToString()); LoadDropDown.journalVoucherRemoval("CR", MrVM.MRNo, MrVM.VchrNo, Session["FinYear"].ToString()); LoadDropDown.journalVoucherSave("CR", "I", MrVM.MRNo, MrVM.VchrNo, Session["FinYear"].ToString(), Session["ProjCode"].ToString(), Session["BranchCode"].ToString(), Convert.ToDateTime(MrVM.MRDate), GCa, Session["UserName"].ToString()); transaction.Complete(); return(Json("1", JsonRequestBehavior.AllowGet)); } else { transaction.Dispose(); return(Json("3", JsonRequestBehavior.AllowGet)); } } catch (Exception) { transaction.Dispose(); return(Json("0", JsonRequestBehavior.AllowGet)); } } }