private void Fprint_Load(object sender, EventArgs e) { fMenu xf = new fMenu(); this.Left = xf.Left + 167; this.Top = xf.Top + 75; this.Width = Screen.PrimaryScreen.Bounds.Width - xf.panel1.Width - 160; this.Height = Screen.PrimaryScreen.Bounds.Height - xf.Top - 170; reportDocument1.FileName = Program.lAppPath + "\\pr.rpt"; tbl = reportDocument1.Database.Tables["Tmp"]; list = reportDocument1; sql = " select * from Tmp "; tb = Program.ExecSelect(sql); if (tb.Rows.Count == 0) { MessageBox.Show("没有符合该条件的记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); crystalReportViewer1.Visible = false; } else { tbl.SetDataSource(tb); list.Refresh(); crystalReportViewer1.Visible = true; } errinf = Program.SqlCmd("delete from Tmp"); }
public ActionResult ExportData_IU(ApplicationHeaderInfo pInfo, App_Detail_PLD01_HDCN_Info pDetail, List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo) { try { string language = AppsCommon.GetCurrentLang(); // Fill export_header string fileName_docx = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VI_" + TradeMarkAppCode.AppCode_TM_4C2_PLD_01_HDCN + ".docx"); AppsCommon.Prepare_Data_Export_D01(ref pDetail, pInfo, pAppDocumentInfo, pFeeFixInfo); List <App_Detail_PLD01_HDCN_Info> _lst = new List <App_Detail_PLD01_HDCN_Info>(); _lst.Add(pDetail); DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_PLD01_HDCN_Info>(_lst, false); _ds_all.Tables[0].TableName = "Table_4c2"; CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _tempfile = "TM_PLD01_HDCN.rpt"; string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"); if (language == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"; } else { _tempfile = "TM_PLD01_HDCN_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf"; } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); //oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), "TM_PLD01_HDCN.rpt")); if (_ds_all != null) { oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); System.IO.Stream oStream = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
public ActionResult Descargar() { if (Request.Cookies[cookie_name] != null) { if (funcion.valid_cookie(Request.Cookies[cookie_name].Value)) { CrystalDecisions.CrystalReports.Engine.ReportDocument reporte = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); reporte.Load(Server.MapPath("~/Reports/Reporte.rpt")); reporte.SetDatabaseLogon("admin", "123456", "SINDECIDIR-PC", "sistemaV2"); reporte.Refresh(); try { Stream stream = reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "Sistema_Reporte.pdf")); } catch { throw; } } else { return(RedirectToAction("Index", "Login")); } } else { return(RedirectToAction("Index", "Login")); } }
private void taxInvoiceToolStripMenuItem_Click(object sender, EventArgs e) { try { DataTable dt = new DataTable(); LogoBind(dt); if (dgvSalesInvoice.CurrentRow != null) { DataTable dtTNC = new DataTable(); NameValueCollection para2 = new NameValueCollection(); para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString()); para2.Add("@i_TNC_Sub", "SALES"); dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC"); DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_SalesInvoice", para, "SalesInvoice - Report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptSalesInvoice.rpt")) { //dtReport.TableName = "PurchaseOrder"; //dtReport.WriteXmlSchema(@"D:\PurchaseOrder.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptSalesInvoice.rpt"); rptDoc.Subreports[0].DataSourceConnections.Clear(); rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC); rptDoc.Database.Tables[1].SetDataSource(dt); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, dtReport, "Tax Invoice", true, true, true, true, true, true, true, true, true, true, true); CurrentUser.AddExtraParameter(rptDoc); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Sales Invoice - [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("Sales Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } }
// Reportes public ActionResult DescargarReporte() { CrystalDecisions.CrystalReports.Engine.ReportDocument reporte = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); reporte.Load(Server.MapPath("~/Reportes/Reporte.rpt")); reporte.SetDatabaseLogon("admin", "123456", "localhost\\SQLEXPRESS", "sistema"); reporte.Refresh(); try { Stream stream = reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "Sistema_Reporte.pdf")); } catch (Exception ex) { throw; } }
public void ReportEngine(string rptNm, int 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); crReportDocument.SetParameterValue(0, OderID); //crReportDocument.SetParameterValue(1,CustID); 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 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 m_mthSetData(cls3DItem[] arrItems) { if (arrItems == null) { return; } DataSet objSet = m_objCreateDS(); DataTable objDT = objSet.Tables["tbReport"]; for (int i = 0; i < arrItems.Length; i++) { DataRow objRow = objDT.NewRow(); arrItems[i].ToDataRow(ref objRow); objDT.Rows.Add(objRow); } m_objDocument.SetDataSource(objSet); m_objDocument.Refresh(); crystalReportViewer1.ReportSource = m_objDocument; crystalReportViewer1.Refresh(); }
public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate) { try { string language = AppsCommon.GetCurrentLang(); App_Detail_C01_BL objBL = new App_Detail_C01_BL(); ApplicationHeaderInfo applicationHeaderInfo = new ApplicationHeaderInfo(); App_Detail_C01_Info app_Detail = new App_Detail_C01_Info(); List <AppFeeFixInfo> appFeeFixInfos = new List <AppFeeFixInfo>(); List <AppDocumentInfo> appDocumentInfos = new List <AppDocumentInfo>(); List <AppDocumentOthersInfo> _LstDocumentOthersInfo = new List <AppDocumentOthersInfo>(); List <AppDocumentOthersInfo> pLstImagePublic = new List <AppDocumentOthersInfo>(); app_Detail = objBL.GetByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref appFeeFixInfos, ref _LstDocumentOthersInfo, ref pLstImagePublic); AppsCommon.Prepare_Data_Export_C01(ref app_Detail, applicationHeaderInfo, appDocumentInfos, pLstImagePublic); if (_LstDocumentOthersInfo != null) { foreach (var item in _LstDocumentOthersInfo) { app_Detail.Note += item.Documentname + " ; "; } if (_LstDocumentOthersInfo.Count > 0) { app_Detail.Note = app_Detail.Note.Substring(0, app_Detail.Note.Length - 2); } } List <App_Detail_C01_Info> _lst = new List <App_Detail_C01_Info>(); _lst.Add(app_Detail); DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_C01_Info>(_lst, false); CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string _tempfile = "C01.rpt"; string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); if (p_View_Translate == 1) { // nếu là tiếng việt thì xem bản tiếng anh và ngược lại if (applicationHeaderInfo.Languague_Code == Language.LangVI) { _tempfile = "C01_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"; } else { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"; } } else { if (applicationHeaderInfo.Languague_Code == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"; } else { _tempfile = "C01_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"; } } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); if (_ds_all != null) { _ds_all.Tables[0].TableName = "Table"; //_ds_all.WriteXml(@"C:\inetpub\C01.xml", XmlWriteMode.WriteSchema); // đè các bản dịch lên if (p_View_Translate == 1) { // nếu là bản xem của thằng dịch App_Translate_BL _App_Translate_BL = new App_Translate_BL(); List <App_Translate_Info> _lst_translate = _App_Translate_BL.App_Translate_GetBy_AppId(pAppHeaderId); AppsCommon.Overwrite_DataSouce_Export(ref _ds_all, _lst_translate); } oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); System.IO.Stream oStream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
private void cmbreports_SelectedIndexChanged(object sender, EventArgs e) { if (cmbreports.SelectedIndex == 1) { try { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_FYID", CurrentUser.FYID.ToString()); dtReport = objList.ListOfRecord("rpt_SalesInvoiceRegister", para, "SalesInvoice - Report"); DataView DVReport; DVReport = dtReport.DefaultView; DVReport.RowFilter = StrFilter; if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptSalesInvoiceRegister.rpt")) { //dtblSalesInvoice .TableName = "PORegister"; //dtblSalesInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptSalesInvoiceRegister.rpt"); //rptDoc.BlankRecords.Height -= (ds.tblItems.Count * 136); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Sales Invoice Register", true, true, true, true, false, true, true, false, false, false, true); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Sales Invoice 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("Sales Invoice - Register Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 2) { rptSalesInvoice_Click(sender, e); } else if (cmbreports.SelectedIndex == 3) { if (dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString().Substring(0, 2) == "RI") { salesInvoiceToolStripMenuItem_Click(sender, e); } else { MessageBox.Show("Retail Invoice not generated for this sale."); } } else if (cmbreports.SelectedIndex == 4) { if (dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString().Substring(0, 2) == "TI") { taxInvoiceToolStripMenuItem_Click(sender, e); } else { MessageBox.Show("Tax Invoice not generated for this sale."); } } //////////////////////// else if (cmbreports.SelectedIndex == 5) { if (dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString().Substring(0, 2) == "ES") { try { DataTable dt = new DataTable(); LogoBind(dt); if (dgvSalesInvoice.CurrentRow != null) { DataTable dtTNC = new DataTable(); NameValueCollection para2 = new NameValueCollection(); para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString()); para2.Add("@i_TNC_Sub", "SALES"); dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC"); DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_SalesInvoice", para, "SalesInvoice - Report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptSalesInvoice.rpt")) { //dtReport.TableName = "PurchaseOrder"; //dtReport.WriteXmlSchema(@"D:\PurchaseOrder.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptSalesInvoice.rpt"); rptDoc.Subreports[0].DataSourceConnections.Clear(); rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC); rptDoc.Database.Tables[1].SetDataSource(dt); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, dtReport, "Estimate", true, true, true, true, true, true, true, true, true, true, true); CurrentUser.AddExtraParameter(rptDoc); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Estimate - [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("Sales Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else { MessageBox.Show("Estimate not generated for this sale."); } } /////////////////// //else if (cmbreports.SelectedIndex == 6) //{ // try // { // DataTable dt = new DataTable(); // LogoBind(dt); // if (dgvSalesInvoice.CurrentRow != null) // { // DataTable dtTNC = new DataTable(); // NameValueCollection para2 = new NameValueCollection(); // para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString()); // para2.Add("@i_TNC_Sub", "SALES"); // dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC"); // DataTable dtReport = new DataTable(); // NameValueCollection para = new NameValueCollection(); // para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString()); // dtReport = objList.ListOfRecord("rpt_SalesInvoice", para, "SalesInvoice - Report"); // if (objList.Exception == null) // { // if (System.IO.File.Exists(CurrentUser.ReportPath + "rptDeliveryChallan.rpt")) // { // //dtReport.TableName = "Logo"; // //dtReport.WriteXmlSchema(@"D:\ERP-CRM\CRM_ICON\Logo.xsd"); // CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); // rptDoc.Load(CurrentUser.ReportPath + "rptDeliveryChallan.rpt"); // rptDoc.Subreports[0].DataSourceConnections.Clear(); // rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC); // //rptDoc.Refresh(); // rptDoc.Database.Tables[1].SetDataSource(dt); // rptDoc.Refresh(); // CurrentUser.AddReportParameters(rptDoc, dtReport, "Delivery Challan", true, true, true, true, true, true, true, true, true, true, true); // CurrentUser.AddExtraParameter(rptDoc); // Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); // fRptView.Text = "Delivery Challan - [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("Sales Invoice", exc.StackTrace); // MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); // } //} else if (cmbreports.SelectedIndex == 6) { try { DataTable dt = new DataTable(); LogoBind(dt); if (dgvSalesInvoice.CurrentRow != null) { DataTable dtTNC = new DataTable(); NameValueCollection para2 = new NameValueCollection(); para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString()); para2.Add("@i_TNC_Sub", "SALES"); dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC"); DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_SalesInvoice", para, "SalesInvoice - Report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptSalesInvoice.rpt")) { //dtReport.TableName = "PurchaseOrder"; //dtReport.WriteXmlSchema(@"D:\PurchaseOrder.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptSalesInvoice.rpt"); rptDoc.Subreports[0].DataSourceConnections.Clear(); rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC); rptDoc.Database.Tables[1].SetDataSource(dt); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, dtReport, "Proforma Invoice", true, true, true, true, true, true, true, true, true, true, true); CurrentUser.AddExtraParameter(rptDoc); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Proforma Invoice - [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("Sales Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 7) { try { if (dgvSalesInvoice.CurrentRow != null) { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_RecID", Convert.ToInt64(dgvSalesInvoice.CurrentRow.Cells["SIID"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_ChallanCumTaxInvoice", para, "SalesInvoice - Report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptChallanCumTaxInvoice.rpt")) { //dtReport.TableName = "ChallanCumTaxInvoice"; //dtReport.WriteXmlSchema(@"D:\ChallanCumTaxInvoice.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptChallanCumTaxInvoice.rpt"); CurrentUser.AddReportParameters(rptDoc, dtReport, "Challan Cum Tax Invoice", true, true, true, true, true, true, true, true, true, true, true); CurrentUser.AddExtraParameter(rptDoc); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Challan Cum Tax Invoice - [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("Sales Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } cmbreports.SelectedIndex = 0; }
public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo) { try { string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string language = AppsCommon.GetCurrentLang(); List <E01_Info_Export> _lst = new List <E01_Info_Export>(); string p_appCode = "E01_Preview"; string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_VN_" + _datetimenow + ".pdf"); if (language == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_VN_" + _datetimenow + ".pdf"; } else { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf"; } E01_Info_Export _E01_Info_Export = new E01_Info_Export(); // Phí cố định List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_E01(pInfo); AppsCommon.Prepare_Data_Export_E01(ref _E01_Info_Export, pInfo, pAppDocumentInfo, _lstFeeFix); _lst.Add(_E01_Info_Export); DataSet _ds_all = ConvertData.ConvertToDataSet <E01_Info_Export>(_lst, false); //_ds_all.WriteXml(@"D:\E01.xml", XmlWriteMode.WriteSchema); CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _tempfile = "E01.rpt"; if (language == Language.LangEN) { _tempfile = "E01_EN.rpt"; } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); if (_ds_all != null) { _ds_all.Tables[0].TableName = "Table1"; oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf); System.IO.Stream oStream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
private void cmbreports_SelectedIndexChanged(object sender, EventArgs e) { if (cmbreports.SelectedIndex == 1) { try { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemStockRegister.rpt")) { //dtblItemStock .TableName = "ItemStockRegister"; //dtblItemStock.WriteXmlSchema(@"D:\ItemStockRegister.xsd"); DataView DVReport; DVReport = dtblItemStock.DefaultView; DVReport.RowFilter = StrFilter; CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptItemStockRegister.rpt"); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Stock Register", true, true, true, true, false, true, true, false, false, false, false); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Item Stock Register - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("File is not exist..."); } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("ItemStock - Register Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 2) { try { if (dgvItemStock.CurrentRow != null) { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_StockID", dgvItemStock.CurrentRow.Cells["StockID"].Value.ToString()); dtReport = objList.ListOfRecord("rpt_ItemBeanCard", para, "ItemStock - Bean Card report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemBeanCard.rpt")) { //dtReport .TableName = "ItemBeanCard"; //dtReport.WriteXmlSchema(@"D:\Report\ItemBeanCard.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptItemBeanCard.rpt"); CurrentUser.AddReportParameters(rptDoc, dtReport, "Item Bean Card", true, true, true, true, false, true, true, false, false, false, false); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Item Bean Card - [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("ItemStock - Bean Card Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 3) { try { DataTable dt = new DataTable(); LogoBind(dt); if (System.IO.File.Exists(CurrentUser.ReportPath + "rptItemStockValuationRegister.rpt")) { //dtblItemStock .TableName = "ItemStockValuationRegister"; //dtblItemStock.WriteXmlSchema(@"D:\ItemStockValuationRegister.xsd"); DataView DVReport; DVReport = dtblItemStock.DefaultView; DVReport.RowFilter = filter; CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptItemStockValuationRegister.rpt"); rptDoc.Database.Tables[1].SetDataSource(dt); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Item Stock Valuation Register", true, true, true, true, false, true, true, false, false, false, false); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Item Stock Register - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("File is not exist..."); } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("ItemStock - Register Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } cmbreports.SelectedIndex = 0; }
public ActionResult ExportDataNew(ApplicationHeaderInfo pInfo, AppTM06DKQTInfoExport pDetail, List <AppDocumentInfo> pAppDocumentInfo, List <AppClassDetailInfo> pAppClassInfo) { try { // AppTM06DKQTInfoExport pDetail= new AppTM06DKQTInfoExport(); string _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/AppForms/C06_Request for_international_trademark_registration_vi_exp.doc"); // Fill export_header string fileName = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C06_Request_for_international_trademark_registration_vi_exp_" + pInfo.Appcode + ".pdf"); // Fill export_detail pDetail.Status = 254; pDetail.Status_Form = 252; pDetail.Relationship = "11"; pDetail.strNgayNopDon = pDetail.NGAYNOPDON.ToDateStringN0(); if (pDetail.REF_APPNO_TEXT != null) { pDetail.REF_APPNO_TEXT = pDetail.REF_APPNO_TEXT.Trim(); } pDetail = CreateInstanceTM06DKQT.CopyAppHeaderInfo(pDetail, pInfo); if (pAppClassInfo != null) { Hashtable _hsGroupclass = new Hashtable(); foreach (var item in pAppClassInfo) { AppClassDetailInfo _newinfo = new AppClassDetailInfo(); _newinfo.CloneObj(); if (_hsGroupclass.ContainsKey(item.Code.Substring(0, 2))) { _newinfo = (AppClassDetailInfo)_hsGroupclass[item.Code.Substring(0, 2)]; } _newinfo.Code = item.Code; _newinfo.Textinput += item.Textinput + ", "; _newinfo.IntTongSanPham++; _hsGroupclass[item.Code.Substring(0, 2)] = _newinfo; } List <AppClassDetailInfo> _listApp = new List <AppClassDetailInfo>(); foreach (DictionaryEntry item in _hsGroupclass) { _listApp.Add((AppClassDetailInfo)item.Value); } foreach (AppClassDetailInfo item in _listApp.OrderBy(m => m.Code)) { pDetail.strListClass += "Nhóm " + item.Code.Substring(0, 2) + ": " + item.Textinput.Trim().Trim(',') + " (" + (item.IntTongSanPham < 10 ? "0" + item.IntTongSanPham.ToString() : item.IntTongSanPham.ToString()) + " sản phẩm)" + "\n"; } } // đẩy file lên server if (pDetail.pfileLogo != null) { pDetail.LOGOURL = AppLoadHelpers.PushFileToServer(pDetail.pfileLogo, AppUpload.Logo); } if (!string.IsNullOrEmpty(pDetail.LOGOURL)) { //Kết xuất ảnh } #region hiển thị tài liệu đính kèm if (pAppDocumentInfo == null) { pAppDocumentInfo = new List <AppDocumentInfo>(); } foreach (AppDocumentInfo item in pAppDocumentInfo) { if (item.Document_Id == "C06DKQT_D_01") { pDetail.TOKHAI_USED = item.Isuse.ToString(); pDetail.TOKHAI_SOTRANG = item.CHAR01; pDetail.TOKHAI_SOBAN = item.CHAR02; continue; } if (item.Document_Id == "C06DKQT_D_02") { pDetail.MAUDK_VPQT_USED = item.Isuse.ToString(); pDetail.MAUDK_VPQT_SO = item.CHAR01; pDetail.MAUDK_VPQT_NGONNGU = item.CHAR02; pDetail.MAUDK_VPQT_SOTRANG = item.CHAR03; pDetail.MAUDK_VPQT_SOBAN = item.CHAR04; continue; } if (item.Document_Id == "C06DKQT_D_03") { pDetail.MAUNDH_USED = item.Isuse.ToString(); pDetail.MAUNDH_SOMAU = item.CHAR01; continue; } if (item.Document_Id == "C06DKQT_D_04") { pDetail.BANSAO_TOKHAI_USED = item.Isuse.ToString(); continue; } if (item.Document_Id == "C06DKQT_D_05") { pDetail.BANSAO_GIAYDK_NHCS_USED = item.Isuse.ToString(); continue; } if (item.Document_Id == "C06DKQT_D_06") { pDetail.BAN_CK_SD_NGANHANG_USED = item.Isuse.ToString(); continue; } if (item.Document_Id == "C06DKQT_D_07") { pDetail.GIAY_UQ_USED = item.Isuse.ToString(); pDetail.GIAY_UQ_NGONNGU = item.CHAR01; continue; } if (item.Document_Id == "C06DKQT_D_08") { pDetail.GIAY_UQ_BANDICH_USED = item.Isuse.ToString(); pDetail.GIAY_UQ_BANDICH_SOTRANG = item.CHAR01; continue; } if (item.Document_Id == "C06DKQT_D_09") { pDetail.GIAY_UQ_BANDICH_BANGOC_USED = item.Isuse.ToString(); continue; } if (item.Document_Id == "C06DKQT_D_010") { pDetail.GIAY_UQ_BANDICH_BANSAO_USED = item.Isuse.ToString(); continue; } if (item.Document_Id == "C06DKQT_D_011") { pDetail.GIAY_UQ_BANGOCNOPSAU_USED = item.Isuse.ToString(); continue; } if (item.Document_Id == "C06DKQT_D_012") { pDetail.GIAY_UQ_BANGOCNOP_THEOSO_USED = item.Isuse.ToString(); pDetail.GIAY_UQ_BANGOCNOP_THEOSO = item.CHAR01; continue; } if (item.Document_Id == "C06DKQT_D_013") { pDetail.CHUNGTU_LEPHI_USED = item.Isuse.ToString(); continue; } if (item.Document_Id == "C06DKQT_D_014") { pDetail.TAILIEUBOSUNG_USED = item.Isuse.ToString(); pDetail.TAILIEUBOSUNG = item.CHAR01; continue; } } #endregion List <AppFeeFixInfo> pFeeFixInfo = CommonFunction.Call_Fee.CallFee_C06(pDetail); pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount; if (pInfo.Languague_Code == Language.LangEN) { pDetail.LEPHI = (pFeeFixInfo[0] as AppFeeFixInfo).Amount_Usd; } List <AppTM06DKQTInfoExport> _lst = new List <AppTM06DKQTInfoExport>(); pDetail.LOGOURL = Server.MapPath(pDetail.LOGOURL); _lst.Add(pDetail); DataSet _ds_all = ConvertData.ConvertToDataSet <AppTM06DKQTInfoExport>(_lst, false); CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _tempfile = "C06.rpt"; //if(AppsCommon.GetCurrentLang() == Language.LangEN) if (pInfo.Languague_Code != Language.LangVI) { _tempfile = "C06.rpt"; } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile), OpenReportMethod.OpenReportByTempCopy); // _ds_all.WriteXmlSchema(@"C:\Users\user\Desktop\LEGALTECH\XMLFILE\TM06DKQT.xml"); //Logger.LogInfo("b3: "); CrystalDecisions.CrystalReports.Engine.PictureObject _pic01; _pic01 = (CrystalDecisions.CrystalReports.Engine.PictureObject)oRpt.ReportDefinition.Sections[0].ReportObjects["Picture1"]; _pic01.Width = 200; _pic01.Height = 200; System.IO.FileInfo file = new System.IO.FileInfo(pDetail.LOGOURL); Bitmap img = new Bitmap(pDetail.LOGOURL); try { double _Const = 6.666666666666 / 2; int _left = 0, _top = 0, _marginleft = 225, _margintop = 5580; int _h = 600; double _d1 = (_h - img.Width) / 2; _d1 = _Const * _d1; _left = _marginleft + Convert.ToInt32(_d1); if (_left < 0) { _left = _marginleft; } _pic01.Left = _left; // top _d1 = (_h - img.Height) / 2; _d1 = _Const * _d1; _top = _margintop + Convert.ToInt32(_d1); if (_top < 0) { _top = _margintop; } _pic01.Top = _top; } catch (Exception) { } finally { img.Dispose(); } if (_ds_all != null) { _ds_all.Tables[0].TableName = "Table1"; oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); System.IO.Stream oStream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate) { try { string language = AppsCommon.GetCurrentLang(); ApplicationHeaderInfo applicationHeaderInfo = new ApplicationHeaderInfo(); App_Detail_PLD01_HDCN_Info app_Detail = new App_Detail_PLD01_HDCN_Info(); List <AppFeeFixInfo> appFeeFixInfos = new List <AppFeeFixInfo>(); List <AppDocumentInfo> appDocumentInfos = new List <AppDocumentInfo>(); App_Detail_PLD01_HDCN_BL objBL = new App_Detail_PLD01_HDCN_BL(); app_Detail = objBL.GetByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref appFeeFixInfos); string _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/AppForms/D01_VI.docx"); DocumentModel document = DocumentModel.Load(_fileTemp); AppsCommon.Prepare_Data_Export_D01(ref app_Detail, applicationHeaderInfo, appDocumentInfos, appFeeFixInfos); List <App_Detail_PLD01_HDCN_Info> _lst = new List <App_Detail_PLD01_HDCN_Info>(); _lst.Add(app_Detail); DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_PLD01_HDCN_Info>(_lst, false); _ds_all.Tables[0].TableName = "Table_4c2"; CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string _tempfile = "TM_PLD01_HDCN.rpt"; string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"); if (p_View_Translate == 1) { // nếu là tiếng việt thì xem bản tiếng anh và ngược lại if (applicationHeaderInfo.Languague_Code == Language.LangVI) { _tempfile = "TM_PLD01_HDCN_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf"; } else { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"; } } else { if (applicationHeaderInfo.Languague_Code == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_VN_" + _datetimenow + ".pdf"; } else { _tempfile = "TM_PLD01_HDCN_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "D01_EN_" + _datetimenow + ".pdf"; } } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); if (_ds_all != null) { oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); System.IO.Stream oStream = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, App_Detail_C01_Info pDetail, List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo, List <AppDocumentOthersInfo> pAppDocOtherInfo, List <AppDocumentOthersInfo> pLstImagePublic) { try { string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string language = AppsCommon.GetCurrentLang(); List <App_Detail_C01_Info> _lst = new List <App_Detail_C01_Info>(); string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); if (language == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"; } else { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"; } AppsCommon.Prepare_Data_Export_C01(ref pDetail, pInfo, pAppDocumentInfo, pLstImagePublic); if (pAppDocOtherInfo != null) { foreach (var item in pAppDocOtherInfo) { pDetail.Note += item.Documentname + " ; "; } if (pAppDocOtherInfo.Count > 0) { pDetail.Note = pDetail.Note.Substring(0, pDetail.Note.Length - 2); } } _lst.Add(pDetail); DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_C01_Info>(_lst, false); //_ds_all.WriteXml(@"C:\inetpub\A01.xml", XmlWriteMode.WriteSchema); CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _tempfile = "C01.rpt"; if (language == Language.LangEN) { _tempfile = "C01_EN.rpt"; } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); if (_ds_all != null) { _ds_all.Tables[0].TableName = "Table"; oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf); System.IO.Stream oStream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
private void cmbreports_SelectedIndexChanged(object sender, EventArgs e) { if (cmbreports.SelectedIndex == 1) { try { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_FYID", CurrentUser.FYID.ToString()); para.Add("@i_UserId", CurrentUser.UserID.ToString()); para.Add("@i_CompId", CurrentCompany.CompId.ToString()); dtReport = objList.ListOfRecord("rpt_IndentRegister", para, "Indent - Report"); DataView DVReport; DVReport = dtReport.DefaultView; DVReport.RowFilter = StrFilter; if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptGRNRegister.rpt")) { //dtblPurchaseInvoice .TableName = "PORegister"; //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptGRNRegister.rpt"); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Indent Register", true, true, true, true, false, true, true, false, false, false, false); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Indent 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("Indent - Register Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 2) { try { if (dgvPurchaseInvoice.CurrentRow != null) { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_PIID", Convert.ToInt64(dgvPurchaseInvoice.CurrentRow.Cells["PIID"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_IndentDetail", para, "Indent - Report"); DataView DVReport; DVReport = dtReport.DefaultView; DVReport.RowFilter = StrFilter; if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptPurchaseInvoiceRegisterWithDetail.rpt")) { //dtblPurchaseInvoice .TableName = "PORegister"; //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptPurchaseInvoiceRegisterWithDetail.rpt"); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Indent Detail", true, true, true, true, false, true, true, false, false, false, false); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Indent Detail - [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("Indent - Detail Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 3) { try { DataTable dt = new DataTable(); LogoBind(dt); if (dgvPurchaseInvoice.CurrentRow != null) { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_RecID", Convert.ToInt64(dgvPurchaseInvoice.CurrentRow.Cells["PIID"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_Indent", para, "Indent - Report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptIndent.rpt")) { //dtblPurchaseInvoice .TableName = "PORegister"; //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptIndent.rpt"); rptDoc.Database.Tables[1].SetDataSource(dt); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, dtReport, "Indent", true, true, true, true, true, true, true, true, true, true, false); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Indent - [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("Indent", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 4) { try { DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_FYID", CurrentUser.FYID.ToString()); para.Add("@i_UserId", CurrentUser.UserID.ToString()); para.Add("@i_CompId", CurrentCompany.CompId.ToString()); dtReport = objList.ListOfRecord("rpt_IndentRegister", para, "Indent - Report"); DataView DVReport; DVReport = dtReport.DefaultView; DVReport.RowFilter = StrFilter; if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptGRNRegister.rpt")) { //dtblPurchaseInvoice .TableName = "PORegister"; //dtblPurchaseInvoice.WriteXmlSchema(@"D:\Report\PORegister.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptGRNRegister.rpt"); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Indent Register", true, true, true, true, false, true, true, false, false, false, false); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Indent 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("Indent - Register Report", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } cmbreports.SelectedIndex = 0; }
private void cmbreports_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmbreports.SelectedIndex == 1) { DataTable dt = new DataTable(); LogoBind(dt); if (dgvDebitNote.CurrentRow != null) { DataTable dtTNC = new DataTable(); //NameValueCollection para2 = new NameValueCollection(); //para2.Add("@i_Code", dgvSalesInvoice.CurrentRow.Cells["SalesCode"].Value.ToString()); //para2.Add("@i_TNC_Sub", "SALES"); //dtTNC = objDA.ExecuteDataTableSP("rpt_Sales_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC"); DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_RecID", Convert.ToInt64(dgvDebitNote.CurrentRow.Cells["DNID"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_DebitNote", para, "DebitNote - Report"); //NameValueCollection para2 = new NameValueCollection(); //_CompId = CurrentCompany.CompId; //para2.Add("@i_CompId", _CompId.ToString()); //dtCompany = objList.ListOfRecord("rpt_Company", para2, "Quotation - Report"); dtReport.TableName = "DebitNote"; dtReport.WriteXmlSchema(@"D:\DebitNote.xsd"); dtReport = objList.ListOfRecord("rpt_DebitNote", para, "DebitNote - Report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptDebitNote.rpt")) { //dtReport.TableName = "PurchaseOrder"; //dtReport.WriteXmlSchema(@"D:\PurchaseOrder.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptDebitNote.rpt"); rptDoc.Subreports[0].DataSourceConnections.Clear(); //rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC); rptDoc.Database.Tables[1].SetDataSource(dt); //rptDoc.Database.Tables[2].SetDataSource(dtCompany); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, dtReport, "", true, false, false, false, false, false, false, false, false, false, false); CurrentUser.AddExtraParameter(rptDoc); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Debit Note - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath."); } } else { MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMessage, "Exception"); } }
public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate) { try { string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string language = AppsCommon.GetCurrentLang(); List <E01_Info_Export> _lst = new List <E01_Info_Export>(); List <AppDocumentInfo> appDocumentInfos = new List <AppDocumentInfo>(); List <AppFeeFixInfo> _lst_appFeeFixInfos = new List <AppFeeFixInfo>(); ApplicationHeaderInfo applicationHeaderInfo = new ApplicationHeaderInfo(); E01_Info_Export _E01_Info_Export = new E01_Info_Export(); var objBL = new BussinessFacade.ModuleTrademark.Application_Header_BL(); ApplicationHeaderInfo _app = objBL.GetAllByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref _lst_appFeeFixInfos); AppsCommon.Prepare_Data_Export_E01(ref _E01_Info_Export, applicationHeaderInfo, appDocumentInfos, _lst_appFeeFixInfos); string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01" + _datetimenow + ".pdf"); string _tempfile = "E01.rpt"; if (p_View_Translate == 1) { // nếu là tiếng việt thì xem bản tiếng anh và ngược lại if (applicationHeaderInfo.Languague_Code == Language.LangEN) { _tempfile = "E01.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01" + _datetimenow + ".pdf"; } else { _tempfile = "E01_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf"; } } else { if (applicationHeaderInfo.Languague_Code == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01" + _datetimenow + ".pdf"; } else { _tempfile = "E01_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "E01_EN_" + _datetimenow + ".pdf"; } } _lst.Add(_E01_Info_Export); DataSet _ds_all = ConvertData.ConvertToDataSet <E01_Info_Export>(_lst, false); //_ds_all.WriteXml(@"D:\E01.xml", XmlWriteMode.WriteSchema); CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); if (_ds_all != null) { _ds_all.Tables[0].TableName = "Table1"; oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf); System.IO.Stream oStream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
private void cmbreports_SelectedIndexChanged(object sender, EventArgs e) { if (cmbreports.SelectedIndex == 1) { try { if (dgvServiceModule.CurrentRow == null) { return; } DataTable dtReport = new DataTable(); NameValueCollection Paralist = new NameValueCollection(); Paralist.Add("@i_ServiceId", dgvServiceModule.CurrentRow.Cells["ServiceId"].Value.ToString()); dtReport = objList.ListOfRecord("rpt_ServiceModule", Paralist, "ServiceModule - Report"); //if (objList.Exception == null) //{ //dtReport.TableName = "ServiceModuleRegister"; //dtReport.WriteXmlSchema(@"D:\ServiceModuleRegister.xsd"); if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceModuleRegister.rpt")) { DataView DVReport; DVReport = dtblItem.DefaultView; DVReport.RowFilter = StrFilter; CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptServiceModuleRegister.rpt"); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Service Module", true, true, true, true, false, true, true, false, false, false, true); //CurrentUser.AddExtraParameter(rptDoc); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Service Module - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath."); } //} } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Service Module", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } else if (cmbreports.SelectedIndex == 2) { try { if (dgvServiceModule.CurrentRow == null) { return; } DataTable dt = new DataTable(); // LogoBind(dt); DataSet dtReport = new DataSet(); NameValueCollection Paralist = new NameValueCollection(); Paralist.Add("@i_RecID", dgvServiceModule.CurrentRow.Cells["ServiceId"].Value.ToString()); dtReport = objList.ListOfDataSetRecordwithPara("rpt_Service_Order", Paralist, "Service Invoice - Report"); if (objList.Exception == null) { //dtReport.Tables[0].TableName = "ServiceOrder"; //dtReport.Tables[0].WriteXmlSchema(@"D:\ServiceOrder.xsd"); if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceOrder.rpt")) { CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptServiceOrder.rpt"); // rptDoc.Database.Tables[1].SetDataSource(dt); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, dtReport.Tables[0], "Service Order", true, true, true, true, false, true, true, false, false, false, true); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Service Order - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath."); } } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Service Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMessage, "Exception"); } } else if (cmbreports.SelectedIndex == 3) { try { DataTable dt = new DataTable(); LogoBind(dt); if (dgvServiceModule.CurrentRow != null) { DataTable dtTNC = new DataTable(); NameValueCollection para2 = new NameValueCollection(); para2.Add("@i_Code", dgvServiceModule.CurrentRow.Cells["RequestNo"].Value.ToString()); para2.Add("@i_TNC_Sub", "SERVICE"); para2.Add("@i_CompId", CurrentCompany.CompId.ToString()); dtTNC = objDA.ExecuteDataTableSP("rpt_Service_TNC", para2, false, ref mException, ref mErrorMsg, "Quotation TNC"); DataTable dtReport = new DataTable(); NameValueCollection para = new NameValueCollection(); para.Add("@i_RecID", Convert.ToInt64(dgvServiceModule.CurrentRow.Cells["ServiceId"].Value).ToString()); dtReport = objList.ListOfRecord("rpt_ServiceInvoice", para, "ServiceInvoice - Report"); if (objList.Exception == null) { if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceInvoice.rpt")) { //dtReport.TableName = "ServiceInvoice"; //dtReport.WriteXmlSchema(@"D:\ServiceInvoice.xsd"); CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptServiceInvoice.rpt"); rptDoc.Subreports[0].DataSourceConnections.Clear(); rptDoc.Subreports[0].Database.Tables[0].SetDataSource(dtTNC); rptDoc.Database.Tables[1].SetDataSource(dt); rptDoc.Refresh(); CurrentUser.AddReportParameters(rptDoc, dtReport, "Service Invoice", true, true, true, true, true, true, true, true, true, true, true); CurrentUser.AddExtraParameter(rptDoc); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Labour Invoice - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("Please check Company Details,\n Go to the Master->Edit->Company Details->ReportPath/DocPath."); } } else { MessageBox.Show(objList.Exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Sales Invoice", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMessage, "Exception"); } } else if (cmbreports.SelectedIndex == 4) { try { if (dgvServiceModule.CurrentRow == null) { return; } DataTable dtReport = new DataTable(); NameValueCollection Paralist = new NameValueCollection(); Paralist.Add("@i_ServiceId", dgvServiceModule.CurrentRow.Cells["ServiceId"].Value.ToString()); dtReport = objList.ListOfRecord("rpt_ServiceModule", Paralist, "ServiceModule - Report"); //if (objList.Exception == null) //{ //dtReport.TableName = "ServiceModuleRegister"; //dtReport.WriteXmlSchema(@"D:\ServiceModuleRegister.xsd"); if (System.IO.File.Exists(CurrentUser.ReportPath + "rptServiceVouchar.rpt")) { DataView DVReport; DVReport = dtblItem.DefaultView; DVReport.RowFilter = StrFilter; CrystalDecisions.CrystalReports.Engine.ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); rptDoc.Load(CurrentUser.ReportPath + "rptServiceVouchar.rpt"); CurrentUser.AddReportParameters(rptDoc, DVReport.ToTable(), "Service Module", true, true, true, true, false, true, true, false, false, false, true); Reports.frmReportViewer fRptView = new Reports.frmReportViewer(); fRptView.Text = "Service Module - [Page Size: A4]"; fRptView.crViewer.ReportSource = rptDoc; fRptView.ShowDialog(); } else { MessageBox.Show("File is not exist..."); } //} } catch (Exception exc) { Utill.Common.ExceptionLogger.writeException("Service Module", exc.StackTrace); MessageBox.Show(Utill.Common.CommonMessage.ExceptionMesg, "Exception"); } } cmbreports.SelectedIndex = 0; }
public void Convert() { //System.Web.HttpContext.Current.Response.Write("hello"); string vstExcep; this._stNmRpt = this._stNmRpt.Replace(".rpt", ""); this._stNmRpt = this._stNmRpt.Replace(".RPT", ""); try { //System.Web.HttpContext.Current.Response.Write(_stNmRpt); System.IO.MemoryStream vioMemor = new System.IO.MemoryStream(); CrystalDecisions.CrystalReports.Engine.ReportDocument vrpRepor = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string vstRepor = System.Web.HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString() + "report\\"+this._stNmRpt + ".rpt"; //System.Web.HttpContext.Current.Response.Write(vstRepor); vrpRepor.Load(vstRepor); if (_dsDatas == null) { return; } vrpRepor.Database.Tables[0].SetDataSource(this._dsDatas.Tables[0]); vrpRepor.Refresh(); //vioMemor = (System.IO.MemoryStream)vrpRepor.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel); vioMemor = (System.IO.MemoryStream)vrpRepor.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); vrpRepor.Close(); try { System.Web.HttpContext.Current.Response.Buffer = false; System.Web.HttpContext.Current.Response.ClearContent(); System.Web.HttpContext.Current.Response.ClearHeaders(); System.Web.HttpContext.Current.Response.ContentType = "application/pdf"; System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + this._stNmRpt.Replace("\\", "") + ".pdf"); System.Web.HttpContext.Current.Response.BinaryWrite(vioMemor.ToArray()); System.Web.HttpContext.Current.Response.Buffer = true; } catch (System.Exception vsqExcep) { vstExcep = vsqExcep.Message; } finally { if (vioMemor != null) { vioMemor.Flush(); vioMemor = null; } else { vioMemor = null; } if (vrpRepor != null) vrpRepor = null; } } catch (System.Exception vsqExcep) { vstExcep = vsqExcep.Message; } }