protected void btnImprimir_Click(object sender, EventArgs e)
    {
        string Ciclo = this.ddlCiclo.SelectedValue;
        int Zona = int.Parse(this.ddlZonas.SelectedValue);
        int PlantelID = int.Parse(this.ddlPlanteles.SelectedValue);
        byte Turno = byte.Parse(this.ddlTurnos.SelectedValue);
        int Estatus = int.Parse(ddlEstatus.SelectedValue);

        string NomPlantel = this.ddlPlanteles.SelectedItem.Text;

        db = new DBEscolarDataContext();
        var res = (from A in db.vwRPTEstadisticaPreInscritos011s
                   where A.Ciclo == Ciclo && A.Zona == Zona && A.PlantelID == PlantelID && A.Turno == (Turno == 0 ? A.Turno : Turno)
                    && A.Estatus == (Estatus == -1 ? A.Estatus : Estatus)
                   orderby A.Zona, A.Plantel, A.Turno, A.Nombre
                   select A).ToList();

        this.lblMensaje.Visible = res.Count() == 0;
        if (res.Count() == 0)
            return;

        ReportDocument rptDoc = new ReportDocument();

        rptDoc.Load(Server.MapPath("../Reportes/rptEstPre01.rpt"));
        rptDoc.SetDataSource(res);
        rptDoc.SetParameterValue("NomPlantel", NomPlantel);

        MemoryStream stream = (MemoryStream)rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        rptDoc.Close();
        rptDoc.Dispose();

        Response.Clear();
        Response.Buffer = true;
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "inline; filename=Alumnos.xls");
        Response.BinaryWrite(stream.ToArray());
        Response.End();
        stream.Close();
        stream.Dispose();
    }
Exemplo n.º 2
1
		private void GeneratePDF()
		{
            ReportDocument rpt = new ReportDocument();
            switch (cboView.SelectedItem.Value)
            {
                case "0":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsDetails.rpt"));
                    break;
                case "1":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsSummary.rpt"));
                    break;
            }

			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\RetailPlus\temp\");

			string strFileName = "chartofacc_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".pdf";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			dest.DiskFileName = strPath + strFileName;

			exportop = rpt.ExportOptions;
	
			SetDataSource(rpt);

			exportop.DestinationOptions = dest;
			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.PortableDocFormat;
			rpt.Export();   rpt.Close();    rpt.Dispose();
			
			fraViewer.Attributes.Add("src","/RetailPlus/temp/" + strFileName);
		}
Exemplo n.º 3
0
		private void GeneratePDF()
		{
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/GeneralLedger.rpt"));

			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\RetailPlus\temp\");

			string strFileName = "generalledger_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".pdf";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			dest.DiskFileName = strPath + strFileName;

			exportop = rpt.ExportOptions;
	
			SetDataSource(rpt);

			exportop.DestinationOptions = dest;
			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.PortableDocFormat;
			rpt.Export();   rpt.Close();    rpt.Dispose();
			
			fraViewer.Attributes.Add("src","/RetailPlus/temp/" + strFileName);
		}
 private void CrystalReportViewer1_Loaded(object sender, RoutedEventArgs e)
 {
     ReportDocument report = new ReportDocument();
     if (m_isurduvisible)
     {
         report.Load("../../Reports/SaleReceipt_u.rpt");
     }
     if (!m_isurduvisible)
     {
         report.Load("../../Reports/SaleReceipt_e.rpt");
     }
     
     ArrayList reportdata = new ArrayList();
     reportdata.Add(productSold);
   
     using(var db = new HCSMLEntities1())
     {               
         try
         {
             report.SetDataSource(from c in db.saleproducts where c.seqid == productSold.seqid select c);
         }
         catch (NotSupportedException ex)
         {}
         catch (Exception ex)
         {}
        
     }
     crystalReportsViewer1.ViewerCore.ReportSource = report;
     report.Dispose();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        String qs = Request.QueryString.Get("bid");
        Response.Write("Query String = " + qs);
        SqlConnection sql = new SqlConnection();
        sql.ConnectionString = "Data Source=(local);Initial Catalog=Hotel;Integrated Security=True";
        sql.Open();

        ReportDocument rpd = new ReportDocument();
        rpd.Load(Server.MapPath("itcreport.rpt"));
        rpd.SetDatabaseLogon("sa", "ak");
        rpd.SetParameterValue(0, qs);
        CrystalReportViewer1.ReportSource = rpd;

        //to convert report in pdf format
        MemoryStream ostream = new MemoryStream();
        Response.Clear();
        Response.Buffer = true;
        ostream = (MemoryStream)rpd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        rpd.Close();
        rpd.Dispose();
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(ostream.ToArray());
        ostream.Flush();
        ostream.Close();
        ostream.Dispose();
    }
Exemplo n.º 6
0
 protected void Page_Unload(object sender, EventArgs e)
 {
     if (crystalReport != null)
     {
         crystalReport.Close();
         crystalReport.Dispose();
         GC.Collect();
         CrystalReportViewer1.Dispose();
     }
 }
Exemplo n.º 7
0
        private bool LoadReportDelivery()
        {
            bool vRet = false;

            Thread.Sleep(2000);
            //if (CheckPrinterOnline(out_PrinterName))
            //{
            string strSQL = "select t.*" +
                            " from rpt.VIEW_DELIV_HEADER t " +     //VIEW_DATA_WEIGHT
                            " where t.LOAD_HEADER_NO=" + LoadHeader_NO;

            DataSet   vDataset = null;
            DataTable dt;

            try
            {
                if (fMain.OraDb.OpenDyns(strSQL, "VIEW_DELIV_HEADER", ref vDataset))
                {
                    dt = vDataset.Tables["VIEW_DELIV_HEADER"];
                    if (dt != null && dt.Rows.Count != 0)
                    {
                        ReportDocument cr         = new ReportDocument();
                        string         reportPath = fMain.App_Path + "\\Report File\\" + out_ReportPath;
                        RaiseEvents(reportPath);
                        if (!File.Exists(reportPath))
                        {
                            fMain.AddListBox = "The specified report does not exist.";
                        }
                        Application.DoEvents();
                        cr.Load(reportPath);
                        cr.Database.Tables["VIEW_DELIV_HEADER"].SetDataSource((DataTable)dt);
                        cr.SetDatabaseLogon("tas", "tam");
                        //cr.SetDataSource((DataTable)dt);
                        cr.SetParameterValue(out_Parametername, LoadHeader_NO);
                        cr.PrintOptions.PrinterName = out_PrinterName;
                        cr.PrintToPrinter(1, false, 0, 0);
                        cr.Dispose();
                        RaiseEvents("Print Report Loading NO " + LoadHeader_NO);
                        RaiseEvents(reportPath);
                        vRet = true;
                    }
                }

                Thread.Sleep(2000);
            }
            catch (Exception exp)
            {
                RaiseEvents("[Print Loading, Load data report] " + exp.Message);
                PrintStepProcess = _PrintStepProcess.InitialReport;
            }
            vDataset = null;
            dt       = null;
            // }
            return(vRet);
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataValidation dv    = new DataValidation();
            string         sPath = dv.CurrentDir(true);
            string         sFN   = sPath + "pdfs//PerformanceDetail.pdf";

            ReportDocument r = new ReportDocument();

            try
            {
                DateTime dtFrom    = Convert.ToDateTime(Request.QueryString["DateFrom"]);
                DateTime dtTo      = Convert.ToDateTime(Request.QueryString["DateTo"]);
                int      iRepID    = Convert.ToInt32(Request.QueryString["RepID"]);
                string   sUserName = Request.QueryString["UserName"].ToString();

                if (iRepID > 0)
                {
                    // Changed from QueryString,
                    // so Admin will get requested Rep
                    // after changing on Home screen.
                    iRepID = Convert.ToInt32(Session["RepID"]);
                }

                string sRpt = (iRepID == 0) ? "PerformanceSummary.rpt" : "PerformanceDetail.rpt";

                // Don't have a UserName for the Summary report.
                if (iRepID == 0)
                {
                    sUserName = "";
                }

                r.Load(System.AppDomain.CurrentDomain.BaseDirectory + sRpt);

                r.SetParameterValue("@from_date", dtFrom);
                r.SetParameterValue("@to_date", dtTo);
                r.SetParameterValue("@rep_id", iRepID);
                r.SetParameterValue("@user_name", sUserName);

                sFN = "C:\\MGMQuotation\\pdfs\\PerformanceDetail.pdf";
                r.ExportToDisk(ExportFormatType.PortableDocFormat, sFN);

                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.WriteFile(sFN);
            }
            catch (Exception ex)
            {
                Response.Write("Exception occurred: " + ex + ".");
            }
            finally
            {
                r.Dispose();
            }
        }
        private bool ExportarPDF()
        {
            DataSet                    GenDS = new DataSet();
            ReportDocument             oRD   = new ReportDocument();
            ExportOptions              oExO;
            DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions();

            admGuiaO.AgenciaOrigenID = AgenciaConectadaID;
            DsGuiaFacturaImpresion dataSrc = admGuiaO.GetDataSetImpresionAgenciaAgencia();

            Session["DatosGuia"] = dataSrc;

            try
            {
                //ds = (DsRendicionesAgencias) Session["dsRendicionAgencia"];

                string sNombrePDF = Server.MapPath(".") + "\\ReportesPDF\\Guia_" + this.admGuiaO.GuiaID + "_" + this.AgenciaConectadaID + ".pdf";

                //Load report
                oRD.Load(Server.MapPath("." + "/Reportes/GuiaImpresa.rpt"));

                //Set Report Datasource
                //BindGrilla();


                oRD.SetDataSource(dataSrc);


                //Export to PDF
                oExDo.DiskFileName = sNombrePDF;
                oExO = oRD.ExportOptions;
                //PrintOptions oExPrint = oRD.PrintOptions;
                //oExPrint.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4Small;
                //oExPrint.PrinterName = "\\" + "\\CQUIROGA\\HP DeskJet 810C";
                //oExPrint.PrinterName = "HP DeskJet 810C";

                oExO.ExportDestinationType = ExportDestinationType.DiskFile;


                oExO.ExportFormatType   = ExportFormatType.PortableDocFormat;
                oExO.DestinationOptions = oExDo;

                //oRD.PrintToPrinter(1,false,1,1);
                oRD.Export();

                oRD.Close();
                oRD.Dispose();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 10
0
 protected void Page_Unload(object sender, EventArgs e)
 {
     try
     {
         crys.Close();
         crys.Dispose();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 11
0
 protected void CrystalReportViewer1_Unload(object sender, EventArgs e)
 {
     if (relatorio != null)
     {
         relatorio.Close();
         relatorio.Dispose();
         relatorio = null;
     }
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
Exemplo n.º 12
0
    protected void GeneratePOAsPDF(DataTable dt, string strPath, string FileName)
    {
        string repFilePath = Server.MapPath("POReport.rpt");

        using (ReportDocument repDoc = new ReportDocument())
        {
            repDoc.Load(repFilePath);

            repDoc.SetDataSource(dt);


            decimal Total_Price  = 0;
            decimal Exchane_rate = 1;
            decimal Vat          = 0;
            decimal sercharge    = 0;
            decimal discount     = 0;
            decimal withholding  = 0;
            foreach (DataRow dr in dt.Rows)
            {
                Exchane_rate = Convert.ToDecimal(dr["EXCHANGE_RATE"].ToString());
                discount     = Convert.ToDecimal(dr["DISCOUNT"].ToString());
                Vat          = Convert.ToDecimal(dr["VAT"].ToString());
                sercharge    = Convert.ToDecimal(dr["SURCHARGES"].ToString());

                Total_Price = Total_Price + (Convert.ToDecimal(dr["REQUESTED_QTY"].ToString()) * Convert.ToDecimal(dr["QUOTED_RATE"].ToString()) - (Convert.ToDecimal(dr["REQUESTED_QTY"].ToString()) * Convert.ToDecimal(dr["QUOTED_RATE"].ToString()) * Convert.ToDecimal(dr["QUOTED_DISCOUNT"].ToString()) / 100));
                if (dr["SURCHARGES"].ToString() == "Spares")
                {
                    repDoc.ReportDefinition.Sections[1].SectionFormat.EnableSuppress = true;
                }
            }
            repDoc.DataDefinition.FormulaFields[1].Text = (Total_Price / Exchane_rate).ToString();
            repDoc.DataDefinition.FormulaFields[2].Text = (Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) * discount / 100).ToString();
            repDoc.DataDefinition.FormulaFields[3].Text = ((Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) - (Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) * discount / 100)) * sercharge / 100).ToString();
            repDoc.DataDefinition.FormulaFields[4].Text = ((Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) - Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[2].Text) + Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[3].Text)) * Vat / 100).ToString();
            repDoc.DataDefinition.FormulaFields[0].Text = ((Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[1].Text) - Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[2].Text) + Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[3].Text) + Convert.ToDecimal(repDoc.DataDefinition.FormulaFields[4].Text)).ToString());


            Response.Buffer = false;
            // Clear the response content and headers
            Response.ClearContent();
            Response.ClearHeaders();

            ExportOptions exp = new ExportOptions();
            exp.ExportFormatType = ExportFormatType.PortableDocFormat;
            PdfRtfWordFormatOptions pd = new PdfRtfWordFormatOptions();

            exp.ExportDestinationType = ExportDestinationType.NoDestination;
            exp.ExportFormatType      = ExportFormatType.PortableDocFormat;
            exp.FormatOptions         = pd;
            repDoc.ExportToHttpResponse(exp, Response, false, "ghjgj");
            repDoc.Close();
            repDoc.Dispose();
        }
    }
