public ActionResult UpdateOpenBalance(OpenBal OpnBal) { RBACUser rUser = new RBACUser(Session["UserName"].ToString()); if (!rUser.HasPermission("GL_OpenBal_Update")) { return(Json("U", JsonRequestBehavior.AllowGet)); } var defAc = LoadDropDown.GetDefAc(); string eCode = ""; string isAsset = OpnBal.Accode.Substring(0, 1); if (isAsset == defAc.AssAc) { OpnBal.OpenBalance = OpnBal.OpenBalance; } else if (isAsset == defAc.LiaAc) { OpnBal.OpenBalance = OpnBal.OpenBalance * (-1); } using (var transaction = new TransactionScope()) { try { OpenBal UpOpnBal = new OpenBal(); UpOpnBal = _pR_OpenBalanceService.All().ToList().FirstOrDefault(x => x.Id == OpnBal.Id); if (UpOpnBal != null) { OpnBal.FinYear = Session["FinYear"].ToString(); Misclns.CopyPropertiesTo(OpnBal, UpOpnBal); _pR_OpenBalanceService.Update(UpOpnBal); _pR_OpenBalanceService.Save(); var THolidayID = UpOpnBal.Id; TransactionLogService.SaveTransactionLog(_transactionLogService, "OpenBal", "Update", THolidayID.ToString(), Session["UserName"].ToString()); eCode = "1"; } else { eCode = "2"; } transaction.Complete(); return(Json(eCode, JsonRequestBehavior.AllowGet)); } catch (Exception) { transaction.Dispose(); return(Json("0", JsonRequestBehavior.AllowGet)); } } }
public ActionResult GetAllDataForOpenBalance(string Proj, string BrCode) { try { List <OpenBal> OBInfoList = new List <OpenBal>(); OBInfoList = _pR_OpenBalanceService.All().Where(s => s.ProjCode == Proj && s.BranchCode == BrCode).ToList(); // Convert the object member "Acccode" to its name from newChart table var defAc = LoadDropDown.GetDefAc(); foreach (var item in OBInfoList) { item.AccName = _NewChartAppService.All().Where(x => x.Accode == item.Accode).Select(s => s.AcName).FirstOrDefault(); string isAsset = item.Accode.Substring(0, 1); if (isAsset == defAc.AssAc) { item.YrCrBal = 0; item.YrDrBal = item.OpenBalance; } else { item.YrDrBal = 0; item.YrCrBal = item.OpenBalance * (-1); } } Session["mydata"] = OBInfoList; if (OBInfoList != null) { return(Json(new { data = OBInfoList }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { data = new EmptyResult() }, JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json("0", JsonRequestBehavior.AllowGet)); } }
public ActionResult GetOpenBalForEdit(int OpenBalId) { try { OpenBal GLOB = new OpenBal(); var defAc = LoadDropDown.GetDefAc(); var Obal = _pR_OpenBalanceService.All().ToList().FirstOrDefault(x => x.Id == OpenBalId); string isAsset = Obal.Accode.Substring(0, 1); if (Obal != null) { GLOB.Id = Obal.Id; GLOB.ProjCode = Obal.ProjCode; GLOB.BranchCode = Obal.BranchCode; GLOB.Accode = Obal.Accode; if (isAsset == defAc.AssAc) { GLOB.OpenBalance = Obal.OpenBalance; } else if (isAsset == defAc.LiaAc) { GLOB.OpenBalance = Obal.OpenBalance * (-1); } } var serializerSettings = new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }; string json = JsonConvert.SerializeObject(GLOB, Formatting.Indented, serializerSettings); if (GLOB != null && GLOB.Id > 0) { return(Json(json, JsonRequestBehavior.AllowGet)); } else { return(Json(new EmptyResult(), JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json("0", JsonRequestBehavior.AllowGet)); } }