private void printBH(bool preview) { Global.checkDirSaveFile(); var doc = new PDF.Document(); PdfWriter docWriter = PdfWriter.GetInstance(doc, new FileStream(BHConstant.SAVE_IN_DIRECTORY + @"\BHang" + preview.ToString() + ".pdf", FileMode.Create)); PdfWriterEvents writerEvent; if (preview) { writerEvent = new PdfWriterEvents("Preview"); docWriter.PageEvent = writerEvent; } Image watermarkImage = Image.GetInstance(AppDomain.CurrentDomain.BaseDirectory + @"logo.png"); watermarkImage.SetAbsolutePosition(doc.PageSize.Width / 2 - 120, 476); writerEvent = new PdfWriterEvents(watermarkImage); docWriter.PageEvent = writerEvent; doc.Open(); doc.Add(FormatConfig.ParaRightBeforeHeader("Mã số phiếu : " + getOrderCode())); doc.Add(FormatConfig.ParaHeader("PHIẾU BÁN HÀNG")); doc.Add(FormatConfig.ParaRightBelowHeader("(SẼ BỔ SUNG HÓA ĐƠN TÀI CHÍNH VÀ THU THÊM THUẾ GTGT 10% SAU)")); doc.Add(FormatConfig.ParaCommonInfoAllBold("Tên khách hàng : ", getCustomerName())); doc.Add(FormatConfig.ParaCommonInfo("Địa chỉ : ", getCustomerAddress())); doc.Add(FormatConfig.ParaCommonInfo("Lý do xuất kho : ", txtReason.Text)); doc.Add(FormatConfig.ParaCommonInfo("Xuất tại kho : ", txtWare.Text)); PDF.pdf.PdfPTable table = FormatConfig.Table(7, new float[] { 0.5f, 3.5f, 1.6f, 0.7f, 0.7f, 1.3f, 1.7f }); table.AddCell(FormatConfig.TableCellHeader("STT")); table.AddCell(FormatConfig.TableCellHeader("Tên sản phẩm")); table.AddCell(FormatConfig.TableCellHeader("Mã SP")); table.AddCell(FormatConfig.TableCellHeader("ĐVT")); table.AddCell(FormatConfig.TableCellHeader("Số lượng")); table.AddCell(FormatConfig.TableCellHeader("Giá (VND)")); table.AddCell(FormatConfig.TableCellHeader("Thành tiền (VND)")); for (int i = 0; i < orderDetails.Count; i++) { if (orderDetails[i].ProductId != 0 && orderDetails[i].AttributeId != 0 && orderDetails[i].UnitId != 0) { table.AddCell(FormatConfig.TableCellBody((i + 1).ToString(), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( getProductName(orderDetails[i].ProductId, orderDetails[i].AttributeId), PdfPCell.ALIGN_LEFT)); table.AddCell(FormatConfig.TableCellBody( getProductCode(orderDetails[i].ProductId), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( getUnitName(orderDetails[i].UnitId), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( orderDetails[i].NumberUnit.ToString(), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( Global.convertToCurrency(orderDetails[i].Price.ToString()), PdfPCell.ALIGN_RIGHT)); table.AddCell(FormatConfig.TableCellBoldBody( Global.convertToCurrency(orderDetails[i].Cost.ToString()), PdfPCell.ALIGN_RIGHT, 1)); } } table.AddCell(FormatConfig.TableCellBoldBody("VAT", PdfPCell.ALIGN_RIGHT, 6)); table.AddCell(FormatConfig.TableCellBoldBody( Global.convertToCurrency(txtVAT.WorkingText), PdfPCell.ALIGN_RIGHT, 6)); table.AddCell(FormatConfig.TableCellBoldBody("Khấu chi", PdfPCell.ALIGN_RIGHT, 6)); table.AddCell(FormatConfig.TableCellBoldBody( Global.convertToCurrency(txtDiscount.WorkingText), PdfPCell.ALIGN_RIGHT, 1)); table.AddCell(FormatConfig.TableCellBoldBody("Tổng", PdfPCell.ALIGN_RIGHT, 6)); table.AddCell(FormatConfig.TableCellBoldBody( Global.convertToCurrency(totalWithTax.ToString()), PdfPCell.ALIGN_RIGHT, 1)); doc.Add(table); doc.Add(FormatConfig.ParaCommonInfoWithItalicContent("Cộng thành tiền (viết bằng chữ) : ", Global.convertCurrencyToText(totalWithTax.ToString()))); doc.Add(FormatConfig.ParaCommonInfo("Ghi chú : ", string.IsNullOrEmpty(txtNote.Text) ? String.Concat(Enumerable.Repeat("...", 48)) : txtNote.Text)); DateTime date = BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate(); doc.Add(FormatConfig.ParaRightBeforeHeader(string.Format("Xuất ngày {0} tháng {1} năm {2}", date.Day, date.Month, date.Year))); PDF.pdf.PdfPTable table2 = FormatConfig.Table(4, new float[] { 2.5f, 2f, 2f, 3.5f }); table2.AddCell(FormatConfig.TableCellHeaderCommon("NGƯỜI LẬP PHIẾU", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellHeaderCommon("NGƯỜI NHẬN", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellHeaderCommon("NGƯỜI GIAO", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellHeaderCommon("THỦ TRƯỞNG ĐƠN VỊ", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên)", PdfPCell.ALIGN_CENTER, FontConfig.SmallItalicFont)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên)", PdfPCell.ALIGN_CENTER, FontConfig.SmallItalicFont)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên)", PdfPCell.ALIGN_CENTER, FontConfig.SmallItalicFont)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên, đóng dấu)", PdfPCell.ALIGN_CENTER, FontConfig.ItalicFont)); doc.Add(table2); doc.Close(); }
private void printXK() { Global.checkDirSaveFile(); var doc = new PDF.Document(); PdfWriter docWriter = PdfWriter.GetInstance(doc, new FileStream(BHConstant.SAVE_IN_DIRECTORY + @"\XKho.pdf", FileMode.Create)); PdfWriterEvents writerEvent; Image watermarkImage = Image.GetInstance(AppDomain.CurrentDomain.BaseDirectory + @"logo.png"); watermarkImage.SetAbsolutePosition(doc.PageSize.Width / 2 - 120, 495); writerEvent = new PdfWriterEvents(watermarkImage); docWriter.PageEvent = writerEvent; doc.Open(); doc.Add(FormatConfig.ParaRightBeforeHeader("Mã số phiếu : " + getOrderCode())); doc.Add(FormatConfig.ParaHeader("PHIẾU XUẤT KHO")); doc.Add(FormatConfig.ParaCommonInfo("Tên khách hàng : ", getCustomerName())); doc.Add(FormatConfig.ParaCommonInfo("Địa chỉ : ", getCustomerAddress())); doc.Add(FormatConfig.ParaCommonInfo("Lý do xuất kho : ", txtReason.Text)); doc.Add(FormatConfig.ParaCommonInfo("Xuất tại kho : ", txtWare.Text)); PDF.pdf.PdfPTable table = FormatConfig.Table(6, new float[] { 0.5f, 4.5f, 1.6f, 0.7f, 0.7f, 2f }); table.AddCell(FormatConfig.TableCellHeader("STT")); table.AddCell(FormatConfig.TableCellHeader("Tên sản phẩm")); table.AddCell(FormatConfig.TableCellHeader("Mã SP")); table.AddCell(FormatConfig.TableCellHeader("ĐVT")); table.AddCell(FormatConfig.TableCellHeader("Số lượng")); table.AddCell(FormatConfig.TableCellHeader("Ghi chú")); for (int i = 0; i < orderDetails.Count; i++) { if (orderDetails[i].ProductId != 0 && orderDetails[i].AttributeId != 0 && orderDetails[i].UnitId != 0) { table.AddCell(FormatConfig.TableCellBody((i + 1).ToString(), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( getProductName(orderDetails[i].ProductId, orderDetails[i].AttributeId), PdfPCell.ALIGN_LEFT)); table.AddCell(FormatConfig.TableCellBody( getProductCode(orderDetails[i].ProductId), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( getUnitName(orderDetails[i].UnitId), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( orderDetails[i].NumberUnit.ToString(), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody( string.IsNullOrEmpty(orderDetails[i].Note) ? "" : orderDetails[i].Note.ToString(), PdfPCell.ALIGN_LEFT)); } } doc.Add(table); doc.Add(FormatConfig.ParaCommonInfo("Ghi chú : ", string.IsNullOrEmpty(txtNote.Text) ? String.Concat(Enumerable.Repeat("...", 96)) : txtNote.Text)); DateTime date = BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate(); doc.Add(FormatConfig.ParaRightBeforeHeader(string.Format("Xuất ngày {0} tháng {1} năm {2}", date.Day, date.Month, date.Year))); PDF.pdf.PdfPTable table2 = FormatConfig.Table(4, new float[] { 2.5f, 2f, 2f, 3.5f }); table2.AddCell(FormatConfig.TableCellHeaderCommon("NGƯỜI LẬP PHIẾU", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellHeaderCommon("NGƯỜI NHẬN", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellHeaderCommon("NGƯỜI GIAO", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellHeaderCommon("THỦ TRƯỞNG ĐƠN VỊ", PdfPCell.NO_BORDER)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên)", PdfPCell.ALIGN_CENTER, FontConfig.SmallItalicFont)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên)", PdfPCell.ALIGN_CENTER, FontConfig.SmallItalicFont)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên)", PdfPCell.ALIGN_CENTER, FontConfig.SmallItalicFont)); table2.AddCell(FormatConfig.TableCellBodyCustom("(Ký, họ tên, đóng dấu)", PdfPCell.ALIGN_CENTER, FontConfig.ItalicFont)); doc.Add(table2); doc.Close(); }
private void ExportFile() { Global.checkDirSaveFile(); var doc = new Document(PageSize.A4, 20, 20, 10, 10); PdfWriter docWriter = PdfWriter.GetInstance(doc, new FileStream(BHConstant.SAVE_IN_DIRECTORY + @"\Kho.pdf", FileMode.Create)); PdfWriterEvents writerEvent; Image watermarkImage = Image.GetInstance(AppDomain.CurrentDomain.BaseDirectory + @"logo.png"); watermarkImage.SetAbsolutePosition(doc.PageSize.Width / 2 - 70, 600); writerEvent = new PdfWriterEvents(watermarkImage); docWriter.PageEvent = writerEvent; doc.Open(); doc.Add(FormatConfig.ParaRightBeforeHeader("In ngày : " + BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate().ToString(BHConstant.DATETIME_FORMAT))); doc.Add(FormatConfig.ParaHeader("BÁO CÁO KHO VÀ THÀNH PHẨM")); doc.Add(FormatConfig.ParaRightBelowHeader("(" + textForPrint + ")")); if (modeReport != 1) doc.Add(ProductsTable()); else { doc.Add(FormatConfig.ParaCommonInfo("Sản phẩm : ", textInfo)); doc.Add(ProductDetailTable()); } doc.Add(FormatConfig.ParaCommonInfo("Ghi chú : ", String.Concat(Enumerable.Repeat("...", 96)))); doc.Close(); }
private void ExportFile() { Global.checkDirSaveFile(); var doc = new Document(PageSize.A4, 20, 20, 10, 10); PdfWriter docWriter = PdfWriter.GetInstance(doc, new FileStream(BHConstant.SAVE_IN_DIRECTORY + @"\KHang.pdf", FileMode.Create)); PdfWriterEvents writerEvent; Image watermarkImage = Image.GetInstance(AppDomain.CurrentDomain.BaseDirectory + @"logo.png"); watermarkImage.SetAbsolutePosition(doc.PageSize.Width / 2 - 70, 550); writerEvent = new PdfWriterEvents(watermarkImage); docWriter.PageEvent = writerEvent; doc.Open(); doc.Add(FormatConfig.ParaRightBeforeHeader("In ngày : " + BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate().ToString(BHConstant.DATETIME_FORMAT))); doc.Add(FormatConfig.ParaHeader("DANH SÁCH KHÁCH HÀNG")); PdfPTable table = FormatConfig.Table(7, new float[] { 0.5f, 2f, 1.3f, 1.3f, 2f, 1.6f, 1.3f }); table.AddCell(FormatConfig.TableCellHeader("STT")); table.AddCell(FormatConfig.TableCellHeader("Tên khách hàng")); table.AddCell(FormatConfig.TableCellHeader("Mã KH")); table.AddCell(FormatConfig.TableCellHeader("SĐT Cty")); table.AddCell(FormatConfig.TableCellHeader("Địa chỉ")); table.AddCell(FormatConfig.TableCellHeader("Người liên lạc")); table.AddCell(FormatConfig.TableCellHeader("SĐT")); for (int i = 0; i < customers.Count; i++) { table.AddCell(FormatConfig.TableCellBody((i + 1).ToString(), PdfPCell.ALIGN_CENTER)); table.AddCell(FormatConfig.TableCellBody(customers[i].CustomerName, PdfPCell.ALIGN_LEFT)); table.AddCell(FormatConfig.TableCellBody(customers[i].CustCode, PdfPCell.ALIGN_LEFT)); table.AddCell(FormatConfig.TableCellBody(customers[i].Phone, PdfPCell.ALIGN_LEFT)); table.AddCell(FormatConfig.TableCellBody(customers[i].Address, PdfPCell.ALIGN_LEFT)); table.AddCell(FormatConfig.TableCellBody(customers[i].ContactPerson, PdfPCell.ALIGN_LEFT)); table.AddCell(FormatConfig.TableCellBody(customers[i].ContactPersonPhone, PdfPCell.ALIGN_LEFT)); } doc.Add(table); doc.Add(FormatConfig.ParaCommonInfo("Ghi chú : ", String.Concat(Enumerable.Repeat("...", 96)))); doc.Close(); }
private void ExportFile() { Global.checkDirSaveFile(); var doc = new Document(PageSize.A4, 20, 20, 10, 10); PdfWriter docWriter = PdfWriter.GetInstance(doc, new FileStream(BHConstant.SAVE_IN_DIRECTORY + @"\CongNo.pdf", FileMode.Create)); PdfWriterEvents writerEvent; Image watermarkImage = Image.GetInstance(AppDomain.CurrentDomain.BaseDirectory + @"logo.png"); watermarkImage.SetAbsolutePosition(doc.PageSize.Width / 2 - 70, 500); writerEvent = new PdfWriterEvents(watermarkImage); docWriter.PageEvent = writerEvent; doc.Open(); if (modeReport == 1) { doc.Add(FormatConfig.ParaRightBeforeHeaderRight(BHConstant.COMPANY_NAME)); doc.Add(FormatConfig.ParaRightBeforeHeaderRight(BHConstant.COMPANY_ADDRESS)); doc.Add(FormatConfig.ParaRightBeforeHeaderRight("ĐT: " + BHConstant.COMPANY_PHONE + " Fax: " + BHConstant.COMPANY_FAX)); } doc.Add(FormatConfig.ParaRightBeforeHeader("In ngày : " + BaoHienRepository.GetBaoHienDBDataContext().GetSystemDate().ToString(BHConstant.DATETIME_FORMAT))); doc.Add(FormatConfig.ParaHeader("BÁO CÁO CÔNG NỢ")); doc.Add(FormatConfig.ParaRightBelowHeader("(" + textForPrint + ")")); if (modeReport != 1) doc.Add(CustomersTable()); else { doc.Add(FormatConfig.ParaCommonInfo("Kính gửi : ", customerPrint.CustomerName)); doc.Add(FormatConfig.ParaCommonInfo("Địa chỉ : ", customerPrint.Address)); doc.Add(FormatConfig.ParaCommonInfo("ĐT : ", customerPrint.Phone + " Fax: " + customerPrint.Fax)); doc.Add(CustomerDetailTable()); } doc.Add(FormatConfig.ParaCommonInfo("", "Quý khách hàng kiểm tra và đối chiếu, nếu có thắc mắc vui lòng liên hệ số điện thoại trên.")); doc.Add(FormatConfig.ParaCommonInfo("", "Chân thành cảm ơn sự hợp tác của quí khách.")); doc.Add(FormatConfig.ParaCommonInfo("Ghi chú : ", String.Concat(Enumerable.Repeat("...", 96)))); doc.Close(); }