Exemplo n.º 13
0
 protected void Page_Unload(object sender, EventArgs e)
 {
     CR_Sec_Invesment_sectorwise_report.Dispose();
     CR_Sec_Invesment_sectorwise_report = null;
     CR_Sec_Invesment_sectorwise_report.Dispose();
     CR_Sec_Invesment_sectorwise_report = null;
     rdoc.Close();
     rdoc.Dispose();
     rdoc = null;
     GC.Collect();
 }
Exemplo n.º 14
0
        }//end page load

        protected void Page_Unload(object sender, EventArgs e)
        {
            CloseReports(_reportDocument);
            _reportDocument.Close();
            _reportDocument.Dispose();
            rptStudentList.Dispose();
            _reportDocument = null;
            rptStudentList  = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }//end page load
        private bool LoadInstructionReport()
        {
            bool vRet = false;
            //if (CheckPrinterOnline(out_PrinterName))
            //    {
            string strSQL = "select t.*" +
                            " from rpt.VIEW_LOADING_INTRODUCTION_TM t " +
                            " where t.LOAD_HEADER_NO=" + LoadHeader_NO;

            DataSet vDataset = null;

            vDataset = new DataSet();
            DataTable dt;

            try
            {
                if (fMain.OraDb.OpenDyns(strSQL, "VIEW_LOADING_INTRODUCTION_TM", ref vDataset))
                {
                    dt = vDataset.Tables["VIEW_LOADING_INTRODUCTION_TM"];
                    ReportDocument cr = new ReportDocument();
                    if (dt != null && dt.Rows.Count != 0)
                    {
                        string reportPath = fMain.App_Path + "\\Report File\\" + out_ReportPath;
                        if (!File.Exists(reportPath))
                        {
                            fMain.AddListBox = "The specified report does not exist \n";
                        }

                        cr.Load(reportPath);
                        //cr.SetDataSource(dt);
                        cr.Database.Tables["VIEW_LOADING_INTRODUCTION_TM"].SetDataSource((DataTable)dt);
                        //cr.SetParameterValue(out_Parametername, LoadHeader_NO);
                        cr.SetParameterValue(out_Parametername, LoadHeader_NO);
                        cr.PrintOptions.PrinterName = out_PrinterName;
                        cr.PrintToPrinter(1, false, 0, 0);
                        cr.Dispose();
                        Thread.Sleep(100);

                        RaiseEvents("PRINT INSTRUCTION REPORT LOADING NUMBER: " + LoadHeader_NO);
                        vRet = true;
                    }
                }
                Thread.Sleep(100);
            }
            catch (Exception exp)
            {
                fMain.LogFile.WriteErrLog("[Print Instruction, Load data report] " + exp.Message);
                PrintInstructionStepProcess = _PrintInstructionStepProcess.InitialReport;
            }
            vDataset = null;
            dt       = null;
            // }
            return(vRet);
        }
Exemplo n.º 16
0
 protected void Page_Unload(object sender, EventArgs e)
 {
     CR_SecInfosummary.Dispose();
     CR_SecInfosummary = null;
     CR_SecInfosummary.Dispose();
     CR_SecInfosummary = null;
     rdoc.Close();
     rdoc.Dispose();
     rdoc = null;
     GC.Collect();
 }
Exemplo n.º 17
0
        public static Stream ExecTransportInstruction(string companyName, string companyAddress, string companyTel, string customerCode,
                                                      string driverName, string licenseNo, string driverTel, string route, string commodity, string trailerNo, string truckNo, string location2export, string location2import, string instructionNo)
        {
            try
            {
                ReportDocument report;
                string         strPath;

                strPath = HttpContext.Current.Request.MapPath("~/FileRpt/Dispatch/TransportIntruction.rpt");

                report = new ReportDocument();
                report.Load(strPath);

                // set date
                report.SetParameterValue("customerCode", customerCode);
                report.SetParameterValue("driverName", driverName);
                report.SetParameterValue("licenseNo", licenseNo);
                report.SetParameterValue("driverTel", driverTel);
                report.SetParameterValue("route", route);
                report.SetParameterValue("commodity", commodity);
                report.SetParameterValue("trailerNo", trailerNo);
                report.SetParameterValue("truckNo", truckNo);
                report.SetParameterValue("location2export", location2export);
                report.SetParameterValue("location2import", location2import ?? "");
                report.SetParameterValue("instructionNo", instructionNo ?? "");
                // set datatable images
                report.SetParameterValue("companyName", companyName ?? "");
                report.SetParameterValue("companyAddress", companyAddress ?? "");
                report.SetParameterValue("companyTel", companyTel ?? "");
                // set parameter currentDate
                //if (language == 1)
                //{
                report.SetParameterValue("currentDate", "Ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year);
                //}
                //else if (language == 2)
                //{
                //	CultureInfo cul = CultureInfo.GetCultureInfo("en-US");
                //	report.SetParameterValue("currentDate", cul.DateTimeFormat.GetMonthName(DateTime.Now.Month) + " " + DateTime.Now.Day + ", " + DateTime.Now.Year);
                //}
                //else
                //{
                //	report.SetParameterValue("currentDate", DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日");
                //}
                Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat);
                report.Close();
                report.Dispose();
                GC.Collect();
                return(stream);
            }
            catch (NullReferenceException)
            {
                throw new NullReferenceException();
            }
        }
Exemplo n.º 18
0
 protected void Page_Unload(object sender, EventArgs e)
 {
     try
     {
         rptdoc.Close();
         rptdoc.Dispose();
     }
     catch (NullReferenceException ex)
     {
     }
 }
Exemplo n.º 19
0
        protected void Page_Unload(object sender, EventArgs e)
        {
            ReportDocument theReport = new ReportDocument();

            CrystalReportViewer1.RefreshReport();


            theReport.Close();
            theReport.Clone();
            theReport.Dispose();
            theReport = null;
        }
Exemplo n.º 20
0
 protected void CrystalReportViewer1_Unload(object sender, EventArgs e)
 {
     //ReportDocument rptReportSource = (ReportDocument)CrystalReportViewer1.ReportSource;
     if (relatorio != null)
     {
         relatorio.Close();
         relatorio.Dispose();
         relatorio = null;
     }
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
Exemplo n.º 21
0
      private void ExportReport(string FileName, ExportFormatType FileFormat)
      {
          if ((FileFormat == ExportFormatType.Excel))
          {
              ExcelFormatOptions excelOpts = new ExcelFormatOptions();
              rpt.ExportOptions.FormatOptions = excelOpts;
          }

          rpt.ExportToStream(FileFormat);

          rpt.Dispose(); rpt.Close();
      }
Exemplo n.º 22
0
 public void Dispose()
 {
     try
     {
         reportDocument.Dispose();
         reportDocument = null;
         reportDocument.Close();
     }
     catch
     {
     }
 }
Exemplo n.º 23
0
        public static void GenerateReport(string FileName, ReportDocument rpt, System.Web.UI.Control ClientScriptBlockControl, ExportFormatType pvtExportFormatType)
        {
            try
            {
                ExportOptions exportop = new ExportOptions();
                DiskFileDestinationOptions dest = new DiskFileDestinationOptions();

                string strFileExtensionName = ".pdf";
                switch (pvtExportFormatType)
                {
                    case ExportFormatType.PortableDocFormat: strFileExtensionName = ".pdf"; exportop.ExportFormatType = ExportFormatType.PortableDocFormat; break;
                    case ExportFormatType.WordForWindows: strFileExtensionName = ".doc"; exportop.ExportFormatType = ExportFormatType.WordForWindows; break;
                    case ExportFormatType.Excel: strFileExtensionName = ".xls"; exportop.ExportFormatType = ExportFormatType.Excel; break;
                }

                string strPath = System.Web.HttpContext.Current.Server.MapPath(@"\retailplus\temp\");
                string strFileName = FileName + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + strFileExtensionName;

                if (System.IO.File.Exists(strPath + strFileName))
                    System.IO.File.Delete(strPath + strFileName);

                dest.DiskFileName = strPath + strFileName;
                exportop.DestinationOptions = dest;
                exportop.ExportDestinationType = ExportDestinationType.DiskFile;
                rpt.Export(exportop); //rpt.Close(); rpt.Dispose();
                
                // remove the error
                if (pvtExportFormatType == ExportFormatType.WordForWindows || pvtExportFormatType == ExportFormatType.Excel || pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    // the maximum report processing jobs limit configured by your system administrator has been reached.
                    rpt.Close(); rpt.Dispose();
                }

                if (pvtExportFormatType == ExportFormatType.PortableDocFormat)
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript = "window.open('" + newWindowUrl + "');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);
                }
                else
                {
                    string newWindowUrl = Constants.ROOT_DIRECTORY + "/temp/" + strFileName;
                    string javaScript = "window.open('" + newWindowUrl + "','_self');";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(ClientScriptBlockControl, ClientScriptBlockControl.GetType(), "openwindow", javaScript, true);

                    //System.Diagnostics.Process p = new System.Diagnostics.Process();
                    //p.StartInfo.FileName = System.Web.HttpContext.Current.Server.MapPath(Constants.ROOT_DIRECTORY + "/temp/" + strFileName);
                    //p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
                    //p.Start();
                }
            }
            catch (Exception ex) { throw ex; }
        }
    private void Imprimir(int AlumnoID)
    {
        DBEscolarDataContext db = new DBEscolarDataContext();
        var Pago = (from P in db.vwRPTPagosEncabezados join D in db.vwRPTPagosDetalles on P.PagoID equals D.PagoID
                    where P.AlumnoID == AlumnoID && P.Ciclo == Utils.CicloActual && (P.Estatus != 0)
                    && D.Clave == "A01"
                    select P).FirstOrDefault();

        if (Pago == null)
        {
            this.lblMensaje.Text = "No se ha encontrado la ficha de pago.<br />Nota: Para poder generar la Ficha de Pago, debes de estar validado.";
            return;
        }
        else if (Pago.Estatus == 3) {

            Alumno Alumno = (from A in db.Alumnos
                             where A.AlumnoID == AlumnoID
                             select A).FirstOrDefault();

            this.lblMensaje.Text = "Felicidades. Tú ficha ha sido pagada y ya te encuentras inscrito con matrícula: " + Alumno.Matricula;
            return;

        }

        var Detalle = (from D in db.vwRPTPagosDetalles
                       where D.PagoID == Pago.PagoID
                       select D).ToList();

        //Actualiza el estatus del pago a 2:Impreso
        db.spEXEPagosCambiaEstatus(AlumnoID, Pago.PagoID, 2, Utils.CicloActual);

        ArrayList col = new ArrayList();
        col.Add(Pago);
        ReportDocument rptDoc = new ReportDocument();

        rptDoc.Load(Server.MapPath("Reportes/rptFichaDePago.rpt"));
        //set dataset to the report viewer.
        rptDoc.SetDataSource(col);
        rptDoc.Subreports["Detalle"].SetDataSource(Detalle);
        rptDoc.Subreports["Detalle2"].SetDataSource(Detalle);

        MemoryStream stream = (MemoryStream)rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        rptDoc.Close();
        rptDoc.Dispose();
        Response.Clear();
        Response.ContentType = @"Application/pdf";
        Response.AddHeader("Content-Disposition", "inline; filename=FichaDePago.pdf");
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        stream.Dispose();
    }
Exemplo n.º 25
0
        private void Exibe_Certidao_Debito(Certidao_debito dados)
        {
            lblMsg.Text = "";
            string sEndereco = dados.Logradouro + ", " + dados.Numero.ToString();
            string sTipo     = "";

            if (dados.Ret == 4)
            {
                sTipo = "CERTDÂO POSITIVA";
            }
            else
            {
                if (dados.Ret == 5)
                {
                    sTipo = "CERTIDÃO POSITIVA EFEITO NEGATIVA";
                }
                else
                {
                    sTipo = "CERTIDÃO NEGATIVA";
                }
            }

            Imovel_bll imovel_Class = new Imovel_bll("GTIconnection");
            string     sProc        = dados.Processo;

            ReportDocument crystalReport = new ReportDocument();

            crystalReport.Load(Server.MapPath("~/Report/CertidaoDebitoValida.rpt"));
            crystalReport.SetParameterValue("NUMCERTIDAO", dados.Numero.ToString("00000") + "/" + dados.Ano.ToString("0000"));
            crystalReport.SetParameterValue("DATAEMISSAO", Convert.ToDateTime(dados.Datagravada).ToString("dd/MM/yyyy") + " às " + Convert.ToDateTime(dados.Datagravada).ToString("HH:mm:ss"));
            crystalReport.SetParameterValue("CONTROLE", dados.Numero.ToString("00000") + dados.Ano.ToString("0000") + "/" + dados.Codigo.ToString() + "-CI");
            crystalReport.SetParameterValue("ENDERECO", sEndereco);
            crystalReport.SetParameterValue("CADASTRO", Convert.ToInt32(dados.Codigo).ToString("000000"));
            crystalReport.SetParameterValue("NOME", dados.Nome);
            crystalReport.SetParameterValue("INSCRICAO", string.IsNullOrWhiteSpace(dados.Inscricao)?"N/A":dados.Inscricao);
            crystalReport.SetParameterValue("BAIRRO", dados.Bairro);
            crystalReport.SetParameterValue("TIPO", sTipo);
            crystalReport.SetParameterValue("PROCESSO", sProc);
            crystalReport.SetParameterValue("ATIVIDADE", string.IsNullOrWhiteSpace(dados.Atividade) ? "N/A" : dados.Atividade);
            crystalReport.SetParameterValue("TRIBUTO", string.IsNullOrWhiteSpace(dados.Lancamento) ? "N/A" : dados.Lancamento);

            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();

            try {
                crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, "comp" + dados.Numero.ToString() + dados.Ano.ToString());
            } catch {
            } finally {
                crystalReport.Close();
                crystalReport.Dispose();
            }
        }
