private static GLLines getEntityByModel(GLLinesModel model, decimal conversionRate) { if (model == null) { return(null); } GLLines entity = new GLLines(); entity.Id = model.Id; entity.HeaderId = model.HeaderId; entity.CodeCombinationId = model.CodeCombinationId; entity.Description = model.Description; entity.EnteredCr = model.EnteredCr; entity.EnteredDr = model.EnteredDr; entity.AccountedCr = model.EnteredCr * conversionRate; entity.AccountedDr = model.EnteredDr * conversionRate; entity.Qty = model.Quantity; entity.TaxRateCode = model.TaxRateCode; if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; } entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return(entity); }
public static void DeleteGLLine(GLLinesModel model) { GLHeaderModel header = SessionHelper.JV; GLLinesModel glLine = header.GlLines.FirstOrDefault(x => x.Id == model.Id); header.GlLines.Remove(glLine); }
public static void UpdateGLLine(GLLinesModel model) { GLHeaderModel header = SessionHelper.JV; header.GlLines.FirstOrDefault(x => x.Id == model.Id).AccountedCr = model.AccountedCr; header.GlLines.FirstOrDefault(x => x.Id == model.Id).AccountedDr = model.AccountedDr; header.GlLines.FirstOrDefault(x => x.Id == model.Id).CodeCombinationId = model.CodeCombinationId; header.GlLines.FirstOrDefault(x => x.Id == model.Id).Description = model.Description; header.GlLines.FirstOrDefault(x => x.Id == model.Id).EnteredCr = model.EnteredCr; header.GlLines.FirstOrDefault(x => x.Id == model.Id).EnteredDr = model.EnteredDr; header.GlLines.FirstOrDefault(x => x.Id == model.Id).Quantity = model.Quantity; header.GlLines.FirstOrDefault(x => x.Id == model.Id).TaxRateCode = model.TaxRateCode; }
public ActionResult AddNewPartial(GLLinesModel model) { if (ModelState.IsValid) { try { bool validated = false; if (model.EnteredCr > 0 && model.EnteredDr > 0) { ViewData["EditError"] = "Both debit and credit can not be entered in one entry."; return(PartialView("createPartial", JVHelper.GetGLLines())); } if (SessionHelper.JV.GlLines.Count != 0) { if (SessionHelper.JV.GlLines.Any(rec => rec.CodeCombinationId == model.CodeCombinationId)) { ViewData["EditError"] = "Duplicate accounts can not be added."; } else { validated = true; model.Id = SessionHelper.JV.GlLines.Last().Id + 1; } } else { model.Id = 1; validated = true; } if (validated) { JVHelper.Insert(model); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", JVHelper.GetGLLines())); }
public ActionResult UpdatePartial(GLLinesModel model) { if (ModelState.IsValid) { try { JVHelper.UpdateGLLine(model); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial", JVHelper.GetGLLines())); }
public ActionResult DeletePartial(GLLinesModel model) { if (ModelState.IsValid) { try { GLHeaderModel header = SessionHelper.JV; JVHelper.DeleteGLLine(model); SessionHelper.JV = header; IList <GLLinesModel> glLines = JVHelper.GetGLLines(); return(PartialView("createPartial", glLines)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("createPartial")); }
public static void Insert(GLLinesModel model) { GLHeaderModel header = SessionHelper.JV; header.GlLines.Add(model); }