/// <summary> /// Returns list of P&L for the specified company,costcenter and selection criteria. /// </summary> /// <param name="param"></param> /// <param name="costcenterId">costcenter id</param> /// <param name="companyId">company id</param> /// <returns>ProfitLoss List</returns> public ActionResult ProfitLossList(MODEL.jQueryDataTableParamModel param, int?companyId = 0) { try { ProfitLossService profitlossService = new ProfitLossService(); List <MODEL.ProfitLoss> profitlossList = new List <MODEL.ProfitLoss>(); List <ProfitLossVO> profitlossVOlist = profitlossService.GetPandLListByCompany(companyId); foreach (ProfitLossVO profitlossVO in profitlossVOlist) { profitlossList.Add(new MODEL.ProfitLoss(profitlossVO)); } //get the field on with sorting needs to happen and set the //ordering function/delegate accordingly. int sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]); var orderingFunction = GetProfitLossOrderingFunction(sortColumnIndex); var result = GetFilteredObjects(param, profitlossList, orderingFunction); return(result); } catch (Exception e) { return(new HttpStatusCodeAndErrorResult(500, e.Message)); } }
/// <summary> /// Save the profitloss details. /// </summary> /// <param name="model">The ProfitLoss model</param> public ActionResult ProfitLossSave(MODEL.ProfitLoss model) { try { ProfitLossService profitlossService = new ProfitLossService(); if (ModelState.IsValid) { //Get user id int?userId = Session.GetUserId(); //ProfitLossVO profitlossVO = new ProfitLossVO(model, userId); ProfitLossVO profitlossVO = model.Transpose(userId); profitlossService.SaveProfitLoss(profitlossVO); return(new HttpStatusCodeResult(200)); } else { throw new ApplicationException(String.Format(Constants.CANNOT_SAVE, Constants.PROFITANDLOSS)); } } catch (ApplicationException e) { return(new HttpStatusCodeAndErrorResult(500, e.Message)); } }
/// <summary> /// Delete p & l for selected ids /// </summary> /// <param name="ids">The selected profitloss ids</param> /// <returns>return the status of the deletion</returns> // POST: /Administration/ProfitLossDelete public ActionResult ProfitLossDelete(List <int> ids) { try { //Get user id int?userId = Session.GetUserId(); ProfitLossService profitlossService = new ProfitLossService(); profitlossService.DeleteProfitLoss(ids, userId); return(new HttpStatusCodeResult(200)); } catch (Exception e) { return(new HttpStatusCodeAndErrorResult(500, e.Message)); } }
public Factory() { DbContext = new DefaultContext(); AccountsService = new AccountsService(DbContext); ClientsService = new ClientsService(DbContext); OpeningsService = new OpeningsService(DbContext); DocumentsService = new DocumentsService(DbContext); ReportsService = new ReportsService(DbContext); DataInitializatorService = new DataInitializatorService(DbContext); ProfitLossService = new ProfitLossService(this); BalanceService = new BalanceService(this); AccountsPrintService = new AccountsPrintService(this); OpeningsPrintService = new OpeningsPrintService(this); DocumentsPrintService = new DocumentsPrintService(this); ReportsPrintService = new ReportsPrintService(this); ProfitLossPrintService = new ProfitAndLossPrintService(this); BalancePrintService = new BalancePrintService(this); }
/// <summary> /// Edit profitloss details by id. /// </summary> /// <param name="id">Profitloss Id</param> /// <returns>The profit loss details view</returns> public ActionResult ProfitLossEdit(int id) { MODEL.ProfitLoss profitloss = new ProfitLoss(); try { ProfitLossService profitlossService = new ProfitLossService(); //Get P&L details ProfitLossVO profitlossVO = profitlossService.GetPandLbyId(id); if (profitlossVO == null) { ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.PROFITANDLOSS)); } else { profitloss = new ProfitLoss(profitlossVO); } } catch (Exception e) { ModelState.AddModelError("", e.Message); } return(PartialView("ProfitLossDetails", profitloss)); }
/// <summary> /// 构造函数 /// </summary> public ProfitLossController() { this.profitLossService = new ProfitLossService(); this.purchaseService = new PurchaseService(); }