Exemplo n.º 26
0
        public static Stream Exec(Dataset.CustomerRevenue.CustomerRevenueGeneral.CustomerRevenueGeneralDataTable datatable,
                                  int language,
                                  string monthYear
                                  )
        {
            try
            {
                ReportDocument report;
                string         strPath;

                strPath = HttpContext.Current.Request.MapPath("~/FileRpt/CustomersExpense/CustomersExpenseListEn.rpt");
                if (language == 3)
                {
                    strPath = HttpContext.Current.Request.MapPath("~/FileRpt/CustomersExpense/CustomersExpenseListJp.rpt");
                }
                else if (language == 1)
                {
                    strPath = HttpContext.Current.Request.MapPath("~/FileRpt/CustomersExpense/CustomersExpenseListVi.rpt");
                }

                report = new ReportDocument();
                report.Load(strPath);
                report.Database.Tables[0].SetDataSource((DataTable)datatable);

                // set parameters
                // set period time
                report.SetParameterValue("period", monthYear);
                // set parameter currentDate
                if (language == 1)
                {
                    report.SetParameterValue("currentDate", "Ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year);
                }
                else if (language == 2)
                {
                    CultureInfo cul = CultureInfo.GetCultureInfo("en-US");
                    report.SetParameterValue("currentDate", cul.DateTimeFormat.GetMonthName(DateTime.Now.Month) + " " + DateTime.Now.Day + ", " + DateTime.Now.Year);
                }
                else
                {
                    report.SetParameterValue("currentDate", DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日");
                }

                Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat);
                report.Close();
                report.Dispose();
                GC.Collect();
                return(stream);
            }
            catch (NullReferenceException)
            {
                throw new NullReferenceException();
            }
        }
Exemplo n.º 27
0
 public void Dispose()
 {
     if (reportDocument != null)
     {
         reportDocument.Close();
         reportDocument.Dispose();
     }
     if (dbConn != null)
     {
         dbConn.Dispose();
     }
 }
Exemplo n.º 28
0
 private void MakeReport(DataTable pfid, string outputPath)
 {
     try
     {
         foreach (DataRow PortfolioID in pfid.Rows)
         {
             report = new ReportDocument();
             report.Load(ServerDetails.reportPath);
             report.DataSourceConnections[0].SetConnection(ServerDetails.servername, ServerDetails.database, ServerDetails.username, ServerDetails.password);
             report.RecordSelectionFormula = "({Customer.Portfolio_ID} ='" + PortfolioID["Portfolio_ID"].ToString() + "')";
             report.SetParameterValue("pf_id", PortfolioID["Portfolio_ID"].ToString());
             string retDate = Convert.ToDateTime(PortfolioID["ret_Date"].ToString()).ToString("dd/MMM/yyyy");
             report.SetParameterValue("ret_Date", retDate);
             FilePath = outputPath + PortfolioID["Portfolio_ID"].ToString() + ".pdf";
             if (!Directory.Exists(outputPath))
             {
                 Directory.CreateDirectory(outputPath);
             }
             if (File.Exists(FilePath))
             {
                 File.Delete(FilePath);
             }
             report.ExportToDisk(ExportFormatType.PortableDocFormat, FilePath);
             report.Close();
             report.Dispose();
         }
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (report != null)
         {
             report.Close();
             report.Dispose();
         }
     }
 }
        private void Exibe_Certidao_ValorVenal(Certidao_valor_venal dados)
        {
            lblMsg.Text = "";
            string sComplemento = dados.Li_compl;
            string sQuadras     = string.IsNullOrWhiteSpace(dados.Li_quadras) ? "" : " Quadra: " + dados.Li_quadras.ToString().Trim();
            string sLotes       = string.IsNullOrWhiteSpace(dados.Li_lotes) ? "" : " Lote: " + dados.Li_lotes.ToString().Trim();

            sComplemento += sQuadras + sLotes;
            string sEndereco = dados.Logradouro + ", " + dados.Numero.ToString() + sComplemento;

            Imovel_bll imovel_Class = new Imovel_bll("GTIconnection");
            Laseriptu  RegIPTU      = imovel_Class.Dados_IPTU(dados.Codigo, DateTime.Now.Year);

            if (RegIPTU == null)
            {
                lblMsg.Text = "Não foi possível emitir certidão para este código";
                return;
            }
            decimal Vvt          = (decimal)RegIPTU.Vvt;
            decimal Vvp          = (decimal)RegIPTU.Vvc;
            decimal Vvi          = (decimal)RegIPTU.Vvi;
            decimal Areaterreno  = (decimal)RegIPTU.Areaterreno;
            string  _valor_metro = string.Format(CultureInfo.GetCultureInfo("pt-BR"), "R${0:#,###.##}", (Vvt / Areaterreno)) + " R$/m²";


            ReportDocument crystalReport = new ReportDocument();

            crystalReport.Load(Server.MapPath("~/Report/CertidaoValorVenalValida.rpt"));
            crystalReport.SetParameterValue("NUMCERTIDAO", dados.Numero.ToString("00000") + "/" + dados.Ano.ToString("0000"));
            crystalReport.SetParameterValue("DATAEMISSAO", dados.Data.ToString("dd/MM/yyyy") + " às " + dados.Data.ToString("HH:mm:ss"));
            crystalReport.SetParameterValue("CONTROLE", dados.Numero.ToString("00000") + dados.Ano.ToString("0000") + "/" + dados.Codigo.ToString() + "-VV");
            crystalReport.SetParameterValue("ENDERECO", sEndereco);
            crystalReport.SetParameterValue("CADASTRO", dados.Codigo.ToString("000000"));
            crystalReport.SetParameterValue("NOME", dados.Nomecidadao);
            crystalReport.SetParameterValue("INSCRICAO", dados.Inscricao);
            crystalReport.SetParameterValue("BAIRRO", dados.Descbairro);
            crystalReport.SetParameterValue("VVT", string.Format(CultureInfo.GetCultureInfo("pt-BR"), "R${0:#,###.##}", Vvt) + " (" + _valor_metro + ")");
            crystalReport.SetParameterValue("VVP", string.Format(CultureInfo.GetCultureInfo("pt-BR"), "R${0:#,###.##}", Vvp));
            crystalReport.SetParameterValue("VVI", string.Format(CultureInfo.GetCultureInfo("pt-BR"), "R${0:#,###.##}", Vvi));

            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();

            try {
                crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, "comp" + dados.Numero.ToString() + dados.Ano.ToString());
            } catch {
            } finally {
                crystalReport.Close();
                crystalReport.Dispose();
            }
        }
Exemplo n.º 30
0
        private void LoadReport()
        {
            var mailer = db.MAILER_GETINFO_BYLISTID(searchText).Select(p => new MailerRpt()
            {
                SenderName           = p.SenderName,
                MailerID             = "*" + p.MailerID + "*",
                SenderID             = p.SenderID,
                SenderPhone          = p.SenderPhone,
                SenderAddress        = p.SenderAddress,
                RecieverName         = p.RecieverName,
                RecieverAddress      = p.RecieverAddress,
                RecieverPhone        = p.RecieverPhone,
                ReceiverDistrictName = p.ReceiDistrictName,
                ReceiverProvinceName = p.RecieProvinceName,
                SenderDistrictName   = p.SendDistrictName,
                SenderProvinceName   = p.SendProvinceName,
                PostOfficeName       = p.PostOfficeName,
                TL           = p.MerchandiseID == "T" ? "X" : ".",
                HH           = p.MerchandiseID == "H" ? "X" : ".",
                MH           = p.MerchandiseID == "M" ? "X" : ".",
                N            = p.MailerTypeID == "SN" ? "X" : ".",
                DB           = p.MerchandiseID == "ST" ? "X" : ".",
                TK           = p.MerchandiseID == "TK" ? "X" : ".",
                COD          = p.COD.Value.ToString("C", MNPOST.Utils.Cultures.VietNam),
                Weight       = p.Weight.ToString(),
                Quantity     = p.Quantity.ToString(),
                Amount       = p.Amount.Value.ToString("C", MNPOST.Utils.Cultures.VietNam),
                Price        = p.Price.Value.ToString("C", MNPOST.Utils.Cultures.VietNam),
                ServicePrice = p.PriceService.Value.ToString("C", MNPOST.Utils.Cultures.VietNam)
            }).ToList();

            if (mailer == null)
            {
                return;
            }

            if (rptH != null)
            {
                rptH.Close();
                rptH.Dispose();
            }

            rptH = new ReportDocument();
            string reportPath = Server.MapPath("~/Report/MNPOSTReport.rpt");

            rptH.Load(reportPath);

            rptH.SetDataSource(mailer);


            MailerRptViewer.ReportSource = rptH;
        }
