/// <summary> /// CRM15_2報表(列印鈕 明細表) /// </summary> /// <param name="ParameterList">變數清單</param> /// <returns>回傳查詢結果</returns> public DataTable CRM15_2(ArrayList ParameterList) { CRMModel.QueryCRMOrderOutOfStockReport BCO = new PIC.VDS2G.BSM.CRM.QueryCRMOrderOutOfStockReport(ConntionDB); DataTable Dt = BCO.PrintDetail(ParameterList); if (Dt.Rows.Count == 0) { throw new Exception("查無資料"); } else { return Dt; } }
/// <summary> /// CRM15_1報表(匯出鈕) /// </summary> /// <param name="ParameterList">變數清單</param> /// <param name="ReportOutputFormat">報表格式(PDF,EXCEL)</param> /// <param name="EOT">匯出Excel方式</param> /// <returns>回傳查詢結果</returns> public DataTable CRM15_1(ArrayList ParameterList, string ReportOutputFormat, ref ReportList.ExcelOtherType EOT ) { CRMModel.QueryCRMOrderOutOfStockReport BCO = new CRMModel.QueryCRMOrderOutOfStockReport(ConntionDB); DataTable Dt = BCO.Export(ParameterList); if (Dt.Rows.Count == 0) { throw new Exception("查無資料"); } //設定使用第三方元件匯出EXCEL if (ReportOutputFormat == "EXCEL") { #region 表頭 //Dt.Columns[0].ColumnName = "供應商"; //Dt.Columns[1].ColumnName = "供應商名稱"; //Dt.Columns[2].ColumnName = "品號"; //Dt.Columns[3].ColumnName = "品名"; //Dt.Columns[4].ColumnName = "營業所"; //Dt.Columns[5].ColumnName = "營業所名稱"; //Dt.Columns[6].ColumnName = "通路"; //Dt.Columns[7].ColumnName = "通路名稱"; //Dt.Columns[8].ColumnName = "店號"; //Dt.Columns[9].ColumnName = "店名"; //Dt.Columns[10].ColumnName = "通路PO單號"; //Dt.Columns[11].ColumnName = "訂單日期 "; //Dt.Columns[12].ColumnName = "流水編號"; //Dt.Columns[13].ColumnName = "訂單編號"; //Dt.Columns[14].ColumnName = "營業專員名稱"; //Dt.Columns[15].ColumnName = "訂單量"; //Dt.Columns[16].ColumnName = "進貨日"; #endregion EOT = ReportList.ExcelOtherType.None; } return Dt; }
/// <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(); }
/// <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; }
/// <summary> /// BUTTON [列印] /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_Print_Click(object sender, EventArgs e) { try { #region 頁面狀態檢查 2009-06-25 cyhsu add this.Page.Validate(); if (!Page.IsValid) { return; } this.Page.Validate("Validate"); if (!Page.IsValid) { return; } #endregion #region 檢查條件 string s_CheckPage = CheckPage(sender); if (s_CheckPage != string.Empty) { ClientScript.RegisterClientScriptBlock(this.GetType(), "CRM151", "<script>alert('" + s_CheckPage + "');</script>"); return; } #endregion #region 設定 hid_PageStauts 狀態 this.hid_PageStauts.Value = "open"; #endregion #region 清空 show_Report 的 Session Session["Rpt_Data_Detl" + PageTimeStamp.Value] = null; Session["Rpt_Data_Gather" + PageTimeStamp.Value] = null; #endregion #region 傳入參數 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"); ArrayList ParameterList = new ArrayList();//20091117 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(txt_BUSDATE_B.Text, "date", false)); ParameterList.Add(GetValueSetParameter(txt_BUSDATE_E.Text, "date", false)); ParameterList.Add(GetValueSetParameter(this.slp_CHAN_NO.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_STORE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_ITEM.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_Z_O_B.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_Z_O_E.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_MANUFACTURE_B.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_MANUFACTURE_E.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.rdb_OUT_OF_STOCK_DAY.SelectedValue, "string", false)); ParameterList.Add(Session["UID"].ToString()); #endregion #region 取得資料 BCO.QueryCRMOrderOutOfStockReport bco = new BCO.QueryCRMOrderOutOfStockReport(ConntionDB); DataTable dt_Result = new DataTable(); if (this.rdb_Report_Status.SelectedValue == "0")//明細表 { dt_Result = bco.PrintDetail(ParameterList); Session["Rpt_Data_Detl" + PageTimeStamp.Value] = dt_Result; } else if (this.rdb_Report_Status.SelectedValue == "1")//彙總表 { dt_Result = bco.PrintSum(ParameterList); Session["Rpt_Data_Gather" + PageTimeStamp.Value] = dt_Result; } if (dt_Result.Rows.Count == 0) { this.CryView.ReportSource = null; ClientScript.RegisterClientScriptBlock(this.GetType(), "CRM151", "<script>alert('查無資料');</script>"); return; } #endregion #region CrystalReport列印報表 //Show_Report(dt_Result); Show_Report2(dt_Result); #endregion #region 設定 hid_PageStauts 狀態 // this.hid_PageStauts.Value = "close";//代表程式完整執行完成 #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { #region 設定頁面狀態 string s_ScriptManager_Script = @" Set_Print_PageStatus ( '" + this.PanelQuery.ClientID + @"', '" + this.but_Print.ClientID + @"', '" + this.but_Close.ClientID + @"', '" + this.hid_PageStauts.Value + @"' ); "; ScriptManager.RegisterStartupScript(this.up_ErrorMsg, typeof(UpdatePanel), "CRM151", s_ScriptManager_Script, true); #endregion } }
/// <summary> /// BUTTON [匯出] /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_Out_Click(object sender, EventArgs e) { try { #region 檢查欄位正確性 this.Page.Validate(); if (!Page.IsValid) { return; } this.Page.Validate("Validate"); if (!Page.IsValid) { return; } #endregion #region 檢查條件 string s_CheckPage = CheckPage(sender); if (s_CheckPage != string.Empty) { ClientScript.RegisterClientScriptBlock(this.GetType(), "CRM151", "<script>alert('" + s_CheckPage + "');</script>"); return; } #endregion #region 傳入參數 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"); ArrayList ParameterList = new ArrayList();//20091117 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(txt_BUSDATE_B.Text, "date", false)); ParameterList.Add(GetValueSetParameter(txt_BUSDATE_E.Text, "date", false)); ParameterList.Add(GetValueSetParameter(this.slp_CHAN_NO.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_STORE.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_ITEM.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_Z_O_B.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_Z_O_E.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_MANUFACTURE_B.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.slp_MANUFACTURE_E.Text, "string", false)); ParameterList.Add(GetValueSetParameter(this.rdb_OUT_OF_STOCK_DAY.SelectedValue, "string", false)); ParameterList.Add(Session["UID"].ToString()); #endregion #region 取得資料 BCO.QueryCRMOrderOutOfStockReport bco = new BCO.QueryCRMOrderOutOfStockReport(ConntionDB); DataTable dt_Result = new DataTable(); if (this.rdb_Report_Status.SelectedValue == "0")//明細表 { dt_Result = bco.Export(ParameterList); } else if (this.rdb_Report_Status.SelectedValue == "1")//彙總表 { throw new Exception("匯出無匯總表功能"); } if (dt_Result.Rows.Count == 0) { this.CryView.ReportSource = null; ClientScript.RegisterClientScriptBlock(this.GetType(), "CRM151", "<script>alert('查無資料');</script>"); return; } #endregion #region CrystalReport匯出Excel string s_FileName = HttpUtility.UrlEncode(this.txt_Out_FileName.Text, System.Text.Encoding.UTF8); string s_rptFilePath = Server.MapPath("./REPORT/CRM151/CRM151_Excel_Detl.rpt"); LoadCrystalReport(s_FileName, s_rptFilePath, dt_Result); #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { #region 設定頁面狀態 string s_ScriptManager_Script = @" Set_Print_PageStatus ( '" + this.PanelQuery.ClientID + @"', '" + this.but_Print.ClientID + @"', '" + this.but_Close.ClientID + @"', '" + this.hid_PageStauts.Value + @"' ); "; ScriptManager.RegisterStartupScript(this.up_ErrorMsg, typeof(UpdatePanel), "CRM151", s_ScriptManager_Script, true); #endregion } }
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(); }