protected void Page_Init(object sender, System.EventArgs e) { try { string sPath = HttpContext.Current.Request.MapPath("~/Report\\"); //表示一个报表,并且包含定义、格式化、加载、导出和打印该报表的属性和方法。 CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); CrystalDecisions.Shared.ParameterDiscreteValue discreteVal = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterValues paraValues = new CrystalDecisions.Shared.ParameterValues(); //加载你事先做好的Crystal Report报表文件 Report.Load(sPath + Request.QueryString["ReportName"], CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy); string sData = PublicApi.fnGetConStr("MNDT").Replace(";", ","); // 設定報表內SQL Server資料庫的登入資訊 CrystalDecisions.Shared.TableLogOnInfo logonInfo = new CrystalDecisions.Shared.TableLogOnInfo(); foreach (CrystalDecisions.CrystalReports.Engine.Table table in Report.Database.Tables) { logonInfo = table.LogOnInfo; var _with1 = logonInfo.ConnectionInfo; _with1.ServerName = fnGetData(sData, "Data Source"); _with1.DatabaseName = fnGetData(sData, "Initial Catalog"); _with1.UserID = fnGetData(sData, "User ID"); _with1.Password = fnGetData(sData, "Password"); table.ApplyLogOnInfo(logonInfo); } Report.SetDataSource(Session["PrintDT"]); //Session["PrintDT"] = null; if (Report.ParameterFields["列印人員"] != null) { Report.SetParameterValue("列印人員", Session["sId"]); } if (Report.ParameterFields["進貨稅額"] != null) { string sSql = " SELECT [parameter] " + " FROM [mndtkind_details] " + " WHERE [kind_id] = 'TAX' " + " AND [code_id] = 'IN' "; Report.SetParameterValue("進貨稅額", PublicApi.fnGetValue(sSql, "MNDT")); } CrystalReportViewer1.PrintMode = CrystalDecisions.Web.PrintMode.ActiveX; //列印顯示列印選項,但只有IE會出現這功能 //Report.PrintToPrinter(1, true, 0, 0); // 直接列印 CrystalReportViewer1.ReportSource = Report; //CrystalReportViewer1.HasExportButton = false; //將匯出的功能False掉 //CrystalReportViewer1.HasPrintButton = false; //CrystalReportViewer1.HasToggleGroupTreeButton = false; //將樹狀結構的按鈕False掉 //CrystalReportViewer1.DisplayGroupTree = false; //將樹狀結構狀態False掉 } catch (Exception e1) { //Functions.fnMessageBox(e1.ToString(), this); } }
protected void Page_Load(object sender, EventArgs e) { CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(Server.MapPath(@"~/Sample.rpt")); report.SetParameterValue("start", bdpStart.SelectedDate.ToString("dd/MM/yyyy")); report.SetParameterValue("End", bdpEnd.SelectedDate.ToString("dd/MM/yyyy")); CrystalReportViewer1.ReportSource = report; }
public void ViewReport(CrystalDecisions.Windows.Forms.CrystalReportViewer CrViewer, string Reportname, string rsSelectionformula, string paraname1, string paraname2, string paraname3, string paraname4, string paraname5, string paravalue1, string paravalue2, string paravalue3, string paravalue4, string paravalue5, int SendToPrinter, Form frm) { rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string REPORTSPATH = Application.StartupPath + ConfigurationManager.AppSettings["ShareFolder"]; rpt.Load((REPORTSPATH + ("\\" + Reportname))); rpt.SetParameterValue(paraname1, paravalue1); rpt.SetParameterValue(paraname2, paravalue2); rpt.SetParameterValue(paraname3, paravalue3); rpt.SetParameterValue(paraname4, paravalue4); rpt.SetParameterValue(paraname5, paravalue5); // CrystalDecisions.CrystalReports.Engine.Table tdCurr; foreach (CrystalDecisions.CrystalReports.Engine.Table tdCurr in rpt.Database.Tables) { rptTLInfo = new CrystalDecisions.Shared.TableLogOnInfo(); rptTLInfo = tdCurr.LogOnInfo; // With... //SERVERNAME.Password = "******"; //dataBaseName.ServerName = "SA"; rptTLInfo.ConnectionInfo.DatabaseName = "IMS"; tdCurr.ApplyLogOnInfo(rptTLInfo); } rpt.SetDatabaseLogon("", "", ".", "IMS"); rpt.SummaryInfo.ReportAuthor = RptAuthor; if ((rsSelectionformula != "")) { rpt.RecordSelectionFormula = rsSelectionformula; } if ((SendToPrinter == 1)) { try { rpt.PrintToPrinter(1, true, 1, 1); } catch (Exception ex) { // MsgBox(ex.Message); } } else { //if (((Para1 == null) // == false)) { // CrViewer.ParameterFieldInfo = parameters; //} CrViewer.ReportSource = rpt; CrViewer.Refresh(); if ((frm.Tag != "ALL BILL REPORT")) { // frm.Show(); // SHOW_PLEASE_WAIT(false); } } }
private void PRO007RViewRC_Load(object sender, EventArgs e) { CrystalDecisions.CrystalReports.Engine.ReportDocument drPrint = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); DataRow oRow = dtPrint.Rows[0]; String sFile = ConfigurationManager.AppSettings["pathpdfRecibos"] + "RC-" + oRow["DOCV_Serie"] + "-" + oRow["DOCV_Numero"] + ".pdf"; try { drPrint.FileName = System.IO.Directory.GetCurrentDirectory() + "\\Reportes\\" + RptFile; drPrint.SetDataSource(dtPrint); for (int p = 0; p <= aParams.Count - 1; p++) { drPrint.SetParameterValue(p, aParams[p]); } if (!File.Exists(sFile)) { drPrint.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, sFile); SendMessage(sFile, oRow); } CrystalReportViewer.ReportSource = drPrint; } catch (Exception ex) { DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void PrintPreView() { var cmd = contxt.Database.Connection.CreateCommand(); //System.Data.Common.DataAdapter da = new System.Data.Common.DataAdapter(); string spName = ""; //var DataReport; if (partner.id == 0) { spName = "PartnerLedger " + dtMonth.Value.Month + ", -1"; //DataReport = contxt.Database.SqlQuery(spName,dtMonth.Value.Month, -1).ToList() } else { spName = "PartnerLedger " + dtMonth.Value.Month + ", " + contxt.SupplierMasters.FirstOrDefault(o => o.AddressBookId == partner.id); } cmd.CommandText = spName; //cmd.ExecuteReader(); contxt.Database.Connection.Open(); report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(ReportName); report.SetDataSource((IDataReader)cmd.ExecuteReader()); report.SetParameterValue("MonthName", String.Format("{0:MMM-yyyy}", dtMonth.Value)); crv.ParameterFieldInfo = new CrystalDecisions.Shared.ParameterFields(); foreach (CrystalDecisions.Shared.ParameterField fld in report.ParameterFields) { crv.ParameterFieldInfo.Add(fld); } crv.ReportSource = report; }
private string generatefiles(DataSet ds, DataTable dt1, string fromdate, string todate, string FirstPath, DataTable mailsetting) { try { DataView dv = new DataView(ds.Tables[0]); string strAttachFirst = string.Empty; string strAttachSecond = string.Empty; bool isSendData = false; System.Collections.ArrayList objList = new ArrayList(); objList.Add(MailSetting(mailsetting)); CrystalDecisions.CrystalReports.Engine.ReportDocument crystalReport; foreach (DataRow Row in dt1.Rows) { MailDetails objMails = new MailDetails(); dv.RowFilter = "SuperZoneID = " + Row["SuperZoneID"].ToString(); crystalReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); crystalReport.Load(Server.MapPath("../Report/MissingRecieptNo.rpt")); crystalReport.SetDataSource(dv.ToTable()); crystalReport.SetParameterValue("FromDP", Convert.ToDateTime(fromdate)); crystalReport.SetParameterValue("TODp", Convert.ToDateTime(todate)); isSendData = dv.ToTable().Rows.Count > 0 ? true : false; strAttachFirst = Server.MapPath(FirstPath + "MissingRecieptNo_" + Convert.ToDateTime(fromdate).ToString("dd-MMM-yyyy") + "_" + Convert.ToDateTime(todate).ToString("dd-MMM-yyyy") + "_" + Row["SuperZoneID"].ToString() + ".pdf"); crystalReport.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, strAttachFirst); crystalReport.Close(); crystalReport.Dispose(); crystalReport = null; objMails.Attachment = strAttachSecond != "" ? strAttachFirst + "," + strAttachSecond : strAttachFirst; objMails.Name = Row["SuperZoneName"].ToString(); objMails.EmailId = Row["Email"].ToString(); string makesubject = "Missing Receipts from " + Convert.ToDateTime(fromdate).ToString("dd-MMM-yyyy") + " TO " + Convert.ToDateTime(todate).ToString("dd-MMM-yyyy"); objMails.Subject = makesubject; objMails.Desc = makesubject; if (isSendData) { objList.Add(objMails); } objMails = null; } return(JsonConvert.SerializeObject(objList)); } catch (Exception ex) { throw; } }
public void GetReport() { try { string sReportHeading = ""; string sAmtInWords = ""; string sReportcomment = ""; string sReportInFile = ""; string strSQL = ""; sReportHeading = ""; if (SessionUserData.AppInfo.TempStrVariable_1 == "IGST") { sReportInFile = "GST_I_Invoice.rpt"; } else { sReportInFile = "GST_SU_Invoice.rpt"; } strSQL = " AAA_M_USP_Print_Invoice " + SessionUserData.Company.CompanyID + "," + SessionUserData.Company.BranchID + "," + SessionUserData.Company.YearID + "," + SessionUserData.AppInfo.TempIntVariable_1; DataTable myDS = new DataTable(); myDS = MaheshAF18.Application.MEF.DA_GetDataTable(strSQL); if (File.Exists(Server.MapPath(myDS.Rows[0]["BL_Logo_Url"].ToString()))) { FileStream stream = new FileStream(Server.MapPath(myDS.Rows[0]["BL_Logo_Url"].ToString()), FileMode.Open, FileAccess.Read); byte[] ImgData = new byte[stream.Length]; stream.Read(ImgData, 0, Convert.ToInt32(stream.Length)); stream.Close(); myDS.Rows[0]["BL_Logo_Img"] = ImgData; } decimal vatTotalAmt = Convert.ToDecimal(0 + myDS.Rows[0]["SINV_HDR_Total_Gross_Amt"].ToString()); sAmtInWords = MaheshAF18.Utility.NoToWord.AmtInWord_INR(vatTotalAmt); CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument = default(CrystalDecisions.CrystalReports.Engine.ReportDocument); myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); myReportDocument.Load(Server.MapPath("..\\Rpt\\") + sReportInFile + ""); myReportDocument.Database.Tables[0].SetDataSource(myDS); //myReportDocument.SetParameterValue("pRepHeading", sReportHeading); myReportDocument.SetParameterValue("AmtInWords ", sAmtInWords); myReportDocument.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, false, "Invoice"); //Session["reportDataSource"] = myReportDocument; //CrystalReportViewer1.DisplayGroupTree = false; //CrystalReportViewer1.ReportSource = myReportDocument; //CrystalReportViewer1.DataBind(); } catch (Exception ex) { DisplayCustomMessageSummary(ex.Message); } }
public void ReportEngine(string rptNm, string OderID) { using (dbDatabaseDataDataContext db = new dbDatabaseDataDataContext()) { //int sample = int.Parse(Request.QueryString["ApplicationId"]); crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); crReportDocument.Load(Server.MapPath(rptNm)); //crReportDocument.Refresh(); ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.DatabaseName = ConfigurationManager.AppSettings["DBaseName"]; connectionInfo.UserID = ConfigurationManager.AppSettings["DBUserName"]; connectionInfo.Password = ConfigurationManager.AppSettings["DBPassword"]; connectionInfo.ServerName = ConfigurationManager.AppSettings["DBServerName"]; CrTables = crReportDocument.Database.Tables; connectionInfo.Type = ConnectionInfoType.SQL; TableLogOnInfo tableLogOnInfo = new TableLogOnInfo(); tableLogOnInfo.ConnectionInfo = connectionInfo; crReportDocument.DataSourceConnections[0].SetConnection(tableLogOnInfo.ConnectionInfo.ServerName, tableLogOnInfo.ConnectionInfo.DatabaseName, tableLogOnInfo.ConnectionInfo.UserID, tableLogOnInfo.ConnectionInfo.Password); int GrocerID = int.Parse((Session["GrocId"]).ToString()); crReportDocument.SetParameterValue("@CustOdrID", OderID); crReportDocument.SetParameterValue("@GrocerId", GrocerID); if (System.IO.File.Exists(Server.MapPath("~/DownloadApplication/ItemLIst" + ".pdf"))) { System.IO.File.Delete(Server.MapPath("~/DownloadApplication/ItemLIst" + ".pdf")); } crReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("~/DownloadApplication/ItemLIst" + ".pdf")); ViewState["ApplicationPath"] = "~/DownloadApplication/ItemLIst" + ".pdf"; FilePath1 = Server.MapPath(ViewState["ApplicationPath"].ToString()); System.Net.WebClient User = new System.Net.WebClient(); byte[] FileBuffer = User.DownloadData(FilePath1); if ((FileBuffer != null)) { Response.ContentType = "application/pdf"; Response.AddHeader("content-length", FileBuffer.Length.ToString()); Response.BinaryWrite(FileBuffer); } Response.Redirect(ViewState["ApplicationPath"].ToString()); } }
public static void PrintReportA8(string IDBienNhan, string reportPath, string PrinterName, string CamThem, string ThayGiayCho) { Model.camdochieuduongEntities camdochieuduongEntity = new Model.camdochieuduongEntities(); Model.GiaoDich GD = camdochieuduongEntity.GiaoDiches.Find(IDBienNhan); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(reportPath); rptDoc.SetParameterValue("P_IDBienNhan", GD.IDBienNhan); rptDoc.SetParameterValue("P_ThayGiayCho", ThayGiayCho); rptDoc.SetParameterValue("P_KhachHang", "Tên: " + GD.KhachHang); rptDoc.SetParameterValue("P_DienThoai", "SĐT: " + GD.DienThoai); rptDoc.SetParameterValue("P_TienCam", "Tiền Cầm: " + String.Format("{0:n0}", GD.TienCam) + " Đ"); rptDoc.SetParameterValue("P_CamThem", CamThem); var MoTa = "Mô Tả: " + GD.MoTa; if (GD.TruHotCon != "") { MoTa = MoTa + "(Còn: " + GD.TruHotCon + ")"; } rptDoc.SetParameterValue("P_MoTa", MoTa); rptDoc.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape; //PaperSize xCustomSize = new PaperSize("Custom", 6, 8); //xCustomSize.PaperName = PaperKind.Custom; //PrintDocument.DefaultPageSettings.PaperSize = xCustomSize; //rptDoc.PrintOptions.PaperSize = ; rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize; rptDoc.PrintOptions.PrinterName = PrinterName; rptDoc.PrintToPrinter(1, false, 1, 1); }
protected void Page_Load(object sender, EventArgs e) { CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string reportPath = Server.MapPath("~/Reports/RptMedico.rpt"); report.Load(reportPath); report.SetDataSource(Session["ReportSource"]); report.SetParameterValue("titulo", "General"); crViewer.ReportSource = report; crViewer.DataBind(); }
private void LlenarParametros(string[,] Parametros) { for (int i = 0; i < Parametros.GetLength(0); i++) //Recorremos la dimención de la primera dimensión { for (int j = 0; j < Parametros.GetLength(1);) //Recorremos la dimensión de la segunda dimensión { //Asignamos los parámetros a la variable RPT, que contiene una instancia del reporte a mostrar RPT.SetParameterValue(Parametros[i, j], Parametros[i, j + 1]); break; } } }
public static void SetReportDefaultParameter(ref CrystalDecisions.CrystalReports.Engine.ReportDocument document) { try { if (document.ParameterFields["CName"] != null) { document.SetParameterValue("CName", MainForm.globelInfo.Rows[0]["Company"].ToString()); } if (document.ParameterFields["PoweredBy"] != null) { document.SetParameterValue("PoweredBy", MainForm.globelInfo.Rows[0]["PoweredBy"].ToString()); } if (document.ParameterFields["FooterText"] != null) { document.SetParameterValue("FooterText", MainForm.globelInfo.Rows[0]["FooterText"].ToString()); } } catch (Exception ex) { } }
public static void PrintReport(string IDBienNhan, string reportPath, string PrinterName) { Model.camdochieuduongEntities camdochieuduongEntity = new Model.camdochieuduongEntities(); Model.GiaoDich GD = camdochieuduongEntity.GiaoDiches.Find(IDBienNhan); var TienCamChu = ""; if (GD.TienCam != 0) { TienCamChu = camdochieuduong.Function.ConvertMoneyToChar.NumberToText(GD.TienCam.ToString()); } else { TienCamChu = ""; } CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(reportPath); rptDoc.SetParameterValue("ms", GD.IDBienNhan); rptDoc.SetParameterValue("P_KhachHang", GD.KhachHang); rptDoc.SetParameterValue("P_DienThoai", GD.DienThoai); rptDoc.SetParameterValue("P_MoTa", GD.MoTa); rptDoc.SetParameterValue("P_TruHotCon", GD.TruHotCon); rptDoc.SetParameterValue("P_TienCam", String.Format("{0:n0}", GD.TienCam)); rptDoc.SetParameterValue("P_GiaTri", String.Format("{0:n0}", GD.GiaTri)); rptDoc.SetParameterValue("P_NgayCam", GD.NgayCam.ToString()); rptDoc.SetParameterValue("P_GioCam", GD.NgayCam.Value.TimeOfDay.ToString()); rptDoc.SetParameterValue("P_TienCamChu", TienCamChu); rptDoc.PrintOptions.ApplyPageMargins(new CrystalDecisions.Shared.PageMargins(0, 0, 0, 0)); rptDoc.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait; rptDoc.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4; rptDoc.PrintOptions.PrinterName = PrinterName.Trim(); rptDoc.PrintToPrinter(1, false, 0, 0); }
private void mnuPriceListRegister_Click(object sender, EventArgs e) { try { if (dgvAccount.CurrentRow != null) { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_AccountID", dgvAccount.CurrentRow.Cells["AccountID"].Value.ToString()); dtReport = objList.ListOfRecord("rpt_AccountMasterPriceListRegister", para, "AccountMaster - PriceList report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptPriceList.rpt")) { //dtReport.TableName = "PriceListRegister"; //dtReport.WriteXmlSchema(@"D:\Report\PriceListRegister.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptPriceList.rpt"); CurrentUser.AddReportParameters(rptDoc, dtReport, "Price List Register", true, true, true, false, false, true, true, false, false, false, false); rptDoc.SetParameterValue("pAccountCode", dgvAccount.CurrentRow.Cells["Code"].Value.ToString()); rptDoc.SetParameterValue("pAccountName", dgvAccount.CurrentRow.Cells["Company"].Value.ToString()); rptDoc.SetParameterValue("pAccountCity", dgvAccount.CurrentRow.Cells["City"].Value.ToString()); rptDoc.SetParameterValue("pAccountPhone", dgvAccount.CurrentRow.Cells["Phone1"].Value.ToString()); rptDoc.SetParameterValue("pCST", CurrentCompany.CST); rptDoc.SetParameterValue("pECC", CurrentCompany.ECC); rptDoc.SetParameterValue("pTin", CurrentCompany.TIN); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Price List Register - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("File is not exist..."); } } else { MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("AccountMaster - PriceList report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } }
public void LoadViewer() { if (Etat != null && ListBoxDocument.SelectedItem != null) { Model.Sage.F_DOCENTETE_Light selected = (Model.Sage.F_DOCENTETE_Light)ListBoxDocument.SelectedItem; if (Etat.ParameterFields.Count == 0) { Etat.RecordSelectionFormula = "{Commande.DO_Piece} = '" + selected.DO_Piece + "'"; Etat.Refresh(); } else if (Etat.ParameterFields.Count > 0) { Etat.SetParameterValue("piece", selected.DO_Piece); //Etat.SetParameterValue("piecetaxes", selected.DO_Piece); //Etat.SetParameterValue("piecetaxes", selected.DO_Piece, "Tableau_Taxes"); } CRViewer.ViewerCore.ReportSource = Etat; /* pour fonction future * * if (Etat.ParameterFields.Count == 0 && parameters != null && parameters.Count(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.SelectionFormula) > 0) * Etat.RecordSelectionFormula = parameters.FirstOrDefault(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.SelectionFormula).ParameterValue; * * // fonctions avec application sur les sous-états * Core.PrintCrystal.Logon(Etat, Core.Global.GetConnectionInfos().SageServer, Core.Global.GetConnectionInfos().SageIntegratedSecurity, Core.Global.GetConnectionInfos().SageDatabase, Core.Global.GetConnectionInfos().SageSQLUser, Core.Global.GetConnectionInfos().SageSQLPass); * * Etat.Refresh(); * * if (Etat.ParameterFields.Count > 0 && parameters != null && parameters.Count(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.ParameterField) > 0) * { * foreach (Model.Internal.CrystalReportParameters crparam in parameters.Where(p => p.ParameterType == Model.Internal.CrystalReportParameters._Type.ParameterField)) * { * Etat.SetParameterValue(crparam.ParameterName, crparam.ParameterValue); * } * } */ } }
private void btnImprimir_Click(object sender, EventArgs e) { Caja caja = new Caja((int)cbxCaja.SelectedValue); string logo = string.Empty; if (!caja.IsNull()) logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo; caja = null; CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rpt.Load("Reportes\\Inventarios.rpt"); rpt.SetDataSource(((DataView)dgvTransacciones.DataSource).Table); rpt.SetParameterValue("Sucursal", cbxSucursal.Text); rpt.SetParameterValue("Caja", cbxCaja.Text); rpt.SetParameterValue("Usuario", cbxUsuarios.Text); rpt.SetParameterValue("Tipo", cbxTipos.Text); rpt.SetParameterValue("FechaIni", dtpFechaIni.Text); rpt.SetParameterValue("FechaFin", dtpFechaFin.Text); rpt.SetParameterValue("Logo", logo); frmReporte frm = new frmReporte(rpt); frm.ShowDialog(); rpt.Dispose(); rpt = null; frm.Dispose(); frm = null; }
public byte[] RunReport(String reportName, String fileName, string travelRequestId) { byte[] response = null; ConnectionInfo crConnectionInFo = new ConnectionInfo(); CrystalDecisions.CrystalReports.Engine.Tables crTables; TableLogOnInfo crTableLogonInfo = new TableLogOnInfo(); DiskFileDestinationOptions crDiskFileDestinationOptions = new CrystalDecisions.Shared.DiskFileDestinationOptions(); ExportOptions crExportOptions = new CrystalDecisions.Shared.ExportOptions(); CrystalDecisions.CrystalReports.Engine.ReportDocument dReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); String rptPath = System.Web.Hosting.HostingEnvironment.MapPath(System.Configuration.ConfigurationManager.AppSettings["rptPath"]); String fName = fileName; dReport.Load(rptPath + reportName); dReport.SetParameterValue("p_travelrequestID", travelRequestId); if (reportName == "Travel_Business_Expense.rpt") { dReport.SetParameterValue("p_travelrequestID", travelRequestId); } string defaultConnectionString = ConfigurationManager.ConnectionStrings["CrystalReport"].ConnectionString; var builder = new DbConnectionStringBuilder(); builder.ConnectionString = defaultConnectionString; crConnectionInFo.DatabaseName = ""; crConnectionInFo.ServerName = builder["SERVICE_NAME"].ToString(); crConnectionInFo.UserID = builder["User ID"].ToString(); crConnectionInFo.Password = builder["Password"].ToString(); crTables = dReport.Database.Tables; crTableLogonInfo.ConnectionInfo = crConnectionInFo; foreach (CrystalDecisions.CrystalReports.Engine.Table rTable in crTables) { rTable.ApplyLogOnInfo(crTableLogonInfo); } foreach (CrystalDecisions.CrystalReports.Engine.ReportDocument subrpt in dReport.Subreports) { foreach (CrystalDecisions.CrystalReports.Engine.Table rTable in subrpt.Database.Tables) { rTable.ApplyLogOnInfo(crTableLogonInfo); } } try { var memoryStream = new MemoryStream(); var data = dReport.ExportToStream(ExportFormatType.PortableDocFormat); data.CopyTo(memoryStream); response = memoryStream.ToArray(); if (File.Exists(rptPath + "Exported/" + fileName + ".pdf")) { File.Delete(rptPath + "Exported/" + fileName + ".pdf"); } FileStream file = new FileStream(rptPath + "Exported/" + fileName + ".pdf", FileMode.Create, FileAccess.ReadWrite); memoryStream.WriteTo(file); file.Close(); file.Dispose(); memoryStream.Close(); memoryStream.Dispose(); //File.WriteAllBytes(rptPath+"Exported/"+fileName+".pdf", response); } catch (Exception ex) { LogMessage.Log("Error generating crystal report : " + ex.Message); throw new Exception(ex.Message); } finally { dReport.Close(); dReport.Dispose(); } return(response); }
/// <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_ProgramID = string.Empty; string par_LoginUser = string.Empty; #region 前置檢查與參數過濾 string par_AcceptDate = this.txtST_ACCEPT_DATE.Text; string par_ChanName = this.ddlChanNo.SelectedItem.Text.Replace("(", " ") ; par_ChanName = par_ChanName.Replace(")", ""); string par_StoreName = string.Empty; if (this.ddlStore.SelectedIndex > 0 ) par_StoreName = this.ddlStore.SelectedItem.Text; par_StoreName = par_StoreName.Replace("(", " "); par_StoreName = par_StoreName.Replace(")", " "); par_ProgramID = this.PageCode; // par_LoginUser = "******"; par_LoginUser = Session["UID"].ToString(); #endregion #region 組合查詢條件至ArrayList ArrayList returnList = new ArrayList(); returnList.Clear(); report.SetParameterValue("AcceptDate", par_AcceptDate); report.SetParameterValue("ProgramName", par_ProgramID); report.SetParameterValue("UserName", par_LoginUser); report.SetParameterValue("ChanName", par_ChanName); report.SetParameterValue("StoreName", par_StoreName); #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; } }
public static void AddReportParameters(CrystalDecisions.CrystalReports.Engine.ReportDocument rpt, DataTable dt, string ReportName, bool CompanyName, bool Address1, bool Address2, bool City, bool PinCode, bool phone, bool Department, bool State, bool Phone2, bool Fax, bool Email) { rpt.SetDataSource(dt); if (ReportName != "") { rpt.SetParameterValue("pReportName", ReportName); } if (CompanyName == true) { rpt.SetParameterValue("pCompanyName", CurrentCompany.CompanyName); } if (Address1 == true) { rpt.SetParameterValue("pAddress1", CurrentCompany.Address1); } if (Address2 == true) { rpt.SetParameterValue("pAddress2", CurrentCompany.Address2); } if (City == true) { rpt.SetParameterValue("pCity", CurrentCompany.City); } if (State == true) { rpt.SetParameterValue("pState", ""); } if (PinCode == true) { rpt.SetParameterValue("pPinCode", CurrentCompany.Pincode); } if (phone == true) { rpt.SetParameterValue("pPhone", CurrentCompany.Phone1); } if (Phone2 == true) { rpt.SetParameterValue("pPhone2", CurrentCompany.Phone2); } if (Fax == true) { rpt.SetParameterValue("pFax", CurrentCompany.Fax); } if (Email == true) { rpt.SetParameterValue("pEmail", CurrentCompany.Email); } }
private void btnImprimir_Click(object sender, EventArgs e) { //MessageBox.Show("Error al generar el reporte", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Caja caja = new Caja((int)cbxCaja.SelectedValue); string logo = string.Empty; if (!caja.IsNull()) logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo; caja = null; CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rpt.Load("Reportes\\CorteCaja.rpt"); rpt.Subreports[0].SetDataSource((DataTable)dgvCheques.DataSource); rpt.SetDataSource((DataTable)dgvTransacciones.DataSource); rpt.SetParameterValue("Caja", cbxCaja.Text); rpt.SetParameterValue("PesosR", tbxPesos.Value); rpt.SetParameterValue("PesosS", tbxCantidad.Value); rpt.SetParameterValue("DolaresR", tbxDolares.Value); rpt.SetParameterValue("DolaresS", tbxCantidad2.Value); rpt.SetParameterValue("PB1000",tbxPB1000.Text); rpt.SetParameterValue("PB500", tbxPB500.Text); rpt.SetParameterValue("PB200", tbxPB200.Text); rpt.SetParameterValue("PB100", tbxPB100.Text); rpt.SetParameterValue("PB50", tbxPB50.Text); rpt.SetParameterValue("PB20", tbxPB20.Text); rpt.SetParameterValue("PM100", tbxPM100.Text); rpt.SetParameterValue("PM20", tbxPM20.Text); rpt.SetParameterValue("PM10", tbxPM10.Text); rpt.SetParameterValue("PM5", tbxPM5.Text); rpt.SetParameterValue("PM2", tbxPM2.Text); rpt.SetParameterValue("PM1", tbxPM1.Text); rpt.SetParameterValue("PM50C", tbxPC50.Text); rpt.SetParameterValue("PM20C", tbxPC20.Text); rpt.SetParameterValue("PM10C", tbxPC10.Text); rpt.SetParameterValue("PM5C", tbxPC5.Text); rpt.SetParameterValue("DB100", tbxDB100.Text); rpt.SetParameterValue("DB50", tbxDB50.Text); rpt.SetParameterValue("DB20", tbxDB20.Text); rpt.SetParameterValue("DB10", tbxDB10.Text); rpt.SetParameterValue("DB5", tbxDB5.Text); rpt.SetParameterValue("DB1", tbxDB1.Text); rpt.SetParameterValue("DM1", tbxDM1.Text); rpt.SetParameterValue("DM50", tbxDC50.Text); rpt.SetParameterValue("DM25", tbxDC25.Text); rpt.SetParameterValue("DM10", tbxDC10.Text); rpt.SetParameterValue("DM5", tbxDC5.Text); rpt.SetParameterValue("DM1C", tbxDC1.Text); rpt.SetParameterValue("Logo", logo); frmReporte frm = new frmReporte(rpt); frm.ShowDialog(); rpt.Dispose(); rpt = null; frm.Dispose(); frm = null; }
private void btnPrint_Click(object sender, EventArgs e) { string strConnect = cn.GetConnectString(); int stt = 0; //if (dgvPacking.Rows.Count > 0 && dgvPacking.Rows.Count <= 12 && txtNumber.Text != "") // && txtNgayXX.Text != "" ) // Kiểm tra điều kiện in if (dgvPacking.Rows.Count > 0 && dgvPacking.Rows.Count <= 12 && txtNumber.Text != "" && txtNgayXX.Text != "") // Kiểm tra điều kiện in { if (pc.checkSplit(dgvPacking)) { string wh = this.getWarehouse(); if (pc.checkUser(Environment.UserName, wh)) //Check user have permission on warehouse { if (dp.isUserWHInvoiceMandatoryValid(Environment.UserName, wh, this.getSalesOrder(), strConnect)) { //MessageBox.Show(dgvPacking.Rows[0].Cells["Date"].Value.ToString()); //string cmd; DataSet ds = new DataSet(); DataTable tb = new DataTable(); int id; string SalesId; string cust = dgvPacking.Rows[0].Cells["CUST"].Value.ToString(); //int num = 0; string PackingId = pc.getPackingByList(pc.getPackingByDatagridview(dgvPacking)); //MessageBox.Show(PackingId); tb.Columns.Add("STT"); //Số thứ tự tb.Columns.Add("ITEM"); //Mã Item tb.Columns.Add("NAME"); //Tên Item tb.Columns.Add("QTY"); //Số lượng tb.Columns.Add("UOM"); //Don vi tb.Columns.Add("BATCH"); //Số lô //tb.Columns.Add("DATE"); //Ngày giao foreach (DataGridViewRow dr in dgvPacking.Rows) { string batchStr = ""; string Qty = dr.Cells["QTY"].Value.ToString(); stt += 1; string[] qty = pc.processQty(dr.Cells["EDITQTY"].Value.ToString()); string[] batch = pc.processBatch(dr.Cells["BATCH"].Value.ToString()); //Neu tach so luong //if (dr.Cells["BATCH"].Value.ToString() != "" && batch.Length == qty.Length) if (dr.Cells["EDITQTY"].Value.ToString() != "" && batch.Length == qty.Length) { for (int i = 0; i < qty.Length; i++) { if (batchStr.Length != 0) { batchStr += ",Số lượng:" + qty[i] + "-" + "Số lô:" + batch[i]; } else { batchStr += "Số lượng:" + qty[i] + "-" + "Số lô:" + batch[i]; } } } if (dr.Cells["EDITQTY"].Value.ToString() == "" && batch.Length == qty.Length) { batchStr = dr.Cells["BATCH"].Value.ToString(); } //tb.Rows.Add(stt, dr.Cells["ITEMID"].Value, dr.Cells["NAME"].Value, Qty, dr.Cells["UNIT"].Value, batchStr, dr.Cells["DATE"].Value); tb.Rows.Add(stt, dr.Cells["ITEMID"].Value, dr.Cells["NAME"].Value, Qty, dr.Cells["UNIT"].Value, batchStr);// Bỏ ngày giao } ds.Tables.Add(tb); id = dp.getId(strConnect) + 1; SalesId = dgvPacking.Rows[0].Cells["SALESID"].Value.ToString(); //INSERT HEADER dp.InsertNumberByStore("InsertNumber_VTIREPORT", id, strConnect, SalesId, PackingId, wh, txtNumber.Text, txtCTrinh.Text, txtDonVi.Text, txtDiaChi.Text, txtNgayXX.Text); //INSERT LINE foreach (DataGridViewRow dr in dgvPacking.Rows) { dp.InsertNumberLinesByStore("InsertNumberLines_VTIREPORT", strConnect, id, SalesId, dr.Cells["PACKINGSLIPID"].Value.ToString(), dr.Cells["WAREHOUSE"].Value.ToString() , dr.Cells["ItemId"].Value.ToString(), dr.Cells["Name"].Value.ToString(), dr.Cells["ORDERQTY"].Value.ToString() , Double.Parse(dr.Cells["QTY"].Value.ToString()), dr.Cells["UNIT"].Value.ToString(), dr.Cells["EDITQTY"].Value.ToString(), dr.Cells["BATCH"].Value.ToString() , dr.Cells["DATE"].Value.ToString(), "", dr.Cells["INVOICEACCOUNT"].Value.ToString(), dr.Cells["CUST"].Value.ToString()); } cryCNXX cnxx = new cryCNXX(); //USER PATTERN CrystalDecisions.CrystalReports.Engine.ReportDocument crys = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string path = Application.StartupPath + "\\Report\\cryCNXX.rpt"; ////MessageBox.Show(path); crys.Load(path); //cryCNXX cnn2 = crys.SetDataSource(ds); crys.SetParameterValue("SoPhieu", txtNumber.Text); crys.SetParameterValue("Cust", cust); crys.SetParameterValue("CTrinh", txtCTrinh.Text); crys.SetParameterValue("DiaChi", txtDiaChi.Text); crys.SetParameterValue("DVThiCong", txtDonVi.Text); //crys.SetParameterValue("Date", DateTime.Now.ToString("dd/MM/yyyy")); crys.SetParameterValue("Date", txtNgayXX.Text); //Ngày xuất xưởng //crys.SetParameterValue("Num", num.ToString() + "/" + DateTime.Now.ToString("MM") + DateTime.Now.ToString("yy") + "-HT"); // crys.SetParameterValue("PackingId", txtPackId.Text); //crys.SetParameterValue("PackingId", PackingId); // frCNXXView view = new frCNXXView(crys); view.ShowDialog(); } else { MessageBox.Show("User " + Environment.UserName + " không có quyền in Sales Order chưa Invoiced." + this.getSalesOrder()); } } else { MessageBox.Show("User " + Environment.UserName + " không có quyền in Chứng Nhận Xuất Xưởng trên kho. " + wh); } } else { MessageBox.Show("Kiểm tra lại tổng số lượng trên cột EditQty"); } } else { MessageBox.Show("Kiểm tra lại dữ liệu, số dòng phải < 12 ,nhập số phiếu và ngày cấp CNXX !"); } }
//Crystal Report 直接輸出 PDF 檔 private void ExportReport(DataTable dt) { CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(Server.MapPath("../REPORT/IVM14/CRIVM14R01.rpt")); report.SetDataSource(dt); //CrystalReport Parameter 參數設定 string Program_ID = string.Empty; string LoginUser = string.Empty; string ChanTransNo = string.Empty; Program_ID = this.PageCode.Substring(0, 5) + "R01"; LoginUser = Session["UID"].ToString(); ChanTransNo = Session["ForChanTransNo"].ToString(); report.SetParameterValue("par_Program_ID", this.PageCode); report.SetParameterValue("par_LoginUser", LoginUser); report.SetParameterValue("par_ChanTransNo", ChanTransNo); //檔案匯出 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(); }
private void btnSaveExit_Click(object sender, EventArgs e) { if (_RptType == 2) { lblErrorMessage.Text = ""; if (System.IO.File.Exists(CurrentUser.ReportPath + "rptProfitnLossStatement.rpt")) { DataTable dt = new DataTable(); NameValueCollection Para = new NameValueCollection(); // Para.Add("@i_AccountID", cmbAccount.SelectedValue.ToString()); Para.Add("@i_FromDate", dtpDate.Value.ToString("MM/dd/yyyy")); Para.Add("@i_ToDate", dtpToDate.Value.ToString("MM/dd/yyyy")); dt = CommList.ListOfRecord("rpt_ProfitLossStatement", Para, "Profit Loss Statement"); //dt.TableName = "ProfitnLossStatement"; //dt.WriteXmlSchema(@"D:\ProfitnLossStatement.xsd"); if (CommList.Exception == null) { CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptProfitnLossStatement.rpt"); CurrentUser.AddReportParameters(rptDoc, dt, "Profit Loss Statement", true, true, true, true, false, true, true, false, false, false, false); rptDoc.SetParameterValue("pFromDate", dtpDate.Value.Date); rptDoc.SetParameterValue("pToDate", dtpToDate.Value.Date); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Profit n Loss Statement - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show(CommList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); } //if (cmbAccount.SelectedIndex > 0) //{ // DataTable dt = new DataTable(); // NameValueCollection Para = new NameValueCollection(); // // Para.Add("@i_AccountID", cmbAccount.SelectedValue.ToString()); // Para.Add("@i_FromDate", dtpDate.Value.ToString("MM/dd/yyyy")); // Para.Add("@i_ToDate", dtpToDate.Value.ToString("MM/dd/yyyy")); // dt = CommList.ListOfRecord("rpt_ProfitLossStatement", Para, "Profit Loss Statement"); // //dt.TableName = "ProfitnLossStatement"; // //dt.WriteXmlSchema(@"D:\ProfitnLossStatement.xsd"); // if (CommList.Exception == null) // { // CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); // rptDoc.Load(CurrentUser.ReportPath + "rptProfitnLossStatement.rpt"); // CurrentUser.AddReportParameters(rptDoc, dt, "Profit Loss Statement", true, true, true, true, false, true, true, false, false, false, false); // rptDoc.SetParameterValue("pFromDate", dtpDate.Value.Date); // rptDoc.SetParameterValue("pToDate", dtpToDate.Value.Date); // Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); // fRptView.Text = "Profit n Loss Statement - [Page Size: A4]"; // fRptView.crViewer.ReportSource = rptDoc; // fRptView.ShowDialog(); // } // else // { // MessageBox.Show(CommList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); // } //} //else //{ // lblErrorMessage.Text = "Please select Account"; // return; //} } else { MessageBox.Show("File is not exist..."); } } else { //--------------------------------------- lblErrorMessage.Text = ""; if (System.IO.File.Exists(CurrentUser.ReportPath + "rptLedger.rpt")) { if (cmbAccount.SelectedIndex > 0) { DataTable dt = new DataTable(); NameValueCollection Para = new NameValueCollection(); Para.Add("@i_AccountID", cmbAccount.SelectedValue.ToString()); Para.Add("@i_FromDate", dtpDate.Value.ToString("MM/dd/yyyy")); Para.Add("@i_ToDate", dtpToDate.Value.ToString("MM/dd/yyyy")); dt = CommList.ListOfRecord("rpt_AccountLedger", Para, "Ledger Report"); if (CommList.Exception == null) { CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptLedger.rpt"); CurrentUser.AddReportParameters(rptDoc, dt, "Ledger Register", true, true, true, true, false, true, true, false, false, false, false); rptDoc.SetParameterValue("pFromDate", dtpDate.Value.Date); rptDoc.SetParameterValue("pToDate", dtpToDate.Value.Date); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Ledger Register - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show(CommList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { lblErrorMessage.Text = "Please select Account"; return; } } else { MessageBox.Show("File is not exist..."); } } }
/// <summary> /// 利用 CrystalReport 列印報表 /// </summary> /// <param name="s_FileName">報表的檔名</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_Source1, DataTable dt_Source2, string reportFormatType) { CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(s_rptFilePath); report.SetDataSource(dt_Source2); string par_Vendor = string.Empty; string par_VendorName = string.Empty; string par_PurDate = string.Empty; string par_PurchaseNo = string.Empty; string par_PlanAcceptDate = string.Empty; par_Vendor = dt_Source1.Rows[0]["VENDOR"].ToString(); par_VendorName = dt_Source1.Rows[0]["VENDOR_NAME"].ToString(); par_PurDate = dt_Source1.Rows[0]["PURCHSE_DATE"].ToString(); par_PurchaseNo = dt_Source1.Rows[0]["PURCHASE_NO"].ToString(); if (dt_Source2.Rows.Count != 0) { par_PlanAcceptDate = dt_Source2.Rows[0]["PLAN_ACCEPT_DATE"].ToString(); } #region 組合查詢條件至ArrayList report.SetParameterValue("par_Vendor", par_Vendor); report.SetParameterValue("par_VendorName", par_VendorName); if (par_PurDate.Trim() != "") { report.SetParameterValue("par_PurDate", GetValueSetParameter(par_PurDate, "date")); } else { report.SetParameterValue("par_PurDate", ""); } report.SetParameterValue("par_PurchaseNo", par_PurchaseNo); if (par_PlanAcceptDate.Trim() != "") { report.SetParameterValue("par_PlanAcceptDate", GetValueSetParameter(par_PlanAcceptDate, "date")); } else { report.SetParameterValue("par_PlanAcceptDate", ""); } #endregion #region 判斷輸出檔案型態 try { 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); Response.ContentType = "application/pdf"; Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length); Response.Flush(); Response.Close(); break; default: break; } } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.Message; } finally { report.Close(); } #endregion }
public void listarTemperatura() { string txtfechaini; string txtfechafin; string f1; string f2; string nombreempresa; CargarDatosTemperatura(out txtfechaini, out txtfechafin, out f1, out f2, out nombreempresa); WS.LOGICA.LReportes logica = new WS.LOGICA.LReportes(); string placa = cboplaca.SelectedValue; DateTime datefrom = Convert.ToDateTime(f1); DateTime dateto = Convert.ToDateTime(f2); if (CalcularDiasDeDiferencia(datefrom, dateto) <= 15 && !string.IsNullOrEmpty(placa)) { List <WS.DATA.ReporteTempuratura> lis = logica.getlistTemperatura(datefrom, dateto, placa); List <RptTemperaturaViewModel> reporteList = new List <RptTemperaturaViewModel>(); if (lis != null) { ControlarAperturayCierre(ref reporteList, lis); if (reporteList.Count() > 0) { ViewState["RptTemperatura"] = reporteList; Documento.Load(Server.MapPath("~/Reporte/reporteTemperaturaOptimizado.rpt")); //Documento.SetDataSource(reporteList); Documento.Database.Tables[0].SetDataSource(reporteList); Documento.SetParameterValue("fechainicio", f1); Documento.SetParameterValue("fechafin", f2); Documento.SetParameterValue("nplaca", cboplaca.Text); Documento.SetParameterValue("empresa", nombreempresa); this.CrystalReportViewer1.ReportSource = Documento; this.CrystalReportViewer1.DataBind(); CrystalReportViewer1.Visible = true; msnTemperatura.Visible = false; //success("Se cargaron los datos Corectamente"); } else { //MensajeAlertaV("No hay datos en el servidor"); //MensajeAlertaV("No hay datos en el Servidor"); CrystalReportViewer1.Visible = false; msnTemperatura.Visible = true; } } } else { //if (string.IsNullOrEmpty(placa)) // MensajeAlertaV("Seleccione alguna placa del vehiculo"); //else // MensajeAlertaV("El reporte de temperatura solo puede sacar menores a 15 dias"); //mensajeAlerta(); } }
/// <summary> /// 產生輸出檔案 /// </summary> /// <param name="s_FileName">產生檔案檔名</param> /// <param name="s_rptFilePath">RPT報表檔路徑及檔名</param> /// <param name="dt_Source">DB抓取的資料集(DataTable)</param> /// <param name="RP">報表變數,如無變數請輸入null</param> /// <param name="ROF">報表格式</param> public void LoadCrystalReport(string s_FileName, string s_rptFilePath, ref DataTable dt_Source, ReportParameter[] RP, string ReportOutputFormat ) { int bytesRead = 0; FileStream FS = new FileStream(s_FileName, FileMode.Create, FileAccess.Write); CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); try { report.Load(s_rptFilePath); report.SetDataSource(dt_Source); //判斷輸出檔案型態 switch (ReportOutputFormat) { case "EXCEL": //如果有報表參數 if (RP != null) { for (int i = 0; i < RP.Length; i++) { if ((RP[i].ParameterName != "") && (RP[i].ParameterValue != null)) { report.SetParameterValue(RP[i].ParameterName, RP[i].ParameterValue); } } } Stream streamXLS = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel); byte[] bytesXLS; try { bytesXLS = new byte[streamXLS.Length]; bytesRead = streamXLS.Read(bytesXLS, 0, bytesXLS.Length); //export file while (bytesRead > 0) { FS.Write(bytesXLS, 0, bytesRead); bytesRead = streamXLS.Read(bytesXLS, 0, bytesXLS.Length); } } catch (Exception ex) { throw ex; } finally { bytesXLS = null; streamXLS.Flush(); streamXLS.Close(); streamXLS.Dispose(); } break; case "PDF": //如果有報表參數 if (RP != null) { for (int i = 0; i < RP.Length; i++) { if ((RP[i].ParameterName != "") && (RP[i].ParameterValue != null)) { report.SetParameterValue(RP[i].ParameterName, RP[i].ParameterValue); } } } Stream streamPDF = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); byte[] bytesPDF; try { bytesPDF = new byte[streamPDF.Length]; bytesRead = streamPDF.Read(bytesPDF, 0, bytesPDF.Length); //streamPDF.Seek(0, System.IO.SeekOrigin.Begin); //export file while (bytesRead > 0) { FS.Write(bytesPDF, 0, bytesRead); bytesRead = streamPDF.Read(bytesPDF, 0, bytesPDF.Length); } } catch (Exception ex) { throw ex; } finally { bytesPDF = null; streamPDF.Flush(); streamPDF.Close(); streamPDF.Dispose(); } break; default: break; } } catch (Exception ex) { throw ex; } finally { FS.Flush(); FS.Close(); FS.Dispose(); report.Close(); report.Dispose(); dt_Source.Dispose(); } }
/// <summary> /// 利用 CrystalReport 列印報表 /// </summary> /// <param name="s_FileName">報表的檔名</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_Source1, DataTable dt_Source2, string reportFormatType) { CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(s_rptFilePath); report.SetDataSource(dt_Source2); string par_Vendor = string.Empty; string par_VendorName = string.Empty; string par_PurDate = string.Empty; string par_PurchaseNo = string.Empty; string par_FAX = string.Empty; string par_TEL = string.Empty; string par_BusinessContact = string.Empty; double par_Tax = 0; par_Vendor = dt_Source1.Rows[0]["VENDOR"].ToString(); par_VendorName = dt_Source1.Rows[0]["VENDOR_NAME"].ToString(); par_PurDate = dt_Source1.Rows[0]["PURCHSE_DATE"].ToString(); par_PurchaseNo = dt_Source1.Rows[0]["PURCHASE_NO"].ToString(); par_FAX = dt_Source1.Rows[0]["INV_FAX_AREA"].ToString() + "-" + dt_Source1.Rows[0]["INV_FAX"].ToString(); par_TEL = dt_Source1.Rows[0]["INV_TEL_AREA"].ToString() + "-" + dt_Source1.Rows[0]["INV_TEL"].ToString(); par_BusinessContact = dt_Source1.Rows[0]["BUSINESS_CONTACT"].ToString(); if (dt_Source2.Rows.Count == 0) par_Tax = 0; else par_Tax = double.Parse(dt_Source2.Rows[0]["TAXRATE"].ToString()); #region 組合查詢條件至ArrayList report.SetParameterValue("par_Vendor", par_Vendor); report.SetParameterValue("par_VendorName", par_VendorName); if (par_PurDate.Trim() != "") { report.SetParameterValue("par_PurDate", GetValueSetParameter(par_PurDate, "date")); } else { report.SetParameterValue("par_PurDate", ""); } report.SetParameterValue("par_PurchaseNo", par_PurchaseNo); report.SetParameterValue("par_FAX", par_FAX); report.SetParameterValue("par_TEL", par_TEL); report.SetParameterValue("par_BusinessContact", par_BusinessContact); report.SetParameterValue("par_Tax", par_Tax); #endregion #region 判斷輸出檔案型態 switch (reportFormatType) { 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; } #endregion }
//列印報表 private void ShowReport(DataSet ds) { #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/ITM061R.rpt")); report.SetDataSource(ds); report.Subreports["ITM061R2"].SetDataSource(ds); report.Subreports["ITM061R3"].SetDataSource(ds); report.SetParameterValue("ProgramName", "ITM061R"); report.SetParameterValue("UserName", Session["UID"].ToString() + Login_Name); if (this.txtCREATEDATE.StartDate.ToString() == "" && this.txtCREATEDATE.EndDate.ToString() == "") report.SetParameterValue("QueryDateRange", "全部"); else report.SetParameterValue("QueryDateRange", this.txtCREATEDATE.StartDate.ToString() + "~" + this.txtCREATEDATE.EndDate.ToString()); if (this.SLP_TimeRange1.StartTime.ToString() == "" && this.SLP_TimeRange1.EndTime.ToString() == "") report.SetParameterValue("QueryTime", "全部"); else report.SetParameterValue("QueryTime", this.SLP_TimeRange1.StartTime.ToString() + "~" + this.SLP_TimeRange1.EndTime.ToString()); report.SetParameterValue("Par_Count", Convert.ToString(ds.Tables["DataTable1"].Rows.Count) + "筆"); //檔案匯出 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 }
public static void AddExtraParameter(CrystalDecisions.CrystalReports.Engine.ReportDocument rpt) { if (CurrentCompany.Name1 != null) { rpt.SetParameterValue("pName1", CurrentCompany.Name1); } else { rpt.SetParameterValue("pName1", ""); } if (CurrentCompany.Name2 != null) { rpt.SetParameterValue("pName2", CurrentCompany.Name2); } else { rpt.SetParameterValue("pName2", ""); } if (CurrentCompany.Name3 != null) { rpt.SetParameterValue("pName3", CurrentCompany.Name3); } else { rpt.SetParameterValue("pName3", ""); } if (CurrentCompany.Name4 != null) { rpt.SetParameterValue("pName4", CurrentCompany.Name4); } else { rpt.SetParameterValue("pName4", ""); } if (CurrentCompany.Name5 != null) { rpt.SetParameterValue("pName5", CurrentCompany.Name5); } else { rpt.SetParameterValue("pName5", ""); } if (CurrentCompany.Name6 != null) { rpt.SetParameterValue("pName6", CurrentCompany.Name6); } else { rpt.SetParameterValue("pName6", ""); } if (CurrentCompany.Value1 != null) { rpt.SetParameterValue("pValue1", CurrentCompany.Value1); } else { rpt.SetParameterValue("pValue1", ""); } if (CurrentCompany.Value2 != null) { rpt.SetParameterValue("pValue2", CurrentCompany.Value2); } else { rpt.SetParameterValue("pValue2", ""); } if (CurrentCompany.Value3 != null) { rpt.SetParameterValue("pValue3", CurrentCompany.Value3); } else { rpt.SetParameterValue("pValue3", ""); } if (CurrentCompany.Value4 != null) { rpt.SetParameterValue("pValue4", CurrentCompany.Value4); } else { rpt.SetParameterValue("pValue4", ""); } if (CurrentCompany.Value5 != null) { rpt.SetParameterValue("pValue5", CurrentCompany.Value5); } else { rpt.SetParameterValue("pValue5", ""); } if (CurrentCompany.Value6 != null) { rpt.SetParameterValue("pValue6", CurrentCompany.Value6); } else { rpt.SetParameterValue("pValue6", ""); } //if (CurrentCompany.Com_Profile != null) //{ // rpt.SetParameterValue("pCompanyProfile", CurrentCompany.Com_Profile); //} //else //{ // rpt.SetParameterValue("pCompanyProfile", ""); //} }
private void rptExpense_Click(object sender, EventArgs e) { try { if (dgvExpense.CurrentRow != null) { DataTable dtReport = new DataTable(); dtReport = CommSelect.SelectRecord(Convert.ToInt64(dgvExpense.CurrentRow.Cells["POID"].Value), "rpt_Expense", "Expense - Report"); if (CommSelect.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptExpense.rpt")) { //dtReport.TableName = "Expense"; //dtReport.WriteXmlSchema(@"D:\Report\Expense.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptExpense.rpt"); CurrentUser.AddReportParameters(rptDoc, dtReport, "Expense", true, true, true, true, true, true, true, false, false, false, false); rptDoc.SetParameterValue("pBusinessLine", CurrentCompany.BusinessLine); rptDoc.SetParameterValue("pCST", CurrentCompany.CST); rptDoc.SetParameterValue("pEmail", CurrentCompany.Email); rptDoc.SetParameterValue("pFax", CurrentCompany.Fax); rptDoc.SetParameterValue("pPhone2", CurrentCompany.Phone2); rptDoc.SetParameterValue("PState", CurrentCompany.State); rptDoc.SetParameterValue("pTin", CurrentCompany.TIN); rptDoc.SetParameterValue("pRegAddress1", CurrentCompany.RegAddress1); rptDoc.SetParameterValue("pRegAddress2", CurrentCompany.RegAddress2); rptDoc.SetParameterValue("pRegCity", CurrentCompany.RegCity); rptDoc.SetParameterValue("pRegFax", CurrentCompany.RegFax); rptDoc.SetParameterValue("pRegPhone", CurrentCompany.RegPhone); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Expense - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("File is not exist..."); } } else { MessageBox.Show(CommSelect.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Expense - Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } }
/// <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_ProgramID = string.Empty; string par_LoginUser = string.Empty; string par_Chan1 = string.Empty; string par_Chan2 = string.Empty; string par_Chan3 = string.Empty; #region 前置檢查與參數過濾 string par_PlanAcceptData = this.txtPLAN_ACCEPT_DATE.Text; par_ProgramID = this.PageCode; string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString(); par_LoginUser = Session["UID"].ToString() + " " + Login_Name; if (dt_Source.Rows[0]["No1_Name"] != System.DBNull.Value) { par_Chan1 = dt_Source.Rows[0]["No1_Name"].ToString(); } if (dt_Source.Rows[0]["No2_Name"] != System.DBNull.Value) { par_Chan2 = dt_Source.Rows[0]["No2_Name"].ToString(); } if (dt_Source.Rows[0]["No3_Name"] != System.DBNull.Value) { par_Chan3 = dt_Source.Rows[0]["No3_Name"].ToString(); } #endregion #region 組合查詢條件至ArrayList report.SetParameterValue("par_ProgramID", par_ProgramID); report.SetParameterValue("par_LoginUser", par_LoginUser); report.SetParameterValue("par_PlanAcceptDate", GetValueSetParameter(par_PlanAcceptData, "string")); report.SetParameterValue("par_Chan1", par_Chan1); report.SetParameterValue("par_Chan2", par_Chan2); report.SetParameterValue("par_Chan3", par_Chan3); #endregion #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(); 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; } #endregion }
/// <summary> /// /// </summary> /// <param name="PickNo">揀貨單號</param> /// <param name="s_FileName">Excel報表的檔名</param> /// <param name="s_rptFilePath">rpt檔的路徑</param> /// <param name="reportFormatType">檔案型態</param> /// <param name="ReportOrderOption">排序類型 "item":品項 "locate":儲位 </param> private void LoadCrystalReport(string PickNo, string s_FileName, string s_rptFilePath, string reportFormatType, string ReportOrderOption) { try { IVMModel.MaintainPickData BCO = new IVMModel.MaintainPickData(ConntionDB); CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(Server.MapPath(s_rptFilePath)); ParameterList.Clear(); ParameterList.Add(PickNo); if (s_rptFilePath != "./REPORT/IVM15/CRIVM15R03.rpt") { DataTable dtResult = new DataTable(); string ProgName = ""; if (s_rptFilePath == "./REPORT/IVM15/CRIVM15R01.rpt") { dtResult = BCO.GetPrintRpt01(ParameterList); ProgName = "IVM15R01"; } else { dtResult = BCO.GetPrintRpt02(ParameterList); ProgName = "IVM15R02"; } DataView dv = new DataView(dtResult); switch (ReportOrderOption) { case "item": dv.Sort = "item"; break; case "locate": dv.Sort = "BLocate_No"; break; default: dv.Sort = "item"; break; } report.SetDataSource(dv.ToTable()); report.SetParameterValue("paraProg", ProgName); report.SetParameterValue("paraUserID", Session["UID"].ToString()); report.SetParameterValue("paraPickNo", PickNo); report.SetParameterValue("paraSource", this.MenuIVM15.SelectedItem.Text); report.SetParameterValue("paraAccDate", ""); report.SetParameterValue("paraReturnNo", ""); report.SetParameterValue("paraRemoveNo", ""); report.SetParameterValue("paraBLocate", ""); report.SetParameterValue("paraELocate", ""); report.SetParameterValue("paraVendor", ""); } else { DataTable dtResult = new DataTable(); dtResult = BCO.GetPrintRpt03(ParameterList); report.SetDataSource(dtResult); report.SetParameterValue("paraProg", "IVM15R03"); report.SetParameterValue("paraUserID", Session["UID"].ToString()); //report.SetParameterValue("paraKind", ""); } 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; } }
private void ShowReport() { #region CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); try { string strFileName = ""; report.Load(Server.MapPath("./REPORT/ALO21/ALO21R01.rpt")); strFileName = HttpUtility.UrlEncode("轉門市進貨單明細表.pdf", System.Text.Encoding.UTF8); #region 2010/02/11 重新查詢 ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); ParameterList.Add(SLP_SLPDate1.Text);//門市進貨日 ParameterList.Add(SLP_SLPDate2.Text);//轉門市進貨單日 ParameterList.Add(GetDisTypeSelectedValue());//配本方式 ParameterList.Add(SLP_SLPNumber1.Text);//理貨批次 ParameterList.Add(Session["UID"].ToString());//執行者 ParameterList.Add(DateTime.Now);//執行日期 ParameterList.Add(string.Format("{0}_{1}", PageTimeStamp.Value, Session["UID"].ToString()));//PageTimeStamp_LoginID :Session_ID ParameterList.Add(-1);//最大筆數 ALOModel.MaintainStAccept BCO = new ALOModel.MaintainStAccept(ConnectionDB); string strErrMsg = ""; DataTable Dt = null; if (rbtn_TransStatus1.Checked)//已轉單 { #region Dt = BCO.QueryStOutAcceptData(ParameterList, out strErrMsg); #endregion } else//未轉單 { #region Dt = BCO.QueryForFind(ParameterList, out strErrMsg); #endregion } #endregion report.SetDataSource(Dt); string Login_Name = ((DataTable)Session["UserInfo"]).Rows[0]["Name"].ToString(); report.SetParameterValue("par_Program_ID", "ALO21R01"); report.SetParameterValue("par_LoginUser", Session["UID"].ToString() + Login_Name); report.SetParameterValue("par_StAcceptDate", SLP_SLPDate1.Text); report.SetParameterValue("par_OutStAcceptDate", SLP_SLPDate2.Text); report.SetParameterValue("par_DisType", GetDisTypeSelectedText()); 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=" + strFileName);//pdf檔名 Response.ContentType = "application/pdf"; Response.OutputStream.Write(bytesPDF, 0, bytesPDF.Length); Response.Flush(); Response.Close(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { report.Close(); } #endregion }
protected void RaporOlustur(string Format) { EFDal ed = new EFDal(); report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string RaporAdi = Request["RaporAdi"].ToString() + ".rpt"; //string RaporAd = Server.MapPath("..\\..\\Rapor\\" + RaporAdi); string RaporAd = Server.MapPath("Rapor\\" + RaporAdi); report.Load(RaporAd); if (RaporAdi == "SertifikaKapak.rpt")//turkak { //100476479 report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString()); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); //report.SetParameterValue("Url", "Url"); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); } if (RaporAdi == "SertifikaKapakTSE.rpt")//tse { //100476479 report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); //report.SetParameterValue("Url", "Url"); } if (RaporAdi == "SertifikaKapakEImza.rpt")//turkak { //100476479 QRCodeOlustur(); report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString()); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); report.SetParameterValue("Url", Session["qrCodeURL"].ToString()); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); } if (RaporAdi == "SertifikaKapakTSEEImza.rpt")//tse { //100476479 QRCodeOlustur(); report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); report.SetParameterValue("Url", Session["qrCodeURL"].ToString()); } if (RaporAdi == "CihazKayit.rpt") { //report.SetParameterValue("Sifre", "bakalim"); string IstekNo = Request["IstekNo"].ToString(); int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); int Yil = int.Parse(Request["Yil"].ToString()); int FirmaId = int.Parse(Request["FirmaId"].ToString()); report.RecordSelectionFormula = "{vCihazKabul.SILINDI}=false and {vCihazKabul.ISTEKNO}=" + IstekNo + " and {vCihazKabul.BOLGEKODU}=" + BolgeKodu.ToString() + " and {vCihazKabul.YIL}=" + Yil.ToString() + " and {vCihazKabul.FIRMAID}=" + FirmaId.ToString(); //report.RecordSelectionFormula = "{vCihazKabul.YIL}=9 and {vCihazKabul.ISTEKNO}=549 and {vCihazKabul.BOLGEKODU}=2"; } if (RaporAdi == "GorevOluru.rpt") { string GorevId = Request["GorevId"].ToString(); //report.RecordSelectionFormula = "{GorevPersonel.GorevID}=" + GorevId ; report.SetParameterValue("AracPlakasi", Session["RaporIcinAracPlakasi"].ToString()); report.SetParameterValue("GorevId", GorevId); Session.Remove("RaporIcinAracPlakasi"); } if (RaporAdi == "TeklifYeni.rpt") { lblUyari.Visible = false; int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); string TeklifNo = Request["TeklifNo"].ToString(); string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu); if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis { lblUyari.Text = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz.."; lblUyari.Visible = true; return; } else { report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.NEICIN}='teklif'"; //report.SetParameterValue("KurumTipi", "Kamu"); //report.SetParameterValue("Telefon", "4545"); } } if (RaporAdi == "TeklifYeniIndirimli.rpt") { lblUyari.Visible = false; int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); string TeklifNo = Request["TeklifNo"].ToString(); string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu); decimal IndirimOrani = 0; if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis { lblUyari.Text = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz.."; lblUyari.Visible = true; return; } else { report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.NEICIN}='teklif'"; using (Service1Client client = new Service1Client()) { IndirimOrani = client.TeklifNodanIndirimOraniniDon(BolgeKodu, TeklifNo); } report.SetParameterValue("IndirimOrani", IndirimOrani); //report.SetParameterValue("Telefon", "4545"); } } if (RaporAdi == "TeklifYeniOnYazisiz.rpt") { int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); string TeklifNo = Request["TeklifNo"].ToString(); string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu); report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.NEICIN}='teklif'"; report.SetParameterValue("KurumTipi", "Kamu"); report.SetParameterValue("Telefon", Telefon); } if (RaporAdi == "FaturaOnYaziDetayli.rpt") { report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString()); report.SetParameterValue("PaketNolari", Session["FaturaOnYaziIcinVirgulleAyrilmisPaketNolar"].ToString()); report.SetParameterValue("PaketBedelleri", decimal.Parse(Session["PaketBedelleri"].ToString())); report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "H"); if (Session["PaketKapsamindaOlmayanlariGizle"] == "E") { report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "E"); Session["PaketKapsamindaOlmayanlariGizle"] = null; } } if (RaporAdi == "FaturaOnYazi.rpt") { report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString()); report.SetParameterValue("MasrafIncelemeUcreti", Session["DetaysizMasrafIncelemeUcreti"].ToString()); report.SetParameterValue("PostaHavale", Session["DetaysizPostaBedeli"].ToString()); /* * DataSet ds=new DataSet(); * ds=ed.Sorgula("SELECT top 1 dbo.firma.MUSTNO, dbo.firma.FIRMAADI, dbo.firma.ADRESI, dbo.firma.ADRESII, dbo.firma.IL_ILCE, dbo.firma.TELEFON, dbo.firma.FAX, dbo.firma.ILGILI, "+ * " dbo.firma.EMAIL, dbo.firma.NOTLAR, dbo.firma.FATADRES, dbo.firma.VERGIDAIRESI, dbo.firma.VERGINO, dbo.firma.BOLGEKODU, dbo.firma.SILINDI, "+ * " dbo.istek.FIRMAID, dbo.istek.YIL, dbo.istek.ISTEKNO, dbo.istek.ALTISTNO, dbo.istek.CIHAZADI, dbo.istek.IMALATCI, dbo.istek.MODEL, dbo.istek.SERINO, "+ * " dbo.istek.OLCUMARALIGI, dbo.istek.ILGLAB, dbo.istek.SORUMLU, dbo.istek.FATBEDEL, dbo.istek.IPTAL, dbo.istek.BOLGEKODU AS isBolgeKodu, dbo.istek.SILINDI AS isSilindi, "+ * " dbo.istek.FATURASIRA, dbo.istek.CIHAZKAPSAMAYRINTITABLOSU, dbo.FaturaOnYazi.ID, dbo.FaturaOnYazi.ISTID, dbo.FaturaOnYazi.BOLGEKODU AS FoyBolgeKodu, "+ * " dbo.FaturaOnYazi.Silindi AS foySilindi, dbo.FaturaOnYazi.FATURANO, dbo.FaturaOnYazi.GUNLUKSIRA,dbo.FaturaOnYazi.EkBolgemi "+ * " FROM dbo.istek INNER JOIN "+ * " dbo.firma ON dbo.istek.FIRMAID = dbo.firma.FIRMAID INNER JOIN "+ * " dbo.FaturaOnYazi ON dbo.istek.ISTID = dbo.FaturaOnYazi.ISTID "+ * " where FaturaOnYazi.ISTID in ("+Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString() +")"); * * report.SetDataSource(ds); */ } if (RaporAdi == "FaturaOnYaziYeni.rpt") { int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString()); report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); using (Service1Client proxy = new Service1Client()) { decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal PostaBedeli = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti); report.SetParameterValue("PostaBedeli", PostaBedeli); report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami); /* * //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise * if (EkBolgeUcretiToplami == 0) * { * report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false); * } */ Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null; } } //if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt") //{ // int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); // using (Service1Client proxy = new Service1Client()) // { // decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // decimal PostaBedeli = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // decimal IndirimOrani = decimal.Parse(Request["IndirimOrani"].ToString()); // report.SetParameterValue("YurtDisindanmi", false); // report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString()); // report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami); // report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti); // report.SetParameterValue("PostaBedeli", PostaBedeli); // report.SetParameterValue("IndirimOrani", IndirimOrani); // /* // //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise // if (EkBolgeUcretiToplami == 0) // { // report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false); // } // */ // } //} if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt") { int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); using (Service1Client proxy = new Service1Client()) { //decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal MasrafIncelemeUcreti = ed.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal PostaBedeli = ed.FaturaNoIcinIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal IndirimOrani = decimal.Parse(Request["IndirimOrani"].ToString()); report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString()); report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti); report.SetParameterValue("PostaBedeli", PostaBedeli); report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami); report.SetParameterValue("IndirimOrani", IndirimOrani); report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString(), "MasrafveInceleme"); report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString(), "MasrafveInceleme"); } } if (RaporAdi == "FirmaEtiketi.rpt") { report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString()); report.SetParameterValue("FirmaId", Request["FirmaId"].ToString()); } if (RaporAdi == "EgitimSertifikasi.rpt") { int EgtBolgeKodu = 0; report.SetParameterValue("@EgitimId", Request["EgitimId"].ToString()); using (Service1Client proxy = new Service1Client()) { //report.SetParameterValue("EgitimiVerenler", proxy.EgitimiVerenlerinIsimleriniVirgulleAyrilmisOlarakDon(int.Parse(Request["EgitimId"].ToString()))); report.SetParameterValue("EgitimiVerenler", ed.kal_BelirliEgitimiVerenListesiDon2(int.Parse(Request["EgitimId"].ToString()))); report.SetParameterValue("EgitimAdi", proxy.EgitimIddenEgitimAdiDon(int.Parse(Request["EgitimId"].ToString()))); using (Service1Client proxyy = new Service1Client()) { EgtBolgeKodu = proxyy.BolgeKoduDon(Context.User.Identity.Name); } if (EgtBolgeKodu == 1)//Gebze { report.SetParameterValue("ImzaAd", "Ali Can Kuyrukluyıldız"); report.SetParameterValue("ImzaStatu", "Gebze Kalibrasyon Müdürü"); } if (EgtBolgeKodu == 2)//Ankara { report.SetParameterValue("ImzaAd", "Abdulmuttalip Aktoğ"); report.SetParameterValue("ImzaStatu", "Kalibrasyon Grup Başkanı"); } if (EgtBolgeKodu == 3)//Bursa { report.SetParameterValue("ImzaAd", "Ömer EYYUPOĞLU"); report.SetParameterValue("ImzaStatu", "Bursa İl Koordinatörü"); } } } SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(); sb.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["KalData"].ToString(); CrystalDecisions.Shared.TableLogOnInfo tliCurrent; foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in report.Database.Tables) { tliCurrent = tbl.LogOnInfo; tliCurrent.ConnectionInfo.ServerName = sb.DataSource; tliCurrent.ConnectionInfo.UserID = sb.UserID; tliCurrent.ConnectionInfo.Password = sb.Password; tliCurrent.ConnectionInfo.DatabaseName = sb.InitialCatalog; tbl.ApplyLogOnInfo(tliCurrent); } if (Format == "PDF") { if (Session["eImzaliOlacak"] == null) { this.ExportReportPdfEImzaYok(); } else { this.ExportReportPdf(); } } if (Format == "Word") { this.ExportReportWord(); } CrystalReportViewer1.ReportSource = report; //Rapor üretildikten hemen sonra faturalandırılan istekler tablosuna yaz if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt") { using (Service1Client proxy = new Service1Client()) { Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null; string[] IstIdler = (string[])Session["FaturalandirildiOlarakIsaretlenecekIstIdler"]; foreach (var item in IstIdler) { try { proxy.FaturalandirilanIsteklereEkle(int.Parse(item)); } catch { //RadNotification1.Text = " <font color='red'> "+item +" istekId li cihaz faturası yazılanlar tablosuna eklenemedi! Bu, cihazın birden fazla faturalandırılmasına yol acabilir. Lütfen istekId sini not alip sistem yöneticisine bildiriniz.</font>"; ; // RadNotification1.Show(); } } } } }
/// <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, DataSet dt_Source, string reportFormatType) { CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(s_rptFilePath); report.SetDataSource(dt_Source); #region 前置檢查與參數過濾 string par_ProgramID = string.Empty; string par_LoginUser = string.Empty; string sTemp; par_ProgramID = this.PageCode; par_LoginUser = Session["UID"].ToString(); #endregion #region 組合查詢條件至Report ArrayList report.SetParameterValue("ProgramName", par_ProgramID); report.SetParameterValue("UserName", par_LoginUser); //"/" report.SetParameterValue("AcceptDate", this.SLP_Accept_Range.RangeStartTextBox.Text + " - " + this.SLP_Accept_Range.RangeEndTextBox.Text); if (this.SLP_VENDER_BEGIN.Text == string.Empty && this.SLP_VENDER_END.Text == string.Empty) sTemp = string.Empty; else if (this.SLP_VENDER_BEGIN.Text == string.Empty) sTemp = " " + " - " + this.SLP_VENDER_END.Text + "" + this.SLP_VENDER_END.Name; else if (this.SLP_VENDER_END.Text == string.Empty) sTemp = this.SLP_VENDER_BEGIN.Text + "" + this.SLP_VENDER_BEGIN.Name + " - "; else sTemp = this.SLP_VENDER_BEGIN.Text + "" + this.SLP_VENDER_BEGIN.Name + " - " + this.SLP_VENDER_END.Text + "" + this.SLP_VENDER_END.Name; report.SetParameterValue("Vendor", sTemp); if (this.SLP_RootNoStart.Text == string.Empty && this.SLP_RootNoEnd.Text == string.Empty) sTemp = string.Empty; else if (this.SLP_RootNoStart.Text == string.Empty) sTemp = " " + " - " + this.SLP_RootNoEnd.Text + "" + this.SLP_RootNoEnd.Name; else if (this.SLP_RootNoEnd.Text == string.Empty) sTemp = this.SLP_RootNoStart.Text + "" + this.SLP_RootNoStart.Name + " - "; else sTemp = this.SLP_RootNoStart.Text + "" + this.SLP_RootNoStart.Name + " - " + this.SLP_RootNoEnd.Text + "" + this.SLP_RootNoEnd.Name; report.SetParameterValue("RootNo", sTemp); if (this.SLP_PMA_BEGIN.Text == string.Empty && this.SLP_PMA_END.Text == string.Empty) sTemp = string.Empty; else if (this.SLP_PMA_BEGIN.Text == string.Empty) sTemp = " " + " - " + this.SLP_PMA_END.Text + "" + this.SLP_PMA_END.Name; else if (this.SLP_PMA_END.Text == string.Empty) sTemp = this.SLP_PMA_BEGIN.Text + "" + this.SLP_PMA_BEGIN.Name + " - "; else sTemp = this.SLP_PMA_BEGIN.Text + "" + this.SLP_PMA_BEGIN.Name + " - " + this.SLP_PMA_END.Text + "" + this.SLP_PMA_END.Name; report.SetParameterValue("PMA", sTemp); if (this.SLP_CATEGORY_BEGIN.Text == string.Empty && this.SLP_CATEGORY_END.Text == string.Empty) sTemp = string.Empty; else if (this.SLP_CATEGORY_BEGIN.Text == string.Empty) sTemp = " " + " - " + this.SLP_CATEGORY_END.Text + "" + this.SLP_CATEGORY_END.Name; else if (this.SLP_CATEGORY_END.Text == string.Empty) sTemp = this.SLP_CATEGORY_BEGIN.Text + "" + this.SLP_CATEGORY_BEGIN.Name + " - "; else sTemp = this.SLP_CATEGORY_BEGIN.Text + "" + this.SLP_CATEGORY_BEGIN.Name + " - " + this.SLP_CATEGORY_END.Text + "" + this.SLP_CATEGORY_END.Name; report.SetParameterValue("CATEGORY", sTemp); report.SetParameterValue("Item", this.SLP_SKU.Text); report.SetParameterValue("Period", this.SLP_PERIOD.Text); if (this.rdabNormal.Checked == true) report.SetParameterValue("Type", this.rdabNormal.Text); else if (this.rdNormal.Checked == true) report.SetParameterValue("Type", this.rdNormal.Text); #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.OutputStream.Write("AA", 0, 2); Response.Flush(); Response.Close(); report.Close(); break; default: break; } }
private void btnImprimir_Click(object sender, EventArgs e) { Caja caja = new Caja(Globales.IdCaja); string logo=string.Empty; if (!caja.IsNull()) logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo; caja = null; CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rpt.Load("Reportes\\Historial.rpt"); rpt.SetDataSource((DataTable)this.dgvPrestamos.DataSource); rpt.SetParameterValue("NoPrestamo", cbxPrestamo.SelectedValue.ToString()); rpt.SetParameterValue("Cliente", cbxCliente.Text); rpt.SetParameterValue("Capital", tbxCapital.Value); rpt.SetParameterValue("PagoMinimo", tbxPago.Value); rpt.SetParameterValue("FechaCorte", dtpFecha.Value); rpt.SetParameterValue("Estatus", cbxEstatus.Text); rpt.SetParameterValue("Logo", logo); frmReporte frm = new frmReporte(rpt); frm.ShowDialog(); rpt.Dispose(); rpt = null; frm.Dispose(); frm = null; }
private void cmbreports_SelectedIndexChanged(object sender, EventArgs e) { if (cmbreports.SelectedIndex == 1) { try { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptExpenseRegister.rpt")) { //dtblExpense .TableName = "PORegister"; //dtblExpense.WriteXmlSchema(@"D:\Report\PORegister.xsd"); DataView DVReport; DVReport = dtblExpense.DefaultView; DVReport.RowFilter = StrFilter; CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptExpenseRegister.rpt"); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Expense Register", true, true, true, true, false, true, true, false, false, false, true); //rptDoc.SetParameterValue("pFromDate", txtFromDate.Text); //rptDoc.SetParameterValue("pToDate", txtTodate.Text); //if (DataValidator.IsDate(txtFromDate.Text.Trim()) && DataValidator.IsDate(txtTodate.Text.Trim())) //{ // rptDoc.SetParameterValue("pPassDate", true); //} //else //{ // rptDoc.SetParameterValue("pPassDate", false); //} Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Expense Register - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("File is not exist..."); } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Expense - Register Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } if (cmbreports.SelectedIndex == 2) { try { if (dgvExpense.CurrentRow != null) { DataTable dtReport = new DataTable(); dtReport = CommSelect.SelectRecord(Convert.ToInt64(dgvExpense.CurrentRow.Cells["ExpenseID"].Value), "rpt_Expense", "Expense - Report"); if (CommSelect.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptExpense.rpt")) { //dtReport.TableName = "Expense"; //dtReport.WriteXmlSchema(@"D:\Report\Expense.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptExpense.rpt"); CurrentUser.AddReportParameters(rptDoc, dtReport, "Expense", true, true, true, true, true, true, true, false, false, false, false); rptDoc.SetParameterValue("pBusinessLine", CurrentCompany.BusinessLine); rptDoc.SetParameterValue("pCST", CurrentCompany.CST); rptDoc.SetParameterValue("pEmail", CurrentCompany.Email); rptDoc.SetParameterValue("pFax", CurrentCompany.Fax); rptDoc.SetParameterValue("pPhone2", CurrentCompany.Phone2); rptDoc.SetParameterValue("PState", CurrentCompany.State); rptDoc.SetParameterValue("pTin", CurrentCompany.TIN); rptDoc.SetParameterValue("pRegAddress1", CurrentCompany.RegAddress1); rptDoc.SetParameterValue("pRegAddress2", CurrentCompany.RegAddress2); rptDoc.SetParameterValue("pRegCity", CurrentCompany.RegCity); rptDoc.SetParameterValue("pRegFax", CurrentCompany.RegFax); rptDoc.SetParameterValue("pRegPhone", CurrentCompany.RegPhone); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Expense - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("File is not exist..."); } } else { MessageBox.Show(CommSelect.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Expense - Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } }
//Crystal Report 直接輸出 PDF 檔 private void ExportReport(DataTable dt, ReportType RType) { string strFileName = string.Empty; CrystalDecisions.CrystalReports.Engine.ReportDocument report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); report.Load(Server.MapPath("./REPORT/PUR052R01.rpt")); report.SetDataSource(dt); //CrystalReport Parameter 參數設定 string Program_ID = string.Empty; string LoginUser = string.Empty; string LoginName = string.Empty; string YearMonth = string.Empty; Program_ID = this.PageCode + "R01"; LoginUser = Session["UID"].ToString(); LoginName = Get_LoginName(); report.SetParameterValue("par_Program_ID", Program_ID); report.SetParameterValue("par_LoginUser", LoginUser); report.SetParameterValue("par_LoginName", LoginName); strFileName = "在途單"; report.SetParameterValue("par_1", txtONWAY_NO.Text); report.SetParameterValue("par_2", txtONWAY_DATE.Text); report.SetParameterValue("par_3", SLP_VendorBase1.TextBox_Code.Text + " " + SLP_VendorBase1.TextBox_Name.Text); //檔案匯出 if (RType == ReportType.PDF) { ExportPDF(strFileName, report); } else { ExportExcel(strFileName, report); } }
protected void RaporOlustur(string Format) { EFDal ed = new EFDal(); report = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string RaporAdi = Request["RaporAdi"].ToString() + ".rpt"; //string RaporAd = Server.MapPath("..\\..\\Rapor\\" + RaporAdi); string RaporAd = Server.MapPath("Rapor\\" + RaporAdi); report.Load(RaporAd); if (RaporAdi == "SertifikaKapak.rpt")//turkak { //100476479 report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString()); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); //report.SetParameterValue("Url", "Url"); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); } if (RaporAdi == "SertifikaKapakTSE.rpt")//tse { //100476479 report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); //report.SetParameterValue("Url", "Url"); } if (RaporAdi == "SertifikaKapakEImza.rpt")//turkak { //100476479 QRCodeOlustur(); report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); //report.SetParameterValue("QRCodeImagePath", Session["QRCodeImagePath"].ToString()); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); report.SetParameterValue("Url", Session["qrCodeURL"].ToString()); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); } if (RaporAdi == "SertifikaKapakTSEEImza.rpt")//tse { //100476479 QRCodeOlustur(); report.SetParameterValue("SayfaSayisi", Request["SayfaSayisi"].ToString()); report.SetParameterValue("@IstID", Request["IstId"].ToString()); report.SetParameterValue("OnayTarihi", Request["OnayTarihi"].ToString().Replace(" 00:00:00", "")); report.SetParameterValue("CihazAdi", Request["CihazAdi"].ToString()); Session["DokumanSaklanacakIstId"] = Request["SayfaSayisi"].ToString(); //report.SetParameterValue("QRCodeImagePath", QRCodeOlustur()); report.SetParameterValue("Url", Session["qrCodeURL"].ToString()); } if (RaporAdi == "CihazKayit.rpt") { //report.SetParameterValue("Sifre", "bakalim"); string IstekNo = Request["IstekNo"].ToString(); int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); int Yil = int.Parse(Request["Yil"].ToString()); int FirmaId = int.Parse(Request["FirmaId"].ToString()); report.RecordSelectionFormula = "{vCihazKabul.SILINDI}=false and {vCihazKabul.ISTEKNO}=" + IstekNo + " and {vCihazKabul.BOLGEKODU}=" + BolgeKodu.ToString() + " and {vCihazKabul.YIL}=" + Yil.ToString() + " and {vCihazKabul.FIRMAID}=" + FirmaId.ToString(); //report.RecordSelectionFormula = "{vCihazKabul.YIL}=9 and {vCihazKabul.ISTEKNO}=549 and {vCihazKabul.BOLGEKODU}=2"; } if (RaporAdi == "GorevOluru.rpt") { string GorevId = Request["GorevId"].ToString(); //report.RecordSelectionFormula = "{GorevPersonel.GorevID}=" + GorevId ; report.SetParameterValue("AracPlakasi", Session["RaporIcinAracPlakasi"].ToString()); report.SetParameterValue("GorevId", GorevId); Session.Remove("RaporIcinAracPlakasi"); } if (RaporAdi == "TeklifYeni.rpt") { lblUyari.Visible = false; int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); string TeklifNo = Request["TeklifNo"].ToString(); string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu); if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis { lblUyari.Text = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz.."; lblUyari.Visible = true; return; } else { report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.NEICIN}='teklif'"; //report.SetParameterValue("KurumTipi", "Kamu"); //report.SetParameterValue("Telefon", "4545"); } } if (RaporAdi == "TeklifYeniIndirimli.rpt") { lblUyari.Visible = false; int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); string TeklifNo = Request["TeklifNo"].ToString(); string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu); decimal IndirimOrani = 0; if (Telefon == "Neg")//Muhtemelen firma kaydı firma tablosuna yapilmamis { lblUyari.Text = "<b><u>UYARI:</u></b><br/>Muhtemel olarak firma tablosunda firma kaydı bulunamadı. Ya da firmaya ait telefon bilgisi girilmemiş.Lütfen kontrol ediniz.."; lblUyari.Visible = true; return; } else { report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.NEICIN}='teklif'"; using (Service1Client client = new Service1Client()) { IndirimOrani = client.TeklifNodanIndirimOraniniDon(BolgeKodu, TeklifNo); } report.SetParameterValue("IndirimOrani", IndirimOrani); //report.SetParameterValue("Telefon", "4545"); } } if (RaporAdi == "TeklifYeniOnYazisiz.rpt") { int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); string TeklifNo = Request["TeklifNo"].ToString(); string Telefon = ed.TeklifNodanFirmaninTelefonunuDon(TeklifNo, BolgeKodu); report.RecordSelectionFormula = "{teklif.TEKLIFNO}='" + TeklifNo + "' and {teklif.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.BOLGEKODU}=" + BolgeKodu.ToString() + " and {birim.NEICIN}='teklif'"; report.SetParameterValue("KurumTipi", "Kamu"); report.SetParameterValue("Telefon", Telefon); } if (RaporAdi == "FaturaOnYaziDetayli.rpt") { report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString()); report.SetParameterValue("PaketNolari", Session["FaturaOnYaziIcinVirgulleAyrilmisPaketNolar"].ToString()); report.SetParameterValue("PaketBedelleri", decimal.Parse(Session["PaketBedelleri"].ToString())); report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "H"); if (Session["PaketKapsamindaOlmayanlariGizle"] == "E") { report.SetParameterValue("PaketKapsamindaOlmayanlariGizle", "E"); Session["PaketKapsamindaOlmayanlariGizle"] = null; } } if (RaporAdi == "FaturaOnYazi.rpt") { report.SetParameterValue("IstIdler", Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString()); report.SetParameterValue("MasrafIncelemeUcreti", Session["DetaysizMasrafIncelemeUcreti"].ToString()); report.SetParameterValue("PostaHavale", Session["DetaysizPostaBedeli"].ToString()); /* DataSet ds=new DataSet(); ds=ed.Sorgula("SELECT top 1 dbo.firma.MUSTNO, dbo.firma.FIRMAADI, dbo.firma.ADRESI, dbo.firma.ADRESII, dbo.firma.IL_ILCE, dbo.firma.TELEFON, dbo.firma.FAX, dbo.firma.ILGILI, "+ " dbo.firma.EMAIL, dbo.firma.NOTLAR, dbo.firma.FATADRES, dbo.firma.VERGIDAIRESI, dbo.firma.VERGINO, dbo.firma.BOLGEKODU, dbo.firma.SILINDI, "+ " dbo.istek.FIRMAID, dbo.istek.YIL, dbo.istek.ISTEKNO, dbo.istek.ALTISTNO, dbo.istek.CIHAZADI, dbo.istek.IMALATCI, dbo.istek.MODEL, dbo.istek.SERINO, "+ " dbo.istek.OLCUMARALIGI, dbo.istek.ILGLAB, dbo.istek.SORUMLU, dbo.istek.FATBEDEL, dbo.istek.IPTAL, dbo.istek.BOLGEKODU AS isBolgeKodu, dbo.istek.SILINDI AS isSilindi, "+ " dbo.istek.FATURASIRA, dbo.istek.CIHAZKAPSAMAYRINTITABLOSU, dbo.FaturaOnYazi.ID, dbo.FaturaOnYazi.ISTID, dbo.FaturaOnYazi.BOLGEKODU AS FoyBolgeKodu, "+ " dbo.FaturaOnYazi.Silindi AS foySilindi, dbo.FaturaOnYazi.FATURANO, dbo.FaturaOnYazi.GUNLUKSIRA,dbo.FaturaOnYazi.EkBolgemi "+ " FROM dbo.istek INNER JOIN "+ " dbo.firma ON dbo.istek.FIRMAID = dbo.firma.FIRMAID INNER JOIN "+ " dbo.FaturaOnYazi ON dbo.istek.ISTID = dbo.FaturaOnYazi.ISTID "+ " where FaturaOnYazi.ISTID in ("+Session["FaturaOnYaziIcinVirgulleAyrilmisIstIdler"].ToString() +")"); report.SetDataSource(ds); */ } if (RaporAdi == "FaturaOnYaziYeni.rpt") { int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString()); report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); using (Service1Client proxy = new Service1Client()) { decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal PostaBedeli = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti); report.SetParameterValue("PostaBedeli", PostaBedeli); report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami); /* //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise if (EkBolgeUcretiToplami == 0) { report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false); } */ Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null; } } //if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt") //{ // int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); // using (Service1Client proxy = new Service1Client()) // { // decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // decimal PostaBedeli = proxy.FaturaNoIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // decimal IndirimOrani = decimal.Parse(Request["IndirimOrani"].ToString()); // report.SetParameterValue("YurtDisindanmi", false); // report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString()); // report.SetParameterValue("FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); // report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami); // report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti); // report.SetParameterValue("PostaBedeli", PostaBedeli); // report.SetParameterValue("IndirimOrani", IndirimOrani); // /* // //Burada rapurun daha az yer tutar,sıkışık görünemsi için EkBolgeler subreportunu kapatabiliriz eğer EkBolgeUcretiToplami == 0 ise // if (EkBolgeUcretiToplami == 0) // { // report.SetParameterValue("IstegeAitEkBolgelerSubReportuGorunsunmu", false); // } // */ // } //} if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt") { int BolgeKodu = ed.kal_BolgeKoduDon(Context.User.Identity.Name); using (Service1Client proxy = new Service1Client()) { //decimal MasrafIncelemeUcreti = proxy.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal MasrafIncelemeUcreti = ed.FaturaNoIcinMasrafIncelemeBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal EkBolgeUcretiToplami = proxy.FaturaNoIcinIcinEkBolgeToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal PostaBedeli = ed.FaturaNoIcinIcinPostaBedeliToplamlari(BolgeKodu, Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); decimal IndirimOrani = decimal.Parse(Request["IndirimOrani"].ToString()); report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString()); report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString()); report.SetParameterValue("MasrafIncelemeToplami", MasrafIncelemeUcreti); report.SetParameterValue("PostaBedeli", PostaBedeli); report.SetParameterValue("EkBolgeToplami", EkBolgeUcretiToplami); report.SetParameterValue("IndirimOrani", IndirimOrani); report.SetParameterValue("@BolgeKodu", Request["BolgeKodu"].ToString(), "MasrafveInceleme"); report.SetParameterValue("@FaturaNo", Session["FaturaIcerigindenRaporaGidenFaturaNo"].ToString(), "MasrafveInceleme"); } } if (RaporAdi == "FirmaEtiketi.rpt") { report.SetParameterValue("BolgeKodu", Request["BolgeKodu"].ToString()); report.SetParameterValue("FirmaId", Request["FirmaId"].ToString()); } if (RaporAdi == "EgitimSertifikasi.rpt") { int EgtBolgeKodu = 0; report.SetParameterValue("@EgitimId", Request["EgitimId"].ToString()); using (Service1Client proxy = new Service1Client()) { //report.SetParameterValue("EgitimiVerenler", proxy.EgitimiVerenlerinIsimleriniVirgulleAyrilmisOlarakDon(int.Parse(Request["EgitimId"].ToString()))); report.SetParameterValue("EgitimiVerenler", ed.kal_BelirliEgitimiVerenListesiDon2(int.Parse(Request["EgitimId"].ToString()))); report.SetParameterValue("EgitimAdi", proxy.EgitimIddenEgitimAdiDon(int.Parse(Request["EgitimId"].ToString()))); using (Service1Client proxyy = new Service1Client()) { EgtBolgeKodu = proxyy.BolgeKoduDon(Context.User.Identity.Name); } if (EgtBolgeKodu == 1)//Gebze { report.SetParameterValue("ImzaAd", "Ali Can Kuyrukluyıldız"); report.SetParameterValue("ImzaStatu", "Gebze Kalibrasyon Müdürü"); } if (EgtBolgeKodu == 2)//Ankara { report.SetParameterValue("ImzaAd", "Abdulmuttalip Aktoğ"); report.SetParameterValue("ImzaStatu", "Kalibrasyon Grup Başkanı"); } if (EgtBolgeKodu == 3)//Bursa { report.SetParameterValue("ImzaAd", "Ömer EYYUPOĞLU"); report.SetParameterValue("ImzaStatu", "Bursa İl Koordinatörü"); } } } SqlConnectionStringBuilder sb = new SqlConnectionStringBuilder(); sb.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["KalData"].ToString(); CrystalDecisions.Shared.TableLogOnInfo tliCurrent; foreach (CrystalDecisions.CrystalReports.Engine.Table tbl in report.Database.Tables) { tliCurrent = tbl.LogOnInfo; tliCurrent.ConnectionInfo.ServerName = sb.DataSource; tliCurrent.ConnectionInfo.UserID = sb.UserID; tliCurrent.ConnectionInfo.Password = sb.Password; tliCurrent.ConnectionInfo.DatabaseName = sb.InitialCatalog; tbl.ApplyLogOnInfo(tliCurrent); } if (Format == "PDF") { if (Session["eImzaliOlacak"] == null) { this.ExportReportPdfEImzaYok(); } else { this.ExportReportPdf(); } } if (Format == "Word") { this.ExportReportWord(); } CrystalReportViewer1.ReportSource = report; //Rapor üretildikten hemen sonra faturalandırılan istekler tablosuna yaz if (RaporAdi == "FaturaOnYaziYeniProtokolBilgili.rpt") { using (Service1Client proxy = new Service1Client()) { Session["FaturaIcerigindenRaporaGidenFaturaNo"] = null; string[] IstIdler = (string[])Session["FaturalandirildiOlarakIsaretlenecekIstIdler"]; foreach (var item in IstIdler) { try { proxy.FaturalandirilanIsteklereEkle(int.Parse(item)); } catch { //RadNotification1.Text = " <font color='red'> "+item +" istekId li cihaz faturası yazılanlar tablosuna eklenemedi! Bu, cihazın birden fazla faturalandırılmasına yol acabilir. Lütfen istekId sini not alip sistem yöneticisine bildiriniz.</font>"; ; // RadNotification1.Show(); } } } } }