Exemplo n.º 31
0
        private void Exibe_Certidao_Isencao(Certidao_isencao dados)
        {
            lblMsg.Text = "";
            string sComplemento = dados.Li_compl == null?"":" " + dados.Li_compl;
            string sQuadras     = string.IsNullOrWhiteSpace(dados.Li_quadras) ? "" : " Quadra: " + dados.Li_quadras.ToString().Trim();
            string sLotes       = string.IsNullOrWhiteSpace(dados.Li_lotes) ? "" : " Lote: " + dados.Li_lotes.ToString().Trim();

            sComplemento += sQuadras + sLotes;
            string sEndereco = dados.Logradouro + ", " + dados.Numero.ToString() + sComplemento;

            Imovel_bll imovel_Class = new Imovel_bll("GTIconnection");
            decimal    nPerc        = (decimal)dados.Percisencao;

            if (nPerc == 0)
            {
                nPerc = 100;
            }
            string sProc = "";

            if (dados.Numero > 0)
            {
                List <IsencaoStruct> ListaIsencao = null;
                ListaIsencao = imovel_Class.Lista_Imovel_Isencao(dados.Codigo, DateTime.Now.Year);
                sProc        = ListaIsencao[0].Numprocesso + " de " + Convert.ToDateTime(ListaIsencao[0].dataprocesso).ToString("dd/MM/yyyy");
            }

            ReportDocument crystalReport = new ReportDocument();

            crystalReport.Load(Server.MapPath("~/Report/CertidaoIsencaoValida.rpt"));
            crystalReport.SetParameterValue("NUMCERTIDAO", dados.Numero.ToString("00000") + "/" + dados.Ano.ToString("0000"));
            crystalReport.SetParameterValue("DATAEMISSAO", dados.Data.ToString("dd/MM/yyyy") + " às " + dados.Data.ToString("HH:mm:ss"));
            crystalReport.SetParameterValue("CONTROLE", dados.Numero.ToString("00000") + dados.Ano.ToString("0000") + "/" + dados.Codigo.ToString() + "-CI");
            crystalReport.SetParameterValue("ENDERECO", sEndereco);
            crystalReport.SetParameterValue("CADASTRO", dados.Codigo.ToString("000000"));
            crystalReport.SetParameterValue("NOME", dados.Nomecidadao);
            crystalReport.SetParameterValue("INSCRICAO", dados.Inscricao);
            crystalReport.SetParameterValue("BAIRRO", dados.Descbairro);
            crystalReport.SetParameterValue("PERC", nPerc);
            crystalReport.SetParameterValue("PROCESSO", sProc);

            HttpContext.Current.Response.Buffer = false;
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();

            try {
                crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, HttpContext.Current.Response, true, "comp" + dados.Numero.ToString() + dados.Ano.ToString());
            } catch {
            } finally {
                crystalReport.Close();
                crystalReport.Dispose();
            }
        }
Exemplo n.º 32
0
        private void GenerateHTML()
        {
            ReportDocument rpt = new ReportDocument();

            switch (cboView.SelectedItem.Value)
            {
            case "0":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsDetails.rpt"));
                break;

            case "1":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/ChartOfAccountsSummary.rpt"));
                break;
            }

            HTMLFormatOptions htmlOpts = new HTMLFormatOptions();

            ExportOptions exportop          = new ExportOptions();
            DiskFileDestinationOptions dest = new DiskFileDestinationOptions();

            string strPath = Server.MapPath(@"\RetailPlus\temp\html\");
//			DeleteTempDirectory(strPath);

            string strFileName = "chartofacc_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".htm";

            if (System.IO.File.Exists(strPath + strFileName))
            {
                System.IO.File.Delete(strPath + strFileName);
            }

            htmlOpts.HTMLFileName             = strFileName;
            htmlOpts.HTMLEnableSeparatedPages = true;;
            htmlOpts.HTMLHasPageNavigator     = true;
            htmlOpts.HTMLBaseFolderName       = strPath;
            rpt.ExportOptions.FormatOptions   = htmlOpts;

            exportop = rpt.ExportOptions;

            exportop.ExportDestinationType = ExportDestinationType.DiskFile;
            exportop.ExportFormatType      = ExportFormatType.HTML40;

            dest.DiskFileName           = strFileName.ToString();
            exportop.DestinationOptions = dest;

            SetDataSource(rpt);

            rpt.Export();   rpt.Close();    rpt.Dispose();

            strFileName = "//" + Request.ServerVariables["SERVER_NAME"].ToString() + FindHTMLFile(strPath, strFileName);

            fraViewer.Attributes.Add("src", strFileName);
        }
Exemplo n.º 33
0
 protected void Page_Unload(object sender, EventArgs e)
 {
     if (myReportDoc == null)
     {
         return;
     }
     else
     {
         myReportDoc.Close();
         myReportDoc.Dispose();
         CrystalReportViewer1.Dispose();
     }
 }
Exemplo n.º 34
0
        public IHttpActionResult Get(string id)
        {
            var rpt = new ReportDocument();

            rpt.Load(@"Reports\JedenWierszArtykulParagraf.rpt");

            var stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            rpt.Close();
            rpt.Dispose();

            return(new AttachmentActionResult("test.pdf", stream, "application/pdf"));
        }
Exemplo n.º 35
0
    public void LoadReport()
    {
        System.IO.MemoryStream stream1 = new System.IO.MemoryStream();

        try
        {
            string Path = Server.MapPath("toefldetails.rpt");
            Path = Path.Substring(0, Path.LastIndexOf('\\'));
            Path = Path.Substring(0, Path.LastIndexOf('\\'));
            Path = Path + "\\Report\\toefldetails.rpt";
            myReportDocument.Load(Path);
            myReportDocument.SetDatabaseLogon("software", "DelFirMENA$idea", "192.168.168.208", "CDB");
            //myReportDocument.SetParameterValue("@Gender", ddl_list.SelectedValue);
            //myReportDocument.SetParameterValue("@Empid", drpFaculty.SelectedValue);
            //myReportDocument.SetParameterValue("@batchcode", drp_Batch.SelectedItem.Text);

            //stream1 = null;
            //ExportOptions ex = myReportDocument.ExportOptions;
            //ex.ExportFormatType = ExportFormatType.PortableDocFormat;
            //ExportRequestContext x = new ExportRequestContext();
            //x.ExportInfo = ex;
            //stream1 = (System.IO.MemoryStream)myReportDocument.FormatEngine.ExportToStream(x);
            //Response.Clear();
            //Response.ContentType = "application/pdf";
            //Response.BinaryWrite(stream1.ToArray());
            //// Response.End();
            //stream1.Close();

            System.IO.Stream oStream   = null;
            byte[]           byteArray = null;
            oStream   = myReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            byteArray = new byte[oStream.Length];
            oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1));
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(byteArray);
            Response.Flush();
            Response.Close();
            myReportDocument.Close();
            myReportDocument.Dispose();
        }
        catch (Exception Ex)
        {
            Response.Write(Ex.Message);
        }

        finally
        {
        }
    }
Exemplo n.º 36
0
        public FileResult ExportPdfKardex(string pinicio, string pfin, int pidItem)
        {
            Stream         stream         = null;
            var            nombreArchivo  = "";
            ReportDocument reportDocument = new ReportDocument();

            byte[] pdfByte = null;

            try
            {
                object                     objetos      = new object();
                EntitiesProveduria         db           = new EntitiesProveduria();
                SqlConnectionStringBuilder builderOrden = new SqlConnectionStringBuilder(db.Database.Connection.ConnectionString);
                SP_KARDEXTableAdapter      tableAdapter = new SP_KARDEXTableAdapter();
                DataTable                  dataTable;

                DateTime fi = DateTime.Parse(pinicio);
                DateTime ff = DateTime.Parse(pfin);
                dataTable = tableAdapter.GetData(pidItem, fi, ff, out objetos);


                String pathReport = Path.Combine(HttpRuntime.AppDomainAppPath, "Reports\\Cr_Kardex.rpt");
                reportDocument.Load(pathReport);
                reportDocument.SetDataSource(dataTable);


                reportDocument.SetDatabaseLogon(builderOrden.UserID, builderOrden.Password);
                reportDocument.SetParameterValue("fecha_inicio", fi);
                reportDocument.SetParameterValue("fecha_fin", ff);
                stream        = reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                pdfByte       = ReadFully(stream);
                nombreArchivo = "Kardex";
                Response.AddHeader("content-disposition", "inline; title='';" + "filename=" + nombreArchivo + ".pdf");
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.Message);
            }
            finally
            {
                if (reportDocument != null)
                {
                    if (reportDocument.IsLoaded)
                    {
                        reportDocument.Close();
                        reportDocument.Dispose();
                    }
                }
            }
            return(File(pdfByte, MediaTypeNames.Application.Pdf));
        }
Exemplo n.º 37
0
        private void GeneratePDF()
        {
            ReportDocument rpt = new ReportDocument();

            switch (cboReportType.SelectedItem.Text)
            {
            case "Posted PO":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPO.rpt"));
                break;

            case "Posted PO Returns":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPOReturns.rpt"));
                break;

            case "Posted Debit Memo":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedDebitMemo.rpt"));
                break;

            case "By Vendor":
                rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PurchaseAnalysis.rpt"));
                break;

            default:
                return;
            }

            ExportOptions exportop          = new ExportOptions();
            DiskFileDestinationOptions dest = new DiskFileDestinationOptions();

            string strPath = Server.MapPath(@"\retailplus\temp\");

            string strFileName = cboReportType.SelectedItem.Text.Replace(" ", "").ToLower() + "_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".pdf";

            if (System.IO.File.Exists(strPath + strFileName))
            {
                System.IO.File.Delete(strPath + strFileName);
            }

            dest.DiskFileName = strPath + strFileName;

            exportop = rpt.ExportOptions;

            SetDataSource(rpt);

            exportop.DestinationOptions    = dest;
            exportop.ExportDestinationType = ExportDestinationType.DiskFile;
            exportop.ExportFormatType      = ExportFormatType.PortableDocFormat;
            rpt.Export();   rpt.Close();    rpt.Dispose();

            fraViewer.Attributes.Add("src", Constants.ROOT_DIRECTORY + "/temp/" + strFileName);
        }
Exemplo n.º 38
0
        //Exporta a Excel el grid
        protected void ExportEt(object sender, EventArgs e)
        {
            string sucursal = cmbSucursal.Value.ToString();

            //1. Configurar la conexión y el tipo de comando
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString);
            try
            {
                SqlCommand comando = new SqlCommand("web_spS_ObtenerRItemsAdicionales", conn);

                SqlDataAdapter adaptador = new SqlDataAdapter(comando);

                DataTable dt = new DataTable();
                adaptador.SelectCommand.CommandType = CommandType.StoredProcedure;
                adaptador.SelectCommand.Parameters.Add(@"Sucursal", SqlDbType.Char).Value = sucursal;
                adaptador.Fill(dt);

                ReportDocument reporteCuadrila = new ReportDocument();
                reporteCuadrila.Load(Server.MapPath("reportess/ResumenOC.rpt"));
                reporteCuadrila.SetDataSource(dt);

                reporteCuadrila.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "Resumen de OC: " + sucursal);

                reporteCuadrila.Close();
                reporteCuadrila.Dispose();

            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                    conn.Close();
                conn.Dispose();

            }
        }
