Пример #1
0
        public DataTable VIM157_11(ArrayList ParameterList,
                                   string ReportOutputFormat,
                                   ref ReportList.ExcelOtherType EOT
                                  )
        {
            IVMModel.MaintainPickData bco = new IVMModel.MaintainPickData(ConntionDB);
            DataTable Dt = new DataTable();
            Dt = bco.GetPrintRpt01(ParameterList);
            DataView dv = new DataView(Dt);
            dv.Sort = "BLocate_No";

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("查無資料");
            }
            else
            {
                return dv.ToTable();
            }
        }
Пример #2
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="PickNo">揀貨單號</param>
    /// <param name="s_FileName">Excel報表的檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="reportFormatType">檔案型態</param>
    /// <param name="ReportOrderOption">排序類型 "item":品項 "locate":儲位 </param>
    private void LoadCrystalReport(string PickNo, string s_FileName, string s_rptFilePath, string reportFormatType, string ReportOrderOption)
    {

        try
        {
            IVMModel.MaintainPickData BCO = new IVMModel.MaintainPickData(ConntionDB);
            CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

            report.Load(Server.MapPath(s_rptFilePath));

            ParameterList.Clear();
            ParameterList.Add(PickNo);

            if (s_rptFilePath != "./REPORT/IVM15/CRIVM15R03.rpt")
            {

                DataTable dtResult = new DataTable();

                string ProgName = "";

                if (s_rptFilePath == "./REPORT/IVM15/CRIVM15R01.rpt")
                {
                    dtResult = BCO.GetPrintRpt01(ParameterList);
                    ProgName = "IVM15R01";
                }
                else
                {
                    dtResult = BCO.GetPrintRpt02(ParameterList);
                    ProgName = "IVM15R02";
                }

                DataView dv = new DataView(dtResult);

                switch (ReportOrderOption)
                {
                    case "item":
                        dv.Sort = "item";
                        break;

                    case "locate":
                        dv.Sort = "BLocate_No";
                        break;

                    default:
                        dv.Sort = "item";
                        break;
                }

                report.SetDataSource(dv.ToTable());

                report.SetParameterValue("paraProg", ProgName);
                report.SetParameterValue("paraUserID", Session["UID"].ToString());
                report.SetParameterValue("paraPickNo", PickNo);
                report.SetParameterValue("paraSource", this.MenuIVM15.SelectedItem.Text);
                report.SetParameterValue("paraAccDate", "");
                report.SetParameterValue("paraReturnNo", "");
                report.SetParameterValue("paraRemoveNo", "");
                report.SetParameterValue("paraBLocate", "");
                report.SetParameterValue("paraELocate", "");
                report.SetParameterValue("paraVendor", "");

            }
            else
            {
                DataTable dtResult = new DataTable();

                dtResult = BCO.GetPrintRpt03(ParameterList);

                report.SetDataSource(dtResult);

                report.SetParameterValue("paraProg", "IVM15R03");
                report.SetParameterValue("paraUserID", Session["UID"].ToString());
                //report.SetParameterValue("paraKind", "");
            }

            switch (reportFormatType)
            {
                case "EXCEL":

                    System.IO.Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
                    byte[] bytesXLS = new byte[streamXLS.Length];
                    streamXLS.Read(bytesXLS, 0, bytesXLS.Length);
                    streamXLS.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";


                    Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
                    Response.Flush();
                    Response.Close();

                    break;
                case "PDF":


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

                    //export file  
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//excel檔名  
                    Response.ContentType = "application/pdf";
                    Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
                    Response.Flush();
                    Response.Close();
                    break;
                default:

                    break;
            }

            report.Close();

        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }