protected void Page_Load(object sender, EventArgs e) { // Set page cache to NO HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetNoServerCaching(); HttpContext.Current.Response.Cache.SetNoStore(); if (Session["UserID"] == null) { Response.Redirect("Login.aspx"); } decimal client_alias = Convert.ToDecimal(Session["UserID"].ToString().Trim().Substring(0, 4)); DataTable dtTable = new DataTable(); dtTable = VPCRMSBAL.GetCompanyName(client_alias); if (dtTable.Rows.Count > 0) { lblCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); } else { lblCompanyName.Text = "Default Name"; } }
protected void Page_Load(object sender, EventArgs e) { // Set page cache to NO //Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); //Response.Cache.SetNoStore(); //Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //Response.AddHeader("Pragma", "no-cache"); //Response.AddHeader("Expires", "0"); if (Session["UserID"] == null) { Response.Redirect("Login.aspx"); } dtCount = VPCRMSBAL.GetStatusCount(Convert.ToDecimal(Session["UserID"].ToString()), Convert.ToString(Session["UserRole"])); // Get Company Name DataTable dtTable = new DataTable(); dtTable = VPCRMSBAL.GetCompanyName(Convert.ToDecimal(Session["UserID"].ToString().Trim().Substring(0, 4))); if (dtTable.Rows.Count > 0) { lblCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); } else { lblCompanyName.Text = "Default Name"; } }
protected void Page_Load(object sender, EventArgs e) { HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetNoServerCaching(); HttpContext.Current.Response.Cache.SetNoStore(); if (Session["UserID"] == null) { Response.Redirect("Login.aspx"); } decimal client_alias = Convert.ToDecimal(Convert.ToDecimal(Session["UserID"].ToString().Trim().Substring(0, 4))); // Get Company Name DataTable dtTable = new DataTable(); dtTable = VPCRMSBAL.GetCompanyName(Convert.ToDecimal(Session["UserID"].ToString().Trim().Substring(0, 4))); if (dtTable.Rows.Count > 0) { lblModalCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); lblQuotModalCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); lblCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); } else { lblCompanyName.Text = "Default Name"; } // Populate Assigned to dropdown on modal. DataTable dtUserTable = new DataTable(); dtUserTable = VPCRMSBAL.GetUserList(client_alias); if (dtUserTable.Rows.Count > 0) { ddlassignedto.DataSource = dtUserTable; ddlassignedto.DataTextField = "clientuserfirstname"; ddlassignedto.DataValueField = "clientuserid"; ddlassignedto.DataBind(); ddlassignedto.Items.Insert(0, new ListItem("Select Assign Person", "0")); ddlassignedto.SelectedIndex = 0; ddlcustomeruser.DataSource = dtUserTable; ddlcustomeruser.DataTextField = "clientuserfirstname"; ddlcustomeruser.DataValueField = "clientuserid"; ddlcustomeruser.DataBind(); ddlcustomeruser.Items.Insert(0, new ListItem("Select Assign Person", "0")); ddlcustomeruser.SelectedIndex = 0; } if (Session["UserRole"].ToString() == "Associate") { ddlstatus.Items.Remove(ddlstatus.Items.FindByValue("Closed")); } }
protected void Page_Load(object sender, EventArgs e) { // Set page cache to NO HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetNoServerCaching(); HttpContext.Current.Response.Cache.SetNoStore(); if (Session["UserID"] == null) { Response.Redirect("Login.aspx"); } decimal client_alias = Convert.ToDecimal(Convert.ToDecimal(Session["UserID"].ToString().Trim().Substring(0, 4))); // Populate Assigned to dropdown on modal. DataTable dtUserTable = new DataTable(); dtUserTable = VPCRMSBAL.GetUserList(client_alias); if (dtUserTable.Rows.Count > 0) { ddlassignedto.DataSource = dtUserTable; ddlassignedto.DataTextField = "clientuserfirstname"; ddlassignedto.DataValueField = "clientuserid"; ddlassignedto.DataBind(); ddlassignedto.Items.Insert(0, new ListItem("Select Assign Person", "")); ddlassignedto.SelectedIndex = 0; } //grdForecasting.Visible = false; // Get Company Name DataTable dtTable = new DataTable(); dtTable = VPCRMSBAL.GetCompanyName(Convert.ToDecimal(Session["UserID"].ToString().Trim().Substring(0, 4))); if (dtTable.Rows.Count > 0) { lblCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); } else { lblCompanyName.Text = "Default Company"; } }
protected void Page_Load(object sender, EventArgs e) { // Set page cache to NO HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetNoServerCaching(); HttpContext.Current.Response.Cache.SetNoStore(); if (Session["UserID"] == null) { Response.Redirect("Login.aspx"); } if ((Session["UserRole"].ToString().Trim()) != "Manager") { Response.Redirect("Dashboard.aspx"); } //Get Client alias from UserID decimal client_alias = Convert.ToDecimal(Session["UserID"].ToString().Trim().Substring(0, 4)); //DataTable dtLogin = new DataTable(); //dtLogin = VPCRMSBAL.GetProductDetails(client_alias); //grdProduct.DataSource = dtLogin; //grdProduct.DataBind(); DataTable dtTable = new DataTable(); dtTable = VPCRMSBAL.GetCompanyName(client_alias); if (dtTable.Rows.Count > 0) { lblCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); lblModalCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); } else { lblCompanyName.Text = "Default Name"; lblModalCompanyName.Text = "Default Name"; } }
public void Report1ExportToPdf(DataTable dataTable) { string path = HttpContext.Current.Server.MapPath("PDF-Files"); string filename = path + "/Report1_" + HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4) + ".pdf"; Document document = new Document(new Rectangle(288f, 144f), 30, 20, 20, 20); document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create)); document.Open(); BaseFont header = iTextSharp.text.pdf.BaseFont.CreateFont("C:\\windows\\fonts\\timesbd.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); FontSelector selector = new FontSelector(); Font f1 = FontFactory.GetFont(FontFactory.TIMES_BOLD, 12); f1.Color = BaseColor.MAGENTA; Font f2 = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16); f1.Color = BaseColor.RED; iTextSharp.text.Font fontHeader = new iTextSharp.text.Font(header, 18, iTextSharp.text.Font.BOLD); DataTable dt = new DataTable(); dt = VPCRMSBAL.GetCompanyName(Convert.ToDecimal(HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4))); if (dt.Rows.Count > 0) { Paragraph para1 = new Paragraph(dt.Rows[0]["clientname"].ToString().Trim(), f2); para1.Alignment = Element.ALIGN_CENTER; document.Add(para1); para1.SpacingAfter = 50f; } Paragraph para2 = new Paragraph(); Phrase phrase1 = new Phrase("DAILY SALES STATISTICS", f1); para2.Alignment = Element.ALIGN_LEFT; para2.Add(phrase1); document.Add(para2); Paragraph para3 = new Paragraph(); Phrase phrase2 = new Phrase("Sales Person: "); Phrase phrase3 = new Phrase(HttpContext.Current.Session["UserFirstName"].ToString().Trim() + HttpContext.Current.Session["UserLastName"].ToString().Trim()); para3.Add(phrase2); para3.Add(phrase3); para3.Alignment = Element.ALIGN_RIGHT; para3.SpacingAfter = 50f; document.Add(para3); PdfPTable table = new PdfPTable(dataTable.Columns.Count); table.WidthPercentage = 100; //Set columns names in the pdf file for (int k = 0; k < dataTable.Columns.Count; k++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Columns[k].ColumnName)); cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; cell.BackgroundColor = new iTextSharp.text.BaseColor(51, 102, 102); table.AddCell(cell); } //Add values of DataTable in pdf file for (int i = 0; i < dataTable.Rows.Count; i++) { for (int j = 0; j < dataTable.Columns.Count; j++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Rows[i][j].ToString())); //Align the cell in the center cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; table.AddCell(cell); } } document.Add(table); document.Close(); } catch (Exception ex) { ILog logger = log4net.LogManager.GetLogger("ErrorLog"); logger.Error(ex.ToString()); HttpContext.Current.Response.Redirect("ErrorPage.aspx"); } }
public static string GenerateQuotationPDF(String customerquoteid) { VPCRMSBAL VPCRMSBAL = new VPCRMSBAL(); string path = HttpContext.Current.Server.MapPath("PDF-Files"); // due to static web method Httpcontext is used. string client_alias = HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4); string filename = path + "/Quotation_" + client_alias + "_" + customerquoteid + ".pdf"; // Check file exists on path or not, if exists delete existing instance and create new one always. if (File.Exists(filename)) { File.Delete(filename); } Document document = new Document(PageSize.A4, 12.5f, 12.5f, 12.5f, 12.5f); try { PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create)); document.Open(); FontSelector selector = new FontSelector(); Font f1 = FontFactory.GetFont(FontFactory.TIMES_BOLD, 12); f1.Color = BaseColor.DARK_GRAY; // Header Content font. Font f2 = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 16); f1.Color = BaseColor.BLACK; // General Text font. Font f3 = FontFactory.GetFont(FontFactory.TIMES, 12); f3.Color = BaseColor.DARK_GRAY; Paragraph quotelabel = new Paragraph("Sales Quotation", f2); quotelabel.Alignment = Element.ALIGN_RIGHT; document.Add(quotelabel); Paragraph linebreak = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1))); document.Add(linebreak); Paragraph quotedate = new Paragraph("Date: " + DateTime.Today.ToString("dd-MM-yyyy"), f3); quotedate.Alignment = Element.ALIGN_RIGHT; document.Add(quotedate); Paragraph quotenum = new Paragraph("Quotation Number: " + customerquoteid, f3); quotenum.Alignment = Element.ALIGN_RIGHT; document.Add(quotenum); DataTable dt = new DataTable(); dt = VPCRMSBAL.GetCompanyName(Convert.ToDecimal(HttpContext.Current.Session["UserID"].ToString().Trim().Substring(0, 4))); if (dt.Rows.Count > 0) { Paragraph para1 = new Paragraph(dt.Rows[0]["clientname"].ToString().Trim(), f1); para1.Alignment = Element.ALIGN_LEFT; document.Add(para1); Paragraph para1a = new Paragraph(dt.Rows[0]["clientaddress1"].ToString().Trim(), f3); para1.Alignment = Element.ALIGN_LEFT; document.Add(para1a); Paragraph para1b = new Paragraph(dt.Rows[0]["clientcontactno1"].ToString().Trim(), f3); para1b.Alignment = Element.ALIGN_LEFT; document.Add(para1b); para1b.SpacingAfter = 30f; } Paragraph para5 = new Paragraph(); Phrase phrase51 = new Phrase("To, ", f3); para5.SpacingBefore = 50f; para5.Add(phrase51); document.Add(para5); DataTable dataTable = new DataTable(); dataTable = VPCRMSBAL.GetQuotationDetailsbyID(Convert.ToDecimal(customerquoteid)); if (dataTable.Rows.Count > 0) { Paragraph phrase52 = new Paragraph(dataTable.Rows[0]["Customer Name"].ToString().Trim() + ",", f1); document.Add(phrase52); Paragraph phrase53 = new Paragraph(dataTable.Rows[0]["Customer Address Line 1"].ToString().Trim() + ",", f3); document.Add(phrase53); Paragraph phrase54 = new Paragraph(dataTable.Rows[0]["Customer Address Line 2"].ToString().Trim() + ",", f3); document.Add(phrase54); Paragraph phrase55 = new Paragraph(dataTable.Rows[0]["Customer City"].ToString().Trim() + " " + dataTable.Rows[0]["Customer District"].ToString().Trim() + ",", f3); document.Add(phrase55); Paragraph phrase56 = new Paragraph(dataTable.Rows[0]["Customer State"].ToString().Trim() + " " + dataTable.Rows[0]["Customer Country"].ToString().Trim() + ",", f3); document.Add(phrase56); Paragraph phrase57 = new Paragraph(dataTable.Rows[0]["Customer Pincode"].ToString().Trim(), f3); document.Add(phrase57); Paragraph phrase41 = new Paragraph("Dear Sir/Madam,", f3); phrase41.SpacingBefore = 30f; document.Add(phrase41); Paragraph phrase42 = new Paragraph("Please see requested quotation details as per below.", f3); phrase42.SpacingAfter = 30f; document.Add(phrase42); //PdfPTable table = new PdfPTable(dataTable.Columns.Count); PdfPTable table = new PdfPTable(4); table.WidthPercentage = 100; table.SetTotalWidth(new float[] { 100f, 20f, 20f, 20f }); //Set columns names in the pdf file //for (int k = 0; k < dataTable.Columns.Count; k++) //PdfPCell srnocell = new PdfPCell(new Phrase("Sr No")); //srnocell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; //srnocell.VerticalAlignment = PdfPCell.ALIGN_CENTER; //srnocell.BackgroundColor = BaseColor.LIGHT_GRAY; //table.AddCell(srnocell); for (int k = 12; k < dataTable.Columns.Count; k++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Columns[k].ColumnName)); if (k == 12) { cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; } cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; cell.BackgroundColor = BaseColor.LIGHT_GRAY; table.AddCell(cell); } //Add values of DataTable in pdf file for (int i = 0; i < dataTable.Rows.Count; i++) { //for (int j = 0; j < dataTable.Columns.Count; j++) //srnocell = new PdfPCell(new Phrase((i + 1).ToString(), f3)); //srnocell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; //srnocell.VerticalAlignment = PdfPCell.ALIGN_CENTER; //table.AddCell(srnocell); for (int j = 12; j < dataTable.Columns.Count; j++) { PdfPCell cell = new PdfPCell(new Phrase(dataTable.Rows[i][j].ToString(), f3)); //Align the cell in the center if (j == 12) { cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; } cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; cell.VerticalAlignment = PdfPCell.ALIGN_CENTER; table.AddCell(cell); } } document.Add(table); } Paragraph thanksline = new Paragraph(new Phrase("Thank you for showing interest in us, we look forward for your positive response.", f3)); thanksline.Alignment = Element.ALIGN_LEFT; thanksline.SpacingBefore = 30f; thanksline.SpacingAfter = 50f; document.Add(thanksline); Paragraph signpara = new Paragraph(new Phrase("Authorized Signatory", f3)); signpara.Alignment = Element.ALIGN_RIGHT; signpara.SpacingAfter = 20f; document.Add(signpara); document.Add(linebreak); Paragraph terms1 = new Paragraph(new Phrase("Terms & Conditions", f1)); terms1.Alignment = Element.ALIGN_LEFT; document.Add(terms1); Paragraph terms2 = new Paragraph(new Phrase("1. Prices are exclusive of taxes.", f3)); terms2.Alignment = Element.ALIGN_LEFT; document.Add(terms2); Paragraph terms3 = new Paragraph(new Phrase("2. All shipments of goods/products will be delivered within ___ months.", f3)); terms3.Alignment = Element.ALIGN_LEFT; document.Add(terms3); Paragraph terms4 = new Paragraph(new Phrase("3. If there are any inconsitancies or conflicts between the standard terms & conditions of sales & terms on any applicable agreement, precedence shall be given to standard terms & conditions of Sale unless the parties agree in writing to contrary.", f3)); terms4.Alignment = Element.ALIGN_JUSTIFIED; document.Add(terms4); document.AddAuthor("VPCRMS"); document.AddCreator("VP Consultancy Services"); document.AddTitle("Quotation"); document.Close(); } catch (Exception ex) { ILog logger = log4net.LogManager.GetLogger("ErrorLog"); logger.Error(ex.ToString()); } return(client_alias); }
protected void Page_Load(object sender, EventArgs e) { // Set page cache to NO HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.Cache.SetNoServerCaching(); HttpContext.Current.Response.Cache.SetNoStore(); if (Session["UserID"] == null) { Response.Redirect("Login.aspx"); } if ((Session["UserRole"].ToString().Trim()) != "Manager") { Response.Redirect("Dashboard.aspx"); } //Get Client alias from UserID decimal client_alias = Convert.ToDecimal(Session["UserID"].ToString().Substring(0, 4)); //DataTable dtLogin = new DataTable(); //// Since this is admin specific page, not client alias is required to pass to below method. //dtLogin = VPCRMSBAL.GetProductAssignment(); //grdProductAssignment.DataSource = dtLogin; //grdProductAssignment.DataBind(); // Populate Assigned to dropdown on modal. DataTable dtUserTable = new DataTable(); dtUserTable = VPCRMSBAL.GetUserList(client_alias); if (dtUserTable.Rows.Count > 0) { ddlusername.DataSource = dtUserTable; ddlusername.DataTextField = "clientuserfirstname"; ddlusername.DataValueField = "clientuserid"; ddlusername.DataBind(); ddlusername.Items.Insert(0, new ListItem("Select Assign Person", "0")); ddlusername.SelectedIndex = 0; } // Populate Product Name to dropdown on modal. DataTable dtProdTable = new DataTable(); dtProdTable = VPCRMSBAL.GetProductList(client_alias); if (dtProdTable.Rows.Count > 0) { ddlProductName.DataSource = dtProdTable; ddlProductName.DataValueField = "productname"; ddlProductName.DataValueField = "productname"; ddlProductName.DataBind(); ddlProductName.Items.Insert(0, new ListItem("Select Product", "0")); ddlProductName.SelectedIndex = 0; } DataTable dtTable = new DataTable(); // change alias param of below step .. hardcoded for testing as of now. dtTable = VPCRMSBAL.GetCompanyName(client_alias); if (dtTable.Rows.Count > 0) { lblCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); lblModalCompanyName.Text = dtTable.Rows[0]["clientname"].ToString(); } else { lblCompanyName.Text = "Default Name"; } }