Beispiel #1
0
    protected void Btn_Export_Click(object sender, EventArgs e)
    {
        try
        {
            #region 傳入參數
            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(SLP_CHAN_NO.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(SLP_Route1.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(SLP_Route2.Text, "string", false));

            #endregion

            #region 取得資料
            STMModel.MaintainRoute BCO = new STMModel.MaintainRoute(ConntionDB);
            DataTable Dt = new DataTable();
            Dt = BCO.QueryRouteRpt(ParameterList);
            #endregion

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
            {
                ErrorMsgLabel.Text = "查無資料";
            }
            else
            {
                #region 設定頁面狀態

                this.hid_PageStatus.Value = "PRINT";
                this.txt_PageStatus.Text = "PRINT";

                #endregion

                string s_FileName = "";      //設定輸出檔名
                string s_rptFilePath = "";   //設定報表路徑

                s_rptFilePath = Server.MapPath("./REPORT/STM29/STM29R01.rpt");
                s_FileName = HttpUtility.UrlEncode("STM29R01_" + "路線路順.xls", System.Text.Encoding.UTF8);

                LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "EXCEL");
            }
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }
    }
Beispiel #2
0
    protected void Btn_Print_Click(object sender, EventArgs e)
    {
        try
        {
            #region 傳入參數
            ParameterList.Clear();
            ParameterList.Add(GetValueSetParameter(SLP_CHAN_NO.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(SLP_Route1.Text, "string", false));
            ParameterList.Add(GetValueSetParameter(SLP_Route2.Text, "string", false));

            #endregion

            #region 取得資料
            STMModel.MaintainRoute BCO = new STMModel.MaintainRoute(ConntionDB);
            DataTable Dt = new DataTable();
            Dt = BCO.QueryRouteRpt(ParameterList);
            #endregion

            if (Dt == null || (Dt != null && Dt.Rows.Count <= 0))
            {
                ErrorMsgLabel.Text = "查無資料";
            }
            else
            {
                #region 設定頁面狀態

                this.hid_PageStatus.Value = "PRINT";
                this.txt_PageStatus.Text = "PRINT";

                #endregion

                string s_FileName = "";      //設定輸出檔名
                string s_rptFilePath = "";   //設定報表路徑

                s_rptFilePath = Server.MapPath("./REPORT/STM29/STM29R01.rpt");
                s_FileName = HttpUtility.UrlEncode("STM29R01_" + "路線路順.PDF", System.Text.Encoding.UTF8);

                LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");

                #region Viewer寫法
                //使用者名稱
                //ParameterList.Clear();
                //ParameterList.Add(Session["UID"].ToString());

                //PIC.VDS2G.COMMON.SYS.MaintainUser BCO2 = new PIC.VDS2G.COMMON.SYS.MaintainUser(ConntionDB);
                //DataTable DtUser = BCO2.QueryUserName(ParameterList);

                //string Login_Name = "";
                //if (DtUser.Rows.Count != 0)
                //{
                //    Login_Name = DtUser.Rows[0]["NAME"].ToString();
                //}

                //#region CrystalReport列印報表

                //string Program_ID = string.Empty;
                //string LoginUser = string.Empty;
                //string LoginName = string.Empty;
                //string Chan_No = string.Empty;
                //string Route1 = string.Empty;
                //string Route2 = string.Empty;

                //CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                //report.Load(Server.MapPath("./REPORT/STM29/STM29R.rpt"));

                //Program_ID = this.PageCode + "R";
                //LoginUser = Session["UID"].ToString();
                //Login_Name = Login_Name.Trim();
                //Chan_No = ((TextBox)SLP_CHAN_NO.FindControl("TextBoxCode")).Text.Trim() + ((TextBox)SLP_CHAN_NO.FindControl("TextBoxName")).Text.Trim();
                //Route1 = ((TextBox)SLP_Route1.FindControl("TextBoxName")).Text.Trim();
                //Route2 = ((TextBox)SLP_Route2.FindControl("TextBoxName")).Text.Trim();

                //ParameterFields par1 = new ParameterFields();
                //AddParameter("par_Program_ID", Program_ID, par1);
                //ParameterFields par2 = new ParameterFields();
                //AddParameter("par_LoginUser", LoginUser, par2);
                //ParameterFields par3 = new ParameterFields();
                //AddParameter("par_LoginName", Login_Name, par3);
                //ParameterFields par4 = new ParameterFields();
                //AddParameter("par_Route1", Route1, par4);
                //ParameterFields par5 = new ParameterFields();
                //AddParameter("par_Route2", Route2, par5);
                //ParameterFields par6 = new ParameterFields();
                //AddParameter("par_Chan_No", Chan_No, par6);

                //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]);

                //report.SetDataSource(Dt);

                //this.CryView.ReportSource = report;

                //#endregion
                #endregion
            }
        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.ToString(); }
        finally { }
    }