Exemplo n.º 39
0
        private void Export(ExportFormatType pvtExportFormatType)
        {
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/_StockTransactionReport.rpt"));

            SetDataSource(rpt);

            ExportOptions exportop = new ExportOptions();
            DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
            string strPath = Server.MapPath(@"\retailplus\temp\");
            string strFileExtensionName = ".pdf";
            switch (pvtExportFormatType)
            {
                case ExportFormatType.PortableDocFormat: strFileExtensionName = ".pdf"; exportop.ExportFormatType = ExportFormatType.PortableDocFormat; break;
                case ExportFormatType.WordForWindows: strFileExtensionName = ".doc"; exportop.ExportFormatType = ExportFormatType.WordForWindows; break;
                case ExportFormatType.Excel: strFileExtensionName = ".xls"; exportop.ExportFormatType = ExportFormatType.Excel; break;
            }
            string strFileName = "tranreport_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + strFileExtensionName;
            if (System.IO.File.Exists(strPath + strFileName))
                System.IO.File.Delete(strPath + strFileName);

            dest.DiskFileName = strPath + strFileName;
            exportop.DestinationOptions = dest;
            exportop.ExportDestinationType = ExportDestinationType.DiskFile;
            rpt.Export(exportop); //rpt.Close(); rpt.Dispose(); 

            if (pvtExportFormatType == ExportFormatType.PortableDocFormat)
            {
                rpt.Close(); rpt.Dispose();
                Response.Redirect(Constants.ROOT_DIRECTORY + "/temp/" + strFileName, false);
            }
            else 
            {
                CRViewer.ReportSource = rpt;
                Session["ReportDocument"] = rpt;
                CRSHelper.OpenExportedReport(strFileName); // OpenExportedReport(strFileName);
            }
            
        }
Exemplo n.º 40
0
        private void INPHIEU_XETNGHIEM(bool IsQuick, string sTitleReport, DateTime NgayIn)
        {
            string strPatient_ID = string.Empty;
            var DTPrint = new DataTable();
            string vTestTypeId; //= GetCheckTestType();
            string vTestID ;//= GetcheckTestID();
            string Test_ID = "-1";
            string TestType = "-1";
            foreach (GridEXRow gridExRow in grdTestInfo.GetCheckedRows())
            {
                TestType += "," + Utility.sDbnull(gridExRow.Cells[TTestTypeList.Columns.TestTypeId].Value, "-1");
                Test_ID += "," + Utility.sDbnull(gridExRow.Cells[TTestInfo.Columns.TestId].Value, "-1");
            }
            vTestTypeId = TestType;
            vTestID = Test_ID;
            if (vTestTypeId == "-1")
            {
                Utility.ShowMsg("Chưa chọn loại xét nghiệm để in");
                return;
            }

                strPatient_ID = Utility.sDbnull(grdTestInfo.GetValue("Patient_ID"));

            DTPrint =
                SPs.GtvtGetTestResultForPrintV2FromDateToDate(strPatient_ID, vTestTypeId, vTestID,dtpTestDateFrom.Value.ToShortDateString(),
                                                              dtpTestDateTo.Value.ToShortDateString()).GetDataSet().Tables[0];
            if (DTPrint.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy bản ghi nào", "Thông báo");
                return;
            }
            ProcessData(ref DTPrint);
            if (SysPara.IsNormalResult == 1)
            {
                string normalLevel = Utility.Int32Dbnull(DTPrint.Rows[0]["Sex"], 1) == 1
                                         ? "Normal_Level"
                                         : "Normal_LevelW";
                ProcessNormalResult(ref DTPrint);
                //ProcessNormalResult(ref DTPrint, "Test_result", normalLevel, -1, 1, 0,
                //                                            "binhthuong", false);
                foreach (DataRow row in DTPrint.Rows)
                {
                    if (
                        (row["Test_result"].ToString().Trim().ToUpper().StartsWith("ÂM"))
                        || (row["Test_result"].ToString().Trim().ToUpper().Contains("AM"))
                        )
                    {
                        row["binhthuong"] = -1;
                    }
                    else if (
                        (row["Test_result"].ToString().Trim().ToUpper().StartsWith("DƯƠ"))
                        || (row["Test_result"].ToString().Trim().ToUpper().Contains("DUO"))
                        )
                    {
                        row["binhthuong"] = 1;
                    }
                }
            }
            //try
            //{
            //    reporttype = File.ReadAllText(filereporttype);
            //    if (chkA5.Checked)
            //    {
            //        StrCode = reporttype;
            //    }
            //    else if (chkA4.Checked)
            //    {
            //        StrCode = reporttype;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Loz" + ex, "Thông báo");
            //}

            string tieude = "", reportname = "";
             var crpt =new ReportDocument();
            if (chkPrintXN.Checked)
            {
                crpt = Utility.GetReport("crpt_InPhieuKetQuaXetNghiem", ref tieude, ref reportname);
            }
            else if(chkPrintOther.Checked)
            {
                crpt = Utility.GetReport("crpt_InPhieuXNKhac", ref tieude, ref reportname);
            }
            if (crpt.FilePath != null &&crpt.FilePath!="")
            {
                var objForm = new frmPrintPreview(sTitleReport, crpt, true, DTPrint.Rows.Count <= 0 ? false : true);
                Utility.UpdateLogotoDatatable(ref DTPrint);
                try
                {
                    DTPrint.AcceptChanges();
                    crpt.SetDataSource(DTPrint);
                    objForm.crptViewer.ReportSource = crpt;
                    ////crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "  PHÒNG TIẾP ĐÓN   ".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                    objForm.crptTrinhKyName = Path.GetFileName(reportname);
                    Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                    Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                    Utility.SetParameterValue(crpt, "sCurrentDate", Date(NgayIn));
                    Utility.SetParameterValue(crpt, "sTitleReport", _myProperties.TieuDeInXNKhac);
                    Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                    if (IsQuick)
                    {
                        objForm.ShowDialog();
                        // Utility.DefaultNow(this);
                    }
                    else
                    {
                        objForm.addTrinhKy_OnFormLoad();
                        crpt.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName;
                        crpt.PrintToPrinter(0, true, 0, 0);
                        crpt.Dispose();
                        CleanTemporaryFolders();
                    }
                }
                catch (Exception ex)
                {
                    if (globalVariables.IsAdmin)
                    {
                        Utility.ShowMsg(ex.ToString());
                    }
                }
            }
            else
            {
                Utility.ShowMsg("Ban hay chon loai mau bao cao","Thong bao");
            }
        }
Exemplo n.º 41
0
        private void ImprimirTicket(int folio)
        {
            Transaccion t = TransaccionesBLL.Obtener(folio);
            Caja caja = new Caja(Globales.IdCaja);
            TipoTransaccion tipo;
            if (t == null || caja.IsNull())
            {
                MessageBox.Show("Nose pudo obtener la información", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            tipo = (TipoTransaccion)t.Datos.IdTipo;
            if (tipo != TipoTransaccion.CambioCheque && tipo != TipoTransaccion.CompraDll && tipo != TipoTransaccion.EntradaPrestamo &&
                tipo != TipoTransaccion.VentaDll && tipo !=TipoTransaccion.Gasto)
            {
                t = null;
                caja = null;
                return;
            }
            string logo = Application.StartupPath + "\\Imagenes\\Logotipos\\" + caja.Sucursal.Datos.Logo;
            ReportDocument rpt= new ReportDocument();
            rpt.Load("Reportes\\Ticket2.rpt");
            rpt.SetParameterValue("SUCURSAL", caja.Sucursal.Datos.RazonSocial);
            rpt.SetParameterValue("RFC", caja.Sucursal.Datos.RFC);
            rpt.SetParameterValue("DIRECCION", caja.Sucursal.Datos.Direccion);
            rpt.SetParameterValue("CABECERA", caja.Sucursal.Datos.Cabecera);
            rpt.SetParameterValue("FOLIO", t.Folio.ToString("00000"));
            rpt.SetParameterValue("FECHA", t.Datos.Fecha);
            rpt.SetParameterValue("PIE", caja.Sucursal.Datos.Pie);
            rpt.SetParameterValue("Logo", logo);
            string concepto,titulo1,titulo2,firma;
            decimal tc,pago,total,cantidad,vuelto;
            switch (tipo)
            {
                case TipoTransaccion.VentaDll:
                case TipoTransaccion.CompraDll:

                    if(tipo == TipoTransaccion.VentaDll)
                    {
                        concepto="Venta de dolares";
                        cantidad= t.Datos.CargosDLL;
                        titulo1="T.C. Venta";
                        tc=t.Datos.TCVenta;
                        total=t.Datos.AbonosMXN;
                    }
                    else
                    {
                        concepto="Compra de dolares";
                        cantidad= t.Datos.AbonosDLL;
                        titulo1="T.C. Compra";
                        tc=t.Datos.TCCompra;
                        total=t.Datos.CargosMXN;
                    }
                    titulo2="Pago con";
                    pago=t.Datos.PagoCliente;
                    vuelto = t.Datos.VueltoCliente;
                    rpt.SetParameterValue("CONCEPTO", concepto);
                    rpt.SetParameterValue("CANTIDAD", cantidad);
                    rpt.SetParameterValue("Titulo1", titulo1);
                    rpt.SetParameterValue("TC", tc);
                    rpt.SetParameterValue("Titulo2", titulo2);
                    rpt.SetParameterValue("Pago", pago);
                    rpt.SetParameterValue("TOTAL", total);
                    rpt.SetParameterValue("Vuelto", vuelto);
                    rpt.SetParameterValue("Firma", "");
                    break;
                case TipoTransaccion.CambioCheque:
                    cantidad = t.Datos.PagoCliente - t.Datos.VueltoCliente;
                    rpt.SetParameterValue("CONCEPTO", "Comisión cambio cheque" );
                    rpt.SetParameterValue("CANTIDAD",cantidad);
                    rpt.SetParameterValue("Titulo1", "comisión %");
                    rpt.SetParameterValue("TC", t.Datos.ChqComision);
                    rpt.SetParameterValue("Titulo2", "Cantidad del chq.");
                    rpt.SetParameterValue("Pago", t.Datos.PagoCliente);
                    rpt.SetParameterValue("TOTAL", cantidad);
                    rpt.SetParameterValue("Vuelto", t.Datos.VueltoCliente);
                    rpt.SetParameterValue("Firma", "");
                    break;
                case TipoTransaccion.EntradaPrestamo:
                    rpt.SetParameterValue("CONCEPTO", "Pago préstamo");
                    rpt.SetParameterValue("CANTIDAD", t.Datos.AbonosMXN);
                    rpt.SetParameterValue("Titulo1", "");
                    rpt.SetParameterValue("TC", 0);
                    rpt.SetParameterValue("Titulo2", "Pago con");
                    rpt.SetParameterValue("Pago", t.Datos.PagoCliente);
                   rpt.SetParameterValue("TOTAL", t.Datos.AbonosMXN);
                   rpt.SetParameterValue("Vuelto", t.Datos.VueltoCliente);
                   rpt.SetParameterValue("Firma", "");
                   break;
                case TipoTransaccion.Gasto:
                   rpt.SetParameterValue("CONCEPTO", "Gasto");
                   rpt.SetParameterValue("CANTIDAD", t.Datos.CargosMXN);
                   rpt.SetParameterValue("Titulo1", "");
                   rpt.SetParameterValue("TC", 0);
                   rpt.SetParameterValue("Titulo2", "Pago con");
                   rpt.SetParameterValue("Pago", t.Datos.PagoCliente);
                   rpt.SetParameterValue("TOTAL", t.Datos.CargosMXN);
                   rpt.SetParameterValue("Vuelto", t.Datos.VueltoCliente);
                   rpt.SetParameterValue("Firma", "Recibo");
                   break;
            }
            if (!Properties.Settings.Default.TicketPantalla)
            {
                rpt.PrintOptions.PrinterName = Properties.Settings.Default.Impresora;
                rpt.PrintToPrinter(Properties.Settings.Default.NoCopias, false, 1, 2);
                rpt.Dispose();
                rpt = null;
            }
            else
            {
                frmReporte frm = new frmReporte(rpt);
                //frm.CrViewer1.PrintReport();
                frm.ShowDialog();
                rpt.Dispose();
                rpt = null;
                frm.Dispose();
                frm = null;
            }
        }
Exemplo n.º 42
0
		private void GenerateHTML()
		{
            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/GeneralLedger.rpt"));

			HTMLFormatOptions htmlOpts = new HTMLFormatOptions();
 
			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\RetailPlus\temp\html\");
//			DeleteTempDirectory(strPath);

			string strFileName = "generalledger_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".htm";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			htmlOpts.HTMLFileName = strFileName;
			htmlOpts.HTMLEnableSeparatedPages = true;;
			htmlOpts.HTMLHasPageNavigator = true;
			htmlOpts.HTMLBaseFolderName = strPath;
			rpt.ExportOptions.FormatOptions = htmlOpts;

			exportop = rpt.ExportOptions;

			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.HTML40;
			
			dest.DiskFileName = strFileName.ToString();
			exportop.DestinationOptions = dest;

			SetDataSource(rpt);

			rpt.Export();   rpt.Close();    rpt.Dispose();

			strFileName = "//" + Request.ServerVariables["SERVER_NAME"].ToString() + FindHTMLFile(strPath,strFileName);	
			
			fraViewer.Attributes.Add("src",strFileName);
		}
Exemplo n.º 43
0
        public string GenerateInvoice(int id)
        {
            string exportFilePath = null;

            #region Get System Parameters
            string Comp_68_Title = this._db.recsys_system_parameter.Where(sp => sp.name == "company_eng_name_68").Select(sp => sp.value).FirstOrDefault();
            string Comp_28_Title = this._db.recsys_system_parameter.Where(sp => sp.name == "company_eng_name_28").Select(sp => sp.value).FirstOrDefault();
            string Comp_68_CTitle = this._db.recsys_system_parameter.Where(sp => sp.name == "company_chi_name_68").Select(sp => sp.value).FirstOrDefault();
            string Comp_28_CTitle = this._db.recsys_system_parameter.Where(sp => sp.name == "company_chi_name_28").Select(sp => sp.value).FirstOrDefault();
            string Comp_Address = this._db.recsys_system_parameter.Where(sp => sp.name == "company_eng_address").Select(sp => sp.value).FirstOrDefault();
            string Comp_CAddress = this._db.recsys_system_parameter.Where(sp => sp.name == "company_chi_address").Select(sp => sp.value).FirstOrDefault();
            string Comp_Tel = this._db.recsys_system_parameter.Where(sp => sp.name == "company_tel").Select(sp => sp.value).FirstOrDefault();
            string Comp_Fax = this._db.recsys_system_parameter.Where(sp => sp.name == "company_fax").Select(sp => sp.value).FirstOrDefault();
            string Comp_Hotline = this._db.recsys_system_parameter.Where(sp => sp.name == "company_service_hotline").Select(sp => sp.value).FirstOrDefault();
            string Comp_Subsidiary = "(A wholly-owned subsidiary of Yau Lee Holding Limited)";
            #endregion Get System Parameters

            #region Get Quotation
            double? quotationItemAmountTotal = (from qi in this._db.recsys_quotation_items
                                                join r in this._db.recsys_relate on qi.id equals r.id2
                                                where r.table1 == "quotation" && r.table2 == "quotation_items" && r.id1 == id && qi.price != null
                                                select qi.price).Sum();
            var quotationItems = (from q in this._db.recsys_quotation
                                  join rc in this._db.recsys_relate_customers on q.customer_id equals rc.id into subrc
                                  from rc2 in subrc.DefaultIfEmpty()
                                  join qi in
                                      (from r in this._db.recsys_relate
                                       join qi in this._db.recsys_quotation_items on r.id2 equals qi.id into subqi
                                       from qi2 in subqi.DefaultIfEmpty()
                                       where r.table1 == "quotation" && r.table2 == "quotation_items" && r.id1 == id
                                       select new
                                       {
                                           q_id = r.id1,
                                           nSequence = qi2.nSequence,
                                           id = qi2.id,
                                           code = qi2.code,
                                           detail = qi2.detail,
                                           detail2 = qi2.detail2,
                                           price = qi2.price
                                       }) on q.id equals qi.q_id
                                  where q.id == id
                                  select new
                                  {
                                      center = rc2.center,
                                      tender_number = q.tender_number,
                                      minor_work = q.minor_work,
                                      invoice = q.invoice,
                                      invoice_date = q.invoice_date,
                                      dummy_date = q.dummy_date,
                                      dummy = q.dummy,
                                      initial = q.initial,
                                      customer_name = rc2.name,
                                      address1 = rc2.address1,
                                      address2 = rc2.address2,
                                      contact = rc2.contact,
                                      email = rc2.email,
                                      tel1 = rc2.tel1,
                                      tel2 = rc2.tel2,
                                      fax1 = rc2.fax1,
                                      fax2 = rc2.fax2,
                                      sequence = qi.nSequence,
                                      detail = q.lang == 1 ? qi.detail : qi.detail2,
                                      price = qi.price.HasValue ? qi.price.Value : 0,
                                      lang = q.lang
                                  }).ToList();

            ArrayList rptSource = new ArrayList();
            foreach (var quotationItem in quotationItems)
            {
                InvoiceCrystalReportModel model = new InvoiceCrystalReportModel
                {
                    Comp_Title = quotationItem.center == "28" ? Comp_28_Title : Comp_68_Title,
                    Comp_CTitle = quotationItem.center == "28" ? Comp_28_CTitle : Comp_68_CTitle,
                    Comp_Address = Comp_Address,
                    Comp_CAddress = Comp_CAddress,
                    Comp_Tel = ": " + Comp_Tel,
                    Comp_Fax = ": " + Comp_Fax,
                    Comp_Hotline = ": " + Comp_Hotline,
                    Comp_Subsidiary = Comp_Subsidiary,
                    invoice_no = string.Format("{0}{1}", quotationItem.dummy == 1 ? "INV-Q" + id : quotationItem.invoice, (string.IsNullOrEmpty(quotationItem.minor_work) ? string.Empty : " /E" + quotationItem.minor_work)),
                    nSeq = quotationItem.sequence.HasValue ? quotationItem.sequence.Value.ToString().PadLeft(2, '0') : string.Empty,
                    invoice_date = quotationItem.invoice_date.HasValue ? quotationItem.invoice_date.Value.ToString("dd-MMM-yy", CultureInfo.CreateSpecificCulture("en-US")) : string.Empty,
                    dummy_date = quotationItem.dummy_date.HasValue ? quotationItem.dummy_date.Value.ToString("dd-MMM-yy", CultureInfo.CreateSpecificCulture("en-US")) : string.Empty,
                    customer_name = quotationItem.customer_name,
                    address1 = quotationItem.address1,
                    address2 = quotationItem.address2 + (string.IsNullOrEmpty(quotationItem.tender_number) ? string.Empty : " (" + quotationItem.tender_number + ")"),
                    contact = quotationItem.contact,
                    tel1 = string.IsNullOrEmpty(quotationItem.tel1) ? string.IsNullOrEmpty(quotationItem.tel2) ? string.Empty
                                                                                                               : quotationItem.tel2
                                                                    : string.IsNullOrEmpty(quotationItem.tel2) ? quotationItem.tel1
                                                                                                               : quotationItem.tel1 + " / " + quotationItem.tel2,
                    fax1 = string.IsNullOrEmpty(quotationItem.fax1) ? string.IsNullOrEmpty(quotationItem.fax2) ? string.Empty
                                                                                                               : quotationItem.fax2
                                                                    : string.IsNullOrEmpty(quotationItem.fax2) ? quotationItem.fax1
                                                                                                               : quotationItem.fax1 + " / " + quotationItem.fax2,
                    detail = quotationItem.detail,
                    price = quotationItem.price,
                    price_total = quotationItemAmountTotal.HasValue ? quotationItemAmountTotal.Value : 0,
                    email = quotationItem.email,
                    initial = quotationItem.initial,
                    lang = quotationItem.lang
                };
                rptSource.Add(model);
            }
            #endregion Get Quotation

            if (quotationItems != null && quotationItems.Count() > 0)
            {
                ReportDocument rd = new ReportDocument();
                try
                {
                    string strRptPath = Server.MapPath("~/Report/Invoice.rpt");
                    string shareDriveRootFolderPath = ConfigurationManager.AppSettings["ShareRootFolderPath"].ToString();
                    string invoiceTempFolder = shareDriveRootFolderPath + @"\Invoice\Temp\";
                    if (!Directory.Exists(invoiceTempFolder))
                    {
                        Directory.CreateDirectory(invoiceTempFolder);
                    }
                    exportFilePath = invoiceTempFolder + Guid.NewGuid() + ".pdf";
                    rd.Load(strRptPath);
                    rd.SetDataSource(rptSource);
                    //Stream stream = rd.ExportToStream(ExportFormatType.PortableDocFormat);
                    rd.ExportToDisk(ExportFormatType.PortableDocFormat, exportFilePath);
                }
                catch
                {
                    exportFilePath = null;
                }
                finally
                {
                    rd.Dispose();
                }
            }

            return exportFilePath;
        }
Exemplo n.º 44
0
        private void Generar(Conexion Datos, string reporte, Reportes report)
        {
            reportDocument = new ReportDocument();

            string sql = null;

            switch (report)
            {
                case Reportes.Lps:
                    sql = "usp_lps_reporte ";
                    sql += IdLpsEmpleado.ToString();
                    sql += ", " + IdEmpresa;
                    break;
                case Reportes.Acumulados:
                    sql = "usp_lps_acumulados_porIdEmpleado ";
                    sql += IdEmpleado.ToString();
                    break;
            }
            reportDocument.Load(reporte);
            reportDocument.SetDataSource(Datos.ExecuteReaderConTransaccion(sql).Tables[0]);
            reportDocument.DataSourceConnections[0].SetConnection("192.168.16.252", "siser_v3", "sa", "Acceso2013");

            switch (report)
            {
                case Reportes.Lps:
                    Reporte = (MemoryStream)reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    break;
                case Reportes.Acumulados:
                    Acumulados = (MemoryStream)reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    break;
            }

            try
            {
                reportDocument.Dispose();
                reportDocument = null;
                reportDocument.Close();
            }
            catch
            {
            }
        }
 //---PhongNT 04/12/2012
 public void Page_UnLoad ( object sender, EventArgs e )
 {
     rptDoc = new ReportDocument ( );
     //Fix lỗi report failed
     if (rptDoc != null)
     {
         try
         {
             this.CrystalReportViewer1.Dispose ( );
             this.CrystalReportViewer1 = null;
             rptDoc.Close ( );
             rptDoc.Dispose ( );
             GC.Collect ( );
         }
         catch
         {
             this.CrystalReportViewer1 = null;
             rptDoc.Close ( );
             rptDoc.Dispose ( );
             GC.Collect ( );
         }
     }
 }
        //protected Boolean CheckAccessAble()
        //{
        //    if (m_perimission_array[(int)Authentication.FUN_INTERFACE.wzxqjh_jjd_report][0] == '1') return true;
        //    return false;
        //}
        private void PrintPDF()
        {
            ReportDocument rpt_doc = new ReportDocument();
            DataSet ds = new DataSet();
            StringBuilder sqlstr = new StringBuilder();
            //sqlstr.Append("select a.jjd_no,a.requisition_id req_id,a.rowstate,a.remark,a.package_no,a.part_no,b.part_name part_name,");
            //sqlstr.Append("b.part_name_e part_name_e,gen_part_package_api.get_package_name(package_no) package_name,");
            //sqlstr.Append("gen_part_package_item_api.get_unit(package_no,part_no) part_unit,gen_part_package_item_api.get_part_spec(package_no,part_no) part_spec,");
            //sqlstr.Append("zh_qty,xh_qty,finish_time,rowversion,project_id proj_id from jp_pkg_jjd_line a,jp_pkg_requisition b where a.requisition_id=b.requisition_id");
            sqlstr.Append(@"select a.jjd_no,a.requisition_id req_id,a.rowstate,a.remark,a.package_no,a.part_no,
               b.part_name   part_name, b.part_name_e part_name_e,   b.package_name package_name,
               b.part_unit part_unit, b.part_spec part_spec, b.released_qty xq_qty,a.zh_qty,
               a.xh_qty, a.finish_time, a.rowversion,a.project_id proj_id
              from jp_pkg_jjd_line a, jp_pkg_requisition_v b where a.requisition_id = b.requisition_id");
            sqlstr.Append(string.Format(" and a.jjd_no ='{0}' order by a.part_no", m_jjd_no));

            OleDbConnection conn = new OleDbConnection(DBHelper.OleConnectionString);
            OleDbCommand cmd = new OleDbCommand();
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);

            //DeliveryVoucher dvchr = (DeliveryVoucher)Session["delivery_voucher"];

            PkgJjd objJjd = new PkgJjd(m_jjd_no);

            //sqlstr.Append(" and requisition_id in (");
            //for (int i = 0; i < dvchr.DeliveryItems.Count; i++)
            //{
            //    if (i == dvchr.DeliveryItems.Count - 1)
            //    {
            //        sqlstr.Append(string.Format("'{0}'", dvchr.DeliveryItems[i].ToString()));
            //    }
            //    else
            //    {
            //        sqlstr.Append(string.Format("'{0}',", dvchr.DeliveryItems[i].ToString()));
            //    }
            //}
            //sqlstr.Append(" )");

            cmd.Connection = conn;
            cmd.CommandText = sqlstr.ToString();

            da.Fill(ds);

            rpt_doc.Load(Request.PhysicalApplicationPath + "\\UI\\Report\\CrysPkgJjd.rpt");
            rpt_doc.SetDataSource(ds.Tables[0]);
            //dvchr.SetDeliveryVoucherNo();
            rpt_doc.SetParameterValue("jjd_no", m_jjd_no);
            //rpt_doc.SetParameterValue("kuwei", "");
            rpt_doc.SetParameterValue("place", objJjd.PlaceName);
            rpt_doc.SetParameterValue("receiver", objJjd.ReceiptPerson);
            rpt_doc.SetParameterValue("recieve_date", objJjd.ReceiptDate);
            rpt_doc.SetParameterValue("receiver_contact", objJjd.ReceiptContract);
            rpt_doc.SetParameterValue("ZHd", objJjd.ZhPlace);
            rpt_doc.SetParameterValue("ZHr", objJjd.ZhPerson);
            rpt_doc.SetParameterValue("ZHdh", objJjd.ZhContract);
            rpt_doc.SetParameterValue("ZHArrTime", objJjd.ZhArrTime);
            rpt_doc.SetParameterValue("XQbm", objJjd.XQDept);
            rpt_doc.SetParameterValue("XQlxr", objJjd.XQPerson);
            rpt_doc.SetParameterValue("XQdh", objJjd.XQContract);
            rpt_doc.SetParameterValue("CYgs", objJjd.CyCompany);
            rpt_doc.SetParameterValue("CYr", objJjd.CyPerson);
            rpt_doc.SetParameterValue("CYdh", objJjd.CyContract);
            rpt_doc.SetParameterValue("CYpz", objJjd.CycCarNo);
            rpt_doc.SetParameterValue("CYjz", objJjd.CyDoc);

            rpt_doc.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
            rpt_doc.PrintOptions.PaperSize = PaperSize.PaperA4;

            using (MemoryStream fp = (MemoryStream)(rpt_doc.ExportToStream(ExportFormatType.PortableDocFormat)))
            {
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(fp.ToArray());
                fp.Close();
                Response.End();
            }

            rpt_doc.Close();
            rpt_doc.Dispose();
        }
Exemplo n.º 47
0
    protected void btninfoBitacora_Click(object sender, EventArgs e)
    {
        string Ciclo = this.ddlCiclo.SelectedValue;
        DBEstadisticas.Escolar db = new DBEstadisticas.Escolar();

        var Bitacora = (from P in db.Bitacora
                        where P.Ciclo == Ciclo
                        group P by new { P.Z, P.P, P.Descripcion } into g
                        select new { Z = g.Key.Z, P = g.Key.P, g.Key.Descripcion, Fecha = g.Max(x => x.Fecha) }).OrderByDescending(x => x.Fecha).ToList();

        if (Bitacora.Count == 0)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", string.Format("alert('{0}');", "No hay registros encontrados"), true);
            return;
        }

        ReportDocument rptDoc = new ReportDocument();
        rptDoc.Load(Server.MapPath("../Reportes/rptEstBitacora01.rpt"));
        rptDoc.SetDataSource(Bitacora);
        rptDoc.SetParameterValue("Ciclo", Ciclo);

        MemoryStream stream = (MemoryStream)rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        rptDoc.Close();
        rptDoc.Dispose();

        Response.Clear();
        Response.Buffer = true;
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "inline; filename=rptEstBitacora01.xls");
        Response.BinaryWrite(stream.ToArray());
        Response.End();
        stream.Close();
        stream.Dispose();
    }
Exemplo n.º 48
0
    private void GenerarReporteXGrupo(int Zona, int Plantel, string Ciclo, int Periodo, byte Turno, byte Semestre)
    {
        EscolarModel.EstaEntities db = new EscolarModel.EstaEntities();

        var Alumnos = (from A in db.vwRPTParcial1XGPO
                       join P in db.vwPlanteles on new { z = A.or_zona, pl = A.or_plant } equals new { z = (byte)P.idZona, pl = (int)P.idPlantel }
                       where A.Ciclo == Ciclo && A.Periodo == Periodo &&
                            A.or_zona == (Zona == 0 ? A.or_zona : Zona) && A.or_plant == (Plantel == 0 ? A.or_plant : Plantel)
                            && A.or_turno == (Turno == 0 ? A.or_turno : Turno) && A.or_semest == (Semestre == 0 ? A.or_semest : Semestre)
                            && P.EsEmsad == 0
                       orderby A.or_zona, A.or_plant, A.or_turno, A.or_semest, A.or_grupo, A.or_asigna
                       select A).ToList();

        if (Alumnos.Count == 0)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", string.Format("alert('{0}');", "No hay registros encontrados"), true);
            return;
        }

        ReportDocument rptDoc = new ReportDocument();
        rptDoc.Load(Server.MapPath("../Reportes/rptEstCalXGpo01.rpt"));
        rptDoc.SetDataSource(Alumnos);
        rptDoc.SetParameterValue("Periodo", Periodo);
        rptDoc.SetParameterValue("Ciclo", Ciclo);

        MemoryStream stream = (MemoryStream)rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
        rptDoc.Close();
        rptDoc.Dispose();

        Response.Clear();
        Response.Buffer = true;
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "inline; filename=rptEstCalXGpo01.xls");
        Response.BinaryWrite(stream.ToArray());
        Response.End();
        stream.Close();
        stream.Dispose();
    }
    //dbINFO._SRV, dbINFO._CAT, dbINFO._UID, dbINFO._PWD
    public void PrintReport(Page _Page, string _ReportName, string _FileName, DataTable dt)
    {
        ReportDocument rptDoc = new ReportDocument();
        try
        {
            rptDoc.Load(_Page.Server.MapPath("~/Reports/" + _ReportName));
            rptDoc.SetDataSource(dt);

            rptDoc.SetDatabaseLogon(dbINFO._UID, dbINFO._PWD, dbINFO._SRV, dbINFO._CAT);
            _Page.Response.Buffer = false;
            _Page.Response.ClearContent();
            _Page.Response.ClearHeaders();
            //Export the Report to Response stream in PDF format and file name Customers
            rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, _Page.Response, true, _FileName);
        }
        catch (Exception ex)
        {
            Utility.ShowHTMLMessage(_Page, "100", ex.Message);
        }
        finally
        {
            rptDoc.Close();
            rptDoc.Dispose();
        }
    }
    public void PrintReport(Page _Page, string _ReportName, string _FileName, DataTable[] dts, string[] _DSTableName,
        string[] paramNames = null, string[] paramValues = null)
    {
        paramNames = paramNames == null ? new string[] { } : paramNames;
        paramValues = paramValues == null ? new string[] { } : paramValues;
        dts = dts == null ? new DataTable[] { } : dts;
        _DSTableName = _DSTableName == null ? new string[] { } : _DSTableName;

        ReportDocument rptDoc = new ReportDocument();
        try
        {
            rptDoc.Load(_Page.Server.MapPath("~/Reports/" + _ReportName));

            dsPSMS ds = new dsPSMS();
            for (int i = 0; i < dts.Length; i++)
            {
                ds.Tables[_DSTableName[i]].Merge(dts[i]);
            }
            if (dts.Length > 0)
                rptDoc.SetDataSource(ds);

            if (paramNames.Length == paramValues.Length)
            {
                for (int i = 0; i < paramNames.Length; i++)
                    rptDoc.SetParameterValue(paramNames[i], paramValues[i]);
            }

            rptDoc.SetDatabaseLogon(dbINFO._UID, dbINFO._PWD, dbINFO._SRV, dbINFO._CAT);
            _Page.Response.Buffer = false;
            _Page.Response.ClearContent();
            _Page.Response.ClearHeaders();
            //Export the Report to Response stream in PDF format and file name Customers
            rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, _Page.Response, true, _FileName);

            _Page.Response.ClearContent();
            _Page.Response.ClearHeaders();
            _Page.Response.Clear();
            _Page.Response.Close();
        }
        catch (Exception ex)
        {
            //DO NOTHING
        }
        finally
        {
            rptDoc.Close();
            rptDoc.Dispose();
        }
    }
        protected void imgbtnVistaPreviaReporteVolumetrias_Click(object sender, EventArgs e)
        {
            //Parametros del store procedure
            string strID = Cookies.GetCookie("cookieEditarVolumetria").Value;
            string strPreciario = Cookies.GetCookie("cookiePreciario").Value;

            string path = AppDomain.CurrentDomain.BaseDirectory;
            //1. Configurar la conexión y el tipo de comando
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString);
            try
            {
                using (var comando = new SqlCommand("web_spS_ObtenerCambiosPreciarioPorVolumetria", conn))
                {
                    using (var adaptador = new SqlDataAdapter(comando))
                    {
                        DataTable dt = new DataTable();
                        adaptador.SelectCommand.CommandType = CommandType.StoredProcedure;
                        adaptador.SelectCommand.Parameters.Add(@"idpreciario", SqlDbType.NVarChar).Value = strPreciario;
                        adaptador.SelectCommand.Parameters.Add(@"Volumetria", SqlDbType.Int).Value = Convert.ToInt32(strID);
                        adaptador.Fill(dt);

                        var reporte = new ReportDocument();
                        reporte.Load(Server.MapPath("reportess/CPreciarioV.rpt"));
                        reporte.SetDataSource(dt);
                        reporte.SetParameterValue("path", path);
                        reporte.SetParameterValue("pathlogo", path + "\\images\\clientes\\");
                        reporte.SetParameterValue("pathlogopro", path + "\\images\\proveedores\\");

                        string strDireccion = Server.MapPath(" ") + "\\reportess\\Volumetrias\\" + strID;

                        //2. Validar si existe el directorio donde se guardaran
                        if (Directory.Exists(strDireccion))
                        {
                            reporte.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf"));

                            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf',null,'height=700,width=660');popup.focus();", true);
                           // reporte.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "Resumen de OC: ");

                        }
                        else
                        {
                            Directory.CreateDirectory(strDireccion);
                            reporte.ExportToDisk(ExportFormatType.PortableDocFormat, Server.MapPath("reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf"));
                            ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('reportess/Volumetrias/" + strID + "/Volumetria " + strID + ".pdf',null,'height=700,width=660');popup.focus();", true);
                        }
                        reporte.Dispose();
                        reporte.Close();
                    } // end using adaptador
                } // end using comando

            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                    conn.Close();
                conn.Dispose();
            }
        }
