/// <summary> /// CRM16_1報表(匯出鈕) /// </summary> /// <param name="ParameterList">變數清單</param> /// <param name="ReportOutputFormat">報表格式(PDF,EXCEL)</param> /// <param name="EOT">匯出Excel方式</param> /// <returns>回傳查詢結果</returns> public DataTable CRM16_1(ArrayList ParameterList, string ReportOutputFormat, ref ReportList.ExcelOtherType EOT ) { #region CRMModel.QueryCRMOrderReport BCO = new CRMModel.QueryCRMOrderReport(ConntionDB); //todo要判別模式 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 = "刊別"; //Dt.Columns[11].ColumnName = "進貨數量 "; //Dt.Columns[12].ColumnName = "退貨數量"; //Dt.Columns[13].ColumnName = "實銷數量"; //Dt.Columns[14].ColumnName = "進貨牌價"; //Dt.Columns[15].ColumnName = "退貨牌價"; //Dt.Columns[16].ColumnName = "時銷牌價"; //Dt.Columns[17].ColumnName = "進貨成本"; //Dt.Columns[18].ColumnName = "退貨成本"; //Dt.Columns[19].ColumnName = "時銷成本"; //Dt.Columns[20].ColumnName = "進貨零售價"; //Dt.Columns[21].ColumnName = "退貨零售價"; //Dt.Columns[22].ColumnName = "時銷零售價"; #endregion EOT = ReportList.ExcelOtherType.None; } return Dt; #endregion }
/// <summary> /// BUTTON [匯出]鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_Out_Click(object sender, EventArgs e) { try { #region 檢查Validate this.Page.Validate(); if (!this.Page.IsValid) { return; } this.Page.Validate("Validate"); if (!this.Page.IsValid) { return; } #endregion #region 檢查條件 string s_CheckPage = CheckPage(sender); if (s_CheckPage != string.Empty) { ClientScript.RegisterClientScriptBlock(this.GetType(), "CRM161", "<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.rdb_STATUS.SelectedValue, "string", 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(Session["UID"].ToString()); #endregion #region 取得資料 BCO.QueryCRMOrderReport bco = new BCO.QueryCRMOrderReport(ConntionDB); DataTable dt_Result = new DataTable(); dt_Result = bco.Export(ParameterList); if (dt_Result.Rows.Count == 0) { this.CryView.ReportSource = null; ClientScript.RegisterClientScriptBlock(this.GetType(), "CRM161", "<script>alert('查無資料');</script>"); return; } #endregion #region CrystalReport匯出Excel //2009-06-17 cyhsu 判斷檔名正確性 string s_OutFile = this.txt_Out_FileName.Text.Trim(); if (s_OutFile.ToLower().IndexOf(".xls") < 0) { s_OutFile = s_OutFile + ".xls"; } string s_FileName = HttpUtility.UrlEncode(s_OutFile, System.Text.Encoding.UTF8); string s_rptFilePath = Server.MapPath("./REPORT/CRM161/CRM161_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), "CRM161", s_ScriptManager_Script, true); #endregion } }