private void ExportCSRCtoPDF(int id) { oVariables = new Variables(intEnvironment); Document doc = new Document(); Cell cell; iTextSharp.text.Table oTable = new iTextSharp.text.Table(2); oTable.BorderWidth = 0; oTable.BorderColor = new iTextSharp.text.Color(255, 255, 255); oTable.Padding = 2; oTable.Width = 100; iTextSharp.text.Font oFontHeader = new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 10, 1); iTextSharp.text.Font oFontBold = new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 8, 1); iTextSharp.text.Font oFont = new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 8, 0); ds = oTPM.GetCSRC(id); int intRequest = Int32.Parse(ds.Tables[0].Rows[0]["requestid"].ToString()); int intItem = Int32.Parse(ds.Tables[0].Rows[0]["itemid"].ToString()); int intNumber = Int32.Parse(ds.Tables[0].Rows[0]["number"].ToString()); DataSet dsResource = oCustomized.GetTPM(intRequest, intItem, intNumber); string strFile = DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + "_" + intProfile.ToString() + ".pdf"; string strPath = oVariables.UploadsFolder() + strFile; string strVirtualPath = oVariables.UploadsFolder() + strFile; FileStream fs = new FileStream(strPath, FileMode.Create); PdfWriter.GetInstance(doc, fs); // PdfWriter.GetInstance(doc, Response.OutputStream); string strHeader = "ClearView CSRC Information"; HeaderFooter header = new HeaderFooter(new Phrase(strHeader, new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 6)), false); header.Border = iTextSharp.text.Rectangle.NO_BORDER; header.Alignment = 2; doc.Header = header; string strFooter = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); HeaderFooter footer = new HeaderFooter(new Phrase(strFooter, new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 6)), false); footer.Border = iTextSharp.text.Rectangle.NO_BORDER; footer.Alignment = 2; doc.Footer = footer; doc.Open(); cell = new Cell(new Phrase("Project Capital Service Review Committee Report", oFontHeader)); cell.Colspan = 2; cell.BackgroundColor = new iTextSharp.text.Color(169, 162, 141); oTable.AddCell(cell); cell = new Cell(new Phrase("PMM Phase", oFontBold)); cell.Colspan = 2; oTable.AddCell(cell); oTable.AddCell(new Cell(new Phrase("Discovery", oFont))); oTable.AddCell(new Cell(new Phrase((ds.Tables[0].Rows[0]["d"].ToString() == "1" ? "Yes" : "No"), oFont))); oTable.AddCell(new Cell(new Phrase("Planning", oFont))); oTable.AddCell(new Cell(new Phrase((ds.Tables[0].Rows[0]["p"].ToString() == "1" ? "Yes" : "No"), oFont))); oTable.AddCell(new Cell(new Phrase("Execution", oFont))); oTable.AddCell(new Cell(new Phrase((ds.Tables[0].Rows[0]["e"].ToString() == "1" ? "Yes" : "No"), oFont))); oTable.AddCell(new Cell(new Phrase("Closing", oFont))); oTable.AddCell(new Cell(new Phrase((ds.Tables[0].Rows[0]["c"].ToString() == "1" ? "Yes" : "No"), oFont))); cell = new Cell(new Phrase("Discovery", oFontBold)); cell.Colspan = 2; oTable.AddCell(cell); oTable.AddCell(new Cell(new Phrase("Phase start date", oFont))); if (ds.Tables[0].Rows[0]["ds"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["ds"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Phase end date", oFont))); if (ds.Tables[0].Rows[0]["de"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["de"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Internal Labor", oFont))); if (ds.Tables[0].Rows[0]["di"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["di"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("External Labor", oFont))); if (ds.Tables[0].Rows[0]["dex"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["dex"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("HW/SW/One Time Cost", oFont))); if (ds.Tables[0].Rows[0]["dh"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["dh"].ToString()).ToString("F"), oFont))); } cell = new Cell(new Phrase("Planning", oFontBold)); cell.Colspan = 2; oTable.AddCell(cell); oTable.AddCell(new Cell(new Phrase("Phase start date", oFont))); if (ds.Tables[0].Rows[0]["ps"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["ps"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Phase end date", oFont))); if (ds.Tables[0].Rows[0]["pe"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["pe"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Internal Labor", oFont))); if (ds.Tables[0].Rows[0]["pi"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["pi"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("External Labor", oFont))); if (ds.Tables[0].Rows[0]["pex"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["pex"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("HW/SW/One Time Cost", oFont))); if (ds.Tables[0].Rows[0]["ph"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["ph"].ToString()).ToString("F"), oFont))); } cell = new Cell(new Phrase("Execution", oFontBold)); cell.Colspan = 2; oTable.AddCell(cell); oTable.AddCell(new Cell(new Phrase("Phase start date", oFont))); if (ds.Tables[0].Rows[0]["es"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["es"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Phase end date", oFont))); if (ds.Tables[0].Rows[0]["ee"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["ee"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Internal Labor", oFont))); if (ds.Tables[0].Rows[0]["ei"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["ei"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("External Labor", oFont))); if (ds.Tables[0].Rows[0]["eex"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["eex"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("HW/SW/One Time Cost", oFont))); if (ds.Tables[0].Rows[0]["eh"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["eh"].ToString()).ToString("F"), oFont))); } cell = new Cell(new Phrase("Closing", oFontBold)); cell.Colspan = 2; oTable.AddCell(cell); oTable.AddCell(new Cell(new Phrase("Phase start date", oFont))); if (ds.Tables[0].Rows[0]["cs"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["cs"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Phase end date", oFont))); if (ds.Tables[0].Rows[0]["ce"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("N / A", oFont))); } else { oTable.AddCell(new Cell(new Phrase(GetDate(ds.Tables[0].Rows[0]["ce"].ToString()), oFont))); } oTable.AddCell(new Cell(new Phrase("Internal Labor", oFont))); if (ds.Tables[0].Rows[0]["ci"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["ci"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("External Labor", oFont))); if (ds.Tables[0].Rows[0]["cex"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["cex"].ToString()).ToString("F"), oFont))); } oTable.AddCell(new Cell(new Phrase("HW/SW/One Time Cost", oFont))); if (ds.Tables[0].Rows[0]["ch"] == DBNull.Value) { oTable.AddCell(new Cell(new Phrase("$0.0", oFont))); } else { oTable.AddCell(new Cell(new Phrase("$" + GetFloat(ds.Tables[0].Rows[0]["ch"].ToString()).ToString("F"), oFont))); } doc.Add(oTable); doc.Close(); fs.Close(); string strURL = oVariables.UploadsFolder() + strFile; oTPM.UpdateCSRCPath(id, oVariables.UploadsFolder() + strFile); strAttachement += "<tr><td><a href=\"" + strURL + "\" target=\"_blank\"><img src=\"/images/icons/pdf.gif \" align=\"absmiddle\" border=\"0\" /> View PCR Document (" + ds.Tables[0].Rows[0]["name"] + ")</a></td></tr> "; //Response.ContentType = "application/pdf"; //Response.AddHeader("Content-Disposition", "attachment; filename=closure_form.pdf"); //Response.End(); //Response.Flush(); }