Exemplo n.º 52
0
        public ActionResult ViewApplication(string applicationid)
        {
            ReportDocument appreport = new ReportDocument();

            appreport.Load(Server.MapPath("~/Reports/ApplicationForm.rpt"));
            appreport.PrintOptions.PaperSize = PaperSize.PaperA4;

            long appid = Convert.ToInt64(applicationid);
            List<CustApplicationReport> appmodel = new List<CustApplicationReport>();
            var customer = db.CustApplicationReports.AsNoTracking().Where(a => a.ApplicationID == appid).FirstOrDefault();
            appmodel.Add(customer);
            appreport.SetDataSource(appmodel);

            Stream stream = appreport.ExportToStream(ExportFormatType.PortableDocFormat);
            appreport.Dispose();
            return File(stream, "application/pdf");

        }
Exemplo n.º 53
0
		private void GeneratePDF()
		{
			ReportDocument rpt = new ReportDocument();

			switch (cboReportType.SelectedItem.Text)
			{
                case "Posted PO":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPO.rpt"));
                    break;
                case "Posted PO Returns":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPOReturns.rpt"));
                    break;
                case "Posted Debit Memo":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedDebitMemo.rpt"));
                    break;
                case "By Vendor":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PurchaseAnalysis.rpt"));
                    break;
                default:
                    return;
					
			}

			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\retailplus\temp\");

			string strFileName = cboReportType.SelectedItem.Text.Replace(" ", "").ToLower() + "_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".pdf";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			dest.DiskFileName = strPath + strFileName;

			exportop = rpt.ExportOptions;
	
			SetDataSource(rpt);

			exportop.DestinationOptions = dest;
			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.PortableDocFormat;
			rpt.Export();   rpt.Close();    rpt.Dispose();

			fraViewer.Attributes.Add("src",Constants.ROOT_DIRECTORY + "/temp/" + strFileName);
		}
