protected void SaveInfo() { Seed_Info info = new Seed_Info(int.Parse(txtKey.Text)); info.SeedsName = txtSeedsName.Text; info.CategoryKey = 1;// int.Parse(DLLCategoryID.SelectedValue); info.CompanyKey = int.Parse(DLLCompany.SelectedValue); info.StatusKey = int.Parse(rdbStatus.SelectedValue); info.SeasonKey = int.Parse(DLLSeason.SelectedValue); if (FileUploadKML.HasFile) { try { FileUploadKML.SaveAs(Server.MapPath("~/Img/Seeds/") + info.SeedsKey.ToString() + ".png"); info.Images = "../Img/Seeds/" + info.SeedsKey.ToString() + ".png"; } catch (Exception ex) { } } else { info.Images = "../Img/Seeds/Default.png"; } info.TypeKey = int.Parse(DDLType.SelectedValue); info.Detail = txtDetail.Text; info.Save(); }
protected void GrDelete(object sender, CommandEventArgs e) { SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"]; nUserLogin.CheckRole("CA0001"); if (!nUserLogin.Role.Del) { Response.Write("<script >alert('Bạn không có quyền xóa danh mục này!')</script>"); } else { try { int mKey = int.Parse(e.CommandArgument.ToString()); Seed_Info info = new Seed_Info(mKey); info.Delete(); DataTable nTable = Seeds_Categories_Data.GetList(0, 1, txtSearch.Text); GV_Seeds.DataSource = nTable; GV_Seeds.DataBind(); } catch { Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>"); } } }
protected void LoadInfo(int Key) { Seed_Info info = new Seed_Info(Key); txtSeedsName.Text = info.SeedsName; if (Key == 0) { DDLType.SelectedValue = "1"; DLLCompany.SelectedValue = "241"; DLLSeason.SelectedValue = "240"; } else { DLLCompany.SelectedValue = info.CompanyKey.ToString(); DDLType.SelectedValue = info.TypeKey.ToString(); DLLSeason.SelectedValue = info.SeasonKey.ToString(); } //DLLCategoryID.SelectedValue = info.CategoryKey.ToString(); rdbStatus.SelectedValue = info.StatusKey.ToString(); txtDetail.Text = info.Detail; imgLink.ImageUrl = info.Images; }
protected void Page_Load(object sender, EventArgs e) { if (this.Request["seedkey"] != null) { seedkey = this.Request["seedkey"].ToInt(); } if (this.Request["from"] != null) { FromDate = DateTime.ParseExact(this.Request["from"], "d/M/yyyy", CultureInfo.InvariantCulture); } if (this.Request["to"] != null) { ToDate = DateTime.ParseExact(this.Request["to"], "d/M/yyyy", CultureInfo.InvariantCulture); } int memberID = HttpContext.Current.Session["MemberID"].ToInt(); if (memberID != 0) { string NameSeed = ""; TNLibrary.Book.Member_Info minfo = new TNLibrary.Book.Member_Info(memberID); MemoryStream ms = new MemoryStream(); Document document = new Document(iTextSharp.text.PageSize.A4.Rotate(), 66, 36, 54, 54); PdfWriter writer = PdfWriter.GetInstance(document, ms); BaseFont bfTimes = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, false); Font fontHeader = new Font(bfTimes, 12, Font.BOLD); Font fontNormal = new Font(bfTimes, 11); Font fontozel = new Font(bfTimes, 12, Font.NORMAL); writer.PageEvent = new PDFFooter(); document.Open(); if (seedkey.ToInt() == 0) { NameSeed = "_Tatca"; DataTable sTable = Report_Data.SeedProcessListReport(memberID, FromDate, ToDate); if (sTable != null) { for (int j = 0; j < sTable.Rows.Count; j++) { seedkey = sTable.Rows[j]["SeedsKey"].ToInt(); Seed_Info sinfo = new Seed_Info(seedkey.ToInt()); Paragraph header = new Paragraph(@"SỔ NHẬT KÝ SẢN XUẤT", new Font(bfTimes, 40, Font.BOLD)); header.Alignment = Element.ALIGN_CENTER; header.SpacingAfter = 20; document.Add(header); Paragraph header1 = new Paragraph(@"Năm............", new Font(bfTimes, 20, Font.NORMAL)); header1.Alignment = Element.ALIGN_CENTER; header1.SpacingAfter = 170; document.Add(header1); document.Add(new Paragraph(@"NÔNG HỘ: " + minfo.Name, new Font(bfTimes, 20, Font.BOLD))); document.Add(new Paragraph(@"MÃ SỐ: " + minfo.MemID, new Font(bfTimes, 20, Font.BOLD))); document.NewPage(); Paragraph Text1 = new Paragraph(@"PHẦN SẢN XUẤT", new Font(bfTimes, 30, Font.BOLD)); Text1.Alignment = Element.ALIGN_CENTER; document.Add(Text1); Paragraph Text2 = new Paragraph(@"Cây trồng: " + sinfo.SeedsName, new Font(bfTimes, 25, Font.NORMAL)); Text2.Alignment = Element.ALIGN_CENTER; document.Add(Text2); Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL)); Text3.Alignment = Element.ALIGN_CENTER; document.Add(Text3); document.NewPage(); #region [ Quản lý giống ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ GIỐNG", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(6); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 20, 15, 15, 15, 20 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Giống", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/Phân phối (Nguồn gốc giống)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày trồng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số lô", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Diện tích", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng giống", fontHeader), 1)); DataTable nTable = Report_Data.SeedProcessReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompanyName"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString() + " " + nTable.Rows[i]["UnitArea"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["UnitQuantity"].ToString(), fontozel), 1)); } } document.Add(mainTable); } #endregion #region [ Quản lý ủ phân hữu cơ ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ Ủ PHÂN HỮU CƠ", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(5); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 10, 45, 15, 15 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại phân", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Khối lượng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp ủ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thời gian ủ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1)); DataTable nTable = Report_Data.CompostingOrganicReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Method"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompostingDates"].ToString() + " ngày", fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Member_Name"].ToString(), fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ Quản lý Mua phân/hóa chất ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ MUA PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(6); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 10, 15, 25, 25, 15, 10 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày mua", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thương mại", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thành phần/ Hoạt chất", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/ Phân phối", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà cung cấp", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1)); DataTable nTable = Report_Data.FertilizerPesticideBuyReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Common"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Company"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ Quản lý Sử dụng phân/hóa chất ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ SỬ DỤNG PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(9); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 9, 11, 14, 15, 10, 15, 10, 10, 6 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cộng việc", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Lý do áp dụng/ Mật độ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị sử dụng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nguyên vật liệu (tên phân bón/ thuốc BVTV/ hóa chất)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Liều lượng (Nồng độ)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng/ lít nước", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("TGCL", fontHeader), 1)); DataTable nTable = Report_Data.FertilizerPesticideUseReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { string TGCL = ""; if (nTable.Rows[i]["TGCL"].ToString() == "") { TGCL = ""; } else { TGCL = nTable.Rows[i]["TGCL"].ToString() + " ngày"; } mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Solution"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["EquipmentName"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dose"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dosage"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(TGCL, fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ ] if (1 == 1) { Paragraph para = new Paragraph(@"KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(5); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 15, 15, 40, 15 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thực hiện", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị, dụng cụ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hoạt động", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mô tả phương pháp thực hiện", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1)); DataTable nTable = Report_Data.CheckEquipmentReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Action"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Info"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ QUẢN LÝ THU HOẠCH, XUẤT BÁN ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ THU HOẠCH, XUẤT BÁN", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(6); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 20, 15, 20, 15, 15 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thu hoạch/ Xuất bán", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số truy vết", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng thu hoạch", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thu hoạch", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng bán (Kg)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nơi thu mua", fontHeader), 1)); DataTable nTable = Report_Data.HarvestedForSaleReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Code"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantityHarvested"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantitySale"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["WhereToBuy"].ToString(), fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ KIỂM KÊ TỒN KHO ] if (1 == 1) { Paragraph para = new Paragraph(@"KIỂM KÊ TỒN KHO", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(4); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 25, 25, 25 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày kiểm kê", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("phân bón/ Hóa chất", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hạn dùng", fontHeader), 1)); DataTable nTable = Report_Data.InventoryReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["ExpireDate"]), fontozel), 1)); } } document.Add(mainTable); document.NewPage(); } #endregion } } } else { Seed_Info sinfo = new Seed_Info(seedkey.ToInt()); NameSeed = "_" + sinfo.SeedsName; Paragraph header = new Paragraph(@"SỔ NHẬT KÝ SẢN XUẤT", new Font(bfTimes, 40, Font.BOLD)); header.Alignment = Element.ALIGN_CENTER; header.SpacingAfter = 20; document.Add(header); Paragraph header1 = new Paragraph(@"Năm............", new Font(bfTimes, 20, Font.NORMAL)); header1.Alignment = Element.ALIGN_CENTER; header1.SpacingAfter = 170; document.Add(header1); document.Add(new Paragraph(@"NÔNG HỘ: " + minfo.Name, new Font(bfTimes, 20, Font.BOLD))); document.Add(new Paragraph(@"MÃ SỐ: " + minfo.MemID, new Font(bfTimes, 20, Font.BOLD))); document.NewPage(); Paragraph Text1 = new Paragraph(@"PHẦN SẢN XUẤT", new Font(bfTimes, 30, Font.BOLD)); Text1.Alignment = Element.ALIGN_CENTER; document.Add(Text1); Paragraph Text2 = new Paragraph(@"Cây trồng: " + sinfo.SeedsName, new Font(bfTimes, 25, Font.NORMAL)); Text2.Alignment = Element.ALIGN_CENTER; document.Add(Text2); Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL)); Text3.Alignment = Element.ALIGN_CENTER; document.Add(Text3); document.NewPage(); #region [ Quản lý giống ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ GIỐNG", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(6); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 20, 15, 15, 15, 20 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Giống", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/Phân phối (Nguồn gốc giống)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày trồng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số lô", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Diện tích", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng giống", fontHeader), 1)); DataTable nTable = Report_Data.SeedProcessReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompanyName"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString() + " " + nTable.Rows[i]["UnitArea"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["UnitQuantity"].ToString(), fontozel), 1)); } } document.Add(mainTable); } #endregion #region [ Quản lý ủ phân hữu cơ ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ Ủ PHÂN HỮU CƠ", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(5); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 10, 45, 15, 15 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại phân", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Khối lượng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp ủ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thời gian ủ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1)); DataTable nTable = Report_Data.CompostingOrganicReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Method"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["CompostingDates"].ToString() + " ngày", fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Member_Name"].ToString(), fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ Quản lý Mua phân/hóa chất ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ MUA PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(6); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 10, 15, 25, 25, 15, 10 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày mua", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thương mại", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thành phần/ Hoạt chất", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà sản xuất/ Phân phối", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nhà cung cấp", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1)); DataTable nTable = Report_Data.FertilizerPesticideBuyReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Common"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Company"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ Quản lý Sử dụng phân/hóa chất ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ SỬ DỤNG PHÂN BÓN, HÓA CHẤT", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(9); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 9, 11, 14, 15, 10, 15, 10, 10, 6 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cộng việc", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Lý do áp dụng/ Mật độ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Phương pháp", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị sử dụng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nguyên vật liệu (tên phân bón/ thuốc BVTV/ hóa chất)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Liều lượng (Nồng độ)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng lượng/ lít nước", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("TGCL", fontHeader), 1)); DataTable nTable = Report_Data.FertilizerPesticideUseReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { string TGCL = ""; if (nTable.Rows[i]["TGCL"].ToString() == "") { TGCL = ""; } else { TGCL = nTable.Rows[i]["TGCL"].ToString() + " ngày"; } mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Parcel"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Area"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Solution"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["EquipmentName"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dose"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Dosage"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(TGCL, fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ ] if (1 == 1) { Paragraph para = new Paragraph(@"KIỂM TRA, BẢO TRÌ, VỆ SINH THIẾT BỊ DỤNG CỤ", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(5); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 15, 15, 40, 15 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thực hiện", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Thiết bị, dụng cụ", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hoạt động", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mô tả phương pháp thực hiện", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thực hiện", fontHeader), 1)); DataTable nTable = Report_Data.CheckEquipmentReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Action"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Info"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ QUẢN LÝ THU HOẠCH, XUẤT BÁN ] if (1 == 1) { Paragraph para = new Paragraph(@"QUẢN LÝ THU HOẠCH, XUẤT BÁN", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(6); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 20, 15, 20, 15, 15 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày thu hoạch/ Xuất bán", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Mã số truy vết", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng thu hoạch", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Người thu hoạch", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng bán (Kg)", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Nơi thu mua", fontHeader), 1)); DataTable nTable = Report_Data.HarvestedForSaleReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Code"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantityHarvested"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["MemberName"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["QuantitySale"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["WhereToBuy"].ToString(), fontozel), 0)); } } document.Add(mainTable); document.NewPage(); } #endregion #region [ KIỂM KÊ TỒN KHO ] if (1 == 1) { Paragraph para = new Paragraph(@"KIỂM KÊ TỒN KHO", new Font(bfTimes, 30, Font.BOLD)); para.Alignment = Element.ALIGN_CENTER; para.SpacingAfter = 20; document.Add(para); PdfPTable mainTable = new PdfPTable(4); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 15, 25, 25, 25 }); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày kiểm kê", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("phân bón/ Hóa chất", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Hạn dùng", fontHeader), 1)); DataTable nTable = Report_Data.InventoryReport(memberID, seedkey.ToInt(), FromDate, ToDate); if (nTable != null) { for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["ExpireDate"]), fontozel), 1)); } } document.Add(mainTable); document.NewPage(); } #endregion } document.Close(); writer.Close(); Response.ContentType = "application/pdf;"; Response.AddHeader("Content-Disposition", "attachment; filename=SoNhatKySanXuat_" + TNLibrary.Book.Utils.RemoveUnicode(minfo.Name.Replace(" ", "")) + TNLibrary.Book.Utils.RemoveUnicode(NameSeed.Replace(" ", "")) + "_" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm") + ".pdf"); byte[] pdf = ms.ToArray(); Response.OutputStream.Write(pdf, 0, pdf.Length); } }
protected void Page_Load(object sender, EventArgs e) { if (this.Request["seedkey"] != null) { seedkey = this.Request["seedkey"].ToInt(); } if (this.Request["from"] != null) { FromDate = DateTime.ParseExact(this.Request["from"], "d/M/yyyy", CultureInfo.InvariantCulture); } if (this.Request["to"] != null) { ToDate = DateTime.ParseExact(this.Request["to"], "d/M/yyyy", CultureInfo.InvariantCulture); } int memberID = HttpContext.Current.Session["MemberID"].ToInt(); if (memberID != 0) { string NameSeed = ""; TNLibrary.Book.Member_Info minfo = new TNLibrary.Book.Member_Info(memberID); MemoryStream ms = new MemoryStream(); Document document = new Document(iTextSharp.text.PageSize.A4.Rotate(), 66, 36, 54, 54); PdfWriter writer = PdfWriter.GetInstance(document, ms); BaseFont bfTimes = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, false); Font fontHeader = new Font(bfTimes, 12, Font.BOLD); Font fontNormal = new Font(bfTimes, 11); Font fontozel = new Font(bfTimes, 12, Font.NORMAL); writer.PageEvent = new PDFFooter(); document.Open(); if (seedkey.ToInt() == 0) { Paragraph header = new Paragraph(@"BÁO CÁO CHI PHÍ TỔNG HỢP", new Font(bfTimes, 40, Font.BOLD)); header.Alignment = Element.ALIGN_CENTER; header.SpacingAfter = 20; document.Add(header); Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL)); Text3.Alignment = Element.ALIGN_CENTER; Text3.SpacingAfter = 150; document.Add(Text3); } else { Paragraph header = new Paragraph(@"BÁO CÁO CHI PHÍ", new Font(bfTimes, 40, Font.BOLD)); header.Alignment = Element.ALIGN_CENTER; header.SpacingAfter = 20; document.Add(header); Paragraph Text3 = new Paragraph(@"Từ " + this.Request["from"] + " đến " + this.Request["to"], new Font(bfTimes, 25, Font.NORMAL)); Text3.Alignment = Element.ALIGN_CENTER; Text3.SpacingAfter = 20; document.Add(Text3); Seed_Info sinfo = new Seed_Info(seedkey.ToInt()); Paragraph headerseed = new Paragraph(sinfo.SeedsName, new Font(bfTimes, 40, Font.BOLD)); headerseed.Alignment = Element.ALIGN_CENTER; headerseed.SpacingAfter = 90; document.Add(headerseed); } document.Add(new Paragraph(@"NÔNG HỘ: " + minfo.Name, new Font(bfTimes, 20, Font.BOLD))); document.Add(new Paragraph(@"MÃ SỐ: " + minfo.MemID, new Font(bfTimes, 20, Font.BOLD))); document.NewPage(); if (seedkey.ToInt() == 0) { NameSeed = "_Tatca"; if (1 == 1) { DataTable mTable = Report_Data.SumMoneyReport(memberID, seedkey, FromDate, ToDate); Paragraph headerTH = new Paragraph(@"Bảng tổng hợp thu chi", new Font(bfTimes, 30, Font.BOLD)); headerTH.Alignment = Element.ALIGN_CENTER; headerTH.SpacingAfter = 20; document.Add(headerTH); PdfPTable THTable = new PdfPTable(2); THTable.WidthPercentage = 100; THTable.SetWidths(new int[] { 50, 50 }); THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1)); THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalBuy)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalBuy)", "")), fontHeader), 1)); THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalSale)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalSale)", "")), fontHeader), 1)); document.Add(THTable); document.Add(new Paragraph("Ghi chú: Tổng chi = Tổng chi giống + Tổng chi phân bón + Tổng chi Thuốc(hóa chất) ", new Font(bfTimes, 15, Font.NORMAL))); document.Add(new Paragraph("Tổng thu = Tổng thu hoạch xuất bán ", new Font(bfTimes, 15, Font.NORMAL))); document.NewPage(); Paragraph headerTP = new Paragraph(@"Thống kê theo thành phần", new Font(bfTimes, 30, Font.BOLD)); headerTP.Alignment = Element.ALIGN_CENTER; headerTP.SpacingAfter = 20; document.Add(headerTP); document.Add(new Paragraph("1. Thống kê theo giống ", new Font(bfTimes, 13, Font.BOLD))); PdfPTable SeedTable = new PdfPTable(2); SeedTable.SpacingBefore = 10; SeedTable.WidthPercentage = 100; SeedTable.SetWidths(new int[] { 50, 50 }); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); double TotalSeedProcess = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Mua giống") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2)); TotalSeedProcess += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi giống : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSeedProcess), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.Add(new Paragraph("2. Thống kê theo phần bón ", new Font(bfTimes, 13, Font.BOLD))); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên phân bón", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); double TotalFertilizers = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Mua phân bón") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2)); TotalFertilizers += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi phân bón : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalFertilizers), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.Add(new Paragraph("3. Thống kê theo Thuốc(hóa chất) ", new Font(bfTimes, 13, Font.BOLD))); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thuốc", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); double TotalPesticides = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Mua thuốc BVTV") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2)); TotalPesticides += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi Thuốc(hóa chất) : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalPesticides), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.Add(new Paragraph("4. Thống kê theo thu hoạch xuất bán ", new Font(bfTimes, 13, Font.BOLD))); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1)); double TotalHarvestedForSale = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Thu hoạch xuất bán") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]), fontozel), 2)); TotalHarvestedForSale += String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu hoạch xuất bán : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalHarvestedForSale), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.NewPage(); DataTable nTable = Report_Data.MoneyReport(memberID, seedkey, FromDate, ToDate); if (nTable != null) { Paragraph headerDate = new Paragraph(@"Bảng tổng hợp thu chi theo ngày", new Font(bfTimes, 30, Font.BOLD)); headerDate.Alignment = Element.ALIGN_CENTER; headerDate.SpacingAfter = 20; document.Add(headerDate); PdfPTable mainTable = new PdfPTable(8); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 5, 10, 20, 20, 10, 10, 10, 15 }); double TotalSale = 0, TotalBuy = 0; mainTable.AddCell(GetCellForBorderlessTable(new Phrase("STT", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại thu chi", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Hàng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Chi", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Thu", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cung Cấp", fontHeader), 1)); for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase((i + 1).ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Type"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalBuy"]), fontozel), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalSale"]), fontozel), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0)); TotalSale += nTable.Rows[i]["TotalSale"].ToDouble(); TotalBuy += nTable.Rows[i]["TotalBuy"].ToDouble(); } mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalBuy), fontHeader), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSale), fontHeader), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); document.Add(mainTable); } } } else { Seed_Info sinfo = new Seed_Info(seedkey.ToInt()); NameSeed = "_" + sinfo.SeedsName; if (1 == 1) { DataTable mTable = Report_Data.SumMoneyReport(memberID, seedkey, FromDate, ToDate); Paragraph headerTH = new Paragraph(@"Bảng tổng hợp thu chi", new Font(bfTimes, 30, Font.BOLD)); headerTH.Alignment = Element.ALIGN_CENTER; headerTH.SpacingAfter = 20; document.Add(headerTH); PdfPTable THTable = new PdfPTable(2); THTable.WidthPercentage = 100; THTable.SetWidths(new int[] { 50, 50 }); THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); THTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1)); THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalBuy)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalBuy)", "")), fontHeader), 1)); THTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Compute("Sum(TotalSale)", "").ToString() == "" ? "0" : mTable.Compute("Sum(TotalSale)", "")), fontHeader), 1)); document.Add(THTable); document.Add(new Paragraph("Ghi chú: Tổng chi = Tổng chi giống + Tổng chi phân bón + Tổng chi Thuốc(hóa chất) ", new Font(bfTimes, 15, Font.NORMAL))); document.Add(new Paragraph("Tổng thu = Tổng thu hoạch xuất bán ", new Font(bfTimes, 15, Font.NORMAL))); document.NewPage(); document.Add(new Paragraph("Thống kê theo thành phần ", new Font(bfTimes, 15, Font.BOLD))); document.Add(new Paragraph("1. Thống kê theo giống ", new Font(bfTimes, 13, Font.BOLD))); PdfPTable SeedTable = new PdfPTable(2); SeedTable.SpacingBefore = 10; SeedTable.WidthPercentage = 100; SeedTable.SetWidths(new int[] { 50, 50 }); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); double TotalSeedProcess = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Mua giống") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2)); TotalSeedProcess += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi giống : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSeedProcess), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.Add(new Paragraph("2. Thống kê theo phần bón ", new Font(bfTimes, 13, Font.BOLD))); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên phân bón", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); double TotalFertilizers = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Mua phân bón") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2)); TotalFertilizers += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi phân bón : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalFertilizers), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.Add(new Paragraph("3. Thống kê theo Thuốc(hóa chất) ", new Font(bfTimes, 13, Font.BOLD))); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên thuốc", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi", fontHeader), 1)); double TotalPesticides = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Mua thuốc BVTV") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]), fontozel), 2)); TotalPesticides += String.Format("{0:#,0}", mTable.Rows[i]["TotalBuy"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng chi Thuốc(hóa chất) : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalPesticides), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.Add(new Paragraph("4. Thống kê theo thu hoạch xuất bán ", new Font(bfTimes, 13, Font.BOLD))); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên giống", fontHeader), 1)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu", fontHeader), 1)); double TotalHarvestedForSale = 0; for (int i = 0; i < mTable.Rows.Count; i++) { if (mTable.Rows[i]["Type"].ToString() == "Thu hoạch xuất bán") { SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(mTable.Rows[i]["Name"].ToString(), fontozel), 0)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]), fontozel), 2)); TotalHarvestedForSale += String.Format("{0:#,0}", mTable.Rows[i]["TotalSale"]).ToDouble(); } } SeedTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng thu hoạch xuất bán : ", fontHeader), 2)); SeedTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalHarvestedForSale), fontozel), 2)); document.Add(SeedTable); SeedTable.DeleteBodyRows(); document.NewPage(); DataTable nTable = Report_Data.MoneyReport(memberID, seedkey, FromDate, ToDate); if (nTable != null) { Paragraph headerDate = new Paragraph(@"Bảng tổng hợp thu chi theo ngày", new Font(bfTimes, 30, Font.BOLD)); headerDate.Alignment = Element.ALIGN_CENTER; headerDate.SpacingAfter = 20; document.Add(headerDate); PdfPTable mainTable = new PdfPTable(8); mainTable.WidthPercentage = 100; mainTable.SetWidths(new int[] { 5, 10, 20, 20, 10, 10, 10, 15 }); double TotalSale = 0, TotalBuy = 0; mainTable.AddCell(GetCellForBorderlessTable(new Phrase("STT", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Ngày", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Loại thu chi", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tên Hàng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Số lượng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Chi", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng Thu", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Cung Cấp", fontHeader), 1)); for (int i = 0; i < nTable.Rows.Count; i++) { mainTable.AddCell(GetCellForBorderlessTable(new Phrase((i + 1).ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(Utils.DateTostring((DateTime)nTable.Rows[i]["DateTime"]), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Type"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Name"].ToString(), fontozel), 0)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Quantity"].ToString() + " " + nTable.Rows[i]["Unit"].ToString(), fontozel), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalBuy"]), fontozel), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", nTable.Rows[i]["TotalSale"]), fontozel), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(nTable.Rows[i]["Address"].ToString(), fontozel), 0)); TotalSale += nTable.Rows[i]["TotalSale"].ToDouble(); TotalBuy += nTable.Rows[i]["TotalBuy"].ToDouble(); } mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("Tổng", fontHeader), 1)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalBuy), fontHeader), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase(String.Format("{0:#,0}", TotalSale), fontHeader), 2)); mainTable.AddCell(GetCellForBorderlessTable(new Phrase("", fontHeader), 1)); document.Add(mainTable); } } } document.Close(); writer.Close(); Response.ContentType = "application/pdf;"; Response.AddHeader("Content-Disposition", "attachment; filename=BaoCaoChiPhi_" + TNLibrary.Book.Utils.RemoveUnicode(minfo.Name.Replace(" ", "")) + TNLibrary.Book.Utils.RemoveUnicode(NameSeed.Replace(" ", "")) + "_" + DateTime.Now.ToString("dd.MM.yyyy_HH.mm") + ".pdf"); byte[] pdf = ms.ToArray(); Response.OutputStream.Write(pdf, 0, pdf.Length); } }