// add bảng E_VoucherCode private E_VoucherCode AddOrEditVoucherPeriod(EVoucherImportModelDTO importModel) { var voucherPeriod = this._voucherPeriodRepo.SelectWhere(x => x.CompanyId == importModel.OrgId && x.VoucheCodeDate == importModel.Time).FirstOrDefault(); if (voucherPeriod != null) { return(voucherPeriod); } var budget = importModel.ImportData.Sum(x => x.Denominations); voucherPeriod = new E_VoucherCode { CompanyId = importModel.OrgId, CompanyName = importModel.OrgName, Budget = budget, TotalValues = 0, VoucheCodeDate = importModel.Time, VoucheCodeMonth = importModel.Time.Month, VoucheCodeYear = importModel.Time.Year, CreateDate = DateTime.Now, CreateUser = importModel.CurrentUserName, }; voucherPeriod = this._voucherPeriodRepo.Add(voucherPeriod); this._unitOfWork.SaveChanges(); return(voucherPeriod); }
public void ImportVoucherModel(EVoucherImportModelDTO importModel) { using (var tsc = this._unitOfWork.BeginTransaction()) { var voucherPeriod = this.AddOrEditVoucherPeriod(importModel); var voucherDenom = this.AddVoucherDenomination(importModel, voucherPeriod.Id); this.AddVoucherLine(importModel, voucherPeriod.Id); tsc.Commit(); } }
private E_VoucherCodeDenominations AddVoucherDenomination(EVoucherImportModelDTO importModel, long voucherPeriodId) { var voucherDenomination = new E_VoucherCodeDenominations { VoucherCodeId = voucherPeriodId, VoucherTypeCode = importModel.VoucherTypeCode, VoucherTypeName = importModel.VoucherTypeName, Denominations = importModel.Denominations, CountNumber = importModel.ImportData.Count, TotalValues = 0, }; voucherDenomination = this._voucherCodeDenomGRepo.Add(voucherDenomination); this._unitOfWork.SaveChanges(); return(voucherDenomination); }
private List <E_VoucherCodeLine> AddVoucherLine(EVoucherImportModelDTO importModel, long voucherPeriodId) { var codeLines = importModel.ImportData.Select(x => new E_VoucherCodeLine { VoucherCodeId = voucherPeriodId, VoucherTypeCode = importModel.VoucherTypeCode, VoucheTypeName = importModel.VoucherTypeName, Denominations = x.Denominations, Code = x.Code, StartDate = x.StartDate, EndDate = x.EndDate, CreateDate = x.CreateDate, CreateUser = importModel.CurrentUserName, Status = 1, StatusName = "", UseDate = x.UseDate }); codeLines = this._vRepo.AddRange(codeLines); this._unitOfWork.SaveChanges(); return(codeLines.ToList()); }
public RespondData ImportVoucherModel(EVoucherImportModelDTO model) { model.CurrentUserName = UserName; this._service.ImportVoucherModel(model); return(DefaultSuccess(string.Empty)); }
public void ImportVoucherModel(EVoucherImportModelDTO importModel) { this._gridRepository.ImportVoucherModel(importModel); }