partial void DeleteHotelRevenue(HotelRevenue instance);
partial void UpdateHotelRevenue(HotelRevenue instance);
protected void btnPDFAll_Click(object sender, System.Web.UI.ImageClickEventArgs e) { var hr = new HotelRevenue(); if (Session["MonthYear"] == null) return; var my = Session["MonthYear"].ToString(); var month = Convert.ToInt32(my.Split('/')[0]); var year = Convert.ToInt32(my.Split('/')[1]); var revenue = HotelDataEntryLib.Page.RevenueHelper.GetAllPropertyByHotelRevenue(year, month); var attachment = "attachment; filename= All Properties" + " Revenue " + my + ".pdf"; var pdfDoc = new Document(PageSize.A4.Rotate(), 30.0f, 5.0f, 40.0f, 0f); var pdfStream = new MemoryStream(); var pdfWriter = PdfWriter.GetInstance(pdfDoc, pdfStream); pdfDoc.Open();//Open Document to write pdfDoc.NewPage(); var fontH = FontFactory.GetFont("ARIAL", 9, Font.BOLD); var fontT = FontFactory.GetFont("ARIAL", 12, Font.BOLD); var font8 = FontFactory.GetFont("ARIAL", 8); var font8B = FontFactory.GetFont("ARIAL", 8, Font.BOLD); var prefacedate = new Paragraph { new Paragraph("Print Date: [" + DateTime.Now + "] ", font8B) }; var widths = new float[] { 60, 75f, 75f, 75f, 75f, 75f, 75f, 75f }; ///////////////////////////////////////////////////////////////////////////////////////////////////////// for (var i = 0; i < revenue.Count; i++) { //Begin table var pdfTable = new PdfPTable(8); pdfTable.HorizontalAlignment = 0; pdfTable.TotalWidth = 781f; pdfTable.LockedWidth = true; pdfTable.SetWidths(widths); pdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table hr.HotelRevenueId = revenue[i].HotelRevenueId; hr.Month = month; hr.Year = year; var listRevenue = RevenueHelper.ListRevenueEntryByMonthYear(hr); var total = CalculateTotal(listRevenue); var preface = new Paragraph(); // Header preface.Add(new Paragraph("[" + revenue[i].CurrencyCode + "] " + revenue[i].PropertyName + " Revenue " + my, fontT)); pdfDoc.Add(preface); PdfPCell pdfPCell = null; //Add Header of the pdf table pdfPCell = new PdfPCell(new Phrase(new Chunk("Date", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Occupancy(%)", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Room Revenue", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("F & B Revenue", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Spa Revenue", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Others", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Total", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Budget", fontH))); pdfTable.AddCell(pdfPCell); //How add the data from datatable to pdf table for (var rows = 0; rows < listRevenue.Count; rows++) { var date = DateTime.Parse(listRevenue[rows].PositionDate.ToString()); pdfPCell = new PdfPCell(new Phrase(new Chunk(date.ToShortDateString(), font8))) { HorizontalAlignment = Element.ALIGN_LEFT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].OccupancyRoom.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].RoomRevenue.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].FBRevenue.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].SpaRevenue.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].Others.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].Total.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].Budget.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); } pdfPCell = new PdfPCell(new Phrase(new Chunk("Total", font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("-", font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[0].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[1].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[2].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[3].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[4].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[5].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfDoc.Add(pdfTable); // add pdf table to the document var newLine = new Paragraph(); newLine.Add(new Paragraph("", fontT)); preface.Leading = 50.0f; pdfDoc.Add(newLine); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// pdfDoc.Add(prefacedate); pdfDoc.Close(); pdfWriter.Close(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", attachment); Response.BinaryWrite(pdfStream.ToArray()); Response.End(); }
partial void InsertHotelRevenue(HotelRevenue instance);
protected void btnPDFAll_Click(object sender, System.Web.UI.ImageClickEventArgs e) { var hr = new HotelRevenue(); if (Session["MonthYear"] == null) { return; } var my = Session["MonthYear"].ToString(); var month = Convert.ToInt32(my.Split('/')[0]); var year = Convert.ToInt32(my.Split('/')[1]); var revenue = HotelDataEntryLib.Page.RevenueHelper.GetAllPropertyByHotelRevenue(year, month); var attachment = "attachment; filename= All Properties" + " Revenue " + my + ".pdf"; var pdfDoc = new Document(PageSize.A4.Rotate(), 30.0f, 5.0f, 40.0f, 0f); var pdfStream = new MemoryStream(); var pdfWriter = PdfWriter.GetInstance(pdfDoc, pdfStream); pdfDoc.Open();//Open Document to write pdfDoc.NewPage(); var fontH = FontFactory.GetFont("ARIAL", 9, Font.BOLD); var fontT = FontFactory.GetFont("ARIAL", 12, Font.BOLD); var font8 = FontFactory.GetFont("ARIAL", 8); var font8B = FontFactory.GetFont("ARIAL", 8, Font.BOLD); var prefacedate = new Paragraph { new Paragraph("Print Date: [" + DateTime.Now + "] ", font8B) }; var widths = new float[] { 60, 75f, 75f, 75f, 75f, 75f, 75f, 75f }; ///////////////////////////////////////////////////////////////////////////////////////////////////////// for (var i = 0; i < revenue.Count; i++) { //Begin table var pdfTable = new PdfPTable(8); pdfTable.HorizontalAlignment = 0; pdfTable.TotalWidth = 781f; pdfTable.LockedWidth = true; pdfTable.SetWidths(widths); pdfTable.SpacingBefore = 15f; // Give some space after the text or it may overlap the table hr.HotelRevenueId = revenue[i].HotelRevenueId; hr.Month = month; hr.Year = year; var listRevenue = RevenueHelper.ListRevenueEntryByMonthYear(hr); var total = CalculateTotal(listRevenue); var preface = new Paragraph(); // Header preface.Add(new Paragraph("[" + revenue[i].CurrencyCode + "] " + revenue[i].PropertyName + " Revenue " + my, fontT)); pdfDoc.Add(preface); PdfPCell pdfPCell = null; //Add Header of the pdf table pdfPCell = new PdfPCell(new Phrase(new Chunk("Date", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Occupancy(%)", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Room Revenue", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("F & B Revenue", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Spa Revenue", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Others", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Total", fontH))); pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("Budget", fontH))); pdfTable.AddCell(pdfPCell); //How add the data from datatable to pdf table for (var rows = 0; rows < listRevenue.Count; rows++) { var date = DateTime.Parse(listRevenue[rows].PositionDate.ToString()); pdfPCell = new PdfPCell(new Phrase(new Chunk(date.ToShortDateString(), font8))) { HorizontalAlignment = Element.ALIGN_LEFT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].OccupancyRoom.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].RoomRevenue.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].FBRevenue.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].SpaRevenue.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].Others.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].Total.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(listRevenue[rows].Budget.ToString("#,##0.00"), font8))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); } pdfPCell = new PdfPCell(new Phrase(new Chunk("Total", font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk("-", font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[0].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[1].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[2].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[3].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[4].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfPCell = new PdfPCell(new Phrase(new Chunk(total[5].ToString("#,##0.00"), font8B))) { HorizontalAlignment = Element.ALIGN_RIGHT }; pdfTable.AddCell(pdfPCell); pdfDoc.Add(pdfTable); // add pdf table to the document var newLine = new Paragraph(); newLine.Add(new Paragraph("", fontT)); preface.Leading = 50.0f; pdfDoc.Add(newLine); } ///////////////////////////////////////////////////////////////////////////////////////////////////////// pdfDoc.Add(prefacedate); pdfDoc.Close(); pdfWriter.Close(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.AppendHeader("Content-Disposition", attachment); Response.BinaryWrite(pdfStream.ToArray()); Response.End(); }