Exemplo n.º 54
0
        private Stream genericReportSetting(ReportDocument report, HttpContext httpctx)
        {   
           
            PropertyBag connectionAttributes = new PropertyBag();
            connectionAttributes.Add("Auto Translate", "-1");
            connectionAttributes.Add("Connect Timeout", "15");
            connectionAttributes.Add("Data Source", ConfigurationManager.AppSettings["Server"]);
            connectionAttributes.Add("General Timeout", "0");
            connectionAttributes.Add("Initial Catalog", ConfigurationManager.AppSettings["Database"]);
            connectionAttributes.Add("Integrated Security", false);
            connectionAttributes.Add("Locale Identifier", "1040");
            connectionAttributes.Add("OLE DB Services", "-5");
            connectionAttributes.Add("Provider", "SQLOLEDB");
            connectionAttributes.Add("Tag with column collation when possible", "0");
            connectionAttributes.Add("Use DSN Default Properties", false);
            connectionAttributes.Add("Use Encryption for Data", "0");
            
            PropertyBag attributes = new PropertyBag();
            attributes.Add("Database DLL", "crdb_ado.dll");
            attributes.Add("QE_DatabaseName", ConfigurationManager.AppSettings["Database"]);
            attributes.Add("QE_DatabaseType", "OLE DB (ADO)");
            attributes.Add("QE_LogonProperties", connectionAttributes);
            attributes.Add("QE_ServerDescription", httpctx.Server);
            attributes.Add("QESQLDB", true);
            attributes.Add("SSO Enabled", false);

            CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo ci = new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
            ci.Attributes = attributes;
            ci.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
            ci.UserName = ConfigurationManager.AppSettings["UserID"];
            ci.Password = ConfigurationManager.AppSettings["Password"];

            foreach (CrystalDecisions.ReportAppServer.DataDefModel.Table table in report.ReportClientDocument.DatabaseController.Database.Tables)
            {
                CrystalDecisions.ReportAppServer.DataDefModel.Procedure newTable = new CrystalDecisions.ReportAppServer.DataDefModel.Procedure();

                newTable.ConnectionInfo = ci;
                newTable.Name = table.Name;
                newTable.Alias = table.Alias;
                newTable.QualifiedName = ConfigurationManager.AppSettings["Database"] + ".dbo." + table.Name;
                report.ReportClientDocument.DatabaseController.SetTableLocation(table, newTable);
            }


            Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat);
            report.Dispose();
            return stream;
        }
