/// <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> /// 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 } }