private static string FooterTabelaComissao(List<Pagamento> listaPagamento) { return string.Format("<tr><td>{0}</th><td>{1}</th><td>{2}</th><td>{3}</th></tr>" , "Total: " , listaPagamento.Sum(p => p.ValorPago) , listaPagamento.Sum(p => p.ValorPago - ((p.ValorPago*p.Contrato.Vendedor.Comissao)/100)) , listaPagamento.Sum(p => ((p.ValorPago * p.Contrato.Vendedor.Comissao) / 100))); }
public void loadTheKho() { _DMTheKho = TheKhoManager.getAllByDate(dtpNgayGhi.Value); gdvTheKho.DataSource = _DMTheKho; _tongLuongSach = _DMTheKho.Sum(tk => tk.SoLuong); lbTongLuongSach.Text = _tongLuongSach.ToString(); }
public void loadSach() { _DMSach = SachManager.getAllAlive() .Where(p => p.tongSoLuongNhapTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0 && p.tongTienNhapTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList() ; lbTongLuongNhap.Text = _DMSach.Sum(s => s.SoLuongNhapTheoThang).ToString(); gdvLoNhap.DataSource = _DMSach; }
public void GenerateReports(IEnumerable<AggregatedSalesReport> reports, string path) { Document doc = new Document(PageSize.A4, 10, 10, 42, 35); PdfWriter.GetInstance(doc, new FileStream(path, FileMode.Create)); doc.Open(); PdfPTable table = new PdfPTable(5); int[] columnWidths = new[] {25, 11, 13, 42, 9}; table.SetWidths(columnWidths); DateTime? currentDate = null; decimal currentSum = 0; IList<decimal> dateSums = new List<decimal>(); this.AddTableHeader(table); foreach (var report in reports) { if (currentDate == null || !report.Date.Date.Equals(currentDate.Value.Date)) { if (currentDate != null) { this.AddDataFooter(table, currentSum, currentDate.Value); dateSums.Add(currentSum); currentSum = 0; } this.AddDataHeader(table, report.Date); } this.AddDataRow(table, report); currentDate = report.Date; currentSum += report.Sum; } if (reports.Any()) { this.AddDataFooter(table, currentSum, currentDate.Value); dateSums.Add(currentSum); } this.AddTableFooter(table, dateSums.Sum()); doc.Add(table); doc.Close(); }
public HttpResponseMessage Invoice(string date, string number, string total, string emails, string clientNumber, string matter, string description) { byte[] pdf = null; using (var ms = new MemoryStream()) { using (var doc = new Document()) { doc.SetMargins(60, 60, 40, 40); PdfWriter.GetInstance(doc, ms); doc.Open(); #region Header var table = new PdfPTable(4) { WidthPercentage = 100 }; var colSizes = new List<float> { 120f, 130f, 140f }; colSizes.Add(doc.PageSize.Width - colSizes.Sum()); table.SetWidths(colSizes.ToArray()); table.AddCell(new PdfPCell { Image = Image.GetInstance(HttpContext.Current.Request.MapPath("~\\App_Data\\Logo.jpg")), BorderColorRight = BaseColor.WHITE, Rowspan = 3 }); table.AddCell(new PdfPCell(CreatePhrase("950 E. State Hwy 114\nSuite 160\nSouthlake, TX 76092")) { HorizontalAlignment = Element.ALIGN_CENTER, VerticalAlignment = Element.ALIGN_MIDDLE, Rowspan = 3 }); table.AddCell(CreateCell("Invoice Date", Element.ALIGN_RIGHT)); table.AddCell(CreateCell(date, Element.ALIGN_CENTER)); table.AddCell(CreateCell("Invoice Number", Element.ALIGN_RIGHT)); table.AddCell(CreateCell(number, Element.ALIGN_CENTER)); table.AddCell(CreateCell("Invoice Total", Element.ALIGN_RIGHT)); table.AddCell(CreateCell(total, Element.ALIGN_CENTER)); doc.Add(table); #endregion #region Emails doc.Add(CreatePhrase(" ")); table = new PdfPTable(1) { WidthPercentage = 100 }; table.AddCell(CreateCell($"Invoice for {emails}", Element.ALIGN_CENTER)); doc.Add(table); #endregion #region Matters doc.Add(CreatePhrase(" ")); table = new PdfPTable(4) { WidthPercentage = 100 }; colSizes = new List<float> { 120f, 130f, 80f }; colSizes.Insert(2, doc.PageSize.Width - colSizes.Sum()); table.SetWidths(colSizes.ToArray()); var columns = new List<string> { "Client", "Matter", "Description", "Amount" }; columns.ForEach(c => { var cell = new PdfPCell { Phrase = CreatePhrase(c, headerFont), HorizontalAlignment = Element.ALIGN_CENTER }; table.AddCell(cell); }); columns = new List<string> { clientNumber, matter, description, total }; columns.ForEach(c => { table.AddCell(CreateCell(c, Element.ALIGN_CENTER)); }); doc.Add(table); #endregion #region Footer doc.Add(CreatePhrase("\nIf you have any questions, please contact us at [email protected].\n")); doc.Add(CreatePhrase("\nThank you for using SyncIDS.com!")); #endregion } pdf = ms.ToArray(); } var response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new ByteArrayContent(pdf); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); return response; }
private void LoadTT() { _DSDaiLy = DaiLyManager.getAllAlive() .Where(dl => dl.tinhTongTienThanhToanTheoThang(_startMonth,_startYear,_endMonth, _endYear) > 0).ToList(); gdvDaiLy.DataSource = _DSDaiLy; lbTongThu.Text = _DSDaiLy.Sum(s => s.TongTienThanhToanTheoThang) + ""; int tongthu = int.Parse(lbTongThu.Text.ToString()); _DSNXB = NhaXuatBanManager.getAllAlive() .Where(dl => dl.tinhTongTienThanhToanTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList(); gdvNXB.DataSource = _DSNXB; lbTongChi.Text = _DSNXB.Sum(s => s.TongTienThanhToanTheoThang) + ""; int tongchi = int.Parse(lbTongChi.Text.ToString()); lbLoiNhuan.Text= tongthu - tongchi + ""; }
private void LoadTT() { _Sach = SachManager.getAll() .Where(s => s.tongSoLuongBanTheoThang(_startMonth,_startYear,_endMonth,_endYear) > 0 && s.tongTienBanTheoThang(_startMonth,_startYear,_endMonth,_endYear) > 0).ToList(); gdvDMSach.DataSource = _Sach; lbSachBanDuoc.Text = _Sach.Sum(s => s.TongSoLuongBanTheoThang) + ""; lbTongTien.Text = _Sach.Sum(s => s.TongTienBanTheoThang) + ""; }
private static PdfPTable PopulatePdfFile(List<DateSalesReports> dataGroups) { PdfPTable table = new PdfPTable(DocumentColumnsCount); table.TotalWidth = TotalFileWidth; table.LockedWidth = true; AddContentMainHeader(table); foreach (var dataGroup in dataGroups) { AddSecondaryHeaderCells(table, dataGroup.Key); AddContentCells(table, dataGroup); } var grandTotal = dataGroups.Sum(dg => dg.TotalSumOfSales).ToString("F"); AddFooterRow(table, "Grand Total: ", grandTotal); return table; }
void LoadGrid(int pTableId) { vBasket = Basket.GetBasketList(pTableId); if (vBasket.Count == 0) { dgvProducts.DataSource = null; return; } gChelner = vBasket[0].Chelner; dgvProducts.DataSource = vBasket; gTable = tables.First(z => z.Id == pTableId);// Table.GetTableById(pTableId); total = vBasket.Sum(t => t.Total); lblTotal.Text = total.ToString("N2"); }
private void LoadBasket() { vBasket = Basket.GetBasketList(gTable.Id); dgvProducts.DataSource = vBasket; total = vBasket.Sum(t => t.Total); lblTotal.Text = total.ToString("N2"); }
private void LoadTT() { if (_CurrentNXB != null) { _DSHDNXB = _CurrentNXB.getHoaDonTheoThang(_startMonth, _startYear, _endMonth, _endYear).ToList(); gdvHoaDon.DataSource = _DSHDNXB; lbTongTienChi.Text = _DSHDNXB.Sum(p => p.TongTien) + ""; } }
private void LoadTT() { if (_CurrentDaiLy != null) { _HDDaiLy = _CurrentDaiLy.getHoaDonTheoThang(_startMonth, _startYear, _endMonth, _endYear).ToList(); gdvHoaDon.DataSource = _HDDaiLy; lbTongTienThu.Text = _HDDaiLy.Sum(p => p.TongTien) + ""; } }
private void loadTT() { if (x == 1) { _DMSachNXB = SachManager.getAll() .Where(s => s.tongSoLuongNXBNoTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0 && s.tongTienNXBNoTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList(); gdvDMSach.DataSource = _DMSachNXB; lbSoLuongNo.Text = _DMSachNXB.Sum(s => s.TongSoLuongNXBNoTheoThang) + ""; lbTongTien.Text = _DMSachNXB.Sum(s => s.TongTienNXBNoTheoThang) + ""; } if (x == 2) { _DMSachDLy = SachManager.getAll() .Where(s => s.tongSoLuongDaiLyNoTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0 && s.tongTienDaiLyNoTheoThang(_startMonth, _startYear, _endMonth, _endYear) > 0).ToList(); gdvDMSach.DataSource = _DMSachDLy; lbSoLuongNo.Text = _DMSachDLy.Sum(s => s.TongSoLuongDaiLyNoTheoThang) + ""; lbTongTien.Text = _DMSachDLy.Sum(s => s.TongTienDaiLyNoTheoTang) + ""; } }
public byte[] printCongNoDaiLy(List<Sach> DMSach, DateTime startDate, DateTime endDate) { try { var filePath = Path.Combine(FolderPath, FileName); PdfWriter writer = PdfWriter.GetInstance(_doc, new FileStream(filePath, FileMode.Create)); //Create table here for write database data var soLuongNo = (decimal)DMSach.Sum(s => s.TongSoLuongDaiLyNoTheoThang); var tongTienNo = (decimal)DMSach.Sum(s => s.TongTienDaiLyNoTheoTang); var HeaderTable = new PdfPTable(2); HeaderTable.HorizontalAlignment = 0; HeaderTable.SpacingBefore = 20; HeaderTable.SpacingAfter = 10; HeaderTable.SetWidths(new int[] { 2, 6 }); HeaderTable.AddCell(createNoBorderCell("Ngày in", 2, 1, 1)); HeaderTable.AddCell(createNoBorderCell(": " + DataDisplayHelper.dislayShortDate(DateTime.Now), 0, 1, 1)); //Thông tin thống kê var InfoTable = new PdfPTable(4); InfoTable.HorizontalAlignment = 0; InfoTable.SpacingAfter = 10; InfoTable.DefaultCell.Border = 0; InfoTable.TotalWidth = 15; InfoTable.SetWidths(new int[] { 2, 2, 2, 2 }); InfoTable.WidthPercentage = 100; InfoTable.DefaultCell.Border = Rectangle.BOX; InfoTable.AddCell(createHeaderCell("Xem từ tháng", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.dislayMonth(startDate), 1, 1, 1)); InfoTable.AddCell(createHeaderCell("Đến tháng", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.dislayMonth(endDate), 1, 1, 1)); InfoTable.AddCell(createHeaderCell("Số lượng nợ", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.displayNumber(soLuongNo), 0, 3, 1)); InfoTable.AddCell(createHeaderCell("Tổng tiền", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.displayMoney(tongTienNo), 0, 3, 1)); //Thống kê nguồn thu var DetailTable = new PdfPTable(8); DetailTable.HorizontalAlignment = 1; DetailTable.SpacingAfter = 10; DetailTable.WidthPercentage = 100; DetailTable.SetWidths(new int[] { 1, 6, 4, 3, 1, 3, 2, 3 }); DetailTable.AddCell(createTableTitleCell("Danh mục sách Đại lý nợ", 0, 8, 1)); DetailTable.AddCell(createNoBorderCell(" ", 1, 8, 1)); foreach (var s in DMSach) { DetailTable.AddCell(createBottomBorderCell(s.MaSoSach.ToString(), 1, 1, 1, BaseColor.LIGHT_GRAY)); DetailTable.AddCell(createBottomBorderCell(s.TenSach, 1, 1, 1, BaseColor.LIGHT_GRAY)); DetailTable.AddCell(createBottomBorderCell(" ", 1, 3, 1, BaseColor.LIGHT_GRAY)); DetailTable.AddCell(createBottomBorderCell("Tổng cộng", 1, 1, 1, BaseColor.LIGHT_GRAY)); DetailTable.AddCell(createBottomBorderCell(DataDisplayHelper.displayNumber((decimal)s.TongSoLuongDaiLyNoTheoThang), 1, 1, 1, BaseColor.LIGHT_GRAY)); DetailTable.AddCell(createBottomBorderCell(DataDisplayHelper.displayMoney((decimal)s.TongTienDaiLyNoTheoTang), 1, 1, 1, BaseColor.LIGHT_GRAY)); var CongNo = s.getCongNoDaiLyTheoThang(startDate.Month, startDate.Year, endDate.Month, endDate.Year); foreach (var p in CongNo) { DetailTable.AddCell(createNoBorderCell(" ", 1, 2, 1)); //DetailTable.AddCell(createNoBorderCell("Phiếu xuất số " + p.Maso, 1, 1, 1)); DetailTable.AddCell(createNoBorderCell("Tháng " + DataDisplayHelper.dislayMonth(p.Thang), 1, 2, 1)); DetailTable.AddCell(createNoBorderCell(" ", 1, 1, 1)); DetailTable.AddCell(createNoBorderCell(DataDisplayHelper.displayMoney(p.DonGia), 1, 1, 1)); DetailTable.AddCell(createNoBorderCell(p.SoLuong.ToString(), 1, 1, 1)); DetailTable.AddCell(createNoBorderCell(DataDisplayHelper.displayMoney(p.ThanhTien), 1, 1, 1)); } } _doc.Open(); _doc.Add(_tilte); _doc.Add(HeaderTable); _doc.Add(InfoTable); _doc.Add(DetailTable); _doc.Close(); return File.ReadAllBytes(filePath); } catch (Exception) { return null; } finally { _doc.Close(); } }
public byte[] printTonKho(List<TheKho> DMTheKho, DateTime date) { try { var filePath = Path.Combine(FolderPath, FileName); PdfWriter writer = PdfWriter.GetInstance(_doc, new FileStream(filePath, FileMode.Create)); //Create table here for write database data var HeaderTable = new PdfPTable(2); HeaderTable.HorizontalAlignment = 0; HeaderTable.SpacingBefore = 20; HeaderTable.SpacingAfter = 10; HeaderTable.SetWidths(new int[] { 2, 6}); HeaderTable.AddCell(createNoBorderCell("Ngày xem",0,1,1)); HeaderTable.AddCell(createNoBorderCell(": "+DataDisplayHelper.dislayShortDate(date),2,1,1)); HeaderTable.AddCell(createNoBorderCell("Ngày in", 0, 1, 1)); HeaderTable.AddCell(createNoBorderCell(": " + DataDisplayHelper.dislayShortDate(DateTime.Now), 2, 1, 1)); var DetailTable = new PdfPTable(5); DetailTable.HorizontalAlignment = 1; DetailTable.SpacingAfter = 10; DetailTable.DefaultCell.Border = 0; DetailTable.SetWidths(new int[] { 3, 4, 4, 2, 4 }); DetailTable.WidthPercentage = 100; DetailTable.DefaultCell.Border = Rectangle.BOX; DetailTable.AddCell(createHeaderCell(TheKhoManager.Properties.MaSoSach, 1, 1, 1)); DetailTable.AddCell(createHeaderCell(SachManager.Properties.TenSach, 1, 1, 1)); DetailTable.AddCell(createHeaderCell(SachManager.Properties.TenTacGia, 1, 1, 1)); DetailTable.AddCell(createHeaderCell(TheKhoManager.Properties.SoLuong, 1, 1, 1)); DetailTable.AddCell(createHeaderCell(TheKhoManager.Properties.NgayGhi, 1, 1, 1)); foreach (var s in DMTheKho) { DetailTable.AddCell(createCell(s.MaSoSach.ToString(), 1, 1, 1)); DetailTable.AddCell(createCell(s.Sach.TenSach, 0, 1, 1)); DetailTable.AddCell(createCell(s.Sach.TenTacGia, 0, 1, 1)); DetailTable.AddCell(createCell(s.SoLuong.ToString(), 0, 1, 1)); DetailTable.AddCell(createCell(DataDisplayHelper.dislayShortDate(s.NgayGhi), 1, 1, 1)); } DetailTable.AddCell(createHeaderCell("Tổng cộng", 2, 3, 1)); DetailTable.AddCell(createCell(DMTheKho.Sum(tk => tk.SoLuong).ToString(), 0, 2, 1)); _doc.Open(); _doc.Add(_tilte); _doc.Add(HeaderTable); _doc.Add(DetailTable); _doc.Close(); return File.ReadAllBytes(filePath); } catch (Exception) { return null; } finally { _doc.Close(); } }
public byte[] printDoanhThu(List<DaiLy> DMDaiLy, List<NhaXuatBan> DMNXB, DateTime startDate, DateTime endDate) { try { var filePath = Path.Combine(FolderPath, FileName); PdfWriter writer = PdfWriter.GetInstance(_doc, new FileStream(filePath, FileMode.Create)); //Create table here for write database data var tongTienThu = (decimal)DMDaiLy.Sum(dl => dl.TongTienThanhToanTheoThang); var tongTienChi = (decimal)DMNXB.Sum(s => s.TongTienThanhToanTheoThang); var HeaderTable = new PdfPTable(2); HeaderTable.HorizontalAlignment = 0; HeaderTable.SpacingBefore = 20; HeaderTable.SpacingAfter = 10; HeaderTable.SetWidths(new int[] { 2, 6 }); HeaderTable.AddCell(createNoBorderCell("Ngày in", 2, 1, 1)); HeaderTable.AddCell(createNoBorderCell(": " + DataDisplayHelper.dislayShortDate(DateTime.Now), 0, 1, 1)); //Thông tin thống kê var InfoTable = new PdfPTable(4); InfoTable.HorizontalAlignment = 0; InfoTable.SpacingAfter = 10; InfoTable.DefaultCell.Border = 0; InfoTable.TotalWidth = 15; InfoTable.SetWidths(new int[] { 2, 2, 2, 2}); InfoTable.WidthPercentage = 100; InfoTable.DefaultCell.Border = Rectangle.BOX; InfoTable.AddCell(createHeaderCell("Xem từ tháng", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.dislayMonth(startDate), 1, 1, 1)); InfoTable.AddCell(createHeaderCell("Đến tháng", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.dislayMonth(endDate), 1, 1, 1)); InfoTable.AddCell(createHeaderCell("Tổng thu", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.displayMoney(tongTienThu), 0, 3, 1)); InfoTable.AddCell(createHeaderCell("Tổng chi", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.displayMoney(tongTienChi), 0, 3, 1)); InfoTable.AddCell(createHeaderCell("Lợi nhuận", 1, 1, 1)); InfoTable.AddCell(createCell(DataDisplayHelper.displayMoney(tongTienThu - tongTienChi), 0, 3, 1)); //Thống kê nguồn thu var DLDetailTable = new PdfPTable(4); DLDetailTable.HorizontalAlignment = 1; DLDetailTable.SpacingAfter = 10; DLDetailTable.WidthPercentage = 100; DLDetailTable.SetWidths(new int[] { 3, 4, 3, 3 }); DLDetailTable.AddCell(createTableTitleCell("Nguồn thu", 0, 4, 1)); DLDetailTable.AddCell(createNoBorderCell(" ", 1, 4, 1)); DLDetailTable.AddCell(createHeaderCell(DaiLyManager.Properties.MaSoDaiLy, 1, 1, 1)); DLDetailTable.AddCell(createHeaderCell(DaiLyManager.Properties.TenDaiLy, 1, 1, 1)); DLDetailTable.AddCell(createHeaderCell(DaiLyManager.Properties.TongTienThanhToan, 1, 1, 1)); DLDetailTable.AddCell(createHeaderCell(DaiLyManager.Properties.TongTienThanhToanTheoThang, 1, 1, 1)); foreach (var s in DMDaiLy) { DLDetailTable.AddCell(createCell(s.MaSoDaiLy.ToString(), 1, 1, 1)); DLDetailTable.AddCell(createCell(s.TenDaiLy, 0, 1, 1)); DLDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)s.TongTienThanhToan), 0, 1, 1)); DLDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)s.TongTienThanhToanTheoThang), 0, 1, 1)); } DLDetailTable.AddCell(createHeaderCell("Tổng cộng", 2, 2, 1)); DLDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)DMDaiLy.Sum(dl => dl.TongTienThanhToan)), 1, 1, 1)); DLDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)DMDaiLy.Sum(dl => dl.TongTienThanhToanTheoThang)), 1, 1, 1)); //Thông kê nguồn chi var NXBDetailTable = new PdfPTable(4); NXBDetailTable.HorizontalAlignment = 1; NXBDetailTable.SpacingAfter = 10; NXBDetailTable.WidthPercentage = 100; NXBDetailTable.SetWidths(new int[] { 3, 4, 3, 3 }); NXBDetailTable.AddCell(createTableTitleCell("Nguồn chi", 0, 4, 1)); NXBDetailTable.AddCell(createNoBorderCell(" ", 1, 4, 1)); NXBDetailTable.AddCell(createHeaderCell(NhaXuatBanManager.Properties.MaSoNXB, 1, 1, 1)); NXBDetailTable.AddCell(createHeaderCell(NhaXuatBanManager.Properties.TenNXB, 1, 1, 1)); NXBDetailTable.AddCell(createHeaderCell(NhaXuatBanManager.Properties.TongTienThanhToan, 1, 1, 1)); NXBDetailTable.AddCell(createHeaderCell(NhaXuatBanManager.Properties.TongTienThanhToanTheoThang, 1, 1, 1)); foreach (var s in DMNXB) { NXBDetailTable.AddCell(createCell(s.MaSoNXB.ToString(), 1, 1, 1)); NXBDetailTable.AddCell(createCell(s.TenNXB, 0, 1, 1)); NXBDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)s.TongTienThanhToan), 0, 1, 1)); NXBDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)s.TongTienThanhToanTheoThang), 0, 1, 1)); } NXBDetailTable.AddCell(createHeaderCell("Tổng cộng", 2, 2, 1)); NXBDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)DMNXB.Sum(dl => dl.TongTienThanhToan)), 1, 1, 1)); NXBDetailTable.AddCell(createCell(DataDisplayHelper.displayMoney((decimal)DMNXB.Sum(dl => dl.TongTienThanhToanTheoThang)), 1, 1, 1)); _doc.Open(); _doc.Add(_tilte); _doc.Add(HeaderTable); _doc.Add(InfoTable); _doc.Add(DLDetailTable); _doc.Add(NXBDetailTable); _doc.Close(); return File.ReadAllBytes(filePath); } catch (Exception) { return null; } finally { _doc.Close(); } }