Exemplo n.º 55
0
    private void GenerarPDF()
    {
        DBEscolarDataContext db = new DBEscolarDataContext();
        var Alumno = (from A in db.vwRPTReinscripcions
                      where A.Matricula == this.Matricula
                      select A).FirstOrDefault();

        if (Alumno == null)//No se encontro
            return;

        System.Collections.ArrayList col = new System.Collections.ArrayList();
        col.Add(Alumno);
        ReportDocument rptDoc = new ReportDocument();

        rptDoc.Load(Server.MapPath("Reportes/rptReinscripcion.rpt"));
        //set dataset to the report viewer.
        rptDoc.SetDataSource(col);

        MemoryStream stream = (MemoryStream)rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
        rptDoc.Close();
        rptDoc.Dispose();
        Response.Clear();
        Response.ContentType = @"Application/pdf";
        Response.AddHeader("Content-Disposition", "inline; filename=Solicitud.pdf");
        // Response.AddHeader("Content-Disposition", "attachment; filename=File.pdf");
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        stream.Dispose();
    }
        //protected Boolean CheckAccessAble()
        //{
        //    if (m_perimission_array[(int)Authentication.FUN_INTERFACE.wzxqjh_jjd_report][0] == '1') return true;
        //    return false;
        //}
        private void PrintPDF()
        {
            ReportDocument rpt_doc = new ReportDocument();
            DataSet ds = new DataSet();
            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append("select requisition_id req_id,matr_seq_no mtr_no, to_char(matr_seq_line_no)||' ' line_no,");//2013-03-22 ming.li ����������ת��Ϊ�ַ����������кŸ�ʽΪ1.00
            sqlstr.Append(" part_no, part_description part_name,project_id proj_id, nvl(project_block,'') proj_block,req_qty qty, part_unit, zh_qty,");//2013-03-22 ming.li �ֶ�Ϊ�գ���ӡ�ո񣬶�����ӡ����
            sqlstr.Append(string.Format("xh_qty from jp_jjd_line where jjd_no ='{0}'", m_jjd_no));

            OleDbConnection conn = new OleDbConnection(DBHelper.OleConnectionString);
            OleDbCommand cmd = new OleDbCommand();
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);

            //DeliveryVoucher dvchr = (DeliveryVoucher)Session["delivery_voucher"];

            Jjd objJjd = new Jjd(m_jjd_no);

            //sqlstr.Append(" and requisition_id in (");
            //for (int i = 0; i < dvchr.DeliveryItems.Count; i++)
            //{
            //    if (i == dvchr.DeliveryItems.Count - 1)
            //    {
            //        sqlstr.Append(string.Format("'{0}'", dvchr.DeliveryItems[i].ToString()));
            //    }
            //    else
            //    {
            //        sqlstr.Append(string.Format("'{0}',", dvchr.DeliveryItems[i].ToString()));
            //    }
            //}
            //sqlstr.Append(" )");

            cmd.Connection = conn;
            cmd.CommandText = sqlstr.ToString();

            da.Fill(ds);

            rpt_doc.Load(Request.PhysicalApplicationPath+"\\UI\\Report\\CrysJj.rpt");
            rpt_doc.SetDataSource(ds.Tables[0]);
            //dvchr.SetDeliveryVoucherNo();
            rpt_doc.SetParameterValue("jjd_no", m_jjd_no);
            //rpt_doc.SetParameterValue("kuwei", "");
            rpt_doc.SetParameterValue("place", objJjd.PlaceName);
            rpt_doc.SetParameterValue("receiver", objJjd.ReceiptPerson);
            rpt_doc.SetParameterValue("recieve_date", objJjd.ReceiptDateStr);
            rpt_doc.SetParameterValue("receiver_contact", objJjd.ReceiptContract);
            rpt_doc.SetParameterValue("ZHd",objJjd.ZhPlace);
            rpt_doc.SetParameterValue("ZHr",objJjd.ZhPerson);
            rpt_doc.SetParameterValue("ZHdh",objJjd.ZhContract);
            rpt_doc.SetParameterValue("ZHArrTime",objJjd.ZhArrTime);
            rpt_doc.SetParameterValue("XQbm",objJjd.XQDept);
            rpt_doc.SetParameterValue("XQlxr",objJjd.XQPerson);
            rpt_doc.SetParameterValue("XQdh",objJjd.XQContract);
            rpt_doc.SetParameterValue("CYgs",objJjd.CyCompany);
            rpt_doc.SetParameterValue("CYr",objJjd.CyPerson);
            rpt_doc.SetParameterValue("CYdh",objJjd.CyContract);
            rpt_doc.SetParameterValue("CYpz",objJjd.CycCarNo);
            rpt_doc.SetParameterValue("CYjz", objJjd.CyDoc);

            rpt_doc.PrintOptions.PaperOrientation = PaperOrientation.Landscape;
            rpt_doc.PrintOptions.PaperSize = PaperSize.PaperA4;

            using (MemoryStream fp = (MemoryStream)(rpt_doc.ExportToStream(ExportFormatType.PortableDocFormat)))
            {
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(fp.ToArray());
                fp.Close();
                Response.End();
            }

            rpt_doc.Close();
            rpt_doc.Dispose();
        }
Exemplo n.º 57
0
		private void GenerateHTML()
		{
			ReportDocument rpt = new ReportDocument();

			switch (cboReportType.SelectedItem.Text)
			{
				case "Posted PO":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPO.rpt"));
					break;
				case "Posted PO Returns":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedPOReturns.rpt"));
					break;
				case "Posted Debit Memo":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PostedDebitMemo.rpt"));
					break;
				case "By Vendor":
                    rpt.Load(Server.MapPath(Constants.ROOT_DIRECTORY + "/Reports/PurchaseAnalysis.rpt"));
					break;
				default:
					return;
					
			}

			HTMLFormatOptions htmlOpts = new HTMLFormatOptions();
 
			ExportOptions exportop = new ExportOptions();
			DiskFileDestinationOptions dest = new DiskFileDestinationOptions();
			
			string strPath = Server.MapPath(@"\retailplus\temp\html\");

			string strFileName = cboReportType.SelectedItem.Text.Replace(" ", "").ToLower() + "_" + Session["UserName"].ToString() + "_" + DateTime.Now.ToString("yyyyMMddhhmmssff") + ".htm";
			if (System.IO.File.Exists(strPath + strFileName))
				System.IO.File.Delete(strPath + strFileName);

			htmlOpts.HTMLFileName = strFileName;
			htmlOpts.HTMLEnableSeparatedPages = true;;
			htmlOpts.HTMLHasPageNavigator = true;
			htmlOpts.HTMLBaseFolderName = strPath;
			rpt.ExportOptions.FormatOptions = htmlOpts;

			exportop = rpt.ExportOptions;

			exportop.ExportDestinationType = ExportDestinationType.DiskFile;
			exportop.ExportFormatType = ExportFormatType.HTML40;
			
			dest.DiskFileName = strFileName.ToString();
			exportop.DestinationOptions = dest;

			SetDataSource(rpt);

            Session["ReportDocument"] = rpt;

			rpt.Export();   rpt.Close();    rpt.Dispose();

			strFileName = "//" + Request.ServerVariables["SERVER_NAME"].ToString() + FindHTMLFile(strPath,strFileName);	
			
			fraViewer.Attributes.Add("src",strFileName);
		}
        //Exporta a Excel el grid
        protected void ExportEt(object sender, EventArgs e)
        {
            string parametro = cmbClasificacion.Value.ToString();

            //1. Configurar la conexión y el tipo de comando
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["OSEF"].ConnectionString);
            try
            {
                SqlCommand comando = new SqlCommand("web_spS_ObtenerReportesPorClasificacion", conn);
                SqlDataAdapter adaptador = new SqlDataAdapter(comando);
                DataTable dt = new DataTable();
                adaptador.SelectCommand.CommandType = CommandType.StoredProcedure;
                adaptador.SelectCommand.Parameters.Add(@"CLASIFICACION", SqlDbType.VarChar).Value = parametro;
                adaptador.Fill(dt);
                ReportDocument reporteCuadrila = new ReportDocument();
                reporteCuadrila.Load(Server.MapPath("reportess/rMantenimientosFacturador.rpt"));
                reporteCuadrila.SetDataSource(dt);
                reporteCuadrila.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.Excel, Response, true, "Reportes Mantenimiento " + parametro);
                reporteCuadrila.Close();
                reporteCuadrila.Dispose();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                    conn.Close();
                conn.Dispose();
            }
        }
Exemplo n.º 59
0
        public static void ShowReport(ReportDocument rptObject, DataSet dataSetName, string forMat)
        {
            int lintCtr = 0;
            try
            {

                if (dataSetName.Tables[0].Rows.Count > 0)
                {
                    rptObject.Database.Tables[0].SetDataSource(dataSetName);

                    ShowReportFromStream(rptObject, forMat);
                }
            }

            catch (Exception ex)
            {
                if (ex.Message.ToString() != "Thread was being aborted.")
                {

                    Console.Write(ex);
                }
            }
            finally
            {
                rptObject.Dispose();
                rptObject = null;
                dataSetName.Dispose();
                dataSetName = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
            }
        }
Exemplo n.º 60
0
        public static void ShowReportFromStream(ReportDocument rptObject, string forMat)
        {
            MemoryStream oStream = null;
            try
            {
                if (forMat == "PD")
                {
                    oStream = (MemoryStream)
                    rptObject.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Buffer = true;
                    HttpContext.Current.Response.ContentType = "application/pdf";
                }
                else
                {
                    //oStream = (MemoryStream)
                    //rptObject.ExportToStream(CrystalDecisions.Shared.ExportFormatType.WordForWindows);
                    //HttpContext.Current.Response.Clear();
                    //HttpContext.Current.Response.Buffer = true;
                    //HttpContext.Current.Response.ContentType = "application/msword";
                    HttpContext.Current.Response.Write("Please Select PDF Format.You Cannot Download this format...");
                }
                HttpContext.Current.Response.BinaryWrite(oStream.ToArray());
                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.Close();
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            finally
            {

                oStream.Flush();
                oStream.Close();
                oStream = null;
                rptObject.Dispose();
                rptObject = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();

            }
        }