protected void btnComment_Click(object sender, EventArgs e) { Random r = new Random(); int num = r.Next(); lblContent.Visible = true; Panel1.Visible = true; lbl2.Text = TextBox1.Text; lbl4.Text = TextBox2.Text; lbl6.Text = TextBox3.Text; lbl8.Text = TextBox4.Text; lbl10.Text = TextBox5.Text; lbl12.Text = TextBox6.Text; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=AEReccommendations" + num.ToString() + ".pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); Panel1.Visible = false; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; //pnFeedbackGrammar.Visible = false; //pnFeedbackContent.Visible = true; }
protected void btnExcel_Click(object sender, EventArgs e) { Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + xlfile); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); //设置输出流为简体中文 this.EnableViewState = false; Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">"); System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw); show(); Panel1.RenderControl(hw); Response.Write(sw.ToString()); Response.End(); }
protected void btnIn_Click(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=WeeklyReport.doc"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-word "; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Session["ctrl"] = Panel1; Panel1.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); }
protected void Button5_Click(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; string FileName = "Followup Show" + DateTime.Now + ".xls"; Response.AddHeader("content-disposition", "attachment;filename=" + FileName); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; using (StringWriter sw = new StringWriter()) { HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } }
protected void imgxl_Click(object sender, ImageClickEventArgs e) { strBrn = Request.QueryString["branch"]; lblbranch0.Text = "Branch:" + strBrn; strComp = Request.QueryString["Comp"]; lblbank0.Text = strComp; lblbank0.Visible = true; lblbranch0.Visible = true; lblrep0.Visible = true; lblrep0.Text = lblrep.Text; try { DataTable dtviewstate = new DataTable(); dtviewstate = (DataTable)(ViewState["datatable"]); gv.DataSource = dtviewstate; if (gv.DataSource == null) { ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('First Press SUBMIT and then press PRINT/DOWNLOAD option')</script>"); } if (gv.DataSource != null) { gv.DataBind(); gv.UseAccessibleHeader = true; gv.HeaderRow.TableSection = TableRowSection.TableHeader; Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=Transaction.xls"); Response.ContentType = "application/excel"; System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); Panel1.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); } } catch (Exception ex) { string m = ex.Message; // WriteLog(m); ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('First Press SUBMIT and then press PRINT/DOWNLOAD option')</script>"); } }
protected void Save_Click(object sender, EventArgs e) { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Tenant Agreement.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 60f, 60f, 50f, 60f); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
protected void imgxl_Click(object sender, ImageClickEventArgs e) { DataTable dtData = new DataTable(); try { dtData = (DataTable)(ViewState["Details"]); gvRptDisp.DataSource = dtData; if (gvRptDisp.DataSource == null) { ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('First Press SUBMIT and then press PRINT/DOWNLOAD option')</script>"); } if (gvRptDisp.DataSource != null) { objlog.WriteLog("DepositIntPayableReport.aspx:imgxl_Click(): binding gvPackage grid"); gvRptDisp.DataBind(); gvRptDisp.UseAccessibleHeader = true; gvRptDisp.HeaderRow.TableSection = TableRowSection.TableHeader; Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=Report.xls"); Response.ContentType = "application/excel"; System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); Panel1.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); } } catch (Exception ex) { string g = ex.Message; g = Regex.Replace(g, "[^a-zA-Z0-9_]+", " "); objlog.WriteLog("DepositIntPayableReport.aspx--->imgxl_Click() Event-->: " + ex.Message + ex); ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('" + g + "')</script>"); } finally { objlog.WriteLog("DepositIntPayableReport.aspx--->imgxl_Click() Event-->:Finally block"); } }
void pdfDownload() { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=DailyAttendanceSummary.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
private void ExportPdf() { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=OrderInvoice.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); //whole table/gridview in SW HtmlTextWriter hw = new HtmlTextWriter(sw); //attached with the StringBuilder Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); //parse html available inside the string pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
protected void Button2_Click(object sender, EventArgs e) { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Invoice.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10, 10, 0, 0); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
private void renderHTML() { //Get the rendered HTML try { StringBuilder SB = new StringBuilder(); StringWriter SW = new StringWriter(SB); HtmlTextWriter htmlTW = new HtmlTextWriter(SW); Panel1.RenderControl(htmlTW); string sHTML = SB.ToString(); string sURL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri.ToString(); ViewState["html"] = sHTML; ViewState["url"] = sURL; } catch (Exception ex) { // log error } }
private void renderHTML() { //Get the rendered HTML StringBuilder SB = new StringBuilder(); StringWriter SW = new StringWriter(SB); HtmlTextWriter htmlTW = new HtmlTextWriter(SW); //htmlTW = "<Form runat=server>" + htmlTW + "</Form>"; //Panel1.RenderControl(htmlTW); Panel1.RenderControl(htmlTW); string sHTML = SB.ToString(); //ltlHTMLOutput.Text = Server.HtmlEncode(dataGridHTML) string sURL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri.ToString(); ViewState["html"] = sHTML; ViewState["url"] = sURL; //Server.Transfer("chameleon-email.aspx",true); }
protected void Button3_Click(object sender, EventArgs e) { try { // ExportGridToExcel(); Response.Clear(); Response.Buffer = true; string FileName = "COMPETITORS SALE FIGURE " + DateTime.Now + ".xls"; Response.AddHeader("content-disposition", "attachment;filename=" + FileName); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; using (StringWriter sw = new StringWriter()) { HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); } } catch { } }
protected void butEmail_Click(object sender, System.EventArgs e) { DataSet ds = new DataSet(); ds = (DataSet)Session["mDS"]; //Get the rendered HTML StringBuilder SB = new StringBuilder(); StringWriter SW = new StringWriter(SB); HtmlTextWriter htmlTW = new HtmlTextWriter(SW); Panel1.RenderControl(htmlTW); string sHTML = SB.ToString(); //ltlHTMLOutput.Text = Server.HtmlEncode(dataGridHTML) string sURL = System.Web.HttpContext.Current.Request.Url.AbsoluteUri.ToString(); Context.Items.Add("html", sHTML); Context.Items.Add("url", sURL); Context.Items.Add("itemCode", ds.Tables[0].Rows[0]["itemCode"].ToString()); Server.Transfer("chameleon-email.aspx", true); }
protected void Button1_Click(object sender, EventArgs e) { Label1.Text = " ( " + DateTime.Now.ToString() + " )"; Response.ContentType = "application/pdf"; Response.AppendHeader("content-disposition", "attachement;filename=Results.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDocument = new Document(PageSize.A4, 10f, 10f, 10f, 10f); HTMLWorker htmlparser = new HTMLWorker(pdfDocument); PdfWriter.GetInstance(pdfDocument, Response.OutputStream); pdfDocument.Open(); htmlparser.Parse(sr); pdfDocument.Close(); Response.Write(pdfDocument); pdfDocument.Close(); Response.Write(pdfDocument); Response.End(); }
public void CreatePDFFactor() { LoadFactorData(); PdfDocument pdf = new PdfDocument(); PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat(); //webBrowser load html whether Waiting htmlLayoutFormat.IsWaiting = false; //page setting PdfPageSettings setting = new PdfPageSettings(); setting.Size = PdfPageSize.A4; //Get innerHtml of Panel Control var sb_htmlCode = new StringBuilder(); Panel1.RenderControl(new HtmlTextWriter(new StringWriter(sb_htmlCode))); string htmlCode = sb_htmlCode.ToString(); //use single thread to generate the pdf from above html code Thread thread = new Thread(() => { pdf.LoadFromHTML(htmlCode, false, setting, htmlLayoutFormat); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); // Save the file to PDF and preview it. string path = Server.MapPath("~/output.pdf"); pdf.SaveToFile(path); CopyAndRenameFile(); // System.Diagnostics.Process.Start(path); SendMail(); Panel1.Visible = false; }
protected void btnExcel_Click(object sender, EventArgs e) { if (txtFrom.Text == "" || txtTo.Text == "") { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请选择日期!');</script>"); return; } try { if (Convert.ToDateTime(txtFrom.Text) > Convert.ToDateTime(txtTo.Text)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('日期错误,请重新填写!');</script>"); return; } } catch (Exception) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('日期错误,请重新填写!');</script>"); return; } Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.Charset = "GB2312"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + xlfile); Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); //设置输出流为简体中文 this.EnableViewState = false; Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">"); System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw); show(); Panel1.RenderControl(hw); Response.Write(sw.ToString()); Response.End(); }
private void ExportGridToPDF() { string dt = System.DateTime.Now.ToString("MM/yyyy"); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=StaffSalaryReport" + dt + ".pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); iTextSharp.text.html.simpleparser.HTMLWorker htmlparser = new iTextSharp.text.html.simpleparser.HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); GridView1.AllowPaging = true; GridView1.DataBind(); }
protected void Button4_Click(object sender, EventArgs e) { if (Session["NCIPL_DONE"].ToString() == "true") { Response.Redirect("default.aspx"); } steps1.Activate("cell5"); Transaction t = new Transaction(this.shipto, this.billto, this.cc, this.shoppingcartV2); //Begin HITT 8329 (CR 21) Save The Raw Order ############################### //Save the Raw Order Details before credit card and before order upload call try { string Fax = ""; string Province = ""; //Only for International Exhibit Order string Country = ""; //Only for International Exhibit Order string interfacename = "ROO"; //"NCIPL"; //NCIPL, ROO or EXHIBIT string international = ""; //Pass "1" for International Order (Currently only for Exhibit) string Zip = t.ShipTo.Zip5; //Zip5 for NCIPL, ROO and Exhibit Domestic Orders. International Zip for Exhibit International Order. string rawpubids = ""; string rawpubqtys = ""; string[] rawpubs = Session["NCIPL_Pubs"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < rawpubs.Length; i++) { //if (pubs[i].Trim() != "") if (string.Compare(rawpubs[i].Trim(), "", true) != 0) { rawpubids += rawpubs[i].Trim() + ","; } } string[] rawqtys = Session["NCIPL_Qtys"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < rawqtys.Length; i++) { //if (qtys[i].Trim() != "") if (string.Compare(rawqtys[i].Trim(), "", true) != 0) { rawpubqtys += rawqtys[i].Trim() + ","; } } if (rawpubids.Length > 1) { rawpubids = rawpubids.TrimEnd(','); } if (rawpubqtys.Length > 1) { rawpubqtys = rawpubqtys.TrimEnd(','); } string CostRecoveryInd = ""; if (t.CC.Cost > 0) { CostRecoveryInd = "1"; } DAL.DAL.SaveRawOrder(t.ShipTo.Organization, t.ShipTo.Fullname, t.ShipTo.Addr1, t.ShipTo.Addr2, t.ShipTo.City, t.ShipTo.State, Zip, t.ShipTo.Zip4, t.ShipTo.Phone, Fax, t.ShipTo.Email, Province, Country, CostRecoveryInd, rawpubids, rawpubqtys, PubEnt.GlobalUtils.Utils.UserIPAddrress(), interfacename, international); } catch (Exception Ex) { //Write to log Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry(); logEnt.Message = "\r\n" + "Unable to invoke SaveRawOrder()." + "\r\n" + "Source: " + Ex.Source + "\r\n" + "Description: " + Ex.Message + "\r\n" + "Stack Trace: " + Ex.StackTrace; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs"); } //End HITT 8329(CR 21) ##################################################### //***EAC SOP---swipe first before creating order if (true) //EAC This used to be Swipe(cc) { int returnvalue = 0; int returnordernum = 0; string pubids = ""; string pubqtys = ""; string[] pubs = Session["NCIPL_Pubs"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < pubs.Length; i++) { //if (pubs[i].Trim() != "") if (string.Compare(pubs[i].Trim(), "", true) != 0) { pubids += pubs[i].Trim() + ","; } } string[] qtys = Session["NCIPL_Qtys"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < qtys.Length; i++) { //if (qtys[i].Trim() != "") if (string.Compare(qtys[i].Trim(), "", true) != 0) { pubqtys += qtys[i].Trim() + ","; } } if (pubids.Length > 1) { pubids = pubids.TrimEnd(','); } if (pubqtys.Length > 1) { pubqtys = pubqtys.TrimEnd(','); } //bool bSaveOrderFlag = false; //if (Session["SEARCHORDER_CUSTID"] != null) //{ //if (Session["SEARCHORDER_CUSTID"].ToString() != "") //{ //bSaveOrderFlag = t.Update(Request.UserHostAddress, Session["SEARCHORDER_CUSTID"].ToString(), pubids, pubqtys, out returnvalue, out returnordernum); //} //else //{ //bSaveOrderFlag = t.Save(Request.UserHostAddress, pubids, pubqtys, out returnvalue, out returnordernum); //} //} //else //{ //bSaveOrderFlag = t.Save(Request.UserHostAddress, pubids, pubqtys, out returnvalue, out returnordernum); //} if (t.Save(PubEnt.GlobalUtils.Utils.UserIPAddrress(), pubids, pubqtys, out returnvalue, out returnordernum)) { //JPJ TO DO: Display returnordernum on Screen. //***EAC Everything looks good at this point Session["NCIPL_DONE"] = "true"; lblAVS_Shipping.Visible = false; //NCIPLCC Label1.Text = "Confirmation"; //Label1.Visible = false; //NCIPLCC steps1.Visible = false; //HITT 8716 Label2.Text = ""; btn2Shipping.Visible = false; btn2Cart.Visible = false; btn2Cancel.Visible = false; btn2Submit.Visible = false; LinkButton1.Visible = false; pnlConfirm1.Visible = true; pnlConfirm2.Visible = true; pnlConfirm3.Visible = true; LblThank.Visible = true; lblorderdt.Text = System.DateTime.Today.ToShortDateString(); lblOrderNum.Text = returnordernum.ToString(); //***EAC The if-then section below is now obsolete 20130109 if (false && shipto.Email.Length > 0 && HasCover(this.shoppingcartV2))//if we have a valid shipto.email address { StringWriter sw = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(sw); string s; //pnlConfirm1.RenderControl(writer); Panel1.RenderControl(writer); pnlBillingInfo.RenderControl(writer); //pnlPaymentInfo.RenderControl(writer); grdItems.RenderControl(writer); ListNerdos.RenderControl(writer); s = sw.ToString(); PubEnt.DAL2.DAL.SaveEmail(shipto.Email, s); try { //SYSTEM.WEB.MAIL -- i know its becoming obsolete MailMessage msg = new MailMessage(); msg.From = ConfigurationManager.AppSettings["PubEntEmailAddress"]; msg.To = shipto.Email; msg.Subject = "Order Confirmation"; msg.Body = s; msg.BodyFormat = MailFormat.Html; SmtpMail.Send(msg); } catch (Exception) { } } //Code for HITT 8716 string printertext = ""; //Used like a flag, will not hold any value string printerShipping = "", printerBilling = "", printerPayment = ""; //Begin - NCIPLCC string printerSplitOrder = ""; if (shoppingcartV2.SplitOrder == "1") { StringWriter swSplitOrder = new StringWriter(); HtmlTextWriter writerSplitOrder = new HtmlTextWriter(swSplitOrder); pnlSplitOrder.RenderControl(writerSplitOrder); printerSplitOrder = swSplitOrder.ToString(); Session["NCIPLCC_PrinterSplitOrder"] = printerSplitOrder; } string printerdtandordnum = ""; StringWriter swDtandOrdnum = new StringWriter(); HtmlTextWriter writerDtandOrdnum = new HtmlTextWriter(swDtandOrdnum); pnlConfirm3.RenderControl(writerDtandOrdnum); printerdtandordnum = swDtandOrdnum.ToString(); swDtandOrdnum.Dispose(); writerDtandOrdnum.Dispose(); Session["NCIPLCC_PrinterOrderDtandOrderNum"] = printerdtandordnum; //End - NCIPLCC StringWriter swShipping = new StringWriter(); HtmlTextWriter writerShipping = new HtmlTextWriter(swShipping); Panel1.RenderControl(writerShipping); printerShipping = swShipping.ToString(); StringWriter swBilling = new StringWriter(); HtmlTextWriter writerBilling = new HtmlTextWriter(swBilling); pnlBillingInfo.RenderControl(writerBilling); printerBilling = swBilling.ToString(); //StringWriter swPayment = new StringWriter(); //HtmlTextWriter writerPayment = new HtmlTextWriter(swPayment); //pnlPaymentInfo.RenderControl(writerPayment); //printerPayment = swPayment.ToString(); Session["NCIPL_PrinterFriendly"] = printertext; Session["NCIPL_PrinterGrid"] = this.shoppingcartV2; Session["NCIPL_PrinterShipping"] = printerShipping; Session["NCIPL_PrinterBilling"] = printerBilling; Session["NCIPL_PrinterPayment"] = printerPayment; if (!shoppingcartV2.isFree2Order(shipto != null ? shipto.State : "")) { Session["NCIPL_PrinterCostRecovery"] = "True"; } else { Session["NCIPL_PrinterCostRecovery"] = "False"; } //End code ResetSessions(); } else { throw (new ApplicationException("Cannot save order.")); } } }
protected void btn2Submit_Click(object sender, EventArgs e) { if (Session["NCIPL_DONE"].ToString() == "true") { Response.Redirect("default.aspx"); } steps1.Activate("cell5"); Transaction t = new Transaction(this.shipto, this.billto, this.cc, this.shoppingcartV2); //***EAC SOP---swipe first before creating order if (true) //EAC This used to be Swipe(cc) { int returnvalue = 0; int returnordernum = 0; string pubids = ""; string pubqtys = ""; string[] pubs = Session["NCIPL_Pubs"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < pubs.Length; i++) { //if (pubs[i].Trim() != "") if (string.Compare(pubs[i].Trim(), "", true) != 0) { pubids += pubs[i].Trim() + ","; } } string[] qtys = Session["NCIPL_Qtys"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < qtys.Length; i++) { //if (qtys[i].Trim() != "") if (string.Compare(qtys[i].Trim(), "", true) != 0) { pubqtys += qtys[i].Trim() + ","; } } if (pubids.Length > 1) { pubids = pubids.TrimEnd(','); } if (pubqtys.Length > 1) { pubqtys = pubqtys.TrimEnd(','); } if (t.Save(PubEnt.GlobalUtils.Utils.UserIPAddrress(), pubids, pubqtys, out returnvalue, out returnordernum)) { //***EAC Everything looks good at this point Session["NCIPL_DONE"] = "true"; lblAVS_Shipping.Visible = false; //NCIPLCC Label1.Text = "Confirmation"; Label1.Visible = false; //NCIPLCC steps1.Visible = false; //HITT 8716 Label2.Text = ""; btn2Shipping.Visible = false; btn2Cart.Visible = false; btn2Cancel.Visible = false; btn2Submit.Visible = false; LinkButton1.Visible = false; pnlConfirm1.Visible = true; pnlConfirm2.Visible = true; pnlConfirm3.Visible = true; LblThank.Visible = true; lblorderdt.Text = System.DateTime.Today.ToShortDateString(); lblOrderNum.Text = returnordernum.ToString(); //***EAC The if-then section below is now obsolete 20130109 //if (false && shipto.Email.Length > 0 && HasCover(this.shoppingcartV2))//if we have a valid shipto.email address //{ // StringWriter sw = new StringWriter(); // HtmlTextWriter writer = new HtmlTextWriter(sw); // string s; // //pnlConfirm1.RenderControl(writer); // Panel1.RenderControl(writer); // pnlBillingInfo.RenderControl(writer); // //pnlPaymentInfo.RenderControl(writer); // grdItems.RenderControl(writer); // ListNerdos.RenderControl(writer); // s = sw.ToString(); // PubEnt.DAL2.DAL.SaveEmail(shipto.Email, s); // try // { //SYSTEM.WEB.MAIL -- i know its becoming obsolete // MailMessage msg = new MailMessage(); // msg.From = ConfigurationManager.AppSettings["PubEntEmailAddress"]; // msg.To = shipto.Email; // msg.Subject = "Order Confirmation"; // msg.Body = s; // msg.BodyFormat = MailFormat.Html; // SmtpMail.Send(msg); // } // catch (Exception) { } //} //Code for HITT 8716 string printertext = ""; //Used like a flag, will not hold any value string printerShipping = "", printerBilling = "", printerPayment = ""; //Begin - NCIPLCC string printerSplitOrder = ""; if (shoppingcartV2.SplitOrder == "1") { StringWriter swSplitOrder = new StringWriter(); HtmlTextWriter writerSplitOrder = new HtmlTextWriter(swSplitOrder); pnlSplitOrder.RenderControl(writerSplitOrder); printerSplitOrder = swSplitOrder.ToString(); Session["NCIPLCC_PrinterSplitOrder"] = printerSplitOrder; } string printerdtandordnum = ""; StringWriter swDtandOrdnum = new StringWriter(); HtmlTextWriter writerDtandOrdnum = new HtmlTextWriter(swDtandOrdnum); pnlConfirm3.RenderControl(writerDtandOrdnum); printerdtandordnum = swDtandOrdnum.ToString(); swDtandOrdnum.Dispose(); writerDtandOrdnum.Dispose(); Session["NCIPLCC_PrinterOrderDtandOrderNum"] = printerdtandordnum; //End - NCIPLCC StringWriter swShipping = new StringWriter(); HtmlTextWriter writerShipping = new HtmlTextWriter(swShipping); Panel1.RenderControl(writerShipping); printerShipping = swShipping.ToString(); StringWriter swBilling = new StringWriter(); HtmlTextWriter writerBilling = new HtmlTextWriter(swBilling); pnlBillingInfo.RenderControl(writerBilling); printerBilling = swBilling.ToString(); //StringWriter swPayment = new StringWriter(); //HtmlTextWriter writerPayment = new HtmlTextWriter(swPayment); //pnlPaymentInfo.RenderControl(writerPayment); //printerPayment = swPayment.ToString(); Session["NCIPL_PrinterFriendly"] = printertext; Session["NCIPL_PrinterGrid"] = this.shoppingcartV2; Session["NCIPL_PrinterShipping"] = printerShipping; Session["NCIPL_PrinterBilling"] = printerBilling; Session["NCIPL_PrinterPayment"] = printerPayment; if (!shoppingcartV2.isFree2Order(shipto != null ? shipto.State : "")) { Session["NCIPL_PrinterCostRecovery"] = "True"; } else { Session["NCIPL_PrinterCostRecovery"] = "False"; } //End code ResetSessions(); } else { throw (new ApplicationException("Cannot save order.")); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["total"] == null || Session["shipping"] == null || Session["naruceno"] == null || Session["CartTable"] == null) { Session.Clear(); Session.Abandon(); Response.Redirect("Cart.aspx"); } DateTime thisDay = DateTime.Today; myDatum.InnerText = thisDay.ToString("d"); SqlConnection con = new SqlConnection(conString); SqlCommand idCom = new SqlCommand("SELECT IDENT_CURRENT('Narudzbe') AS Current_Identity", con); con.Open(); SqlDataReader reader = idCom.ExecuteReader(); if (reader.Read()) { idNarudzba = int.Parse(reader["Current_Identity"].ToString()); } con.Close(); if (idNarudzba != 0) { Session["idNarudzba"] = idNarudzba; Narudzba.InnerText = "Broj narudžbe: " + idNarudzba; if (Session["Pouzece"] != null) { Label1.Text = "Plaćanje gotovinom prilikom dostave.\n Dostava unutar 3 dana."; Label2.Visible = false; Control div = FindControl("div"); div.Visible = false; } if (Session["Banka"] != null) { Label1.Text = "Direktna bankovna transakcija"; } if (Session["CartTable"] != null) { string logoPath = Server.MapPath("~/Images/icones/habibi_shop_pdf.png"); logo.Src = logoPath; HtmlGenericControl tbl = new HtmlGenericControl("table"); tbl.Attributes["class"] = "table table-bordered"; HtmlGenericControl tbody = new HtmlGenericControl("tbody"); tbl.Controls.Add(tbody); HtmlGenericControl tr = new HtmlGenericControl("tr"); tbody.Controls.Add(tr); HtmlGenericControl th = new HtmlGenericControl("td"); th.Style.Add("font-weight", "bold"); th.InnerText = "Proizvod"; tr.Controls.Add(th); HtmlGenericControl th2 = new HtmlGenericControl("td"); th2.Style.Add("font-weight", "bold"); th2.InnerText = "Ukupno"; tr.Controls.Add(th2); foreach (DataRow item in ((DataTable)Session["CartTable"]).Rows) { HtmlGenericControl tr2 = new HtmlGenericControl("tr"); tbody.Controls.Add(tr2); HtmlGenericControl td = new HtmlGenericControl("td"); td.InnerText = item.ItemArray[1].ToString() + " " + "x" + " " + item.ItemArray[6].ToString(); tr2.Controls.Add(td); HtmlGenericControl td2 = new HtmlGenericControl("td"); td2.InnerText = (float.Parse(item.ItemArray[3].ToString()) * float.Parse(item.ItemArray[6].ToString())).ToString() + "Kn"; tr2.Controls.Add(td2); } HtmlGenericControl tr3 = new HtmlGenericControl("tr"); tbody.Controls.Add(tr3); HtmlGenericControl th3 = new HtmlGenericControl("th"); th3.InnerText = "Ukupna cijena proizvoda"; tr3.Controls.Add(th3); HtmlGenericControl th4 = new HtmlGenericControl("th"); th4.InnerText = Session["total"].ToString(); tr3.Controls.Add(th4); HtmlGenericControl tr4 = new HtmlGenericControl("tr"); tbody.Controls.Add(tr4); HtmlGenericControl td3 = new HtmlGenericControl("td"); td3.InnerText = "Dostava"; tr4.Controls.Add(td3); HtmlGenericControl td4 = new HtmlGenericControl("td"); td4.InnerText = String.Format("{0:0.00}", ((float)Session["shipping"])) + "Kn"; tr4.Controls.Add(td4); HtmlGenericControl tr5 = new HtmlGenericControl("tr"); tbody.Controls.Add(tr5); HtmlGenericControl td5 = new HtmlGenericControl("td"); td5.InnerText = "Način plaćanja"; tr5.Controls.Add(td5); HtmlGenericControl td6 = new HtmlGenericControl("td"); td6.InnerText = Label1.Text; tr5.Controls.Add(td6); HtmlGenericControl tr6 = new HtmlGenericControl("tr"); tbody.Controls.Add(tr6); HtmlGenericControl th5 = new HtmlGenericControl("th"); th5.InnerText = "Ukupno"; th5.Style.Add("font-weight", "bold"); tr6.Controls.Add(th5); float sum = float.Parse(Session["total"].ToString()) + float.Parse(Session["shipping"].ToString()); HtmlGenericControl th6 = new HtmlGenericControl("th"); th6.InnerText = String.Format("{0:0.00}", sum) + "kn"; th6.Style.Add("font-weight", "bold"); tr6.Controls.Add(th6); myTable.Controls.Add(tbl); SqlCommand podaciCom = new SqlCommand("SELECT [Ime], [Prezime], [Adresa], [Grad], [Telefon] FROM Narudzbe WHERE [idNarudzba] = @myID", con); podaciCom.Parameters.AddWithValue("@myID", idNarudzba); con.Open(); SqlDataReader reader1 = podaciCom.ExecuteReader(); if (reader1.Read()) { naziv.InnerText = (string)reader1["Ime"] + " " + (string)reader1["Prezime"]; adresa.InnerText = (string)reader1["Adresa"] + ", " + (string)reader1["Grad"]; tel.InnerText = (string)reader1["Telefon"]; } con.Close(); } } else { Panel1.Controls.Clear(); HtmlGenericControl DivContainer = new HtmlGenericControl(); DivContainer.Attributes["class"] = "container"; DivContainer.TagName = "div"; HtmlGenericControl row = new HtmlGenericControl("div"); row.Attributes["class"] = "row"; HtmlGenericControl col = new HtmlGenericControl("div"); col.Attributes["class"] = "col-md-12 main-wrap"; HtmlGenericControl con1 = new HtmlGenericControl("div"); con1.Attributes["class"] = "main-content"; HtmlGenericControl commerce = new HtmlGenericControl("div"); commerce.Attributes["class"] = "commerce"; HtmlGenericControl para = new HtmlGenericControl("p"); para.Attributes["class"] = "cart-empty"; para.InnerText = "Došlo je do problema s vašem narudžbom, molimo ponovno naručite."; para.Style.Add("color", "#ea3a1a"); commerce.Controls.Add(para); con1.Controls.Add(commerce); col.Controls.Add(con1); row.Controls.Add(col); DivContainer.Controls.Add(row); Panel1.Controls.Add(DivContainer); } String path = Server.MapPath("~/Narudzbe/Narudzba" + idNarudzba + ".pdf"); StringWriter sw2 = new StringWriter(); HtmlTextWriter hw2 = new HtmlTextWriter(sw2); Panel1.RenderControl(hw2); byte[] bytes = RenderPDF(sw2.ToString()); FileStream fs = new FileStream(path, FileMode.Create); fs.Write(bytes, 0, bytes.Length); fs.Close(); SqlConnection con2 = new SqlConnection(conString); con2.Open(); SqlCommand email = new SqlCommand("SELECT [Email] FROM Narudzbe WHERE [idNarudzba] = @myID2", con2); email.Parameters.AddWithValue("@myID2", idNarudzba); string email2 = Convert.ToString(email.ExecuteScalar()); con2.Close(); // Specify the from and to email address MailMessage mailMessage = new MailMessage("*****@*****.**", email2); // Specify the email body String path1 = Server.MapPath("~/Images/icones/habibi_shop.png"); Attachment inlineLogo = new Attachment(path1); mailMessage.Attachments.Add(inlineLogo); string contentID = "Image"; inlineLogo.ContentId = contentID; mailMessage.Body = //"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" + //"<html xmlns='http://www.w3.org/1999/xhtml' xmlns: v = 'urn:schemas-microsoft-com:vml' xmlns: o = 'urn:schemas-microsoft-com:office:office'>" + // "<head>" ////"<style type='text/css'>#img1{display: block;}#img2{display:none}@media all and(max-width:499px){#img1{display:none;}#img2{display:block;}}</style>" //+ "<style type='text/css'>#visibledesktop{display: block;}#visiblephone{display:none;}@media(max-width:450px){#visibledesktop{display:none;}#visiblephone{display:block;}}</style>" //+ "</head>" //"<body>" //+ "<div id='visibledesktop'>" "<center><img id='img1' src=\"cid:" + contentID + "\" width=\"40%\" /></center>" //+ "<img id='img2' src=\"cid:" + contentID + "\" style=\"width: 100%; height: 50%;\" />" + "<hr style='border-top: 1px dashed #8c8b8b;'></hr>" + " <br/>" + "Poštovani, <br/>Vaša narudžba je zaprimljena <br/><br/>" + "<hr style='border-top: 1px dashed #8c8b8b;'></hr>" + " <br/>" + "<p style='font-size:16px!important;font-weight:bold;color:#333333;'>Broj narudžbe:" + idNarudzba + "<p style='font-size:16px!important;font-weight:bold;color:#333333;'>Datum: " + thisDay.ToString("d") + "<p style='font-size:16px!important;font-weight:bold;color:#333333;'>Dostava na Vašu adresu unutar 3 radna dana" + "<p style='font-size:16px!important;font-lightt:bold;color:#333333;'>Račun u prilogu maila," + " <br/><br/>" + "<span>Hvala na Vašoj kupnji :)</span></div>"; // + "<div id='visiblephone'>" ////+ "<center><img id='img1' src=\"cid:" + contentID + "\" style=\"width: 100%; height: 50%;\" /></center>" //+ "<img id='img2' src=\"cid:" + contentID + "\" width=\"100%\" />" //+ "<hr style='border-top: 1px dashed #8c8b8b;'></hr>" + " <br/>" //+ "Poštovani, <br/>Vaša narudžba je zaprimljena <br/><br/>" + //"<hr style='border-top: 1px dashed #8c8b8b;'></hr>" + " <br/>" + //"<p style='font-size:16px!important;font-weight:bold;color:#333333;'>Broj narudžbe:" + idNarudzba //+ "<p style='font-size:16px!important;font-weight:bold;color:#333333;'>Datum: " + thisDay.ToString("d") //+ "<p style='font-size:16px!important;font-weight:bold;color:#333333;'>Dostava na Vašu adresu unutar 3 radna dana" //+ "<p style='font-size:16px!important;font-lightt:bold;color:#333333;'>Račun u prilogu maila," + " <br/><br/>" //+ "<span>Hvala na Vašoj kupnji :)</span></div>" //+ "</body></html>"; mailMessage.IsBodyHtml = true; // Specify the email Subject mailMessage.Subject = "Narudžba " + idNarudzba; mailMessage.Attachments.Add(new Attachment(path)); mailMessage.To.Add("*****@*****.**"); // Specify the SMTP server name and post number SmtpClient smtpClient = new SmtpClient("mail.habibi-orient.com", 8889); // Specify your gmail address and password smtpClient.Credentials = new System.Net.NetworkCredential() { UserName = "******", Password = "******" }; // Gmail works on SSL, so set this property to true //smtpClient.EnableSsl = true; // Finall send the email message using Send() method smtpClient.Send(mailMessage); Response.Redirect("orderreceived.aspx", true); }
protected void btnExport_Click(object sender, EventArgs e) { try { if (ddlPonumber.SelectedIndex != 0) { string MainCategory = ClsPurchaseInvoice.Get_MainCategory_BasedOn_POID(Convert.ToInt64(ddlPonumber.SelectedValue.ToString())); if (MainCategory != "Support") { Panel1.Visible = true; value = Convert.ToInt32(ddlPonumber.SelectedValue.ToString()); if (value != -1) { DataTable dt = ClsReportPurchaseOrder.Report_PurchaseOrder(value); lbl_Ponumber.Text = dt.Rows[0]["PO Number"].ToString(); lbl_PoDate.Text = Convert.ToDateTime(dt.Rows[0]["PO Date"]).ToString("dd-MM-yyyy"); lbl_PO_RaisedTO.Text = dt.Rows[0]["PO_Raise_TO"].ToString(); lbl_Bill_Address.Text = dt.Rows[0]["BillingAddress"].ToString(); lbl_Ship_Address.Text = dt.Rows[0]["ShippingAddress"].ToString(); //lbl_Footer_Address1.Text = dt.Rows[0]["BillingAddress"].ToString(); lbl_Term4.Text = "4. Warranty :" + dt.Rows[0]["Warranty"].ToString(); lblBillGST.Text = dt.Rows[0]["GST"].ToString(); lblBillPAN.Text = dt.Rows[0]["PAN"].ToString(); lblSPA.Text = dt.Rows[0]["SPANumber"].ToString(); // lblShipGST.Text= dt.Rows[0]["GST"].ToString(); lblShipPAN.Text = dt.Rows[0]["PAN"].ToString(); DataTable DT1 = ClsPurchaseInvoice.Get_PurchaseOrderForInvoice(value); int CategoryID = 0; //foreach (DataRow row in DT1.Rows) //{ //for (int i = 0; i < DT1.Rows.Count - 1; i++) //{ // CategoryID = Convert.ToInt32(DT1.Rows[i]["catagoryid"].ToString()); //if (CategoryID == 33) //{ //GetSalesManager(); GetSalesManagerAMC1(); //lbl_Term3.Text = ""; //} //else //{ // GetSalesManager(); //} // } //if (CategoryID == 33) //{ //foreach (GridViewRow row in GridView1.Rows) //{ // foreach (TableCell cell in row.Cells) // { // row.Cells[0].Width = 10; // } //} Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=PO.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GridView1.HeaderRow.Style.Add("width", "10%"); GridView1.HeaderRow.Style.Add("font-size", "10px"); GridView1.Style.Add("font-size", "8px"); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 100f, 100f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfWriter.PageEvent = new Comman.ITextEvents(); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); // Response.End(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); Panel1.Visible = false; GetMasterList(); #region old code //} //else //{ // Response.ContentType = "application/pdf"; // Response.AddHeader("content-disposition", "attachment;filename=PO.pdf"); // Response.Cache.SetCacheability(HttpCacheability.NoCache); // StringWriter sw = new StringWriter(); // HtmlTextWriter hw = new HtmlTextWriter(sw); // GvwSaleseOrderDetails.HeaderRow.Style.Add("width", "10%"); // GvwSaleseOrderDetails.HeaderRow.Style.Add("font-size", "10px"); // GvwSaleseOrderDetails.Style.Add("font-size", "8px"); // Panel1.RenderControl(hw); // StringReader sr = new StringReader(sw.ToString()); // Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 20f, 20f); // HTMLWorker htmlparser = new HTMLWorker(pdfDoc); // PdfWriter.GetInstance(pdfDoc, Response.OutputStream); // pdfDoc.Open(); // htmlparser.Parse(sr); // pdfDoc.Close(); // Response.Write(pdfDoc); // // Response.End(); // HttpContext.Current.Response.Flush(); // HttpContext.Current.Response.SuppressContent = true; // HttpContext.Current.ApplicationInstance.CompleteRequest(); // Panel1.Visible = false; // GetMasterList(); //} #endregion } else { Panel1.Visible = false; ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select PO Number.');</script>", false); } } else { Panel2.Visible = true; value = Convert.ToInt32(ddlPonumber.SelectedValue.ToString()); if (value != -1) { DataTable dt = ClsReportPurchaseOrder.Report_PurchaseOrder(value); lbl_PonumberSupport.Text = dt.Rows[0]["PO Number"].ToString(); lbl_PoDateSupport.Text = Convert.ToDateTime(dt.Rows[0]["PO Date"]).ToString("dd-MM-yyyy"); lbl_PO_RaisedTO.Text = dt.Rows[0]["PO_Raise_TO"].ToString(); lbl_Bill_Address_Support.Text = dt.Rows[0]["BillingAddress"].ToString(); lbl_Ship_Address_Support.Text = dt.Rows[0]["ShippingAddress"].ToString(); lblSPA.Text = dt.Rows[0]["SPANumber"].ToString(); lblSupBilGST.Text = dt.Rows[0]["GST"].ToString(); lblSupBilPAN.Text = dt.Rows[0]["PAN"].ToString(); //lbl_Footer_Address1.Text = dt.Rows[0]["BillingAddress"].ToString(); DataTable DT1 = ClsPurchaseInvoice.Get_PurchaseOrderForInvoice(value); foreach (DataRow row in DT1.Rows) { int CategoryID = Convert.ToInt32(DT1.Rows[0]["catagoryid"].ToString()); if (CategoryID == 5 || CategoryID == 20 || CategoryID == 30 || CategoryID == 31 || CategoryID == 32 || CategoryID == 33 || CategoryID == 42) { //GetSalesManagerSupport(); GetSalesManagerAMC(); lbl_Term3.Text = ""; } else { GetSalesManagerSupport(); } } Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=PO.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GridView3.HeaderRow.Style.Add("width", "10%"); GridView3.HeaderRow.Style.Add("font-size", "10px"); GridView3.Style.Add("font-size", "8px"); Panel2.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 130f, 100f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfWriter.PageEvent = new Comman.ITextEvents(); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); // Response.End(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); Panel2.Visible = false; GetMasterList(); } else { Panel2.Visible = false; ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select PO Number.');</script>", false); } } } else { Panel1.Visible = false; ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select PO Number.');</script>", false); } } catch (Exception ex) { } //ddlPonumber.SelectedItem.Value = "-1"; }
protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["id"].ToString(); //string q = "Select * from tbl_order where emailid='" + Session["user"].ToString() + "'"; //cmd = new SqlCommand(q, con); //da = new SqlDataAdapter(cmd); //dt = new DataTable(); //da.Fill(dt); //gvReport.DataSource = dt; //gvReport.DataBind(); //lblDataTitle.Text = Session["user"].ToString(); string q = "Select id as ID,name as NAME,city as CITY,address as ADDRESS,emailid as EMAIL_ID,pincode as PINCODE,mnumber as MOBILE_NUMBER from tbl_order where id='" + id + "'"; cmd = new SqlCommand(q, con); da = new SqlDataAdapter(cmd); dt = new DataTable(); da.Fill(dt); gvReport.DataSource = dt; gvReport.DataBind(); string q1 = "Select id as ID,order_id as ORDER_NUMBER,product_name as NAME,product_price as PRICE,product_qty as QUANTITY from tbl_order_details where order_id='" + id + "'"; cmd = new SqlCommand(q1, con); da = new SqlDataAdapter(cmd); dt = new DataTable(); da.Fill(dt); gvReport1.DataSource = dt; gvReport1.DataBind(); int tot = 0; String q5 = "Select * from tbl_order_details where order_id='" + id + "'"; cmd = new SqlCommand(q5, con); con.Open(); cmd.ExecuteNonQuery(); dt = new DataTable(); da = new SqlDataAdapter(cmd); da.Fill(dt); foreach (DataRow dr in dt.Rows) { tot += Convert.ToInt32(dr["product_price"].ToString()) * Convert.ToInt32(dr["product_qty"].ToString()); } lblTotal.Text = tot.ToString(); con.Close(); lblDate.Text = DateTime.Now.ToString(); lblDataTitle.Text = "ORDER INVOICE"; //SqlDataReader dr; //cmd = new SqlCommand("select COUNT(*) as count from tbl_order; ", con); //con.Open(); //dr = cmd.ExecuteReader(); //if (dr.Read()) //{ // lblTotal.Text = " Total Order:" + dr["count"].ToString(); //} //con.Close(); //lblDate.Text = DateTime.Now.ToString(); //lblDataTitle.Text = "Total Order"; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Order.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
protected void lnkprintPDF_Click(object sender, EventArgs e) { PlantMaster _plant = _plantRepo.getplantByWeighingMachine(Session["PlantID"].ToString(), "com1"); //BaseFont bfR = iTextSharp.text.pdf.BaseFont.CreateFont(BaseFont.TIMES_ROMAN, iTextSharp.text.pdf.BaseFont.CP1257, iTextSharp.text.pdf.BaseFont.EMBEDDED); //PdfWriter writer = PdfWriter.GetInstance(document, fs); StyleSheet style1 = new StyleSheet(); style1.LoadTagStyle(HtmlTags.TABLE, HtmlTags.FONTSIZE, "8px"); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=DateWiseReports.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); hw.AddStyleAttribute("font-size", "8pt"); // rptList.DataBind(); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 20f, 20f); // pdfDoc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); string CompanyLogo = HttpContext.Current.Server.MapPath(".") + @"\images\companylogo\logo.jpg"; string header1 = HttpContext.Current.Server.MapPath(".") + @"\images\header1.png"; string header2 = HttpContext.Current.Server.MapPath(".") + @"\images\header2.png"; //imgLogo.ImageUrl = "/images/companylogo/" + company.CompanyLogo; //added on 24-10-2019 BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false); var boldTableFont = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.BOLD); var NORMALFont = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL); PdfPTable table1 = new PdfPTable(4); table1.WidthPercentage = 100; table1.SetWidths(new float[] { 0.10f, 0.13f, 0.15f, 0.20f }); //First Row PdfPCell cellheaderleft = new PdfPCell(); cellheaderleft.Border = 0; iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(header1); image.ScaleAbsolute(230f, 200f); image.Alignment = Element.HEADER; cellheaderleft.AddElement(image); table1.AddCell(cellheaderleft); cellheaderleft = new PdfPCell(); cellheaderleft.Border = 0; image.ScaleAbsolute(230f, 200f); image.Alignment = Element.HEADER; cellheaderleft.AddElement(image); table1.AddCell(cellheaderleft); cellheaderleft = new PdfPCell(); cellheaderleft.Border = 0; image.ScaleAbsolute(230f, 200f); image.Alignment = Element.HEADER; cellheaderleft.AddElement(image); table1.AddCell(cellheaderleft); PdfPCell cellheaderright = new PdfPCell(); cellheaderright.Border = 0; cellheaderright.Rowspan = 2; iTextSharp.text.Image image2 = iTextSharp.text.Image.GetInstance(header2); image2.ScaleAbsolute(190f, 500f); image2.Alignment = Element.HEADER; cellheaderright.AddElement(image2); table1.AddCell(cellheaderright); //2nd Row cellheaderleft = new PdfPCell(); cellheaderleft.Border = 0; iTextSharp.text.Image logoImage = iTextSharp.text.Image.GetInstance(CompanyLogo); image.ScaleAbsolute(250f, 200f); image.Alignment = Element.HEADER; cellheaderleft.AddElement(logoImage); table1.AddCell(cellheaderleft); cellheaderleft = new PdfPCell(); cellheaderleft.Border = 0; table1.AddCell(cellheaderleft); string PlantCodeAddress = _plant.PlantName + "\n" + _plant.PlantAddress1 + "\n" + _plant.PlantAddress2; var p = new Paragraph(PlantCodeAddress, boldTableFont); cellheaderleft = new PdfPCell(); cellheaderleft.Border = 0; cellheaderleft.HorizontalAlignment = Element.ALIGN_CENTER; cellheaderleft.AddElement(p); table1.AddCell(cellheaderleft); PdfPCell Reportname = new PdfPCell(new Phrase("Date wise Report", boldTableFont)); Reportname.HorizontalAlignment = Element.ALIGN_LEFT; Reportname.Padding = 5; Reportname.Colspan = 2; table1.AddCell(Reportname); PdfPCell tripdatetime = new PdfPCell(new Phrase("Print Date/Time :", boldTableFont)); tripdatetime.HorizontalAlignment = Element.ALIGN_RIGHT; table1.AddCell(tripdatetime); PdfPCell tripdatetimeValue = new PdfPCell(new Phrase(DateTime.Now.ToString(), NORMALFont)); tripdatetimeValue.HorizontalAlignment = Element.ALIGN_LEFT; table1.AddCell(tripdatetimeValue); pdfDoc.Add(table1); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); }
protected void Button4_Click(object sender, EventArgs e) { if (Session["NCIPLEX_DONE"].ToString() == "true") { Response.Redirect("location.aspx"); } steps1.Activate("cell5"); //NCIPLex Transaction t = new Transaction(this.shipto, this.billto, this.cc, this.shoppingcart ); Transaction t = new Transaction(this.shipto, this.billto, this.cc, this.shoppingcart); //Begin HITT 8329 (CR 21) Save The Raw Order ############################### //Save the Raw Order Details before credit card and before order upload call try { string Fax = ""; string Province = ""; //Only for International Exhibit Order string Country = ""; //Only for International Exhibit Order //string interfacename = "NCIPLex"; //NCIPL, ROO or EXHIBIT string interfacename = ConfigurationManager.AppSettings["InterfaceName"]; string international = ""; //Pass "1" for International Order (Currently only for Exhibit) string Zip = t.ShipTo.Zip5; //Zip5 for NCIPL, ROO and Exhibit Domestic Orders. International Zip for Exhibit International Order. if (string.Compare(ShipLocation, "International", true) == 0) { international = "1"; Province = t.ShipTo.State; Country = t.ShipTo.Country; } string rawpubids = ""; string rawpubqtys = ""; string[] rawpubs = Session["NCIPLEX_Pubs"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < rawpubs.Length; i++) { //if (pubs[i].Trim() != "") if (string.Compare(rawpubs[i].Trim(), "", true) != 0) { rawpubids += rawpubs[i].Trim() + ","; } } string[] rawqtys = Session["NCIPLEX_Qtys"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < rawqtys.Length; i++) { //if (qtys[i].Trim() != "") if (string.Compare(rawqtys[i].Trim(), "", true) != 0) { rawpubqtys += rawqtys[i].Trim() + ","; } } if (rawpubids.Length > 1) { rawpubids = rawpubids.TrimEnd(','); } if (rawpubqtys.Length > 1) { rawpubqtys = rawpubqtys.TrimEnd(','); } string CostRecoveryInd = ""; //JPJ 03-10-11 NCIPLex does not accept credit card orders //if (t.CC.Cost > 0) // CostRecoveryInd = "1"; SQLDataAccess.SaveRawOrder(t.ShipTo.Organization, t.ShipTo.Fullname, t.ShipTo.Addr1, t.ShipTo.Addr2, t.ShipTo.City, t.ShipTo.State, Zip, t.ShipTo.Zip4, t.ShipTo.Phone, Fax, t.ShipTo.Email, Province, Country, CostRecoveryInd, rawpubids, rawpubqtys, Request.UserHostAddress, interfacename, international); } catch (Exception Ex) { //Write to log Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry logEnt = new Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry(); logEnt.Message = "\r\n" + "Unable to invoke SaveRawOrder()." + "\r\n" + "Source: " + Ex.Source + "\r\n" + "Description: " + Ex.Message + "\r\n" + "Stack Trace: " + Ex.StackTrace; Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(logEnt, "Logs"); } //End HITT 8329(CR 21) ##################################################### //***EAC SOP---swipe first before creating order //if (Swipe(this.cc)) //Should return true for a free transaction -COMMENTED FOR NCIPLex //{ int returnvalue = 0; int returnordernum = 0; string pubids = ""; string pubqtys = ""; string[] pubs = Session["NCIPLEX_Pubs"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < pubs.Length; i++) { //if (pubs[i].Trim() != "") if (string.Compare(pubs[i].Trim(), "", true) != 0) { pubids += pubs[i].Trim() + ","; } } string[] qtys = Session["NCIPLEX_Qtys"].ToString().Split(new Char[] { ',' }); for (var i = 0; i < qtys.Length; i++) { //if (qtys[i].Trim() != "") if (string.Compare(qtys[i].Trim(), "", true) != 0) { pubqtys += qtys[i].Trim() + ","; } } if (pubids.Length > 1) { pubids = pubids.TrimEnd(','); } if (pubqtys.Length > 1) { pubqtys = pubqtys.TrimEnd(','); } if (t.Save(Request.UserHostAddress, pubids, pubqtys, ConfId, ShipLocation, out returnvalue, out returnordernum)) { //***EAC Everything looks good at this point Session["NCIPLEX_DONE"] = "true"; lblAVS_Shipping.Visible = false; Label1.Text = "Confirmation"; steps1.Visible = false; //HITT 8716 Label2.Text = ""; btn2Shipping.Visible = false; btn2Cart.Visible = false; btn2Cancel.Visible = false; btn2Submit.Visible = false; LinkButton1.Visible = false; pnlConfirm1.Visible = true; pnlConfirm2.Visible = true; LblThank.Visible = true; lblorderdt.Text = System.DateTime.Today.ToShortDateString(); //NCIPLex does not allow Nerdo publications to be ordered - COMMENT below eamil section //if (shipto.Email.Length > 0 && HasCover(this.shoppingcart))//if we have a valid shipto.email address //{ // StringWriter sw = new StringWriter(); // HtmlTextWriter writer = new HtmlTextWriter(sw); // string s; // //pnlConfirm1.RenderControl(writer); // Panel1.RenderControl(writer); // pnlBillingInfo.RenderControl(writer); // pnlPaymentInfo.RenderControl(writer); // grdItems.RenderControl(writer); // ListNerdos.RenderControl(writer); // s = sw.ToString(); // NCIPLex.DAL2.DAL.SaveEmail(shipto.Email, s); // try // { //SYSTEM.WEB.MAIL -- i know its becoming obsolete // MailMessage msg = new MailMessage(); // msg.From = ConfigurationManager.AppSettings["PubEntEmailAddress"]; // msg.To = shipto.Email; // msg.Subject = "Order Confirmation"; // msg.Body = s; // msg.BodyFormat = MailFormat.Html; // SmtpMail.Send(msg); // } // catch (Exception) { } //} //Code for HITT 8716 string printertext = ""; //Used like a flag, will not hold any value string printerShipping = "", printerBilling = "", printerPayment = ""; StringWriter swShipping = new StringWriter(); HtmlTextWriter writerShipping = new HtmlTextWriter(swShipping); Panel1.RenderControl(writerShipping); printerShipping = swShipping.ToString(); StringWriter swBilling = new StringWriter(); HtmlTextWriter writerBilling = new HtmlTextWriter(swBilling); pnlBillingInfo.RenderControl(writerBilling); printerBilling = swBilling.ToString(); StringWriter swPayment = new StringWriter(); HtmlTextWriter writerPayment = new HtmlTextWriter(swPayment); pnlPaymentInfo.RenderControl(writerPayment); printerPayment = swPayment.ToString(); Session["NCIPLEX_PrinterFriendly"] = printertext; Session["NCIPLEX_PrinterGrid"] = this.shoppingcartV2; Session["NCIPLEX_PrinterShipping"] = printerShipping; Session["NCIPLEX_PrinterBilling"] = printerBilling; Session["NCIPLEX_PrinterPayment"] = printerPayment; // if (this.cc.Cost > 0) // Session["NCIPLEX_PrinterCostRecovery"] = "True"; // else Session["NCIPLEX_PrinterCostRecovery"] = "False"; //End code ResetSessions(); Response.Redirect("confirm_order.aspx", true); //JPJ 032211 - Newly added confirmation page } else { throw (new ApplicationException("Cannot save order.")); } //} //else{ // //throw (new ApplicationException("Problem with credit card transaction")); // Response.Redirect("ccproblem.aspx", true); //} }
//private void LoadTax() //{ // DataTable DtTaxDetails = new DataTable(); // try // { // DtTaxDetails = ClsMaster.Get_SalesTaxdetails(value); // TableRow objTableRow = new TableRow(); // TableCell objTableCell = new TableCell(); // if(DtTaxDetails.Rows.Count>0) // { // //Code TO Add Datas in Table // for (int iRow = 0; iRow < DtTaxDetails.Rows.Count; iRow++) // { // objTableRow = new TableRow(); // for (int iColumn = 0; iColumn < DtTaxDetails.Columns.Count; iColumn++) // { // objTableCell = new TableCell(); // objTableCell.Text = DtTaxDetails.Rows[iRow][iColumn].ToString(); // // objTableCell.Width = Unit.Pixel(120); // objTableCell.Wrap = false; // objTableCell.HorizontalAlign = HorizontalAlign.Right; // objTableRow.Cells.Add(objTableCell); // } // BooksTable.Rows.Add(objTableRow); // } // } // //Code to Create HtmlPage for the Report // StringWriter sw = new StringWriter(); // HtmlTextWriter htw = new HtmlTextWriter(sw); // StringBuilder strData = new StringBuilder(string.Empty); // StringBuilder strFunction = new StringBuilder(string.Empty); // string strHTMLpath = HttpContext.Current.Server.MapPath("HtmlFile/PrintPage.htm"); // BooksTable.RenderControl(htw); // StreamWriter strWriter = new StreamWriter(strHTMLpath, false, Encoding.Default); // strData.Append("<html><body>"); // strData.Append(htw.InnerWriter.ToString()); // strData.Append("</body></html>"); // strWriter.Write(strData.ToString()); // strWriter.Close(); // strWriter.Dispose(); // } // catch (Exception ex) // { // } //} protected void btnExport_Click(object sender, EventArgs e) { Panel1.Visible = true; TabScanner.Visible = false; TabService.Visible = false; TabSupport.Visible = false; value = Convert.ToInt32(ddlSONumber.SelectedValue.ToString()); if (value != 0) { DataTable dt = ClsMaster.Get_SalesSummary(value); if (dt.Rows[0]["M_ShortName"].ToString() == "SCN" || dt.Rows[0]["M_ShortName"].ToString() == "CON" || dt.Rows[0]["M_ShortName"].ToString() == "SOF" || dt.Rows[0]["M_ShortName"].ToString() == "RN") { TabScanner.Visible = true; lblInvoiceNo.Text = dt.Rows[0]["Invoice_Number"].ToString(); lblCustomerNo.Text = dt.Rows[0]["CusutomerOrderNO"].ToString(); lblInvoiceDate.Text = dt.Rows[0]["InvocieDate"].ToString(); lblCustomerdate.Text = dt.Rows[0]["CusutomerOrderdate"].ToString(); lblDCno.Text = dt.Rows[0]["DC_no"].ToString(); lblDCDate.Text = dt.Rows[0]["DC_Date"].ToString(); lblCreditPrediod.Text = dt.Rows[0]["CreditPeriod"].ToString(); lblWarranty.Text = dt.Rows[0]["Warranty"].ToString(); lblCustVAT.Text = dt.Rows[0]["VATCST"].ToString(); lblCustPan.Text = dt.Rows[0]["PAN"].ToString(); lblCustSerTax.Text = dt.Rows[0]["ServiceTaxNumber"].ToString(); } else if (dt.Rows[0]["M_ShortName"].ToString() == "SER") { TabService.Visible = true; lblSerInvoiceNo.Text = dt.Rows[0]["Invoice_Number"].ToString(); lblSerCustomerNo.Text = dt.Rows[0]["CusutomerOrderNO"].ToString(); lblSerInvoiceDate.Text = dt.Rows[0]["InvocieDate"].ToString(); lblSerContractDate.Text = dt.Rows[0]["CusutomerOrderdate"].ToString(); lblSerCreditPeriod.Text = dt.Rows[0]["CreditPeriod"].ToString(); lblSerCustVAT.Text = dt.Rows[0]["VATCST"].ToString(); lblSerCustPAN.Text = dt.Rows[0]["PAN"].ToString(); lblSerCustSerTax.Text = dt.Rows[0]["ServiceTaxNumber"].ToString(); } else if (dt.Rows[0]["M_ShortName"].ToString() == "SUP") { TabSupport.Visible = true; lblSupInvocieNO.Text = dt.Rows[0]["Invoice_Number"].ToString(); lblSupCustomerNo.Text = dt.Rows[0]["CusutomerOrderNO"].ToString(); lblSupInvoicedate.Text = dt.Rows[0]["InvocieDate"].ToString(); lblSupContractDate.Text = dt.Rows[0]["CusutomerOrderdate"].ToString(); lblSupCreditPeriod.Text = dt.Rows[0]["CreditPeriod"].ToString(); lblSupWarranty.Text = dt.Rows[0]["Warranty"].ToString(); lblSupVAT.Text = dt.Rows[0]["VATCST"].ToString(); lblSupPAN.Text = dt.Rows[0]["PAN"].ToString(); lblSupSerTax.Text = dt.Rows[0]["ServiceTaxNumber"].ToString(); } lbl_Ship_Address.Text = dt.Rows[0]["ShippingAddress"].ToString(); lbl_Bill_Address.Text = dt.Rows[0]["BillingAddress"].ToString(); LoadGridDetails(); // LoadTax(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=SalesTaxInvoice.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); // GvwSaleseOrderDetails.HeaderRow.Style.Add("width", "10%"); GvwSaleseOrderDetails.HeaderRow.Style.Add("font-size", "10px"); GvwSaleseOrderDetails.Style.Add("font-size", "8px"); //for (int i = 0; i <= GvwSaleseOrderDetails.Rows.Count - 1; i++) //{ // if (GvwSaleseOrderDetails.Rows[i].Cells[0].Text == "") // { // GvwSaleseOrderDetails.Rows[i].BackColor = System.Drawing.Color.DarkRed; // } //} Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 20f, 20f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); // Response.End(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); Panel1.Visible = false; LoadSoNumber(); } else { Panel1.Visible = false; ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select SO Number.');</script>", false); } //ddlPonumber.SelectedItem.Value = "-1"; }
protected void btnExport_GST_Click(object sender, EventArgs e) { try { if (Convert.ToInt32(ddlGSTnumber.SelectedValue.ToString()) != 0) { Panel1.Visible = true; DataTable dt = objGST.Get_GST_DCDetailsonID(Convert.ToInt32(ddlGSTnumber.SelectedValue)); if (dt.Rows.Count > 0) { LblSRDCNum.Text = dt.Rows[0]["Serial No. of delivery challan"].ToString(); LblTrans.Text = dt.Rows[0]["Mode of Transport"].ToString(); LblGST.Text = dt.Rows[0]["GSTIN"].ToString(); LblVehical.Text = dt.Rows[0]["Vehicle No"].ToString(); Lblsupply.Text = dt.Rows[0]["Place of Supply"].ToString(); LblDate.Text = dt.Rows[0]["DC_Date"].ToString(); LblName.Text = dt.Rows[0]["Name"].ToString(); LblAddress.Text = dt.Rows[0]["Address"].ToString(); LblState.Text = dt.Rows[0]["State"].ToString(); Lbl_Place_Suply.Text = dt.Rows[0]["Place of Supply"].ToString(); LblGst_Uniq.Text = dt.Rows[0]["GSTIN/Unique ID"].ToString(); DataTable DT1 = objGST.Get_GST_DC_Product_DetailsonID(Convert.ToInt32(ddlGSTnumber.SelectedValue)); if (DT1.Rows.Count > 0) { GridView1.DataSource = DT1; GridView1.DataBind(); } DataTable dt2 = objGST.Get_GST_DC_TotAmt_onID(Convert.ToInt32(ddlGSTnumber.SelectedValue)); if (dt2.Rows.Count > 0) { LblAmountBeforeTax.Text = dt2.Rows[0]["Total Amount before Tax"].ToString(); LblAmountAfterTax.Text = dt2.Rows[0]["Total Amount after Tax"].ToString(); } DataTable dt3 = objGST.Get_GST_DC_Tax_onID(Convert.ToInt32(ddlGSTnumber.SelectedValue)); if (dt3.Rows.Count > 0) { for (int i = 0; i < dt3.Rows.Count; i++) { if (dt3.Rows[i]["Taxname"].ToString() == "Add: CGST" || dt3.Rows[i]["Taxname"].ToString() == "Add: IGST") { trcgstigst.Visible = true; lblAddCGST.Text = dt3.Rows[i]["TAX"].ToString(); lblCGSTIGST.Text = dt3.Rows[i]["Taxname"].ToString(); } else if (dt3.Rows[i]["Taxname"].ToString() == "Add: SGST") { trsgst.Visible = true; LblAddSGST.Text = dt3.Rows[i]["TAX"].ToString(); lblSGST.Text = dt3.Rows[i]["Taxname"].ToString(); } else if (dt3.Rows[i]["Taxname"].ToString() == "Add: Exempted Tax @ NIL") { trnull.Visible = true; LblAddExumpted.Text = dt3.Rows[i]["TAX"].ToString(); lblExumpted.Text = dt3.Rows[i]["Taxname"].ToString(); } } } //int CategoryID = 0; //Get_GST_DC_MasterList(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=GST_DC_Form.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); GridView1.HeaderRow.Style.Add("width", "10%"); GridView1.HeaderRow.Style.Add("font-size", "10px"); GridView1.Style.Add("font-size", "8px"); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 120f, 100f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfWriter.PageEvent = new Comman.ITextGSTEvent(); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); Panel1.Visible = false; //Get_GST_DC_MasterList(); } } else { Panel1.Visible = false; ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select GST DC Number.');</script>", false); } } catch (Exception ex) { } }
protected void pdfBtn_Click(object sender, EventArgs e) { try { var lbl = string.Format("IndividualTestReport_{0}_{1}", candidateId.Text, batchName.Text); //Response.Clear(); //Response.ContentType = "application/pdf"; //Response.AddHeader("content-disposition", "attachment;filename="+lbl+".pdf"); //Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.Buffer = true; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); //GlobalConfig gc = new GlobalConfig(); //gc.SetPaperSize(PaperKind.A4); //gc.SetPaperOrientation(true); //byte[] pdfBuf = new SynchronizedPechkin(gc).Convert(sr.ReadToEnd()); //MemoryStream ms = new MemoryStream(pdfBuf); //ms.WriteTo(Response.OutputStream); //Response.End(); string pdf_page_size = "A4"; PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), pdf_page_size, true); string pdf_orientation = "Landscape"; PdfPageOrientation pdfOrientation = (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation), pdf_orientation, true); //int webPageWidth = 1024; //try //{ // webPageWidth = Convert.ToInt32(TxtWidth.Text); //} //catch { } //int webPageHeight = 0; //try //{ // webPageHeight = Convert.ToInt32(TxtHeight.Text); //} //catch { } // instantiate a html to pdf converter object HtmlToPdf converter = new HtmlToPdf(); // set css media type converter.Options.CssMediaType = (HtmlToPdfCssMediaType)Enum.Parse(typeof(HtmlToPdfCssMediaType), "Screen", true); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; //converter.Options.WebPageWidth = webPageWidth; //converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(sr.ReadToEnd()); // save pdf document doc.Save(Response, false, lbl + ".pdf"); // close pdf document doc.Close(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { WSProfile filter = new WSProfile(System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0], Path.GetFileName(Request.Url.AbsolutePath) + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name, ApplicationType.WebApplication); filter.LogError(ex); } }
protected void btnExport_Click(object sender, EventArgs e) { Panel1.Visible = true; tblIGST.Visible = false; value = Convert.ToInt32(ddlSONumber.SelectedValue.ToString()); if (value != 0) { DataTable Dt = BusinessServices.GetSOInvoicedataForPdf(Convert.ToInt32(ddlSONumber.SelectedValue)); lblInvoiceNo.Text = Dt.Rows[0]["Invoice_Number"].ToString(); lblCustPoNum.Text = Dt.Rows[0]["SO_CusutomerOrderNO"].ToString(); lblInvoiceDate.Text = Dt.Rows[0]["Invocie_Date"].ToString(); lblCustPOdate.Text = Dt.Rows[0]["SO_CusutomerOrderdate"].ToString(); lblReverseCharge.Text = Dt.Rows[0]["ReverseCharge"].ToString(); lblTransportMode.Text = Dt.Rows[0]["TransportMode"].ToString(); lblGSTIN.Text = Dt.Rows[0]["GSTIN"].ToString(); lblDCNum.Text = Dt.Rows[0]["DC_no"].ToString(); lblSate.Text = Dt.Rows[0]["State_Name"].ToString(); lblStatecode.Text = Dt.Rows[0]["StateCode"].ToString(); lblDateofSupply.Text = Dt.Rows[0]["DC_Date"].ToString(); lblPaymentterm.Text = Dt.Rows[0]["PaymentTerm"].ToString(); lblPlaceofSupply.Text = Dt.Rows[0]["SupplyStateName"].ToString(); lblSupplyCode.Text = Dt.Rows[0]["SupplyStateCode"].ToString(); lblWarrenty.Text = Dt.Rows[0]["Warranty"].ToString(); lblNatureofSupply.Text = Dt.Rows[0]["NatureofSupply"].ToString(); if (Dt.Rows[0]["SO_Main_CategoryID"].ToString() == "3" || Dt.Rows[0]["SO_Main_CategoryID"].ToString() == "4") { lblHNatureofSupply.Text = "Nature of Service :"; } else { lblHNatureofSupply.Text = "Nature of Supply :"; } LblBilName.Text = Dt.Rows[0]["CustomerName"].ToString(); lbl_Bill_Address.Text = Dt.Rows[0]["SO_Billing_TO"].ToString(); lblBilGSTIN.Text = Dt.Rows[0]["SupGSTIN"].ToString(); lblBilState.Text = " " + Dt.Rows[0]["SupplyStateName"].ToString(); lblBilStateCode.Text = Dt.Rows[0]["SupplyStateCode"].ToString(); lblShipName.Text = Dt.Rows[0]["CustomerName"].ToString(); lbl_Ship_Address.Text = Dt.Rows[0]["SO_Shipping_TO"].ToString(); // lblShipGSTIN.Text = ""; // lblShipState.Text = Dt.Rows[0]["SupplyStateName"].ToString(); // lblShipStateCode.Text = Dt.Rows[0]["SupplyStateCode"].ToString(); string SalesType = Dt.Rows[0]["SalesType"].ToString(); Session["LocationName"] = Dt.Rows[0]["Location_Name"].ToString(); if (SalesType == "CGST-SGST-INTRA STATE") { LoadGridDetails(); TblCgst.Visible = true; tblIGST.Visible = false; // LoadTax(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=SalesTaxInvoice.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); // GvwSaleseOrderDetails.HeaderRow.Style.Add("width", "10%"); GvSalesInvcDet.HeaderRow.Style.Add("font-size", "8px"); GvSalesInvcDet.Style.Add("font-size", "8px"); //for (int i = 0; i <= GvSalesInvcDet.Rows.Count - 1; i++) //{ // GvSalesInvcDet.Rows[i].Cells[1].Style.Add("Width", "1000px"); // //if (GvwSaleseOrderDetails.Rows[i].Cells[0].Text == "") // //{ // // GvwSaleseOrderDetails.Rows[i].BackColor = System.Drawing.Color.DarkRed; // //} //} Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 120f, 130f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfWriter.PageEvent = new Comman.ITextSoEvent(); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); // Response.End(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); Panel1.Visible = false; } else if (SalesType == "IGST-INTER STATE") { LoadGridIGSTDetails(); TblCgst.Visible = false; tblIGST.Visible = true; Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=SalesTaxInvoice.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); // GvwSaleseOrderDetails.HeaderRow.Style.Add("width", "10%"); GVSalesInvcDetIGST.HeaderRow.Style.Add("font-size", "8px"); GVSalesInvcDetIGST.Style.Add("font-size", "8px"); //for (int i = 0; i <= GvSalesInvcDet.Rows.Count - 1; i++) //{ // GvSalesInvcDet.Rows[i].Cells[1].Style.Add("Width", "1000px"); // //if (GvwSaleseOrderDetails.Rows[i].Cells[0].Text == "") // //{ // // GvwSaleseOrderDetails.Rows[i].BackColor = System.Drawing.Color.DarkRed; // //} //} Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 20f, 20f, 120f, 130f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfWriter.PageEvent = new Comman.ITextSoEvent(); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); // Response.End(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); Panel1.Visible = false; } LoadSoNumber(); } else { Panel1.Visible = false; ScriptManager.RegisterStartupScript(this, typeof(Page), "Alert", "<script>alert('Please Select SO Number.');</script>", false); } }
protected void Button1_Click(object sender, EventArgs e) { DateTime vencimento = new DateTime(2007, 9, 10); Instrucao_Itau item1 = new Instrucao_Itau(9, 5); Instrucao_Itau item2 = new Instrucao_Itau(81, 10); Cedente c = new Cedente("00.000.000/0000-00", "Empresa de Atacado", "0542", "13000"); //Na carteira 198 o código do Cedente é a conta bancária c.Codigo = 13000; Boleto b = new Boleto(vencimento, 1642, "198", "92082835", c); b.NumeroDocumento = "1008073"; b.Sacado = new Sacado("000.000.000-00", "Fulano de Silva"); b.Sacado.Endereco.End = "SSS 154 Bloco J Casa 23"; b.Sacado.Endereco.Bairro = "Testando"; b.Sacado.Endereco.Cidade = "Testelândia"; b.Sacado.Endereco.CEP = "70000000"; b.Sacado.Endereco.UF = "DF"; item2.Descricao += " " + item2.QuantidadeDias.ToString() + " dias corridos do vencimento."; b.Instrucoes.Add(item1); b.Instrucoes.Add(item2); MailMessage mail = new MailMessage(); mail.To.Add(new MailAddress(TextBox1.Text)); mail.Subject = "Teste de envio de Boleto Bancário"; mail.IsBodyHtml = true; mail.Priority = MailPriority.High; BoletoBancario itau = new BoletoBancario(); itau.CodigoBanco = 341; itau.Boleto = b; if (RadioButton1.Checked) { mail.Subject += " - On-Line"; Panel1.Controls.Add(itau); System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter htmlTW = new HtmlTextWriter(sw); Panel1.RenderControl(htmlTW); string html = sw.ToString(); // mail.Body = html; } else { mail.Subject += " - Off-Line"; mail.AlternateViews.Add(itau.HtmlBoletoParaEnvioEmail()); } //string html1 = ""; //using (StreamReader sr = new StreamReader(mail.AlternateViews[0].ContentStream)) //{ // html1 = sr.ReadToEnd(); // sr.Close(); // sr.Dispose(); //} //Response.Write(html1); SmtpClient objSmtpClient = new SmtpClient(); objSmtpClient.Send(mail); Label1.Text = "Boleto enviado para o email: " + TextBox1.Text; }