public UpdateOutput <DivisionDto, long> Update(UpdateInput <DivisionDto, long> input) { Division newDivisionEntity = input.Entity.MapTo <Division>(); if (newDivisionEntity == null) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Division\""); } if (!DivisionPolicy.CanUpdateEntity(newDivisionEntity)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionUpdateDenied, "\"Division\""); } DivisionRepository.Includes.Add(r => r.LastModifierUser); DivisionRepository.Includes.Add(r => r.CreatorUser); DivisionRepository.Includes.Add(r => r.Teams); DivisionRepository.Update(newDivisionEntity); DivisionDto newDivisionDto = (DivisionRepository.Get(newDivisionEntity.Id)).MapTo <DivisionDto>(); DivisionRepository.Includes.Clear(); return(new UpdateOutput <DivisionDto, long>() { UpdatedEntity = newDivisionDto }); }
// POST api/Divisions public DivisionDto Post([FromBody] DivisionDto division) { var newDivision = division.ConvertFromDto(); DivisionService.Add(newDivision); return(newDivision.ConvertToDto()); }
public ChangeActivityOutput <DivisionDto, long> ChangeActivity(ChangeActivityInput input) { DivisionRepository.Includes.Add(r => r.LastModifierUser); DivisionRepository.Includes.Add(r => r.CreatorUser); DivisionRepository.Includes.Add(r => r.Teams); Division divisionEntity = DivisionRepository.Get(input.EntityId); if (divisionEntity == null) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Division\""); } if (!DivisionPolicy.CanChangeActivityForEntity(divisionEntity)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionChangeActivityDenied, "\"Division\""); } divisionEntity.IsActive = input.IsActive == null ? !divisionEntity.IsActive : (bool)input.IsActive; DivisionDto newDivisionDto = (divisionEntity).MapTo <DivisionDto>(); DivisionRepository.Update(divisionEntity); DivisionRepository.Includes.Clear(); return(new ChangeActivityOutput <DivisionDto, long>() { Entity = newDivisionDto }); }
public RetrieveOutput <DivisionDto, long> Retrieve(RetrieveDivisionInput input) { if (input.IsActive ?? true) { UowManager.Current.EnableFilter(Filters.IPassivableFilter); } DivisionRepository.Includes.Add(r => r.LastModifierUser); DivisionRepository.Includes.Add(r => r.CreatorUser); DivisionRepository.Includes.Add(r => r.Teams); IList <Division> divisionEntities = DivisionRepository.GetAll() .WhereIf(input.Id != null, r => r.Id == input.Id) .WhereIf(!String.IsNullOrEmpty(input.Name), r => r.Name.ToLower().Contains(input.Name.ToLower())) .ToList(); if (divisionEntities.Count != 1) { throw new CityQuestItemNotFoundException(CityQuestConsts.CityQuestItemNotFoundExceptionMessageBody, "\"Division\""); } if (!DivisionPolicy.CanRetrieveEntity(divisionEntities.Single())) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionRetrieveDenied, "\"Division\""); } DivisionDto divisionEntity = divisionEntities.Single().MapTo <DivisionDto>(); DivisionRepository.Includes.Clear(); return(new RetrieveOutput <DivisionDto, long>() { RetrievedEntity = divisionEntity }); }
public CreateOutput <DivisionDto, long> Create(CreateInput <DivisionDto, long> input) { Division newDivisionEntity = input.Entity.MapTo <Division>(); newDivisionEntity.IsDefault = false; newDivisionEntity.IsActive = true; if (!DivisionPolicy.CanCreateEntity(newDivisionEntity)) { throw new CityQuestPolicyException(CityQuestConsts.CQPolicyExceptionCreateDenied, "\"Division\""); } DivisionRepository.Includes.Add(r => r.LastModifierUser); DivisionRepository.Includes.Add(r => r.CreatorUser); DivisionRepository.Includes.Add(r => r.Teams); DivisionDto newDivisionDto = (DivisionRepository.Insert(newDivisionEntity)).MapTo <DivisionDto>(); DivisionRepository.Includes.Clear(); return(new CreateOutput <DivisionDto, long>() { CreatedEntity = newDivisionDto }); }
public IEnumerable <DivisionDto> GetAllDivisions() { var divisionDtos = new List <DivisionDto>(); using (var connection = new SqlConnection(ConnectionString)) { var command = new SqlCommand("SELECT Id, Name FROM Divisions", connection); command.Connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { Int32.TryParse(reader["Id"].ToString().Trim(), out int id); var name = reader["Name"].ToString().Trim(); var division = new DivisionDto(id, name); divisionDtos.Add(division); } } return(divisionDtos); }
// PUT api/Divisions/5 public DivisionDto Put([FromBody] DivisionDto division) { var updatedDivision = division.ConvertFromDto(); DivisionService.Update(updatedDivision); return(updatedDivision.ConvertToDto()); }
private void BtnSave_Click(object sender, RoutedEventArgs e) { try { DivisionDto divisionDto = new DivisionDto(); //divisionDto.idDivision = int.Parse(tbDivisionID.Text); divisionDto.Budget = double.Parse(tbBudget.Text); divisionDto.CountWorkers = int.Parse(tbCountWorker.Text); divisionDto.Title = tbTitle.Text; IDivisionProcess divisionProcess = ProcessFactory.GetDivisionProcess(); if (_id == 0) { divisionProcess.Add(divisionDto); } else { divisionDto.idDivision = _id; divisionProcess.Update(divisionDto); } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void SetTitle(ExcelWorksheet worksheet, DivisionDto division, DateTimeOffset dueDate) { var company = "PT DAN LIRIS"; var title = "LAPORAN BUDGET CASH FLOW"; var divisionName = "SEMUA DIVISI"; if (division != null) { divisionName = $"DIVISI: {division.Name}"; } var cultureInfo = new CultureInfo("id-ID"); var date = $"PERIODE {dueDate.AddMonths(1).DateTime.ToString("MMMM yyyy", cultureInfo)}"; worksheet.Cells["A1"].Value = company; worksheet.Cells["A1:H1"].Merge = true; worksheet.Cells["A1:H1"].Style.Font.Size = 20; worksheet.Cells["A1:H1"].Style.Font.Bold = true; worksheet.Cells["A2"].Value = title; worksheet.Cells["A2:H2"].Merge = true; worksheet.Cells["A2:H2"].Style.Font.Size = 20; worksheet.Cells["A2:H2"].Style.Font.Bold = true; worksheet.Cells["A3"].Value = divisionName; worksheet.Cells["A3:H3"].Merge = true; worksheet.Cells["A3:H3"].Style.Font.Size = 20; worksheet.Cells["A3:H3"].Style.Font.Bold = true; worksheet.Cells["A4"].Value = date; worksheet.Cells["A4:H4"].Merge = true; worksheet.Cells["A4:H4"].Style.Font.Size = 20; worksheet.Cells["A4:H4"].Style.Font.Bold = true; }
public UnitItemDto(double total, double nominal, double currencyNominal, DivisionDto division, UnitDto unit) { Total = total; Nominal = nominal; CurrencyNominal = currencyNominal; Division = division; Unit = unit; }
public UnitDto(string unitId, string unitCode, string unitName, string divisionCode, string divisionId, string divisionName) { int.TryParse(unitId, out var id); Id = id; Code = unitCode; Name = unitName; Division = new DivisionDto(divisionCode, divisionId, divisionName); }
public async Task UpdateDivision(DivisionDto input) { var division = _divisionRepository.FirstOrDefault(input.Id); division.Name = input.Name; division.StationId = input.StationId; await _divisionRepository.UpdateAsync(division); }
public async Task DeleteDivisionAsync(DivisionDto input) { var division = _divisionRepository.FirstOrDefault(input.Id); if (division == null) { throw new UserFriendlyException("Division Year not Found!"); } await _divisionRepository.DeleteAsync(division); }
public void Load(DivisionDto divisionDto) { if (divisionDto == null) { return; } _id = divisionDto.idDivision; //this.tbDivisionID.Text = divisionDto.idDivision.ToString(); this.tbBudget.Text = divisionDto.Budget.ToString(); this.tbCountWorker.Text = divisionDto.CountWorkers.ToString(); this.tbTitle.Text = divisionDto.Title.ToString(); }
public static Division Convert(DivisionDto divisionDto) { if (divisionDto == null) { return(null); } Division division = new Division(); division.Budget = divisionDto.Budget; division.CountWorkers = divisionDto.CountWorkers; division.idDivision = divisionDto.idDivision; division.Title = divisionDto.Title; return(division); }
private void BtnEdit_Click(object sender, RoutedEventArgs e) { switch (currentTable) { case "Worker": WorkerDto workerDto = (WorkerDto)dgMain.SelectedItem; if (workerDto != null) { WorkerWindow workerWindow = new WorkerWindow(); workerWindow.Load(workerDto); workerWindow.ShowDialog(); MenuItem_Click(sender, e); //update table } break; case "Division": DivisionDto divisionDto = (DivisionDto)dgMain.SelectedItem; if (divisionDto != null) { DivisionWindow divisionWindow = new DivisionWindow(); divisionWindow.Load(divisionDto); divisionWindow.ShowDialog(); MenuItem_Click_1(sender, e); } break; case "ExpenseByWorker": ExpenseDto expenseDto = (ExpenseDto)dgMain.SelectedItem; if (expenseDto != null) { ExpenseWindow expenseWindow = new ExpenseWindow(); expenseWindow.Load(expenseDto); expenseWindow.ShowDialog(); MenuItem_Click_3(sender, e); } break; case "TypeExpense": TypeExpenseDto typeExpenseDto = (TypeExpenseDto)dgMain.SelectedItem; if (typeExpenseDto != null) { TypeExpenseWindow typeExpenseWindow = new TypeExpenseWindow(); typeExpenseWindow.Load(typeExpenseDto); typeExpenseWindow.ShowDialog(); MenuItem_Click_4(sender, e); } break; } }
private static void SetTitle(Document document, DivisionDto division, DateTimeOffset dueDate, int offset) { var company = "PT DAN LIRIS"; var title = "LAPORAN BUDGET CASHFLOW"; var divisionName = "DIVISI: "; if (division != null) { divisionName += division.Name; } else { divisionName = "SEMUA DIVISI"; } var cultureInfo = new CultureInfo("id-ID"); var date = $"PERIODE {dueDate.AddMonths(1).AddHours(offset).DateTime.ToString("MMMM yyyy", cultureInfo)}"; var table = new PdfPTable(1) { WidthPercentage = 100, HorizontalAlignment = Element.ALIGN_LEFT }; var cell = new PdfPCell() { Border = Rectangle.NO_BORDER, HorizontalAlignment = Element.ALIGN_LEFT, Phrase = new Phrase(company, _headerFont), }; table.AddCell(cell); cell.Phrase = new Phrase(title, _headerFont); table.AddCell(cell); cell.Phrase = new Phrase(divisionName, _headerFont); table.AddCell(cell); cell.Phrase = new Phrase(date, _headerFont); table.AddCell(cell); cell.Phrase = new Phrase("\n", _headerFont); table.AddCell(cell); document.Add(table); }
internal async Task <OperationDto> Division() { Console.WriteLine("Please, specify divididend."); DivisionDto dto = new DivisionDto(); dto.Dividend = double.Parse(Console.ReadLine()); Console.WriteLine("Please, specify divisor."); dto.Divisor = double.Parse(Console.ReadLine()); Console.WriteLine("If you want to store the calculation, please, specify a new id."); int?id = null; if (int.TryParse(Console.ReadLine(), out int tmp)) { id = tmp; } return(await DoOperation(dto, id, DivisionRoute)); }
public async Task <ActionResult <OperationDto> > Div(DivisionDto divisionDto) { if (divisionDto.Divisor == 0) { return(BadRequest(new { Message = "Can not divide by 0." })); } try { Operation operation = await operationService.Div(divisionDto.OperationId, divisionDto.Dividend, divisionDto.Divisor); return(Ok(OperationMapper.Map(operation))); } catch (Exception ex) { logger.Error(ex, ex.Message); return(Problem("There was a problem processing your request", statusCode: (int?)HttpStatusCode.InternalServerError)); } }
public static MemoryStream Generate(DivisionDto division, DateTimeOffset dueDate, int offset, BudgetCashflowDivision data) { var document = new Document(PageSize.A4.Rotate(), 20, 20, 20, 20); var stream = new MemoryStream(); var writer = PdfWriter.GetInstance(document, stream); document.Open(); SetTitle(document, division, dueDate, offset); SetTable(document, data, division, dueDate, offset); document.Close(); byte[] byteInfo = stream.ToArray(); stream.Write(byteInfo, 0, byteInfo.Length); stream.Position = 0; return(stream); }
public async Task <ActionResult> Edit(int id, DivisionDto input) { // TODO: Add update logic here if (ModelState.IsValid) { await _divisionAppService.UpdateDivision(input); return(RedirectToAction("Index")); } else { var stations = _stationAppService.GetStations().Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Name }); ViewBag.StationId = stations; return(View(input)); } }
public static MemoryStream Generate(DivisionDto division, DateTimeOffset dueDate, int offset, BudgetCashflowDivision data) { using (var package = new ExcelPackage()) { var worksheet = package.Workbook.Worksheets.Add("Sheet 1"); SetTitle(worksheet, division, dueDate); SetTableHeader(worksheet, data.Headers); SetData(worksheet, data); worksheet.Cells[worksheet.Cells.Address].AutoFitColumns(); var stream = new MemoryStream(); package.SaveAs(stream); return(stream); } }
private DivisionDto LoadDto(SafeSqlDataReader data) { TimeZoneInfo currentUserTimeZoneInfo = DalHelpers.GetCurrentUserTimeZoneInfo(); DivisionDto dto = new DivisionDto() { DivisionKey = data.GetInt32("DivisionKey"), CreatedByUserKey = data.GetInt32("CreatedByUserKey"), CreatedByUserId = data.GetString("CreatedByUserId"), CreatedOnDate = TimeZoneInfo.ConvertTimeFromUtc(data.GetSmartDate("CreatedOnDate"), currentUserTimeZoneInfo), DivisionId = data.GetString("DivisionId"), DivisionValue = data.GetInt32("DivisionValue"), ModifiedByUserKey = data.GetInt32("ModifiedByUserKey"), ModifiedByUserId = data.GetString("ModifiedByUserId"), ModifiedOnDate = TimeZoneInfo.ConvertTimeFromUtc(data.GetSmartDate("ModifiedOnDate"), currentUserTimeZoneInfo), Name = data.GetString("Name"), }; return(dto); }
public void fillExcelTableByType(IEnumerable <object> grid, string currentTable, FileInfo xlsxFile) { if (grid != null) { ExcelPackage pck = new ExcelPackage(xlsxFile); var excel = pck.Workbook.Worksheets.Add(currentTable); int x = 1; int y = 1; // Устанавливает фиксированный десятичный разделитель (нужно для верногораспознавания типа данных Excel'ем). CultureInfo cultureInfo = new CultureInfo(Thread.CurrentThread.CurrentCulture.Name); Thread.CurrentThread.CurrentCulture = cultureInfo; cultureInfo.NumberFormat.NumberDecimalSeparator = "."; // Первая строка (шапка таблицы) – жирным стилем. excel.Cells["A1: Z1"].Style.Font.Bold = true; // Выравнивание текста в ячейках – по левому краю. excel.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Left; // Устанавливает формат ячеек. excel.Cells.Style.Numberformat.Format = "General"; // Пустой объект для получения списка property. Object dtObj = new Object(); switch (currentTable) { case "Worker": dtObj = new WorkerDto(); break; case "Division": dtObj = new DivisionDto(); break; case "ExpenseByWorker": dtObj = new ExpenseDto(); break; case "TypeExpense": dtObj = new TypeExpenseDto(); break; } // Генерация шапки таблицы. foreach (var prop in dtObj.GetType().GetProperties()) { excel.Cells[y, x].Value = prop.Name.Trim(); x++; } // Генерация строк-записей таблицы. foreach (var item in grid) { y++; // Объект-контейнер для текущего читаемого элемента. Object itemObj = item; x = 1; foreach (var prop in itemObj.GetType().GetProperties()) { object t = prop.GetValue(itemObj, null); object val; if (t == null) { val = ""; } else { val = t.ToString(); // Если тип сложный, то вытаскиваем нужное поле. if (t is WorkerDto) { val = ((WorkerDto)t).Name; } if (t is DivisionDto) { val = ((DivisionDto)t).Title; } if (t is ExpenseDto) { val = ((ExpenseDto)t).Description; } if (t is TypeExpenseDto) { val = ((TypeExpenseDto)t).Title; } } excel.Cells[y, x].Value = val; x++; } } // Устанавливаем размер колонок по ширине содержимого. excel.Cells.AutoFitColumns(); // Сохраняем файл. pck.Save(); } else { MessageBox.Show("Данные не загружены!"); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { switch (currentTable) { case "Worker": WorkerDto item = (WorkerDto)dgMain.SelectedItem; if (item == null) { MessageBox.Show("Choose item from delete", "Worker delete"); return; } MessageBoxResult result = MessageBox.Show("Delete " + item.Name + "?", "Worker delete", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result != MessageBoxResult.Yes) { return; } ProcessFactory.GetWorkerProcess().Delete(item.idWorker); MenuItem_Click(sender, e); //update table break; case "Division": DivisionDto itemDivision = (DivisionDto)dgMain.SelectedItem; if (itemDivision == null) { MessageBox.Show("Choose item from delete", "Division delete"); return; } MessageBoxResult resultDivision = MessageBox.Show("Delete " + itemDivision.Title + "?", "Division delete", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (resultDivision != MessageBoxResult.Yes) { return; } ProcessFactory.GetDivisionProcess().Delete(itemDivision.idDivision); MenuItem_Click_1(sender, e); break; case "ExpenseByWorker": ExpenseDto itemExpenseDto = (ExpenseDto)dgMain.SelectedItem; if (itemExpenseDto == null) { MessageBox.Show("Choose item from delete", "Expense delete"); return; } MessageBoxResult resultExpense = MessageBox.Show("Delete " + itemExpenseDto.Description + "?", "Expense delete", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (resultExpense != MessageBoxResult.Yes) { return; } ProcessFactory.GetExpenseByWorkerProcess().Delete(itemExpenseDto.idConsumption); MenuItem_Click_3(sender, e); break; case "TypeExpense": TypeExpenseDto itemTypeExpenseDto = (TypeExpenseDto)dgMain.SelectedItem; if (itemTypeExpenseDto == null) { MessageBox.Show("Choose item from delete", "Type expense delete"); return; } MessageBoxResult resultTypeExpense = MessageBox.Show("Delete " + itemTypeExpenseDto.Title + "?", "Type expense delete", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (resultTypeExpense != MessageBoxResult.Yes) { return; } ProcessFactory.GetExpenseByWorkerProcess().Delete(itemTypeExpenseDto.idType); MenuItem_Click_4(sender, e); break; } }
public void Update(DivisionDto divisionDto) { _divisionDao.Update(DtoConverter.Convert(divisionDto)); }
public void Add(DivisionDto divisionDto) { _divisionDao.Add(DtoConverter.Convert(divisionDto)); }
private static void SetTable(Document document, BudgetCashflowDivision data, DivisionDto division, DateTimeOffset dueDate, int offset) { var cellRotate = new PdfPCell() { Border = Element.RECTANGLE, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_TOP, Rotation = 90 }; var cellCenter = new PdfPCell() { Border = Element.RECTANGLE, HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_CENTER }; var cellLeft = new PdfPCell() { Border = Element.RECTANGLE, HorizontalAlignment = Element.ALIGN_LEFT, VerticalAlignment = Element.ALIGN_CENTER }; var cellRight = new PdfPCell() { Border = Element.RECTANGLE, HorizontalAlignment = Element.ALIGN_RIGHT, VerticalAlignment = Element.ALIGN_CENTER }; var dynamicHeadersPerPage = 2; var splittedHeaders = data.Headers.Select((header, index) => data.Headers.Skip(index * dynamicHeadersPerPage).Take(dynamicHeadersPerPage).ToList()).Where(header => header.Any()).ToList(); var isFirstPage = true; var loopedHeaders = 0; var loopedChildHeaders = 0; var isLastPage = false; var loopedCounter = 0; foreach (var headers in splittedHeaders) { loopedCounter += headers.Count * 3; if (loopedCounter == data.Headers.Count * 3) { isLastPage = true; } if (isFirstPage) { var dynamicColumns = headers.Count * 3; var columns = 5 + dynamicColumns; if (isLastPage) { columns += 1; } var table = new PdfPTable(columns) { WidthPercentage = 100, HorizontalAlignment = Element.ALIGN_LEFT }; var widths = new List <float>() { 2f, 2f, 1f, 20f, 4f }; foreach (var header in headers) { widths.Add(8f); widths.Add(8f); widths.Add(8f); } if (isLastPage) { widths.Add(8f); } table.SetWidths(widths.ToArray()); cellCenter.Rowspan = 2; cellCenter.Colspan = 4; cellCenter.Phrase = new Phrase("KETERANGAN", _smallBoldFont); table.AddCell(cellCenter); cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase("MATA UANG", _smallBoldFont); table.AddCell(cellCenter); foreach (var header in headers) { cellCenter.Rowspan = 1; cellCenter.Colspan = 3; cellCenter.Phrase = new Phrase(header, _smallBoldFont); table.AddCell(cellCenter); } if (isLastPage) { cellCenter.Rowspan = 2; cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase("TOTAL", _smallBoldFont); table.AddCell(cellCenter); } foreach (var header in headers) { cellCenter.Rowspan = 1; cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase("NOMINAL VALAS", _smallBoldFont); table.AddCell(cellCenter); cellCenter.Phrase = new Phrase("NOMINAL IDR", _smallBoldFont); table.AddCell(cellCenter); cellCenter.Phrase = new Phrase("ACTUAL", _smallBoldFont); table.AddCell(cellCenter); } foreach (var item in data.Items) { if (item.IsUseSection) { cellRotate.Rowspan = item.SectionRows > 0 ? item.SectionRows : 1; cellRotate.Phrase = new Phrase(item.CashflowType.Name, _smallBoldFont); table.AddCell(cellRotate); } if (item.IsUseGroup) { cellRotate.Rowspan = item.GroupRows > 0 ? item.GroupRows : 1; cellRotate.Phrase = new Phrase(item.TypeName, _smallBoldFont); table.AddCell(cellRotate); } if (item.IsLabelOnly) { var labelOnlyColspan = 3 + dynamicColumns; if (isLastPage) { labelOnlyColspan += 1; } cellLeft.Colspan = labelOnlyColspan; cellLeft.Phrase = new Phrase(item.CashflowCategory.Name, _smallBoldFont); table.AddCell(cellLeft); } if (item.IsSubCategory) { cellLeft.Colspan = 1; cellLeft.Phrase = new Phrase("", _smallFont); table.AddCell(cellLeft); if (item.IsShowSubCategoryLabel) { cellLeft.Phrase = new Phrase(item.CashflowSubCategory.Name, _smallFont); } else { cellLeft.Phrase = new Phrase("", _smallFont); } table.AddCell(cellLeft); cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase(item.Currency?.Code, _smallFont); table.AddCell(cellCenter); foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsSummary) { cellLeft.Colspan = 2; if (item.IsShowSummaryLabel) { cellLeft.Phrase = new Phrase(item.SummaryLabel, _smallBoldFont); } else { cellLeft.Phrase = new Phrase("", _smallFont); } table.AddCell(cellLeft); cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase(item.Currency?.Code, _smallFont); table.AddCell(cellCenter); foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsDifference) { cellLeft.Colspan = 3; if (item.IsShowDifferenceLabel) { cellLeft.Phrase = new Phrase(item.DifferenceLabel, _smallBoldFont); } else { cellLeft.Phrase = new Phrase("", _smallFont); } table.AddCell(cellLeft); cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase(item.Currency?.Code, _smallFont); table.AddCell(cellCenter); foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsGeneralSummary) { cellLeft.Colspan = 4; if (item.IsShowGeneralSummaryLabel) { cellLeft.Phrase = new Phrase(item.GeneralSummaryLabel, _smallBoldFont); } else { cellLeft.Phrase = new Phrase("", _smallFont); } table.AddCell(cellLeft); cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase(item.Currency?.Code, _smallFont); table.AddCell(cellCenter); foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsCurrencyRate) { cellLeft.Colspan = 4; if (item.IsShowCurrencyLabel) { cellLeft.Phrase = new Phrase(item.CurrencyRateLabel, _smallBoldFont); } else { cellLeft.Phrase = new Phrase("", _smallFont); } table.AddCell(cellLeft); cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase(item.Currency?.Code, _smallFont); table.AddCell(cellCenter); cellRight.Colspan = 1; cellRight.Phrase = new Phrase(item.Currency == null ? "" : item.Currency.Rate.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); var currencyRateColumns = dynamicColumns; if (isLastPage) { currencyRateColumns += 1; } cellRight.Colspan = currencyRateColumns; cellRight.Phrase = new Phrase("", _smallFont); table.AddCell(cellRight); } if (item.IsEquivalent) { cellLeft.Colspan = 4; cellLeft.Phrase = new Phrase("Total Surplus (Defisit) Equivalent", _smallBoldFont); table.AddCell(cellLeft); cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase("IDR", _smallFont); table.AddCell(cellCenter); //cellRight.Colspan = 1; //cellRight.Phrase = new Phrase(item.Equivalent.ToString("#,##0.00"), _smallFont); //table.AddCell(cellRight); var equivalentColumns = dynamicColumns; //if (isLastPage) // equivalentColumns += 1; cellRight.Colspan = equivalentColumns; cellRight.Phrase = new Phrase("", _smallFont); table.AddCell(cellRight); if (isLastPage) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(item.Equivalent.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } } document.Add(table); } else { document.NewPage(); SetTitle(document, division, dueDate, offset); var dynamicColumns = headers.Count * 3; var columns = dynamicColumns; if (isLastPage) { columns += 1; } var table = new PdfPTable(columns) { WidthPercentage = 100, HorizontalAlignment = Element.ALIGN_LEFT }; var widths = new List <float>(); foreach (var header in headers) { widths.Add(8f); widths.Add(8f); widths.Add(8f); } if (isLastPage) { widths.Add(8f); } table.SetWidths(widths.ToArray()); foreach (var header in headers) { cellCenter.Rowspan = 1; cellCenter.Colspan = 3; cellCenter.Phrase = new Phrase(header, _smallBoldFont); table.AddCell(cellCenter); } if (isLastPage) { cellCenter.Rowspan = 2; cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase("TOTAL", _smallBoldFont); table.AddCell(cellCenter); } foreach (var header in headers) { cellCenter.Rowspan = 1; cellCenter.Colspan = 1; cellCenter.Phrase = new Phrase("NOMINAL VALAS", _smallBoldFont); table.AddCell(cellCenter); cellCenter.Phrase = new Phrase("NOMINAL IDR", _smallBoldFont); table.AddCell(cellCenter); cellCenter.Phrase = new Phrase("ACTUAL", _smallBoldFont); table.AddCell(cellCenter); } foreach (var item in data.Items) { if (item.IsLabelOnly) { cellLeft.Colspan = columns; cellLeft.Phrase = new Phrase("\n", _smallBoldFont); table.AddCell(cellLeft); } if (item.IsSubCategory) { foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsSummary) { foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsDifference) { foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsGeneralSummary) { foreach (var subCategoryItem in item.Items.Skip(loopedChildHeaders).Take(headers.Count)) { cellRight.Colspan = 1; cellRight.Phrase = new Phrase(subCategoryItem.CurrencyNominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Nominal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); cellRight.Phrase = new Phrase(subCategoryItem.Actual.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } if (isLastPage) { cellRight.Phrase = new Phrase(item.DivisionActualTotal.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } if (item.IsCurrencyRate) { cellRight.Colspan = columns; cellRight.Phrase = new Phrase("\n", _smallFont); table.AddCell(cellRight); } if (item.IsEquivalent) { if (!isLastPage) { cellRight.Colspan = columns; cellRight.Phrase = new Phrase("\n", _smallFont); table.AddCell(cellRight); } else { cellRight.Colspan = columns - 1; cellRight.Phrase = new Phrase("\n", _smallFont); table.AddCell(cellRight); cellRight.Colspan = 1; cellRight.Phrase = new Phrase(item.Equivalent.ToString("#,##0.00"), _smallFont); table.AddCell(cellRight); } } } document.Add(table); } isFirstPage = false; loopedHeaders += headers.Count; loopedChildHeaders += headers.Count; } }
// DELETE api/Divisions/5 public void Delete([FromBody] DivisionDto division) { DivisionService.Delete(division.ConvertFromDto()); }
public static Division ConvertFromDto(this DivisionDto divisionDto) { return(new Division(divisionDto.Id, divisionDto.Name)); }