コード例 #1
0
ファイル: CGD16.cs プロジェクト: ChiangHanLung/PIC_VDS
        /// <summary>
        /// 產生CGD16第一張報表_退貨通知單
        /// </summary>
        /// <param name="ParameterList">查詢DB的參數</param>
        /// <returns>回傳查詢結果</returns>
        public DataTable GGD16_1(ArrayList ParameterList)
        {
            CGDModel.ProcessTemplateItemPrint BCO = new CGDModel.ProcessTemplateItemPrint(ConntionDB);

            DataTable Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateItem, ParameterList);

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("查無資料");
            }

            return Dt;
        }
コード例 #2
0
ファイル: CGD16.cs プロジェクト: ChiangHanLung/PIC_VDS
        /// <summary>
        /// 產生CGD16第二張報表_模板(圖形32以內)
        /// </summary>
        /// <param name="ParameterList">查詢DB的參數</param>
        /// <returns>回傳查詢結果</returns>
        public DataTable GGD16_2(ArrayList ParameterList, string ReportOutputFormat, ref ReportList.ExcelOtherType EOT)
        {
            string strDefaultPath = "";

            CGDModel.ProcessTemplateItemPrint BCO = new CGDModel.ProcessTemplateItemPrint(ConntionDB);

            DataTable Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateItemPic, ParameterList);
            Dt.Columns.Add("IMG_FILE", System.Type.GetType("System.Byte[]"));

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("模板(圖形32以內)查無資料");
            }
            else
            {
                foreach (DataRow dr in Dt.Rows)
                {
                    try
                    {
                        FileStream fs;
                        BinaryReader br;

                        strDefaultPath = ParameterList[5].ToString() + dr["Cover_File"].ToString();

                        fs = new FileStream(strDefaultPath, FileMode.Open, FileAccess.Read);
                        br = new BinaryReader(fs);

                        byte[] imgbyte = new byte[fs.Length + 1];
                        imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
                        dr["IMG_FILE"] = imgbyte;
                        fs.Close();
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }

            //設定使用第三方元件匯出EXCEL
            if (ReportOutputFormat == "EXCEL")
            {
                EOT = ReportList.ExcelOtherType.None;
            }

            return Dt;
        }
コード例 #3
0
ファイル: CGD161.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    /// <summary>
    /// 列印鈕
    /// </summary>
    protected void btnPrintReport_Click(object sender, EventArgs e)
    {
        if (VerifyFormData() == true)
        {
            string strDefaultPath = "";

            try
            {
                ErrorMsgLabel.Text = "";
                this.hid_PageStatus.Value = "PRINT";

                string SessionIDName = "CGD161_" + PageTimeStamp.Value;
                CGDModel.ProcessTemplateItemPrint BCO = new CGDModel.ProcessTemplateItemPrint(ConntionDB);

                DataTable Dt;
                ParameterList.Clear();

                if (radRtnNote.Checked)//-------------------退貨通知單-------------------------------------------------------------------------
                {
                    ParameterList.Add(SLP_SLPDate.Text.Trim());
                    ParameterList.Add(SLP_Route_S.Text.Trim());
                    ParameterList.Add(SLP_Route_E.Text.Trim());
                    ParameterList.Add(SlP_Route.Text.Trim());
                    ParameterList.Add(SLP_Store.Text.Trim());
                    ParameterList.Add(Session["UID"].ToString() + PageTimeStamp.Value);

                    Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateItem, ParameterList);

                    if (Dt.Rows.Count == 0)
                    {
                        this.hid_PageStatus.Value = "QUERY";
                        this.CrystalReportViewer1.Visible = false;
                        ErrorMsgLabel.Text = "退貨通知單查無資料";
                        //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD161.aspx", "alert(' 退貨通知單查無資料 ');", true);

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

                        s_rptFilePath = Server.MapPath("./REPORT/CGD161R01.rpt");
                        s_FileName = HttpUtility.UrlEncode("退貨通知單.PDF", System.Text.Encoding.UTF8);


                        LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");
                    }
                }
                else if (radTemp32.Checked)//-------------------模板(圖形 32以內)--------------------------------------------------------------
                {
                    ParameterList.Add(SLP_SLPDate.Text.Trim());
                    ParameterList.Add(SLP_Route_S.Text.Trim());
                    ParameterList.Add(SLP_Route_E.Text.Trim());
                    ParameterList.Add(SlP_Route.Text.Trim());
                    ParameterList.Add(SLP_Store.Text.Trim());

                    Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateItemPic, ParameterList);
                    Dt.Columns.Add("IMG_FILE", System.Type.GetType("System.Byte[]"));
                    //DataTable dt = new DataTable();
                    //dt.Columns.Add("T_DATE", System.Type.GetType("System.String"));
                    //dt.Columns.Add("REMARK_CONTENT", System.Type.GetType("System.String"));
                    //dt.Columns.Add("ITEM_NAME", System.Type.GetType("System.String"));
                    //dt.Columns.Add("PERIOD", System.Type.GetType("System.String"));
                    //dt.Columns.Add("COVER_FILE", System.Type.GetType("System.String"));
                    //dt.Columns.Add("BARCODE", System.Type.GetType("System.String"));
                    //dt.Columns.Add("IMG_FILE", System.Type.GetType("System.Byte[]"));
                    //dt.Columns.Add("GRP", System.Type.GetType("System.String"));

                    if (Dt.Rows.Count == 0)
                    {
                        this.hid_PageStatus.Value = "QUERY";
                        this.CrystalReportViewer1.Visible = false;
                        ErrorMsgLabel.Text = "模板(圖形 32以內)查無資料";
                        //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD161.aspx", "alert(' 模板(圖形 32以內)查無資料 ');", true);

                        return;
                    }
                    else
                    {

                        foreach (DataRow dr in Dt.Rows)
                        {
                            try
                            {
                                FileStream fs;
                                BinaryReader br;

                                strDefaultPath = webConfigPath + dr["Cover_File"].ToString();

                                fs = new FileStream(strDefaultPath, FileMode.Open, FileAccess.Read);
                                br = new BinaryReader(fs);

                                byte[] imgbyte = new byte[fs.Length + 1];
                                imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
                                dr["IMG_FILE"] = imgbyte;
                                fs.Close();
                            }
                            catch (Exception ex)
                            {

                            }
                        }
                        ////第一份報表
                        //foreach (DataRow dr1 in Dt.Rows)
                        //{
                        //    DataRow nr = dt.NewRow();
                        //    for (int i = 0; i < 7; i++)
                        //    {
                        //        nr[i] = dr1[i];
                        //    }
                        //    nr[7] = "1";
                        //    dt.Rows.Add(nr);
                        //}
                        ////第二份報表
                        //foreach (DataRow dr2 in Dt.Rows)
                        //{
                        //    DataRow nr1 = dt.NewRow();
                        //    for (int i = 0; i < 7; i++)
                        //    {
                        //        nr1[i] = dr2[i];
                        //    }
                        //    nr1[7] = "2";
                        //    dt.Rows.Add(nr1);
                        //}
                        //dt.AcceptChanges();
                    }

                    // ShowReport(dt, "2");

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

                    s_rptFilePath = Server.MapPath("./REPORT/CGD161R02.rpt");
                    s_FileName = HttpUtility.UrlEncode("模板(圖形 32以內).PDF", System.Text.Encoding.UTF8);


                    LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");
                }
                else if (radTemp40.Checked)//-------------------模版(圖形 33~40)---------------------------------------------------------------
                {
                    ParameterList.Add(SLP_SLPDate.Text.Trim());
                    ParameterList.Add(SLP_Route_S.Text.Trim());
                    ParameterList.Add(SLP_Route_E.Text.Trim());
                    ParameterList.Add(SlP_Route.Text.Trim());
                    ParameterList.Add(SLP_Store.Text.Trim());

                    Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateItemPic, ParameterList);
                    Dt.Columns.Add("IMG_FILE", System.Type.GetType("System.Byte[]"));
                    //DataTable dt = new DataTable();
                    //dt.Columns.Add("T_DATE", System.Type.GetType("System.String"));
                    //dt.Columns.Add("REMARK_CONTENT", System.Type.GetType("System.String"));
                    //dt.Columns.Add("ITEM_NAME", System.Type.GetType("System.String"));
                    //dt.Columns.Add("PERIOD", System.Type.GetType("System.String"));
                    //dt.Columns.Add("COVER_FILE", System.Type.GetType("System.String"));
                    //dt.Columns.Add("BARCODE", System.Type.GetType("System.String"));
                    //dt.Columns.Add("IMG_FILE", System.Type.GetType("System.Byte[]"));
                    //dt.Columns.Add("GRP", System.Type.GetType("System.String"));

                    if (Dt.Rows.Count == 0)
                    {
                        this.hid_PageStatus.Value = "QUERY";
                        this.CrystalReportViewer1.Visible = false;
                        ErrorMsgLabel.Text = "模板(圖形 33~40)查無資料";
                        //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD161.aspx", "alert(' 模板(圖形 33~40)查無資料 ');", true);

                        return;
                    }
                    else
                    {
                        foreach (DataRow dr in Dt.Rows)
                        {
                            try
                            {
                                FileStream fs;
                                BinaryReader br;

                                strDefaultPath = webConfigPath + dr["Cover_File"].ToString();

                                fs = new FileStream(strDefaultPath, FileMode.Open, FileAccess.Read);
                                br = new BinaryReader(fs);

                                byte[] imgbyte = new byte[fs.Length + 1];
                                imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
                                dr["IMG_FILE"] = imgbyte;
                                fs.Close();
                            }
                            catch (Exception ex)
                            {

                            }
                        }
                        ////第一份報表
                        //foreach (DataRow dr1 in Dt.Rows)
                        //{
                        //    DataRow nr = dt.NewRow();
                        //    for (int i = 0; i < 7; i++)
                        //    {
                        //        nr[i] = dr1[i];
                        //    }
                        //    nr[7] = "1";
                        //    dt.Rows.Add(nr);
                        //}
                        ////第二份報表
                        //foreach (DataRow dr2 in Dt.Rows)
                        //{
                        //    DataRow nr1 = dt.NewRow();
                        //    for (int i = 0; i < 7; i++)
                        //    {
                        //        nr1[i] = dr2[i];
                        //    }
                        //    nr1[7] = "2";
                        //    dt.Rows.Add(nr1);
                        //}
                        //dt.AcceptChanges();
                    }

                    //ShowReport(dt, "3");

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

                    s_rptFilePath = Server.MapPath("./REPORT/CGD161R03.rpt");
                    s_FileName = HttpUtility.UrlEncode("模板(圖形 33~40).PDF", System.Text.Encoding.UTF8);


                    LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");
                }
                else if (radTemp64.Checked)//-------------------模版(圖形 41~64)---------------------------------------------------------------
                {
                    ParameterList.Add(SLP_SLPDate.Text.Trim());
                    ParameterList.Add(SLP_Route_S.Text.Trim());
                    ParameterList.Add(SLP_Route_E.Text.Trim());
                    ParameterList.Add(SlP_Route.Text.Trim());
                    ParameterList.Add(SLP_Store.Text.Trim());

                    Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateItemPic, ParameterList);
                    Dt.Columns.Add("IMG_FILE", System.Type.GetType("System.Byte[]"));

                    if (Dt.Rows.Count == 0)
                    {
                        this.hid_PageStatus.Value = "QUERY";
                        this.CrystalReportViewer1.Visible = false;
                        ErrorMsgLabel.Text = "模板(圖形 41~64)查無資料";
                        //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD161.aspx", "alert(' 模板(圖形 41~64)查無資料 ');", true);

                        return;
                    }
                    else
                    {
                        foreach (DataRow dr in Dt.Rows)
                        {
                            try
                            {
                                FileStream fs;
                                BinaryReader br;

                                strDefaultPath = webConfigPath + dr["Cover_File"].ToString();

                                fs = new FileStream(strDefaultPath, FileMode.Open, FileAccess.Read);
                                br = new BinaryReader(fs);

                                byte[] imgbyte = new byte[fs.Length + 1];
                                imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
                                dr["IMG_FILE"] = imgbyte;
                                fs.Close();
                            }
                            catch (Exception ex)
                            {

                            }
                        }
                    }

                    // ShowReport(Dt, "4");

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

                    s_rptFilePath = Server.MapPath("./REPORT/CGD161R04.rpt");
                    s_FileName = HttpUtility.UrlEncode("模板(圖形 41~64).PDF", System.Text.Encoding.UTF8);


                    LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");
                }
                else if (radTemp80.Checked)//-------------------模版(圖形 65~80)---------------------------------------------------------------
                {
                    ParameterList.Add(SLP_SLPDate.Text.Trim());
                    ParameterList.Add(SLP_Route_S.Text.Trim());
                    ParameterList.Add(SLP_Route_E.Text.Trim());
                    ParameterList.Add(SlP_Route.Text.Trim());
                    ParameterList.Add(SLP_Store.Text.Trim());

                    Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateItemPic, ParameterList);
                    Dt.Columns.Add("IMG_FILE", System.Type.GetType("System.Byte[]"));

                    if (Dt.Rows.Count == 0)
                    {
                        this.hid_PageStatus.Value = "QUERY";
                        this.CrystalReportViewer1.Visible = false;
                        ErrorMsgLabel.Text = "模板(圖形 65~80)查無資料";
                        //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD161.aspx", "alert(' 模板(圖形 65~80)查無資料 ');", true);

                        return;
                    }
                    else
                    {
                        foreach (DataRow dr in Dt.Rows)
                        {
                            try
                            {
                                FileStream fs;
                                BinaryReader br;

                                strDefaultPath = webConfigPath + dr["Cover_File"].ToString();

                                fs = new FileStream(strDefaultPath, FileMode.Open, FileAccess.Read);
                                br = new BinaryReader(fs);

                                byte[] imgbyte = new byte[fs.Length + 1];
                                imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
                                dr["IMG_FILE"] = imgbyte;
                                fs.Close();
                            }
                            catch (Exception ex)
                            {

                            }
                        }
                    }

                    //ShowReport(Dt, "5");

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

                    s_rptFilePath = Server.MapPath("./REPORT/CGD161R05.rpt");
                    s_FileName = HttpUtility.UrlEncode("模板(圖形 65~80).PDF", System.Text.Encoding.UTF8);


                    LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");
                }
                else if (radGenIrregular.Checked)//-------------------一般通路不定期-----------------------------------------------------------
                {
                    ParameterList.Add(SLP_SLPDate1.Text.Trim());

                    Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateEndItem, ParameterList);

                    if (Dt.Rows.Count == 0)
                    {
                        this.hid_PageStatus.Value = "QUERY";
                        this.CrystalReportViewer1.Visible = false;
                        ErrorMsgLabel.Text = "一般通路不定期查無資料";
                        //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD161.aspx", "alert(' 一般通路不定期查無資料 ');", true);

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

                        s_rptFilePath = Server.MapPath("./REPORT/CGD161R06.rpt");
                        s_FileName = HttpUtility.UrlEncode("一般通路不定期退書通知單.PDF", System.Text.Encoding.UTF8);


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

                    //ShowReport(Dt, "6");
                }
                else if (radSpecIrregular.Checked)//特殊通路不定期-----------------------------------------------------------------------------
                {
                    ParameterList.Add(SLP_SLPDate1.Text.Trim());

                    Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryTemplateEndChanItem, ParameterList);

                    if (Dt.Rows.Count == 0)
                    {
                        this.hid_PageStatus.Value = "QUERY";
                        this.CrystalReportViewer1.Visible = false;
                        ErrorMsgLabel.Text = "特殊通路不定期查無資料";
                        //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD161.aspx", "alert(' 特殊通路不定期查無資料 ');", true);

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

                        s_rptFilePath = Server.MapPath("./REPORT/CGD161R07.rpt");
                        s_FileName = HttpUtility.UrlEncode("特殊通路不定期退書通知單.PDF", System.Text.Encoding.UTF8);


                        LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF");
                    }
                    // ShowReport(Dt, "7");
                }
            }
            catch (Exception ex)
            {
                ErrorMsgLabel.Text = ex.Message;
            }
            finally { }
        }
    }