Example #1
0
    /// <summary>
    /// 按下CrystalReportViewer的[匯出這份報表]
    /// </summary>
    /// <param name="dt">列印資料</param>
    private void Show_Report(DataTable dt)
    {
        TextBox txt_BUSDATE_B = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode");
        TextBox txt_BUSDATE_E = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate2")).FindControl("TextBoxCode");

        string s_par_Program_ID = string.Empty;
        string s_par_LoginUser = string.Empty;
        string s_par_BUSDATE = string.Empty;
        string s_par_CHAN_NO = string.Empty;
        string s_par_ITEM = string.Empty;
        string s_par_Z_O = string.Empty;
        string s_par_MANUFACTURE = string.Empty;
        string s_par_OUT_OF_STOCK_DAY = string.Empty;

        report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

        if (this.rdb_Report_Status.SelectedValue == "0")//明細表
        { report.Load(Server.MapPath("./REPORT/CRM151/CRM151_Report_Detl.rpt")); }
        else if (this.rdb_Report_Status.SelectedValue == "1")//彙總表
        { report.Load(Server.MapPath("./REPORT/CRM151/CRM151_Report_Main.rpt")); }

        s_par_Program_ID = this.PageCode;
        s_par_LoginUser = Session["UID"].ToString();
        s_par_BUSDATE = txt_BUSDATE_B.Text.Trim() + "~" + txt_BUSDATE_E.Text.Trim();
        s_par_CHAN_NO = this.slp_CHAN_NO.Text.Trim();
        s_par_ITEM = this.slp_ITEM.Text.Trim();
        s_par_Z_O = this.slp_Z_O_B.Text.Trim() + "~" + this.slp_Z_O_E.Text.Trim();
        s_par_MANUFACTURE = this.slp_MANUFACTURE_B.Text.Trim() + "~" + this.slp_MANUFACTURE_E.Text.Trim();
        s_par_OUT_OF_STOCK_DAY = this.rdb_OUT_OF_STOCK_DAY.SelectedItem.Text.Trim();

        ParameterFields par1 = new ParameterFields();
        AddParameter("par_Program_ID", s_par_Program_ID, par1);
        ParameterFields par2 = new ParameterFields();
        AddParameter("par_LoginUser", s_par_LoginUser, par2);
        ParameterFields par3 = new ParameterFields();
        AddParameter("par_BUSDATE", s_par_BUSDATE, par3);
        ParameterFields par4 = new ParameterFields();
        AddParameter("par_CHAN_NO", s_par_CHAN_NO, par4);
        ParameterFields par5 = new ParameterFields();
        AddParameter("par_ITEM", s_par_ITEM, par5);
        ParameterFields par6 = new ParameterFields();
        AddParameter("par_Z_O", s_par_Z_O, par6);
        ParameterFields par7 = new ParameterFields();
        AddParameter("par_MANUFACTURE", s_par_MANUFACTURE, par7);
        ParameterFields par8 = new ParameterFields();
        AddParameter("par_OUT_OF_STOCK_DAY", s_par_OUT_OF_STOCK_DAY, par8);

        this.CryView.ReportSource = null;

        this.CryView.ParameterFieldInfo.Add(par1[0]);
        this.CryView.ParameterFieldInfo.Add(par2[0]);
        this.CryView.ParameterFieldInfo.Add(par3[0]);
        this.CryView.ParameterFieldInfo.Add(par4[0]);
        this.CryView.ParameterFieldInfo.Add(par5[0]);
        this.CryView.ParameterFieldInfo.Add(par6[0]);
        this.CryView.ParameterFieldInfo.Add(par7[0]);
        this.CryView.ParameterFieldInfo.Add(par8[0]);

        if (this.rdb_Report_Status.SelectedValue == "1")
        {
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.rdb_OUT_OF_STOCK_DAY.SelectedValue, "string", false));
            ParameterList.Add(Session["UID"].ToString());

            int i_CRM_REQUEST_NO_COUNT = 0;
            BCO.QueryCRMOrderOutOfStockReport bco = new BCO.QueryCRMOrderOutOfStockReport(ConntionDB);
            i_CRM_REQUEST_NO_COUNT = bco.QUERY_CRM151_PRINTSUM_COUNT(ParameterList);

            ParameterFields par9 = new ParameterFields();
            AddParameter("par_CRM_REQUEST_NO_COUNT", i_CRM_REQUEST_NO_COUNT.ToString(), par9);
            this.CryView.ParameterFieldInfo.Add(par9[0]);
        }

        report.SetDataSource(dt);
        this.CryView.ReportSource = report;
    }
Example #2
0
    /// <summary>
    /// 列印轉PDF檔
    /// </summary>
    /// <param name="dt">列印資料</param>
    private void Show_Report2(DataTable dt)
    {
        TextBox txt_BUSDATE_B = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate1")).FindControl("TextBoxCode");
        TextBox txt_BUSDATE_E = (TextBox)((ASP.wui_slp_slp_slpdate_ascx)this.slp_BUSDATE.FindControl("SLP_SLPDate2")).FindControl("TextBoxCode");

        string s_FileName = txt_Out_FileName.Text;
        if (s_FileName.ToLower().IndexOf(".xls") < 0)
        {
            s_FileName = s_FileName + ".pdf";
        }
        else
        {
            s_FileName = s_FileName.Substring(0, s_FileName.Length - 4) + ".pdf";
        }
        s_FileName = HttpUtility.UrlEncode(s_FileName, System.Text.Encoding.UTF8);

        //Load Report
        report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        if (this.rdb_Report_Status.SelectedValue == "0")//明細表
        { report.Load(Server.MapPath("./REPORT/CRM151/CRM151_Report_Detl.rpt")); }
        else if (this.rdb_Report_Status.SelectedValue == "1")//彙總表
        { report.Load(Server.MapPath("./REPORT/CRM151/CRM151_Report_Main.rpt")); }
        report.SetDataSource(dt);

        // Set Parameter
        report.SetParameterValue("par_Program_ID", this.PageCode);
        report.SetParameterValue("par_LoginUser", Session["UID"].ToString());
        report.SetParameterValue("par_BUSDATE", txt_BUSDATE_B.Text.Trim() + "~" + txt_BUSDATE_E.Text.Trim());
        report.SetParameterValue("par_CHAN_NO", this.slp_CHAN_NO.Text.Trim());
        report.SetParameterValue("par_ITEM", this.slp_ITEM.Text.Trim());
        report.SetParameterValue("par_Z_O", this.slp_Z_O_B.Text.Trim() + "~" + this.slp_Z_O_E.Text.Trim());
        report.SetParameterValue("par_MANUFACTURE", this.slp_MANUFACTURE_B.Text.Trim() + "~" + this.slp_MANUFACTURE_E.Text.Trim());
        report.SetParameterValue("par_OUT_OF_STOCK_DAY", this.rdb_OUT_OF_STOCK_DAY.SelectedItem.Text.Trim());
        if (this.rdb_Report_Status.SelectedValue == "1")
        {
            ArrayList ParameterList = new ArrayList();//20091117

            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(this.rdb_OUT_OF_STOCK_DAY.SelectedValue, "string", false));
            ParameterList.Add(Session["UID"].ToString());

            int i_CRM_REQUEST_NO_COUNT = 0;
            BCO.QueryCRMOrderOutOfStockReport bco = new BCO.QueryCRMOrderOutOfStockReport(ConntionDB);
            i_CRM_REQUEST_NO_COUNT = bco.QUERY_CRM151_PRINTSUM_COUNT(ParameterList);

            report.SetParameterValue("par_CRM_REQUEST_NO_COUNT", i_CRM_REQUEST_NO_COUNT.ToString());
        }

        System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, bytes.Length);
        stream.Seek(0, System.IO.SeekOrigin.Begin);

        //export file  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  

        Response.ContentType = "application/vnd.ms-excel;charset='utf-8'";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");

        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.Flush();
        Response.Close();
        report.Close();
    }
Example #3
0
    public static string getCount(string OUT_OF_STOCK_DAYControl, string UserID)
    {
        ParameterList.Clear();
        ParameterList.Add(OUT_OF_STOCK_DAYControl);
        ParameterList.Add(UserID);

        int i_CRM_REQUEST_NO_COUNT = 0;
        BCO.QueryCRMOrderOutOfStockReport bco = new BCO.QueryCRMOrderOutOfStockReport(ConntionDB);
        i_CRM_REQUEST_NO_COUNT = bco.QUERY_CRM151_PRINTSUM_COUNT(ParameterList);

        return i_CRM_REQUEST_NO_COUNT.ToString();
    }