Exemplo n.º 1
0
    /// <summary>
    /// GetCustomerName :Private method used to get customer name
    /// </summary>
    private void GetCustomerName()
    {
        try
        {
            string strWhere = string.Empty;
            string strTable = string.Empty;

            if (Request.QueryString["CASMode"] == null)
            {
                strWhere = "CustNo='" + Request.QueryString["CustNo"].Trim().Replace("||", "&") + "'";
                strTable = "CAS_CustomerData";
            }
            else
            {
                strWhere = "Chain='" + Request.QueryString["Chain"].Trim().Replace("||", "&") + "'";
                strTable = "CAS_ChainData";
            }

            PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet customerData = new PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet();

            DataTable dtSalesDetails = customerData.GetCustomerActivityDetail(strWhere, "CustName,BranchNo,BranchDesc", strTable);

            if (dtSalesDetails.Rows.Count > 0)
            {
                Session["CustomerName"] = dtSalesDetails.Rows[0]["CustName"].ToString();
                if (Request.QueryString["Branch"].Trim() == "0")
                {
                    StrBranch = dtSalesDetails.Rows[0]["BranchNo"].ToString() + "-" + dtSalesDetails.Rows[0]["BranchDesc"].ToString();
                }
                else
                {
                    StrBranch = Request.QueryString["BranchName"].Trim();
                }
            }
            else
            {
                Session["CustomerName"] = "";
                if (Request.QueryString["Branch"].Trim() == "0")
                {
                    StrBranch = Request.QueryString["BranchName"].Trim();
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Function to fill the customer contact notes
    /// </summary>
    public void FilllNotes()
    {
        try
        {
            string strWhere = "CustNo='" + Request.QueryString["CustNo"].Trim().Replace("||", "&") + "'";

            // Initailize the class customer activity sheet
            PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet customerData = new PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet();

            // Get the data's in the datatable by calling the class function
            dtContactNotes = customerData.GetCustomerActivityDetail(strWhere, strNotesColumns, strNotesTable);

            // Get the datas in the datatable to bind the data in a single row
            DataTable dt = new DataTable();
            dt.Columns.Add("PreviousNote", typeof(string));
            dt.Columns.Add("LastOutRepNote", typeof(string));
            dt.Columns.Add("LastInRepNote", typeof(string));

            DataRow drow = dt.NewRow();
            if (dtContactNotes != null && dtContactNotes.Rows.Count != 0)
            {
                dtContactNotes.DefaultView.RowFilter = "NoteType='Previous Visit Note'";
                drow[0] = (dtContactNotes.DefaultView.ToTable().Rows.Count != 0) ? dtContactNotes.DefaultView.ToTable().Rows[0][0].ToString() : "";
                dtContactNotes.DefaultView.RowFilter = "NoteType='Last Outside Sales Rep  Notes'";
                drow[1] = (dtContactNotes.DefaultView.ToTable().Rows.Count != 0) ? dtContactNotes.DefaultView.ToTable().Rows[0][0].ToString() : "";
                dtContactNotes.DefaultView.RowFilter = "NoteType='Last Inside Sales Rep  Notes'";
                drow[2] = (dtContactNotes.DefaultView.ToTable().Rows.Count != 0) ? dtContactNotes.DefaultView.ToTable().Rows[0][0].ToString() : "";
            }
            else
            {
                drow[0] = "";
                drow[1] = "";
                drow[2] = "";
            }
            dt.Rows.Add(drow);

            // Code to bind the datatable in the datagrid
            dgContactNotes.DataSource = dt;
            dgContactNotes.DataBind();
        }
        catch (Exception ex) { }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Function to fill the customer details
    /// </summary>
    public void FillCustomerDetails()
    {
        try
        {
            string strWhere = "curmonth=" + Request.QueryString["Month"].Trim() + " and " +
                              "curYear=" + Request.QueryString["Year"].Trim() + " and CustNo='" + Request.QueryString["CustNo"].Trim().Replace("||", "&") + "'";

            strTable = Request.QueryString["CASMode"] == null ? strTable : "CAS_ChainData";

            // Initailize the class customer activity sheet
            PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet customerData = new PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet();

            // Get the data's in the datatable by calling the class function
            dtCustomerData = customerData.GetCustomerActivityDetail(strWhere, strDisplayColumns, strTable);

            // Bind the datagrid with datatables
            dgCas.DataSource = dtCustomerData;
            dgCas.DataBind();
        }
        catch (Exception ex) { Response.Write(ex.Message.ToString()); }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SystemCheck systemCheck = new SystemCheck();

        systemCheck.SessionCheck();
        try
        {
            // Get the mode in the variable
            string strMode = Request.QueryString["mode"].Trim();

            // Get the url of the pages in the string
            string strUrl = Request.QueryString["URL"].Trim();

            strUrl = strUrl.Replace("~", "&");
            string[] url = strUrl.Split(',');

            strDetailType = Session["DetailType"] != null ? Session["DetailType"].ToString() : "PFC Employee";

            // Using HTTP Post get the content of the pages in the array
            for (int i = 0; i < url.Length; i++)
            {
                WebRequest   req    = WebRequest.Create(Global.IntranetSiteURL + "CustomerActivitySheet/" + url[i].Trim().Replace('`', ',') + "&ChartType=" + Session["ChartType"].ToString() + "&ChartPalette=" + Session["ChartPalette"].ToString() + "&CustomerType=" + Session["CustomerType"].ToString() + "&mode=" + strMode + "&DetailType=" + strDetailType + "&PrintMode=Print");
                WebResponse  resp   = req.GetResponse();
                StreamReader reader = new StreamReader(resp.GetResponseStream(), System.Text.Encoding.ASCII);

                // Get the page content in the string
                string   strHtml = reader.ReadToEnd();
                string[] strhtm  = strHtml.Split('~');
                strHtml = strhtm[1].ToString();
                strHtml = strHtml.Replace("|>", "");
                strHtml = strHtml.Replace("|\">", "");
                strHtml = strHtml.Replace("</html>", "");
                strHtml = strHtml.Replace("</form>", "");
                strHtml = strHtml.Replace("</body>", "");
                if ((i == url.Length - 1) && (url[i].ToString().IndexOf("SalesCategoryDetail") != -1))
                {
                    strHtml = strHtml.Replace("style=\"page-break-after:always;\"", "");
                }
                else
                {
                    strHtml = (i == url.Length - 1) ? strHtml.Replace("page-break-after:always", "") : strHtml;
                }
                // Assing the page content in to the div
                strHtml = strHtml.Replace("???", "-");
                strHtml = strHtml.Replace("??", "  ");

                divContent.InnerHtml = divContent.InnerHtml + "<form>" + strHtml + "</form>";
            }

            if (strMode.Trim() == "Print")
            {
                // Script to print the current form
                Response.Write("<script>window.print();</script>");
            }
            else
            {
                // Code to export the pages to pdf
                string strFilename = DateTime.Now.ToString().Replace("/", "");
                strFilename = strFilename.Replace(" ", "");
                strFilename = strFilename.Replace(":", "");

                // Get the HTML FileName in a string
                string strHTMLFilename = "CAS" + Session["SessionID"].ToString() + strFilename + ".htm";

                // Get the PDF FileName in a string
                string strPDFilename = "CAS" + Session["SessionID"].ToString() + strFilename + ".pdf";
                string strContent    = divContent.InnerHtml.Replace("style=\"width:100%;border-collapse:collapse;\"", "style=\"width:100%;border-collapse:collapse;border-left:1px;border-right:1px;border-bottom:1px;border-top:1px\"");

                // Code to create the HTML File
                FileInfo     fn        = new FileInfo(Server.MapPath(strHTMLFilename));
                StreamWriter writeHTML = fn.CreateText();
                writeHTML.WriteLine("<html>");
                writeHTML.WriteLine("<head>");
                writeHTML.WriteLine("<link href=\"../CustomerActivitySheet/Styles/Styles.css\" rel=\"stylesheet\" type=\"text/css\" />" +
                                    "<link href=\"../SalesAnalysisReport/StyleSheet/Styles.css\" rel=\"stylesheet\" type=\"text/css\" />");
                writeHTML.WriteLine("</head>");
                writeHTML.WriteLine("<body>");
                writeHTML.WriteLine(strContent.Replace("class=DashBoardBk", ""));
                writeHTML.WriteLine("</body>");
                writeHTML.WriteLine("</html>");
                writeHTML.Close();

                // Initialize the class variable Customeractivitysheet
                PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet cs = new PFC.Intranet.BusinessLogicLayer.CustomerActivitySheet();

                // Code to create the pdf file
                cs.CreatePDF(Global.IntranetSiteURL + "CustomerActivitySheet/" + strHTMLFilename, Server.MapPath("PDF/" + strPDFilename));

                // Code to save or open the pdf file
                string pathFileName = Server.MapPath("PDF/" + strPDFilename);
                fStream = new System.IO.FileStream(pathFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);

                Byte[] b;
                if (fStream.Length > 0)
                {
                    b = new Byte[fStream.Length];
                    Response.Clear();
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.ContentType = "application/unknown";
                    fStream.Read(b, 0, (int)fStream.Length - 1);
                    Response.AddHeader("Content-Disposition", "attachment;filename=" + strPDFilename);
                    Response.BinaryWrite(b);
                    Response.End();
                    fStream.Close();
                }
            }
        }
        catch (Exception ex)
        {
            fStream.Close();
        }
        finally
        {
        }
    }