protected void Page_Load(object sender, EventArgs e) { DataValidation dv = new DataValidation(); string sPath = dv.CurrentDir(true); string sFN = sPath + "pdfs//AgentStockPrices.pdf"; ReportDocument r = new ReportDocument(); try { string sRpt = "AgentStockPrices.rpt"; r.Load(System.AppDomain.CurrentDomain.BaseDirectory + sRpt); sFN = "C:\\MGMQuotation\\pdfs\\AgentStockPrices.rpt"; r.ExportToDisk(ExportFormatType.PortableDocFormat, sFN); System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.ContentType = "application/pdf"; System.Web.HttpContext.Current.Response.WriteFile(sFN); } catch (Exception ex) { Response.Write("Exception occurred: " + ex + "."); } finally { r.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { DataValidation dv = new DataValidation(); string sPath = dv.CurrentDir(true); string sFN = sPath + "pdfs//PerformanceDetail.pdf"; ReportDocument r = new ReportDocument(); try { DateTime dtFrom = Convert.ToDateTime(Request.QueryString["DateFrom"]); DateTime dtTo = Convert.ToDateTime(Request.QueryString["DateTo"]); int iRepID = Convert.ToInt32(Request.QueryString["RepID"]); string sUserName = Request.QueryString["UserName"].ToString(); if (iRepID > 0) { // Changed from QueryString, // so Admin will get requested Rep // after changing on Home screen. iRepID = Convert.ToInt32(Session["RepID"]); } string sRpt = (iRepID == 0) ? "PerformanceSummary.rpt" : "PerformanceDetail.rpt"; // Don't have a UserName for the Summary report. if (iRepID == 0) { sUserName = ""; } r.Load(System.AppDomain.CurrentDomain.BaseDirectory + sRpt); r.SetParameterValue("@from_date", dtFrom); r.SetParameterValue("@to_date", dtTo); r.SetParameterValue("@rep_id", iRepID); r.SetParameterValue("@user_name", sUserName); sFN = "C:\\MGMQuotation\\pdfs\\PerformanceDetail.pdf"; r.ExportToDisk(ExportFormatType.PortableDocFormat, sFN); System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.ContentType = "application/pdf"; System.Web.HttpContext.Current.Response.WriteFile(sFN); } catch (Exception ex) { Response.Write("Exception occurred: " + ex + "."); } finally { r.Dispose(); } }
protected void btnPreview_Click(object sender, EventArgs e) { DataValidation dv = new DataValidation(); string sPath = dv.CurrentDir(true); int iQuoteID = Convert.ToInt32(Session["QuoteID"]); bool bOEM = lblOEM.Visible; bool bOEMEmail; SaveQuote(); // Make sure all required fields, including all item Submittal Notes, are entered. string sErrorMsg = q.SubmittalRequire(iQuoteID); lblErrorMsg.Text = sErrorMsg; if (sErrorMsg != "") { return; } if (q.CreatePDF(iQuoteID, false, bOEM, false, true, out bOEMEmail) == false) { return; } string sURL = q.QuotePDFUrl(iQuoteID, false, true); // Hard-coding to production since we don't seem to have access rights to QA. // ************************************************************************** string sPathFull = ""; if (Convert.ToBoolean(WebConfigurationManager.AppSettings["LocalMachine"]) == true) { sPathFull = WebConfigurationManager.AppSettings["LocalWebSiteUrl"] + sURL; } else { sPathFull = "https://MGMQuotation.MGMTransformer.com//MGMQuotation//pdfs//" + sURL;// + } // ************************************************************************** // Open PDF in another browser. ResponseHelper.Redirect(sPathFull, "_blank", ""); System.Diagnostics.Process.Start(sPathFull); }
protected void Page_Load(object sender, EventArgs e) { DataValidation dv = new DataValidation(); string sPath = dv.CurrentDir(true); string sFN = sPath + "pdfs//GiftCardPromotion.pdf"; ReportDocument r = new ReportDocument(); try { DateTime dtFrom = Convert.ToDateTime(Request.QueryString["DateFrom"]); DateTime dtTo = Convert.ToDateTime(Request.QueryString["DateTo"]); int iRepID = Convert.ToInt32(Request.QueryString["RepID"]); // If zero, selecting all. // Update order totals for this report. RefreshData(dtFrom, dtTo); string sRpt = "GiftCardPromotion.rpt"; r.Load(System.AppDomain.CurrentDomain.BaseDirectory + sRpt); r.SetParameterValue("@from_date", dtFrom); r.SetParameterValue("@to_date", dtTo); r.SetParameterValue("@rep_id", iRepID); sFN = "C:\\MGMQuotation\\pdfs\\GiftCardPromotion.pdf"; r.ExportToDisk(ExportFormatType.PortableDocFormat, sFN); System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.ContentType = "application/pdf"; System.Web.HttpContext.Current.Response.WriteFile(sFN); } catch (Exception ex) { Response.Write("Exception occurred: " + ex + "."); } finally { r.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { DataValidation dv = new DataValidation(); string sPath = dv.CurrentDir(true); string sFN = sPath + "pdfs//QuoteStatus.pdf"; ReportDocument r = new ReportDocument(); try { DateTime dtFrom = Convert.ToDateTime(Request.QueryString["DateFrom"]); DateTime dtTo = Convert.ToDateTime(Request.QueryString["DateTo"]); string sUserName = Request.QueryString["UserName"].ToString(); r.Load(System.AppDomain.CurrentDomain.BaseDirectory + "QuoteStatus.rpt"); r.SetParameterValue("@from_date", dtFrom); r.SetParameterValue("@to_date", dtTo); r.SetParameterValue("@user_name", sUserName); r.SetParameterValue("FullName", Session["FullName"].ToString()); sFN = "C:\\MGMQuotation\\pdfs\\QuoteStatus.pdf"; r.ExportToDisk(ExportFormatType.PortableDocFormat, sFN); System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.ContentType = "application/pdf"; System.Web.HttpContext.Current.Response.WriteFile(sFN); } catch (Exception ex) { Response.Write("Exception occurred: " + ex + "."); } finally { r.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { DataValidation dv = new DataValidation(); string sPath = dv.CurrentDir(true); string sFN = sPath + "pdfs//PriceList.pdf"; string sPriceType = Request.QueryString["winding"].ToString(); string sEfficiency = Request.QueryString["efficiency"].ToString(); int iRepID = Convert.ToInt32(Session["RepDistributorID"]); ReportDocument r = new ReportDocument(); try { string sSource = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "PriceList.rpt"); r.Load(sSource); r.SetParameterValue("@winding", sPriceType); r.SetParameterValue("@rep_id", iRepID); r.SetParameterValue("@efficiency", sEfficiency); sFN = "C:\\MGMQuotation\\pdfs\\PriceList.pdf"; r.ExportToDisk(ExportFormatType.PortableDocFormat, sFN); System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.ContentType = "application/pdf"; System.Web.HttpContext.Current.Response.WriteFile(sFN); } catch (Exception ex) { Response.Write("Exception occurred: " + ex + "."); } finally { r.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { DataValidation dv = new DataValidation(); //create document Document document = new Document(); try { int iQuoteID = int.Parse(Request.QueryString["QuoteID"].ToString()); Quotes q = new Quotes(); DataSet ds = q.QuotePDFSelect(iQuoteID); string sQuoteNum = ds.Tables[0].Rows[0]["QuoteNum"].ToString(); sQuoteNum = sQuoteNum.Substring(2, sQuoteNum.Length - 2); // Strip off leading WQ. string sRepName = ds.Tables[0].Rows[0]["Rep"].ToString(); sRepName = sRepName.Replace(" ", ""); // Generate PDF File Name. string sProjectName = RemoveSpecialCharacters(ds.Tables[0].Rows[0]["ProjectName"].ToString()); sProjectName = (sProjectName == null || sProjectName == "") ? "":"_" + sProjectName; string pdfFileName = "MGM_" + sRepName + "_" + sQuoteNum + sProjectName + ".pdf"; document = new Document(iTextSharp.text.PageSize.A4_LANDSCAPE.Rotate(), 25, 0, 20, 0); string sPath = dv.CurrentDir(true); PdfWriter.GetInstance(document, new FileStream(sPath + "pdfs//" + pdfFileName, FileMode.Create)); document.Open(); document.AddAuthor("MGM Transformer Company"); WebClient cl = new WebClient(); String htmlText; List <IElement> htmlarraylist; string strImage = ""; iTextSharp.text.Image chartImg; //Add Page one document.NewPage(); chartImg = iTextSharp.text.Image.GetInstance(Server.MapPath("images/MGMLOGO.jpg")); chartImg.ScalePercent(float.Parse("20")); chartImg.Alignment = iTextSharp.text.Image.UNDERLYING; document.Add(chartImg); //string baseUrl = "https://mgmquotation.mgmtransformer.com/mgmquotation/mgmquotationqa/"; // string baseUrl = "https://localhost/"; //string baseUrl = Request.Url.ToString().Replace(Request.Url.PathAndQuery, ""); string[] split = new string[] { "pdf" }; string baseUrl = Request.Url.ToString().ToLower().Split(split, StringSplitOptions.None)[0]; htmlText = cl.DownloadString(baseUrl + "pdf_page1.aspx?QuoteID=" + iQuoteID + "&QuoteName=" + sRepName + "_" + iQuoteID); var sr = new StringReader(htmlText); htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, null); htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null); for (int k = 0; k < htmlarraylist.Count; k++) { IElement ele = (IElement)htmlarraylist[k]; PdfPTable tbl = ele as PdfPTable; if (tbl != null && tbl.NumberOfColumns == 17) { // #, KVA, Phase, Primary Voltage, Secondary Voltage, TempRise, Hertz, Winding Material, Electrostatic Shield, // Enclosure, Sound Level, TP1, K-Factor, Unit Price, Qty, Extended Price, Catalog Number or Accessory tbl.SetWidths(new float[] { 2F, 2F, 2F, 3F, 3F, 2F, 1F, 3F, 3F, 4F, 2F, 1F, 3F, 2F, 1F, 3F, 6F }); document.Add(ele); } else { document.Add(ele); } } //Create page onwards //Set scale default to 45% string scale = "45"; string unitCase = ""; string data = ""; string sPrimaryVoltageDW = ""; string sSecondaryVoltageDW = ""; DataTable dt = ds.Tables[1]; // QuoteDetails. foreach (DataRow dr in dt.Rows) { if (dr["KitID"].ToString() == "" || dr["KitID"].ToString() == "0") { document.SetMargins(50, 0, 0, 0); document.NewPage(); sPrimaryVoltageDW = DeltaWye(dr["PrimaryVoltageDW"].ToString(), dr["Phase"].ToString()); sSecondaryVoltageDW = DeltaWye(dr["SecondaryVoltageDW"].ToString(), dr["Phase"].ToString()); data = "?quoteid=" + iQuoteID.ToString() + ""enum=" + ds.Tables[0].Rows[0]["QuoteNum"].ToString() + ""ename=" + ds.Tables[0].Rows[0]["QuoteName"].ToString() + "&detailiddisplay=" + dr["DetailIDDisplay"].ToString() + "&kva=" + dr["KVA"].ToString() + "&pvolts=" + dr["PrimaryVoltage"].ToString() + "&svolts=" + dr["SecondaryVoltage"].ToString() + "&pvoltsdw=" + sPrimaryVoltageDW + "&svoltsdw=" + sSecondaryVoltageDW + "&electrostaticshield=" + dr["ElectrostaticShield"].ToString() + "&phase=" + dr["Phase"].ToString() + "&hertz=" + dr["Hertz"].ToString() + "&temp=" + dr["Temperature"].ToString() + "&winding=" + dr["Windings"].ToString() + "&kfactor=" + dr["KFactor"].ToString() + "&tp1=" + dr["TP1"].ToString() + "&soundlevel=" + dr["SoundLevel"].ToString() + "&weight=" + dr["Weight"].ToString() + ""enumber=" + sRepName + "_" + iQuoteID + "&item=" + dr["DetailID"].ToString() + "&enclosure=" + dr["Enclosure"].ToString() + "&company=" + ds.Tables[0].Rows[0]["Company"].ToString(); htmlText = cl.DownloadString(baseUrl + "pdf_page2.aspx" + data); htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(htmlText), null); //add the case image unitCase = dr["UnitCase"].ToString(); scale = "45.5"; switch (unitCase) { case "A": strImage = "CASE_GPA.jpg"; break; case "B": strImage = "CASE_GPB.jpg"; break; case "B+": strImage = "CASE_GPB+.jpg"; break; case "C": strImage = "CASE_GPC.jpg"; break; case "C+": strImage = "CASE_GPC+.jpg"; break; case "D": strImage = "CASE_GPD.jpg"; break; case "E": strImage = "CASE_GPE.jpg"; break; case "F": strImage = "CASE_GPF.jpg"; break; } chartImg = iTextSharp.text.Image.GetInstance(Server.MapPath("cases/" + strImage)); chartImg.ScalePercent(float.Parse(scale)); chartImg.Alignment = iTextSharp.text.Image.UNDERLYING; document.Add(chartImg); for (int k = 0; k < htmlarraylist.Count; k++) { document.Add((IElement)htmlarraylist[k]); } } } SetPDFFileName(pdfFileName); Response.Clear(); //Response.Write(pdfFileName); // Not used in ASP version. } catch (Exception ex) { logger.Error("pdf:" + ex.Message + " " + ex.StackTrace); } finally { if (document.IsOpen()) { document.Close(); } } }