本文整理汇总了C#中CrystalDecisions.CrystalReports.Engine.ReportDocument.Close方法的典型用法代码示例。如果您正苦于以下问题:C# ReportDocument.Close方法的具体用法?C# ReportDocument.Close怎么用?C# ReportDocument.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrystalDecisions.CrystalReports.Engine.ReportDocument
的用法示例。
在下文中一共展示了ReportDocument.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowReport
/// <summary>
/// 報表列印
/// </summary>
/// <param name="dt"></param>
/// <param name="strPRINT_TYPE"></param>
private void ShowReport(DataTable dt, string strPRINT_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
string strFileName = "";
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(Server.MapPath("./REPORT/CAM14/CAM14R01.rpt"));
strFileName = HttpUtility.UrlEncode("折讓單無法開立明細表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
report.SetDataSource(dt);
report.SetParameterValue("par_Program_ID", "CAM14R01");
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
report.SetParameterValue("par_GROUP_NO", slp_GROUP_NO_S.Text + Request[((TextBox)slp_GROUP_NO_S.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", "") + (string.IsNullOrEmpty(slp_GROUP_NO_S.Text) ? "" : "~") + slp_GROUP_NO_E.Text + Request[((TextBox)slp_GROUP_NO_E.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_PAY_RFNO", txtPAY_RFNO.Text);
report.SetParameterValue("par_RFNO", txtRFNO.Text);
report.SetParameterValue("par_STORE", slp_STORE.Text + Request[((TextBox)slp_STORE.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_ROOTNO", SLP_RootNo.Text + Request[((TextBox)SLP_RootNo.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_SETTLE_TYPE", rdoPAY_TYPE1.Checked ? "一般" : (rdoPAY_TYPE2.Checked ? "關店" : "虛擬店"));
System.IO.Stream stream = null;
byte[] b = null;
stream = (strPRINT_TYPE == "PDF" ? report.ExportToStream(ExportFormatType.PortableDocFormat) : report.ExportToStream(ExportFormatType.Excel));
b = new byte[stream.Length];
stream.Read(b, 0, b.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);
Response.ContentType = (strPRINT_TYPE == "PDF" ? "application/pdf" : "application/vnd.ms-excel");
Response.OutputStream.Write(b, 0, b.Length);
Response.Flush();
Response.Close();
report.Close();
stream.Close();
#endregion
}
示例2: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
/// /// <param name="reportFormatType">檔案型態</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, string reportFormatType)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
string par_ChanNo = string.Empty;
string par_Store = string.Empty;
#region 前置檢查與參數過濾
par_ChanNo = Server.UrlDecode(Request.QueryString["Chan"].ToString());
par_Store = Server.UrlDecode(Request.QueryString["Store"].ToString());
#endregion
#region 組合查詢條件至ArrayList
ArrayList returnList = new ArrayList();
returnList.Clear();
report.SetParameterValue("ChanNo", par_ChanNo);
report.SetParameterValue("Store", par_Store);
#endregion
//判斷輸出檔案型態
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();
report.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();
report.Close();
break;
default:
break;
}
}
示例3: ShowReportA
//.........这里部分代码省略.........
if (((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text == "ALL")
report.SetParameterValue("par_Tax_Type_B", "全部");
else
report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
//report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
}
else if (V_RPT == "VAM123R")
{
FileName = "進項憑證明細表(發票與折讓)";
report.SetParameterValue("par_Program_ID", V_RPT);
report.SetParameterValue("par_Program_ID_B", V_RPT);
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
report.SetParameterValue("par_LoginUser_B", Session["UID"].ToString() + Login_Name);
if (this.SLP_SLPDateRange.StartDate.ToString() == "" && this.SLP_SLPDateRange.EndDate.ToString() == "")
{
report.SetParameterValue("par_Source_date", "全部");
report.SetParameterValue("par_Source_date_B", "全部");
}
else
{
report.SetParameterValue("par_Source_date", this.SLP_SLPDateRange.StartDate.ToString() + "-" + this.SLP_SLPDateRange.EndDate.ToString());
report.SetParameterValue("par_Source_date_B", this.SLP_SLPDateRange.StartDate.ToString() + "-" + this.SLP_SLPDateRange.EndDate.ToString());
}
if (this.SLP_SLPDateRange1.StartDate.ToString() == "" && this.SLP_SLPDateRange1.EndDate.ToString() == "")
{
report.SetParameterValue("par_Keyin_date", "全部");
report.SetParameterValue("par_Keyin_date_B", "全部");
}
else
{
report.SetParameterValue("par_Keyin_date", this.SLP_SLPDateRange1.StartDate.ToString() + "-" + this.SLP_SLPDateRange1.EndDate.ToString());
report.SetParameterValue("par_Keyin_date_B", this.SLP_SLPDateRange1.StartDate.ToString() + "-" + this.SLP_SLPDateRange1.EndDate.ToString());
}
if (this.SLP_VendorBase1.Text.Trim() == "" && this.SLP_VendorBase2.Text.Trim() == "")
{
report.SetParameterValue("par_Vandor", "全部");
report.SetParameterValue("par_Vandor_B", "全部");
}
else
{
report.SetParameterValue("par_Vandor", this.SLP_VendorBase1.Text.Trim() + "-" + this.SLP_VendorBase2.Text.Trim());
report.SetParameterValue("par_Vandor_B", this.SLP_VendorBase1.Text.Trim() + "-" + this.SLP_VendorBase2.Text.Trim());
}
if (((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text == "ALL")
{
report.SetParameterValue("par_Tax_Type", "全部");
report.SetParameterValue("par_Tax_Type_B", "全部");
}
else
{
report.SetParameterValue("par_Tax_Type", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
report.SetParameterValue("par_Tax_Type_B", ((DropDownList)this.SLP_EnumBase.FindControl("D1")).SelectedItem.Text);
}
}
//檔案匯出
if (V_FORM_TYPE == "XLS")
{
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=" + HttpUtility.UrlEncode(FileName + ".XLS", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/xls";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
}
else
{
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=" + HttpUtility.UrlEncode(FileName + ".PDF", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
}
report.Close();
#endregion
}
示例4: ShowReportA
private void ShowReportA(DataTable dtA, DataTable dtB, string V_FORM_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(Server.MapPath("./REPORT/VAM051/VAM052R01.rpt"));
DataSet ds = new DataSet();
dtA.TableName = "VAM052_R1";
ds.Tables.Add(dtA.Copy());
dtB.TableName = "VAM052_R2";
ds.Tables.Add(dtB.Copy());
report.SetDataSource(ds);
report.SetParameterValue("par_Count", Convert.ToString(dtA.Rows.Count + dtB.Rows.Count));
if (this.hidTYPE.Value == "1")
{
report.SetParameterValue("par_Program_ID", "註記解除");
report.SetParameterValue("par_YM", this.Label7.Text);
report.SetParameterValue("par_Source_date", "註記解除日期/時間:" + System.DateTime.Now.ToLongDateString());
report.SetParameterValue("par_LoginName", "註記解除人員:" + Session["UID"].ToString() + Login_Name);
}
else
{
report.SetParameterValue("par_Program_ID", "註記確認");
report.SetParameterValue("par_YM", this.SLP_YearMonth1.Text);
report.SetParameterValue("par_Source_date", "註記日期/時間:" + System.DateTime.Now.ToLongDateString());
report.SetParameterValue("par_LoginName", "註記人員:" + Session["UID"].ToString() + Login_Name);
}
//檔案匯出
if (V_FORM_TYPE == "XLS")
{
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=" + HttpUtility.UrlEncode("供應商單品結帳.XLS", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/xls";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
}
else
{
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=" + HttpUtility.UrlEncode("供應商單品結帳.PDF", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
}
report.Close();
#endregion
}
示例5: ExportReport
//Crystal Report 直接輸出 PDF 檔
private void ExportReport(DataTable dt)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(Server.MapPath("./REPORT/CGR021R01.rpt"));
report.SetDataSource(dt);
//CrystalReport Parameter 參數設定
string Program_ID = string.Empty;
string LoginUser = string.Empty;
Program_ID = this.PageCode.Substring(0, 5) + "R01";
LoginUser = Session["UID"].ToString();
report.SetParameterValue("par_Program_ID", this.PageCode);
report.SetParameterValue("par_LoginUser", LoginUser);
//檔案匯出
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=" + HttpUtility.UrlEncode("退貨結轉檢核異常報表.PDF", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/pdf";
Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length);
Response.Flush();
Response.Close();
report.Close();
}
示例6: LoadCrystalReport
//.........这里部分代码省略.........
{
s_par_Route_S = "";
}
if (((TextBox)SLP_Route_E.FindControl("TextBoxCode")).Text != "")
{
s_par_Route_E = ((TextBox)SLP_Route_E.FindControl("TextBoxCode")).Text + " " + Request[SLP_Route_E.TextBox_Name.UniqueID].ToString();
}
else
{
s_par_Route_E = "";
}
if (((TextBox)SLP_StoreChain_S.FindControl("TextBoxCode")).Text != "")
{
s_par_StoreChain_S = ((TextBox)SLP_StoreChain_S.FindControl("TextBoxCode")).Text + " " + Request[SLP_StoreChain_S.TextBox_Name.UniqueID].ToString();
}
else
{
s_par_StoreChain_S = "";
}
if (((TextBox)SLP_StoreChain_E.FindControl("TextBoxCode")).Text != "")
{
s_par_StoreChain_E = ((TextBox)SLP_StoreChain_E.FindControl("TextBoxCode")).Text + " " + Request[SLP_StoreChain_E.TextBox_Name.UniqueID].ToString();
}
else
{
s_par_StoreChain_E = "";
}
s_par_Report = rblPrintType.SelectedItem.Text;
#endregion
report.SetParameterValue("par_Program_ID", s_par_Program_ID);
report.SetParameterValue("par_LoginUser", s_par_LoginUser);
report.SetParameterValue("par_ST_Accept_Date", s_par_ST_Accept_Date);
report.SetParameterValue("par_Trans_No", s_par_Trans_No_S + " ~ " + s_par_Trans_No_E);
report.SetParameterValue("par_Trans_Vendor", s_par_Trans_Vendor_S + " ~ " + s_par_Trans_Vendor_E);
report.SetParameterValue("par_Routee", s_par_Route_S + " ~ " + s_par_Route_E);
report.SetParameterValue("par_StoreChain", s_par_StoreChain_S + " ~ " + s_par_StoreChain_E);
report.SetParameterValue("par_Report", s_par_Report);
#region 判斷輸出檔案型態並輸出
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;
#endregion
}
report.Close();
}
示例7: LoadCrystalReport
/// <summary>
/// 利用 CrystalReport 列印 Excel 報表
/// </summary>
/// <param name="s_FileName">Excel報表的檔名</param>
/// <param name="s_rptFilePath">rpt檔的路徑</param>
/// <param name="dt_Source">要列印的資料</param>
private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source)
{
if (s_FileName.ToLower().IndexOf(".xls") < 0)
{
s_FileName = s_FileName + ".xls";
}
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(s_rptFilePath);
report.SetDataSource(dt_Source);
System.IO.Stream stream = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
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();
}
示例8: ShowReport
/// <summary>
/// 顯示報表
/// </summary>
private void ShowReport(DataTable dt, string strPRINT_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
string strFileName = "";
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (this.rdoRPT_TYPE.SelectedIndex == 1)
{
report.Load(Server.MapPath("./REPORT/CAM30/CAM30R01.rpt"));
strFileName = HttpUtility.UrlEncode("CAM30R01_帳差統計匯總表_結算匯總." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
else
{
report.Load(Server.MapPath("./REPORT/CAM30/CAM30R02.rpt"));
strFileName = HttpUtility.UrlEncode("CAM30R02_帳差統計明細表_結算明細." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
report.SetDataSource(dt);
report.SetParameterValue("par_Program_ID", rdoRPT_TYPE.SelectedIndex == 1 ? "CAM30R01" : "CAM30R02");
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
report.SetParameterValue("par_Group", slp_GROUP_NO_S.Text + ((TextBox)slp_GROUP_NO_S.FindControl("TextBoxName")).Text.Replace("查無資料", "") + (string.IsNullOrEmpty(slp_GROUP_NO_S.Text) ? "" : "~") + slp_GROUP_NO_E.Text + ((TextBox)slp_GROUP_NO_E.FindControl("TextBoxName")).Text.Replace("查無資料", ""));
report.SetParameterValue("par_Store", slp_STORE.Text + ((TextBox)slp_STORE.FindControl("TextBoxName")).Text.Replace("查無資料", ""));
report.SetParameterValue("par_RootNo", slp_ROOT_NO.Text + ((TextBox)slp_ROOT_NO.FindControl("TextBoxName")).Text.Replace("查無資料", ""));
report.SetParameterValue("par_acDate", slp_ACCT_MONTH_S.Text + (string.IsNullOrEmpty(slp_ACCT_MONTH_S.Text) ? "" : "~") + slp_ACCT_MONTH_E.Text);
report.SetParameterValue("pay_payRfno", txtPAY_RFNO.Text);
report.SetParameterValue("pay_rfno", txtRFNO.Text);
report.SetParameterValue("par_profit", slp_PROFIT_CENTER_S.Text + ((TextBox)slp_PROFIT_CENTER_S.FindControl("TextBoxName")).Text.Replace("查無資料", "") + (string.IsNullOrEmpty(slp_PROFIT_CENTER_S.Text) ? "" : "~") + slp_PROFIT_CENTER_E.Text + ((TextBox)slp_PROFIT_CENTER_E.FindControl("TextBoxName")).Text.Replace("查無資料", ""));
if (slp_TAX_TYPE.Text == "0")
{
report.SetParameterValue("par_TaxType", "應稅");
}
else if (slp_TAX_TYPE.Text == "1")
{
report.SetParameterValue("par_TaxType", "免稅");
}
else if (slp_TAX_TYPE.Text == "2")
{
report.SetParameterValue("par_TaxType", "零稅");
}
else
{
report.SetParameterValue("par_TaxType", "");
}
System.IO.Stream stream = null;
byte[] b = null;
stream = (strPRINT_TYPE == "PDF" ? report.ExportToStream(ExportFormatType.PortableDocFormat) : report.ExportToStream(ExportFormatType.Excel));
b = new byte[stream.Length];
stream.Read(b, 0, b.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);
Response.ContentType = (strPRINT_TYPE == "PDF" ? "application/pdf" : "application/vnd.ms-excel");
Response.OutputStream.Write(b, 0, b.Length);
Response.Flush();
Response.Close();
report.Close();
#endregion
}
示例9: LoadCrystalReport
//.........这里部分代码省略.........
}
}
report.SetDataSource(dtResult);
DataTable dtMainData = BCOVGR.GetPrintRpt01Main(Request.QueryString["ID"].ToString());
if (dtMainData.Rows.Count > 0)
{
report.SetParameterValue("paraBusiness_Contact1", dtMainData.Rows[0]["Business_Contact"].ToString());
report.SetParameterValue("paraBusiness_Fax", dtMainData.Rows[0]["Business_Fax"].ToString());
report.SetParameterValue("paraReturn_Date", dtMainData.Rows[0]["Return_Date"].ToString());
report.SetParameterValue("paraVendor_Name", dtMainData.Rows[0]["Vendor_Name"].ToString());
report.SetParameterValue("paraVendor", dtMainData.Rows[0]["Vendor"].ToString());
report.SetParameterValue("paraReturn_No", dtMainData.Rows[0]["Return_No"].ToString());
report.SetParameterValue("paraTax_Total_Amt", dtMainData.Rows[0]["Tax_Total_Amt"].ToString());
report.SetParameterValue("paraUnTax_Total_Amt", dtMainData.Rows[0]["UnTax_Total_Amt"].ToString());
report.SetParameterValue("paraTax_Amt", dtMainData.Rows[0]["Tax_Amt"].ToString());
//ParameterFields par1 = new ParameterFields();
//AddParameter("paraBusiness_Contact1", dtMainData.Rows[0]["Business_Contact1"].ToString(), par1);
//ParameterFields par2 = new ParameterFields();
//AddParameter("paraBusiness_Fax", dtMainData.Rows[0]["Business_Fax"].ToString(), par2);
//ParameterFields par3 = new ParameterFields();
//AddParameter("paraReturn_Date", dtMainData.Rows[0]["Return_Date"].ToString(), par3);
//ParameterFields par4 = new ParameterFields();
//AddParameter("paraVendor_Name", dtMainData.Rows[0]["Vendor_Name"].ToString(), par4);
//ParameterFields par5 = new ParameterFields();
//AddParameter("paraVendor", dtMainData.Rows[0]["Vendor"].ToString(), par5);
//ParameterFields par6 = new ParameterFields();
//AddParameter("paraReturn_No", dtMainData.Rows[0]["Return_No"].ToString(), par6);
//ParameterFields par7 = new ParameterFields();
//AddParameter("paraTax_Total_Amt", dtMainData.Rows[0]["Tax_Total_Amt"].ToString(), par7);
//ParameterFields par8 = new ParameterFields();
//AddParameter("paraUnTax_Total_Amt", dtMainData.Rows[0]["UnTax_Total_Amt"].ToString(), par8);
//ParameterFields par9 = new ParameterFields();
//AddParameter("paraTax_Amt", dtMainData.Rows[0]["Tax_Amt"].ToString(), par9);
}
else
{
string strErr = "查無資料";
this.ErrorMsgLabel.Text = strErr;
return;
}
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;
}
}
示例10: ShowReport1
/// <summary>
/// 顯示報表
/// </summary>
private void ShowReport1(DataTable dt, string strPRINT_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
string strFileName = "";
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (this.rdoRPT_TYPE1.SelectedIndex == 0)
{
report.Load(Server.MapPath("./REPORT/CAM30/CAM30R06.rpt"));
strFileName = HttpUtility.UrlEncode("CAM30R06_PAY累計報表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
else if (this.rdoRPT_TYPE1.SelectedIndex == 1)
{
report.Load(Server.MapPath("./REPORT/CAM30/CAM30R07.rpt"));
strFileName = HttpUtility.UrlEncode("CAM30R07_PAY帳差明細表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
else if (this.rdoRPT_TYPE1.SelectedIndex == 2)
{
report.Load(Server.MapPath("./REPORT/CAM30/CAM30R05.rpt"));
strFileName = HttpUtility.UrlEncode("CAM30R05_平日驗收帳差明細表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
else if (this.rdoRPT_TYPE1.SelectedIndex == 3)
{
report.Load(Server.MapPath("./REPORT/CAM30/CAM30R09.rpt"));
strFileName = HttpUtility.UrlEncode("CAM30R09_通路單號彙總表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
report.SetDataSource(dt);
if (this.rdoRPT_TYPE1.SelectedIndex == 0)
{
report.SetParameterValue("par_Program_ID", "CAM30R06");
}
else if (this.rdoRPT_TYPE1.SelectedIndex == 1)
{
report.SetParameterValue("par_Program_ID", "CAM30R07");
}
else if (this.rdoRPT_TYPE1.SelectedIndex == 2)
{
report.SetParameterValue("par_Program_ID", "CAM30R05");
}
else if (this.rdoRPT_TYPE1.SelectedIndex == 3)
{
report.SetParameterValue("par_Program_ID", "CAM30R09");
}
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
report.SetParameterValue("par_Group", slp_GROUP_NO_S1.Text + Request[((TextBox)slp_GROUP_NO_S1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", "") + (string.IsNullOrEmpty(slp_GROUP_NO_S1.Text) ? "" : "~") + slp_GROUP_NO_E1.Text + Request[((TextBox)slp_GROUP_NO_E1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_Store", slp_STORE1.Text + Request[((TextBox)slp_STORE1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_sellDate", slp_BUS_DATE.StartDate + (string.IsNullOrEmpty(slp_BUS_DATE.StartDate) ? "" : "~") + slp_BUS_DATE.EndDate);
report.SetParameterValue("par_acDate", slp_BUS_YM.Text);
report.SetParameterValue("par_chanSourceNo", txtCHAN_SOURCE_NO.Text);
report.SetParameterValue("par_source", chkSTAKind.Items[0].Selected && chkSTAKind.Items[1].Selected ? "進貨/退貨" : (chkSTAKind.Items[0].Selected ? "進貨" : "退貨"));
report.SetParameterValue("par_reportType", rdoRPT_DATA.SelectedItem.Text);
report.SetParameterValue("par_Pay_Month", SLP_PAY_MONTH_S.Text + (string.IsNullOrEmpty(SLP_PAY_MONTH_S.Text) ? "" : "~") + SLP_PAY_MONTH_E.Text);
System.IO.Stream stream = null;
byte[] b = null;
stream = (strPRINT_TYPE == "PDF" ? report.ExportToStream(ExportFormatType.PortableDocFormat) : report.ExportToStream(ExportFormatType.Excel));
b = new byte[stream.Length];
stream.Read(b, 0, b.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);
Response.ContentType = (strPRINT_TYPE == "PDF" ? "application/pdf" : "application/vnd.ms-excel");
Response.OutputStream.Write(b, 0, b.Length);
Response.Flush();
Response.Close();
report.Close();
#endregion
}
示例11: ShowReport2
private void ShowReport2(DataTable dt, string strPRINT_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
string strFileName = "";
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (this.rbtTAB3_RPT_TYPE.SelectedValue == "0")
{
report.Load(Server.MapPath("./REPORT/CAM30/CAM30R08.rpt"));
strFileName = HttpUtility.UrlEncode("CAM30R08_單品帳差彚總表(品項)." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
report.SetDataSource(dt);
if (this.rbtTAB3_RPT_TYPE.SelectedIndex == 0)
{
report.SetParameterValue("par_Program_ID", "CAM30R08");
}
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
string strCloseYM = string.Empty;
if (slpTAB3_CloseYM_B.Text != "")
strCloseYM = slpTAB3_CloseYM_B.Text + " ~ " + slpTAB3_CloseYM_E.Text;
string strPayDate = string.Empty;
if (slpTAB3_PayDate.StartDate != "")
strPayDate = slpTAB3_PayDate.StartDate + " ~ " + slpTAB3_PayDate.EndDate;
string strSignDate = string.Empty;
if (slpTAB3_SignDate.StartDate != "")
strSignDate = slpTAB3_SignDate.StartDate + " ~ " + slpTAB3_SignDate.EndDate;
string strStoreGroup = string.Empty;
if (slpTAB3_StoreGroup_B.Text != "")
strStoreGroup = slpTAB3_StoreGroup_B.Text + " ~ " + slpTAB3_StoreGroup_E.Text;
string strChanNo = string.Empty;
if (slpTAB3_CHAN_NO_B.Text != "")
strChanNo = slpTAB3_CHAN_NO_B.Text + " ~ " + slpTAB3_CHAN_NO_E.Text;
string strStore = string.Empty;
if (slpTAB3_STORE_B.Text != "")
strStore = slpTAB3_STORE_B.Text + " ~ " + slpTAB3_STORE_E.Text;
string strRFNO = string.Empty;
if (txtTAB3_RFNO_B.Text != "")
strRFNO = txtTAB3_RFNO_B.Text + " ~ " + txtTAB3_RFNO_E.Text;
string strRoot = "ALL";
if (rbtTAB3_Root.SelectedValue == "1")
strRoot = "雜誌";
else if (rbtTAB3_Root.SelectedValue == "2")
strRoot = "圖書";
string strSTAKIND = string.Empty;
if (chkTAB3_STAKIND.Items[0].Selected == true)
strSTAKIND = "進貨";
if (chkTAB3_STAKIND.Items[1].Selected == true)
{
if (strSTAKIND != "")
strSTAKIND += "/";
strSTAKIND += "退貨";
}
if (chkTAB3_STAKIND.Items[2].Selected == true)
{
if (strSTAKIND != "")
strSTAKIND += "/";
strSTAKIND += "補帳";
}
if (chkTAB3_STAKIND.Items[3].Selected == true)
{
if (strSTAKIND != "")
strSTAKIND += "/";
strSTAKIND += "調撥";
}
string strTAXTYPE = string.Empty;
if (rbtTAB3_TAX_TYPE.SelectedValue == "")
strTAXTYPE = "ALL";
else if (rbtTAB3_TAX_TYPE.SelectedValue == "0")
strTAXTYPE = "應稅";
else if (rbtTAB3_TAX_TYPE.SelectedValue == "1")
strTAXTYPE = "免稅";
else
strTAXTYPE = "X";
string strITEM = string.Empty;
if (slpTAB3_ITEM_B.Text != "")
strITEM = slpTAB3_ITEM_B.Text + " ~ " + slpTAB3_ITEM_E.Text;
string strPERIOD = string.Empty;
//.........这里部分代码省略.........
示例12: ShowReport
/// <summary>
/// 顯示報表
/// </summary>
private void ShowReport(DataTable dt, string strPRINT_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
string strFileName = "";
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (rdoREPORT_KIND1.SelectedIndex == 0)//供應商
{
if (rdoREPORT_KIND2.SelectedIndex == 0)//彙總
{
report.Load(Server.MapPath("./REPORT/CAM29/CAM29R01.rpt"));
report.SetDataSource(dt);
report.SetParameterValue("par_Program_ID", "CAM29R01");
strFileName = HttpUtility.UrlEncode("CAM29R01_檔期供應商彙總表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
else//明細
{
report.Load(Server.MapPath("./REPORT/CAM29/CAM29R03.rpt"));
report.SetDataSource(dt);
report.SetParameterValue("par_Program_ID", "CAM29R03");
strFileName = HttpUtility.UrlEncode("CAM29R03_檔期供應商明細表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
}
else if (rdoREPORT_KIND1.SelectedIndex == 1)//門市
{
report.Load(Server.MapPath("./REPORT/CAM29/CAM29R02.rpt"));
report.SetDataSource(dt);
report.SetParameterValue("par_Program_ID", "CAM29R02");
strFileName = HttpUtility.UrlEncode("CAM29R02_檔期門市明細表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
else if (rdoREPORT_KIND1.SelectedIndex == 2)//成本
{
report.Load(Server.MapPath("./REPORT/CAM29/CAM29R04.rpt"));
report.SetDataSource(dt);
report.SetParameterValue("par_Program_ID", "CAM29R04");
strFileName = HttpUtility.UrlEncode("CAM29R04_檔期門市彙總表-成本." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
else if (rdoREPORT_KIND1.SelectedIndex == 3)//特殊書展
{
report.Load(Server.MapPath("./REPORT/CAM29/CAM29R05.rpt"));
report.SetDataSource(dt);
report.SetParameterValue("par_Program_ID", "CAM29R05");
strFileName = HttpUtility.UrlEncode("CAM29R05_檔期特殊書展表." + strPRINT_TYPE, System.Text.Encoding.UTF8);
}
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
report.SetParameterValue("par_GROUP_NO", slp_GROUP_NO_S.Text + " " + Request[((TextBox)slp_GROUP_NO_S.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", "") + (string.IsNullOrEmpty(slp_GROUP_NO_S.Text) ? "" : "~") + slp_GROUP_NO_E.Text + " " + Request[((TextBox)slp_GROUP_NO_E.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_VENDER", slp_MANUFACTURE.Text + " " + Request[((TextBox)slp_MANUFACTURE.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_STORE", slp_STORE.Text + " " + Request[((TextBox)slp_STORE.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_SETTLE_YM", slp_AC_BALANCE_DATE_S.Text + " " + (string.IsNullOrEmpty(slp_AC_BALANCE_DATE_S.Text) ? "" : "~") + slp_AC_BALANCE_DATE_E.Text);
report.SetParameterValue("par_SIGN_DATE", slp_SIGN_DATE.StartDate + (string.IsNullOrEmpty(slp_SIGN_DATE.StartDate) ? "" : " ~ ") + slp_SIGN_DATE.EndDate);
report.SetParameterValue("par_BUS_DATE", slp_BUS_DATE.StartDate + (string.IsNullOrEmpty(slp_BUS_DATE.StartDate) ? "" : " ~ ") + slp_BUS_DATE.EndDate);
report.SetParameterValue("par_PROMOTE_ID", txtPROMOTE_ID_S.Text + (string.IsNullOrEmpty(txtPROMOTE_ID_S.Text) ? "" : " ~ ") + txtPROMOTE_ID_E.Text);
report.SetParameterValue("par_AC_UID", slp_AC_UID.Text + " " + Request[((TextBox)slp_AC_UID.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
string strDISCOUNT_TYPE = string.Empty;
if (rdoDISCOUNT_TYPE.SelectedValue == "")
strDISCOUNT_TYPE = "全部";
else if (rdoDISCOUNT_TYPE.SelectedValue == "B")
strDISCOUNT_TYPE = "原折扣";
else if (rdoDISCOUNT_TYPE.SelectedValue == "A")
strDISCOUNT_TYPE = "促銷折扣";
report.SetParameterValue("par_DISCOUNT_TYPE", strDISCOUNT_TYPE);
report.SetParameterValue("par_Z_O", slp_Z_O_S.Text + " " + Request[slp_Z_O_S.TextBox_Name.UniqueID].ToString().Replace("查無資料", "") + (string.IsNullOrEmpty(slp_Z_O_S.Text) ? "" : " ~ ") + slp_Z_O_E.Text + " " + Request[slp_Z_O_E.TextBox_Name.UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_SAL_ID", slp_SAL_ID.Text + " " + Request[slp_SAL_ID.TextBox_Name.UniqueID].ToString().Replace("查無資料", ""));
string strVer = string.Empty;
if (rdoVer.SelectedValue == "0")
strVer = "新版";
else if (rdoVer.SelectedValue == "1")
strVer = "舊版";
report.SetParameterValue("par_VER", strVer);
System.IO.Stream stream = null;
byte[] b = null;
stream = (strPRINT_TYPE == "PDF" ? report.ExportToStream(ExportFormatType.PortableDocFormat) : report.ExportToStream(ExportFormatType.Excel));
b = new byte[stream.Length];
stream.Read(b, 0, b.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);
Response.ContentType = (strPRINT_TYPE == "PDF" ? "application/pdf" : "application/vnd.ms-excel");
Response.OutputStream.Write(b, 0, b.Length);
Response.Flush();
Response.Close();
report.Close();
#endregion
}
示例13: ShowReport
private void ShowReport(DataTable dt, string strRptName, string strPRINT_TYPE)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
string strFileName = "";
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
report.Load(Server.MapPath("./REPORT/CAM08/CAM08R" + strRptName + ".rpt"));
report.SetDataSource(dt);
switch (strRptName)
{
case "01":
strFileName = HttpUtility.UrlEncode("CAM08R01_銷貨月報表_彙總金額." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
case "02":
strFileName = HttpUtility.UrlEncode("CAM08R02_銷貨月報表_明細金額." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
case "05":
strFileName = HttpUtility.UrlEncode("CAM08R05_結算月報表_明細金額." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
case "06":
strFileName = HttpUtility.UrlEncode("CAM08R06_結算月報表_彙總金額." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
case "07":
strFileName = HttpUtility.UrlEncode("CAM08R07_銷貨月報表_彙總數量." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
case "08":
strFileName = HttpUtility.UrlEncode("CAM08R08_銷貨月報表_明細數量." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
case "11":
strFileName = HttpUtility.UrlEncode("CAM08R11_結算月報表_明細數量." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
case "12":
strFileName = HttpUtility.UrlEncode("CAM08R12_結算月報表_彙總數量." + strPRINT_TYPE, System.Text.Encoding.UTF8);
break;
}
report.SetParameterValue("par_Program_ID", "CAM08R" + strRptName);
report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name);
switch (strRptName)
{
case "01":
case "02":
case "07":
case "08":
report.SetParameterValue("par_Z_O", slp_Z_O.Text + Request[((TextBox)slp_Z_O.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_SAL_ID", slp_SAL_ID.Text + Request[((TextBox)slp_SAL_ID.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_GROUP_NO", slp_GROUP_NO_S.Text + Request[((TextBox)slp_GROUP_NO_S.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", "") + (string.IsNullOrEmpty(slp_GROUP_NO_S.Text) ? "" : "~") + slp_GROUP_NO_E.Text + Request[((TextBox)slp_GROUP_NO_E.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_PAY_RFNO", txtPAY_RFNO.Text);
report.SetParameterValue("par_RFNO", txtRFNO.Text);
report.SetParameterValue("par_STORE", slp_STORE.Text + Request[((TextBox)slp_STORE.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_ROOTNO", slp_ROOTNO.Text);
report.SetParameterValue("par_BUS_DATE", slp_BUS_DATE.StartDate + (string.IsNullOrEmpty(slp_BUS_DATE.StartDate) ? "" : "~") + slp_BUS_DATE.EndDate);
report.SetParameterValue("par_REPORT_TYPE", rdoREPORT_KIND1_1.SelectedItem.Text + "/" + rdoREPORT_KIND2_1.SelectedItem.Text);
break;
case "05":
case "06":
case "11":
case "12":
report.SetParameterValue("par_Z_O", slp_Z_O1.Text + Request[((TextBox)slp_Z_O1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_SAL_ID", slp_SAL_ID1.Text + Request[((TextBox)slp_SAL_ID1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_GROUP_NO", slp_GROUP_NO_S1.Text + Request[((TextBox)slp_GROUP_NO_S1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", "") + (string.IsNullOrEmpty(slp_GROUP_NO_S1.Text) ? "" : "~") + slp_GROUP_NO_E1.Text + Request[((TextBox)slp_GROUP_NO_E1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_PAY_RFNO", txtPAY_RFNO1.Text);
report.SetParameterValue("par_RFNO", txtRFNO1.Text);
report.SetParameterValue("par_STORE", slp_STORE1.Text + Request[((TextBox)slp_STORE1.FindControl("TextBoxName")).UniqueID].ToString().Replace("查無資料", ""));
report.SetParameterValue("par_ROOTNO", slp_ROOTNO1.Text);
report.SetParameterValue("par_BUS_DATE", slp_BUS_YM_S.Text + (string.IsNullOrEmpty(slp_BUS_YM_S.Text) ? "" : "~") + slp_BUS_YM_E.Text);
report.SetParameterValue("par_REPORT_TYPE", rdoREPORT_KIND1_2.SelectedItem.Text + "/" + rdoREPORT_KIND2_2.SelectedItem.Text);
report.SetParameterValue("par_AC_CLOSE", rdoAC_CLOSE.SelectedItem.Text);
report.SetParameterValue("par_ROLE", slp_ROLE.Text);
break;
}
System.IO.Stream stream = null;
byte[] b = null;
stream = (strPRINT_TYPE == "PDF" ? report.ExportToStream(ExportFormatType.PortableDocFormat) : report.ExportToStream(ExportFormatType.Excel));
b = new byte[stream.Length];
stream.Read(b, 0, b.Length);
stream.Seek(0, System.IO.SeekOrigin.Begin);
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + strFileName);
Response.ContentType = (strPRINT_TYPE == "PDF" ? "application/pdf" : "application/vnd.ms-excel");
Response.OutputStream.Write(b, 0, b.Length);
Response.Flush();
Response.Close();
report.Close();
#endregion
}
示例14: Show_Report2
/// <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();
}
示例15: ShowReportDB
private void ShowReportDB(DataTable dt, int iMaxTarget, int iMaxSubsidy)
{
#region 利用CrystalReport列印報表
//使用者名稱
DataTable dt1 = new DataTable();
dt1 = (DataTable)Session["UserInfo"];
string Login_Name = dt1.Rows[0]["Name"].ToString();
CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (this.rdoType4.Checked)
report.Load(Server.MapPath("./REPORT/VAM131/VAM131R04B.rpt"));
else
report.Load(Server.MapPath("./REPORT/VAM131/VAM131R05B.rpt"));
DataTable dtR = new DataTable();
dtR = this.MakeDTForRptD();
string[] arrField, arrField1;
arrField = new string[10] { "獎勵金一", "獎勵金二", "獎勵金三", "獎勵金四", "獎勵金五", "獎勵金六", "獎勵金七", "獎勵金八", "獎勵金九", "獎勵金十" };
arrField1 = new string[10] { "物流費一", "物流費二", "物流費三", "物流費四", "物流費五", "物流費六", "物流費七", "物流費八", "物流費九", "物流費十" };
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow drA = dtR.NewRow();
drA[0] = dt.Rows[i][0].ToString();
drA[1] = dt.Rows[i][1].ToString();
if (dt.Rows[i][2].ToString() != "")
{
if (this.rdoType4.Checked)
drA[2] = Convert.ToDateTime(dt.Rows[i][2].ToString()).ToShortDateString();
else
drA[2] = dt.Rows[i][2].ToString();
}
drA[3] = Convert.ToDecimal(dt.Rows[i][3].ToString());
drA[4] = Convert.ToDecimal(dt.Rows[i][4].ToString());
drA[5] = Convert.ToDecimal(dt.Rows[i][5].ToString());
drA[6] = Convert.ToDecimal(dt.Rows[i][6].ToString());
drA[7] = Convert.ToDecimal(dt.Rows[i][7].ToString());
for (int j = 0; j < iMaxTarget; j++)
{
drA[8 + j] = Convert.ToDecimal(dt.Rows[i][8 + j].ToString());
}
for (int k = 0; k < iMaxSubsidy; k++)
{
drA[8 + iMaxTarget + k] = Convert.ToDecimal(dt.Rows[i][18 + k].ToString());
}
drA[8 + iMaxTarget + iMaxSubsidy] = Convert.ToDecimal(dt.Rows[i][28].ToString());
for (int l = 29; l < 29 + iMaxTarget; l++)
{
if (dt.Rows[i][l].ToString() != "")
drA[l] = arrField[l - 29] + ":" + dt.Rows[i][l].ToString();
else
drA[l] = dt.Rows[i][l].ToString();
}
dtR.Rows.Add(drA);
}
report.SetDataSource(dtR);
for (int j = 0; j < iMaxTarget; j++)
{
report.SetParameterValue("par_Field" + Convert.ToString(9 + j), arrField[j]);
}
for (int j = 0; j < iMaxSubsidy; j++)
{
report.SetParameterValue("par_Field" + Convert.ToString(9 + iMaxTarget + j), arrField1[j]);
}
report.SetParameterValue("par_Field" + Convert.ToString(9 + iMaxTarget + iMaxSubsidy), "未稅金額");
for (int j = 0; j < 20 - (iMaxTarget + iMaxSubsidy); j++)
{
report.SetParameterValue("par_Field" + Convert.ToString(10 + iMaxTarget + iMaxSubsidy + j), "");
}
//this.CryView.ReportSource = report;
//檔案匯出
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=" + HttpUtility.UrlEncode("停止往來及合約追溯彙總表_" + System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + ".XLS", System.Text.Encoding.UTF8));//匯出檔名
Response.ContentType = "application/xls";
Response.OutputStream.Write(bytesXLS, 0, bytesXLS.Length);
Response.Flush();
Response.Close();
report.Close();
#endregion
}