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();
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable _dtCabeceraOper = null;
                DataTable _dtDetalleOper = null;
                _dtCabeceraOper = (DataTable)Session["dtCabeceraOperacion"];
                _dtDetalleOper = CopiarDT(g_dtDetOperacion);
                _dtDetalleOper = CambiarMonedaDetOperacion(_dtDetalleOper);

                if (_dtDetalleOper != null && _dtCabeceraOper != null)
                {
                    if (_dtDetalleOper.Rows.Count != 0)
                    {
                        ReportDocument rpt = new ReportDocument();
                        rpt.Load(Server.MapPath("rpt/crFactura.rpt"));
                        rpt.FileName = Server.MapPath("rpt/crFactura.rpt");
                        rpt.SetDataSource(_dtCabeceraOper);
                        rpt.Subreports[0].SetDataSource(_dtDetalleOper);

                        CrystalReportViewer1.ReportSource = rpt;
                        CrystalReportViewer1.ReuseParameterValuesOnRefresh = true;

                        // bloque de código donde exportamos el reporte a pdf directamente
                        using (var mStream = (MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat))
                        {
                            Response.Clear();
                            Response.Buffer = true;
                            Response.ContentType = "application/pdf";
                            Response.BinaryWrite(mStream.ToArray());
                        }
                        Response.End();
                    }
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void CriaPDF()
        {
            Hashtable hash = (Hashtable)Session["HashSolicitacoes"];

            DSCabecalhoSolicitacaoAmbulatorial cabecalho = new DSCabecalhoSolicitacaoAmbulatorial();
            cabecalho.Tables.Add((DataTable)hash["cabecalho"]);

            DSRelatorioSolicitacaoAmbulatorial conteudo = new DSRelatorioSolicitacaoAmbulatorial();
            conteudo.Tables.Add((DataTable)hash["corpo"]);

            Session.Remove("HashSolicitacoes");
            ReportDocument repDoc = new ReportDocument();
            repDoc.Load(Server.MapPath("RelatoriosCrystal/CrystalReportViewer_SolicitacaoAmbulatorial.rpt"));
            repDoc.SetDataSource(conteudo.Tables[1]);
            repDoc.Subreports["CrystalReportViewer_CabecalhoSolicitacaoAmbulatorial.rpt"].SetDataSource(cabecalho.Tables[1]);

            System.IO.Stream s = repDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("content-disposition", "attachment; filename=RelatorioSolicitacaoAmbulatorial.pdf");
            Response.AddHeader("content-length", ((System.IO.MemoryStream)s).ToArray().Length.ToString());
            Response.BinaryWrite(((System.IO.MemoryStream)s).ToArray());
            Response.End();
            //Response.Flush();
            //Response.Close();
        }
    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.º 5
0
 private void DivSchedule()
 {
     string strExportFile = null;
     strExportFile = Session["Report"].ToString();
     ReportDocument crReportDocument = default(ReportDocument);
     crReportDocument = new ReportDocument();
     crReportDocument.Load(Server.MapPath(Session["Report"].ToString()));
     CSBC.Components.Season.ClsSchedules oData = new CSBC.Components.Season.ClsSchedules();
     //Pass the populated dataset to the report
     crReportDocument.SetDataSource(oData.GetGames(1, 1, Convert.ToInt32(Session["ScheduleNo"]),
         Convert.ToInt32(Session["TeamNbr"]), Session["ScheduleDesc"].ToString(), Session["TeamName"].ToString()));
     crReportDocument.SetParameterValue("SeasonDesc", Session["SeasonDesc"]);
     crReportDocument.SetParameterValue("CompanyName", Session["CompanyName"]);
     crReportDocument.SetParameterValue("TeamName", Session["TeamName"]);
     crReportDocument.SetParameterValue("Division", Session["ScheduleDesc"]);
     System.IO.MemoryStream s =
         (MemoryStream) crReportDocument.ExportToStream(ExportFormatType.PortableDocFormat);
     var _with1 = HttpContext.Current.Response;
     _with1.ClearContent();
     _with1.ClearHeaders();
     _with1.ContentType = "application/pdf";
     _with1.AddHeader("Content-Disposition", "inline; filename=" + strExportFile);
     _with1.BinaryWrite(s.ToArray());
     _with1.End();
     //CrystalReportViewer1.ReportSource = crReportDocument
     crReportDocument = null;
     oData = null;
 }
        public ActionResult ExportReport()
        {
            List<Investment> allInvestment = new List<Investment>();

            using (efarmingEntities dc = new efarmingEntities())
            {
                allInvestment = dc.Investments.ToList();
            }

            ReportDocument rd = new ReportDocument();
            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "rpt_InvestmentList.rpt"));
            rd.SetDataSource(allInvestment);

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

            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return File(stream, "application/pdf", "InvestmentList.pdf");
            }
            catch (Exception)
            {

                throw;
            }
        }
 private void bindReport()
 {
     if (Convert.ToString(Session[Global.SESSION_KEY_CULTURE]) == "ar-AE")
     {
         dt = RL.PrintMaterListEnglish();
     }
     else
     {
         dt = RL.PrintMaterListEnglish();
     }
     if (dt.Rows.Count > 0)
     {
         ReportDocument report = new ReportDocument();
         report.Load(Server.MapPath("..//..//Reports//PrintAllMatter.rpt"));
         report.SetDataSource(dt);
         // report.Refresh();
         //CrystalReportViewer1.ReportSource = report;
         MemoryStream oStream = new MemoryStream(); // using System.IO
         oStream = (MemoryStream)report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
         Response.Clear(); Response.Buffer = true;
         Response.ContentType = "application/pdf";
         Response.BinaryWrite(oStream.ToArray());
         Response.End();
     }
 }
 /// <summary>
 /// Erzeugt aus einer CrystalReportsDatei oder einem PDF einen PDF Stream und sendet ihn an den Client
 /// </summary>
 /// <param name="pin_ReportVorlage">Pfad der Vorlage</param>
 /// <param name="pin_ReportAuswahl">reportspezifische Daten</param>
 /// <returns>Stream der ein PDF enthält</returns>
 public Stream ErzeugeReport(string pin_ReportVorlage, string pin_ReportAuswahl)
 {
     if (pin_ReportVorlage.Substring(pin_ReportVorlage.LastIndexOf(".") + 1) == "pdf")
     {
         // Umwandeln des PDF Vordrucks in einen Stream
         FileStream Report = new FileStream(Directory.GetCurrentDirectory() + pin_ReportVorlage, System.IO.FileMode.Open, System.IO.FileAccess.Read);
         byte[] Buffer = new byte[(int)Report.Length];
         Report.Read(Buffer, 0, (int)Report.Length);
         Report.Close();
         // Versenden der Daten als MemoryStream
         System.Windows.Forms.MessageBox.Show("Schicke Raus !!");
         return new MemoryStream(Buffer, 0, Buffer.Length);
     }
     else
     {
         // Erstellen eines Reports
         ReportDocument Report = new ReportDocument();
         // Lade Reportvorlage
         Report.Load(Directory.GetCurrentDirectory() + pin_ReportVorlage);
         // Besondere SELECT Anfrage auf den Datensatz anwenden
         if (pin_ReportAuswahl != String.Empty)
             Report.DataDefinition.RecordSelectionFormula = pin_ReportAuswahl;
         // muss als Stream übertragen werden, da ReportDocuments nicht Serializable sind
         return Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
     }
 }
        private void CriaPDF()
        {
            Hashtable hashtable = (Hashtable)Session["HashAgendaMontadaPublicada"];

            DSCabecalhoAgendaMontadaPublicada cabecalho = new DSCabecalhoAgendaMontadaPublicada();
            cabecalho.Tables.Add((DataTable)hashtable["cabecalho"]);

            DSRelatorioAgendaMontadaPublicada dados = new DSRelatorioAgendaMontadaPublicada();
            dados.Tables.Add((DataTable)hashtable["dados"]);

            ReportDocument repDoc = new ReportDocument();

            repDoc.Load(Server.MapPath("RelatoriosCrystal/CrystalReportViewer_AgendaMontadaPublicada.rpt"));
            repDoc.SetDataSource(dados.Tables[1]);
            repDoc.Subreports["CrystalReportViewer_CabecalhoAgendaMontadaPublicada.rpt"].SetDataSource(cabecalho.Tables[1]);

            System.IO.Stream s = repDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "applicattion/octect-stream";
            Response.AddHeader("Content-Disposition", "attachment;filename=RelatorioDeAgendasMontadasPublicadas.pdf");
            Response.AddHeader("Content-Length", s.Length.ToString());
            Response.BinaryWrite(((System.IO.MemoryStream)s).ToArray());
            Response.End();

            Session.Remove("HashAgendaMontadaPublicada");
        }
Exemplo n.º 10
0
        protected void CriaPDF()
        {
            Hashtable hash = (Hashtable)Session["HashVagasDisponivel"];

            //CrystalReportViewer_AgendaPrestador.DisplayToolbar = true;
            //CrystalReportViewer_AgendaPrestador.EnableDatabaseLogonPrompt = false;

            DSRelatorioVagasDisponivel conteudo = new DSRelatorioVagasDisponivel();
            conteudo.Tables.Add((DataTable)hash["corpo"]);

            ReportDocument repDoc = new ReportDocument();
            repDoc.Load(Server.MapPath("RelatoriosCrystal/CrystalReportViewer_VagasDisponivel.rpt"));
            repDoc.SetDataSource(conteudo.Tables[1]);

            //repDoc.Database.Tables["CabecalhoAgendaPrestador"].SetDataSource((DataTable)hash["cabecalho"]);
            //repDoc.Database.Tables["RelatorioAgendaPrestador"].SetDataSource((DataTable)hash["corpo"]);

            System.IO.Stream s = repDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "applicattion/octect-stream";
            Response.AddHeader("Content-Disposition", "attachment;filename=RelatorioVagasDisponivel.pdf");
            Response.AddHeader("Content-Length", s.Length.ToString());
            Response.BinaryWrite(((System.IO.MemoryStream)s).ToArray());
            Response.End();
        }
Exemplo n.º 11
0
        public virtual System.IO.Stream GetStreamReporte(ExportFormatType Formato)
        {
            ReportDocument reportDocument = new ReportDocument();
            string path = Path.Combine(Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory), "Reportes\\"), ClaseReporte.ResourceName);
            reportDocument.Load(path);
            reportDocument.SetDataSource(GetDatosReporte());

            return reportDocument.ExportToStream(Formato);
        }
Exemplo n.º 12
0
 /// <summary>
 /// Diese Funktion lädt alle Systemereignisse.
 /// <returns name="pout_Systemereignisse">Menge aller Systemereignisse die bisher geworfen wurde.</returns>
 /// </summary>
 public System.IO.Stream ErzeugeEtb()
 {
     // Erstellen eines Reports
     ReportDocument pout_Report = new ReportDocument();
     // Lade Reportvorlage
     pout_Report.Load(System.IO.Directory.GetCurrentDirectory() + @"\ReportVorlagen\ETB.rpt");
     Console.WriteLine(System.IO.Directory.GetCurrentDirectory());
     // muss als Stream übertragen werden, da ReportDocuments nicht Serializable sind
     return pout_Report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
 }
    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();
    }
        //Relatório de LISTA DE DESPESAS .PDF (Crystal Report) - Funcionando mas vem sem parâmetors ainda 24/11/2015.
        public ActionResult GenerateReport()
        {
            ReportDocument rd = new ReportDocument(); //(Crystal Report)
           
            rd.Load(Path.Combine(Server.MapPath("../Reports/CrystalReportDespesas.rpt")));
            ViewBag.ListDespesas = db.DespesasEmps.ToList();

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            Stream stream = rd.ExportToStream
               (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            stream.Seek(0, SeekOrigin.Begin);
            return File(stream, "application/pdf", "ListaDespesas.pdf");

        }
Exemplo n.º 15
0
        // Revenue - Expense - TaxExpense - Divident = NetEarnings
        public ActionResult ReportIncomeStatement(int period, int yearPeriod)
        {
            var     company = _companyService.GetQueryable().FirstOrDefault();
            Closing closing = _closingService.GetObjectByPeriodAndYear(period, yearPeriod);

            if (closing == null)
            {
                return(Content(Constant.ErrorPage.ClosingNotFound));
            }

            ValidComb Revenue = _validCombService.FindOrCreateObjectByAccountAndClosing(_accountService.GetObjectByLegacyCode(Constant.AccountLegacyCode.Revenue).Id, closing.Id);
            ValidComb COGS    = _validCombService.FindOrCreateObjectByAccountAndClosing(_accountService.GetObjectByLegacyCode(Constant.AccountLegacyCode.COGS).Id, closing.Id);
            // TODO
            decimal OperationalExpensesAmount = 0, InterestEarningAmount = 0, DepreciationAmount = 0, AmortizationAmount = 0, TaxAmount = 0, DividentAmount = 0;

            ModelIncomeStatement model = new ModelIncomeStatement()
            {
                CompanyName         = company.Name,
                BeginningDate       = closing.BeginningPeriod.Date,
                EndDate             = closing.EndDatePeriod.Date,
                Revenue             = Revenue.Amount,
                COGS                = COGS.Amount,
                OperationalExpenses = OperationalExpensesAmount,
                InterestEarning     = InterestEarningAmount,
                Depreciation        = DepreciationAmount,
                Amortization        = AmortizationAmount,
                Tax      = TaxAmount,
                Divident = DividentAmount
            };

            List <ModelIncomeStatement> list = new List <ModelIncomeStatement>();

            list.Add(model);

            var rd = new ReportDocument();

            //Loading Report
            rd.Load(Server.MapPath("~/") + "Reports/Finance/IncomeStatement.rpt");

            // Setting report data source
            rd.SetDataSource(list);

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

            return(File(stream, "application/pdf"));
        }
Exemplo n.º 16
0
        public ActionResult printreceipt(int?id)
        {
            if (Session["empName"] != null)
            {
                string name = Session["empName"].ToString();

                var emp2      = _db.Employee.Where(d => d.employeeName == name).FirstOrDefault();
                var _allowAll = _db.HowCanAcess.Where(s => s.employeeID == emp2.id).FirstOrDefault();

                ReportDocument rd     = new ReportDocument();
                var            infoes = _db.Info.FirstOrDefault();

                rd.Load(Path.Combine(Server.MapPath("~/Report/test2.rpt")));
                var emp = _db.Employee.Where(f => f.id == id).FirstOrDefault();
                rd.SetDataSource(_db.feeses.Where(f => f.NumberOfCase == id).Select(p => new
                {
                    id = p.ID,
                    // Employee = _db.Employee.Where(f => f.id.ToString() == p.Employee).Select(f => f.employeeName).FirstOrDefault(),

                    NumberOfCase = p.NumberOfCase,

                    DateofRevice = p.DateofRevice,
                    clientID_ID  = p.clientID,
                    recived      = p.recived,
                    notes        = p.notes,
                    EmployeeName = p.EmployeeName,

                    money = _db.Cases.Where(f => f.id == p.NumberOfCase).Select(f => f.money).FirstOrDefault(),


                    //info data
                    img         = infoes.Img.Replace(@"~\", ""),
                    description = infoes.description,
                    Number      = infoes.Number,
                    PlaceName   = infoes.PlaceName,
                }).ToList());

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "aaplication/pdf", "اتعاب القضيه.pdf"));
            }
            return(RedirectToAction("HavntAccess", "Employees"));
        }
Exemplo n.º 17
0
        public FileResult ViewPDF(int?id)
        {
            Stream         stream         = null;
            var            nombreArchivo  = "";
            ReportDocument reportDocument = new ReportDocument();

            byte[] pdfByte = null;
            try
            {
                EPRTA_MOVIMIENTO                  solicitud    = unitOfWork.MovimientoRepository.GetById(id);
                EntitiesProveduria                db           = new EntitiesProveduria();
                SqlConnectionStringBuilder        builderVenta = new SqlConnectionStringBuilder(db.Database.Connection.ConnectionString);
                SP_REQUISICION_BODEGATableAdapter tableAdapter = new SP_REQUISICION_BODEGATableAdapter();
                object    objetos    = new object();
                DataTable dataTable  = tableAdapter.GetData(id, out objetos);
                String    pathReport = Path.Combine(HttpRuntime.AppDomainAppPath, "Reports\\Cr_Requisicion_Bodega.rpt");

                reportDocument.Load(pathReport);
                reportDocument.SetDataSource(dataTable);


                reportDocument.SetDatabaseLogon(builderVenta.UserID, builderVenta.Password);

                stream        = reportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                pdfByte       = ReadFully(stream);
                nombreArchivo = "REQUISICION DE BODEGA ";
                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));
        }
        public CrystalReportResult(string reportPath, object dataSet,List<ReportParameter> paramList,string type="pdf")
        {
            ReportDocument reportDocument = new ReportDocument();
            reportDocument.Load(reportPath);

            reportDocument.SetDataSource(dataSet);
            foreach (var item in paramList)
            {
                reportDocument.SetParameterValue(item.Name, item.Value);
            }

            #region extra
            //ParameterValues currentParameterValues = new ParameterValues();
            //ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
            //ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
            //ParameterFieldDefinition parameterFieldDefinition;

            //foreach (var param in paramList)
            //{
            //    if (param.Value != null)
            //    {
            //        if (param.IsInteger)
            //            var value = Int64.Parse(param.Value);
            //        else if (param.IsDateTime)
            //            parameterDiscreteValue.Value = DateTime.Parse(param.Value);
            //        else if (param.IsBoolean)
            //            parameterDiscreteValue.Value = bool.Parse(param.Value);
            //        else
            //            parameterDiscreteValue.Value = param.Value;
            //    }
            //    else
            //    {
            //        parameterDiscreteValue.Value = DBNull.Value;
            //    }

            //    currentParameterValues.Add(parameterDiscreteValue);

            //    parameterFieldDefinition = parameterFieldDefinitions[param.Name];
            //    parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);

            //}
            #endregion

            _contentBytes = StreamToBytes(reportDocument.ExportToStream(GetFormatType(type)));
        }
Exemplo n.º 19
0
        public ActionResult Export()
        {
            var query = entities.statements.Select(s => s.Acnumber).FirstOrDefault();


            string         pwd = GeneratePassword(query);
            ReportDocument rd  = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/CrystalReport2.rpt")));
            rd.SetDataSource(entities.statements.Select(s => new
            {
                Id = s.Id,
                TransactionDate = s.TransactionDate,
                CustomerName    = s.CustomerName,
                CardNumber      = s.CardNumber,
                imagePath       = s.imagePath,



                PostedDate = s.PostedDate,
                DescriptionOfTransactions = s.DescriptionOfTransactions,
                TransactionsAmount        = s.TransactionsAmount,
                BilledAmount = s.BilledAmount,
                DRCR         = s.DRCR,
            }).ToList());
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            // stream.Seek(0, SeekOrigin.Begin);

            Stream t_Output;

            using (Stream t_Input = stream)
                //using (Stream t_Output = new FileStream(Server.MapPath(".") + "\\test_encrypted.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
                using (t_Output = new FileStream("C:\\img\\" + "test_encrypted.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    iTextSharp.text.pdf.PdfReader t_Reader = new iTextSharp.text.pdf.PdfReader(t_Input);
                    iTextSharp.text.pdf.PdfEncryptor.Encrypt(t_Reader, t_Output, true, pwd, pwd, iTextSharp.text.pdf.PdfWriter.ALLOW_PRINTING);
                }

            //return File("C:\\img\\" + "test_encrypted.pdf", "application/pdf", "ListStatement.pdf");

            return(View());
        }
Exemplo n.º 20
0
        public ActionResult PrintExpenses()
        {
            if (Session["empName"] != null)
            {
                string name = Session["empName"].ToString();

                var emp2      = _db.Employee.Where(d => d.employeeName == name).FirstOrDefault();
                var _allowAll = _db.HowCanAcess.Where(s => s.employeeID == emp2.id).FirstOrDefault();

                if (_allowAll.Staticis == true)
                {
                    ReportDocument rd = new ReportDocument();

                    rd.Load(Path.Combine(Server.MapPath("~/Report/expensesReport.rpt")));
                    var infoes = _db.Info.FirstOrDefault();



                    rd.SetDataSource(_db.Expenses.Select(p => new
                    {
                        id           = p.id,
                        Expensestype = _db.Expensestypes.Where(f => f.id.ToString() == p.Expensestype).Select(f => f.catogery).FirstOrDefault(),
                        office       = _db.Offices.Where(f => f.Id.ToString() == p.office).Select(f => f.OfficeName).FirstOrDefault(),
                        date         = p.date,
                        values       = p.values,
                        Comment      = p.Comment,


                        //info data
                        img         = infoes.Img.Replace(@"~\", ""),
                        description = infoes.description,
                        Number      = infoes.Number,
                        PlaceName   = infoes.PlaceName,
                    }).ToList());

                    Response.Buffer = false;
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    stream.Seek(0, SeekOrigin.Begin);
                    return(File(stream, "aaplication/pdf", "سجل المصروفات.pdf"));
                }
            }
            return(RedirectToAction("HavntAccess", "Employees"));
        }
Exemplo n.º 21
0
        public ActionResult Info()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/"), "Information.rpt"));
            var Info = (from d in db.Departments
                        join e in db.Employees on d.DepartmentId equals e.DepartmentId
                        select new { e.EmployeeName, d.DepartmentName, e.JoinDate, e.Grade }).ToList();

            rd.SetDataSource(Info);
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "Info.pdf"));
        }
Exemplo n.º 22
0
        public ActionResult IndexPDF()
        {
            var            allclients = db.Clients.ToList();
            ReportDocument rd         = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "Client Index.rpt"));

            rd.SetDataSource(allclients);
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "Client Index.pdf"));
        }
Exemplo n.º 23
0
        //Report generation

        public ActionResult ExportAttendanceListing()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Report/Attendance/Attendance.rpt")));
            rd.SetDataSource(inventorymgtEntities.attendance_emp.ToList());

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

            Stream str = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            str.Seek(0, SeekOrigin.Begin);
            String savedFileName = string.Format("AttendanceListing_{0}", DateTime.Now);

            return(File(str, "application/pdf", savedFileName));
        }
Exemplo n.º 24
0
        public ActionResult ExportOrderListing()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/OrderListingReport.rpt")));
            rd.SetDataSource(db.Orders.ToList());

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

            Stream str = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            str.Seek(0, SeekOrigin.Begin);
            string savedFilename = string.Format("OrderListing_{0}", DateTime.Now + ".pdf");

            return(File(str, "application/pdf", savedFilename));
        }
Exemplo n.º 25
0
        //REPORTE CON YASUO MANCO TROLL AFK CON LA LIBRERIA CRYSTAL REPORT PARA VISUAL STUDIO
        public ActionResult ExportacionLista()
        {
            ReportDocument reporteNormal = new ReportDocument();

            reporteNormal.Load(Path.Combine(Server.MapPath("~/MisReportes/OrdenLista.rpt")));
            reporteNormal.SetDataSource(db.Orden.ToList());

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

            Stream ReportTodos = reporteNormal.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            ReportTodos.Seek(0, SeekOrigin.Begin);
            string guardararchivo = string.Format("OrdenLista_{0}", DateTime.Now);

            return(File(ReportTodos, "appication/pdf", guardararchivo));
        }
Exemplo n.º 26
0
        public ActionResult ReporteTareas()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reportes/Viewers/"), "TareasReport.rpt"));

            rd.SetDataSource(ObjTarea.TareasReporte());

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


            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "TareasReporte.pdf"));
        }
Exemplo n.º 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt = BUS.SqlDataAccessHelper.ExecuteQuery("spReportDoanhThu");

            ReportDocument rptDoc = new ReportDocument();
            // load report
            rptDoc.Load(Server.MapPath("ReportDoanhThu.rpt"));
            // fill data
            rptDoc.SetDataSource(dt);

            MemoryStream oStream = (MemoryStream)rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(oStream.ToArray());
            Response.End();
        }
        public ActionResult AllReport()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Report/"), "CrystalReportTeacher.rpt"));

            rd.SetDataSource(db.tblTeachers.ToList());

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


            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "Teacher.pdf"));
        }
Exemplo n.º 29
0
    protected void btnPrint_Click(object sender, EventArgs e)
    {
        System.IO.MemoryStream stream1 = new System.IO.MemoryStream();
        string Path = "";

        if (RbtStatistics.Checked == true)
        {
            Path = Server.MapPath("~/Report/Followuptobedone-satistics.rpt");
        }
        else
        {
            Path = Server.MapPath("~/Report/Followuptobedone_Detail.rpt");
        }

        myReportDocument.Load(Path);
        myReportDocument.SetParameterValue("@flag", ChkDate.Checked == true ? 1 : 0);
        myReportDocument.SetParameterValue("@fromdate", ChkDate.Checked == false ? DateTime.Now :Report(txtFromDate.Text));
        myReportDocument.SetParameterValue("@todate", ChkDate.Checked == false ? DateTime.Now : Report(txtToDate.Text));
        myReportDocument.SetParameterValue("@groupcode", ddlCountry.SelectedValue);
        myReportDocument.SetParameterValue("@empid", ddlemp.SelectedValue);
        myReportDocument.SetParameterValue("@callerstatus", ddlStudentStatus.SelectedValue);
        //myReportDocument.SetParameterValue("@SemID", drpSemester.SelectedValue);
        myReportDocument.SetDatabaseLogon("software", "DelFirMENA$idea");
        CrystalReportViewer1.ReportSource = myReportDocument;
        CrystalReportViewer1.DataBind();
        CrystalReportViewer1.HasExportButton          = true;
        CrystalReportViewer1.HasPrintButton           = true;
        CrystalReportViewer1.HasSearchButton          = true;
        CrystalReportViewer1.HasToggleGroupTreeButton = false;

        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();
    }
Exemplo n.º 30
0
        public ActionResult Report(RequestIssue requestıssue, FormCollection formcollection)
        {
            ReportDocument rptH = new ReportDocument();

            rptH.FileName = Server.MapPath("~/RDLC/SurveyReport.rpt");

            rptH.Refresh();
            //rptH.Load();

            var value = new ParameterDiscreteValue();

            var requests_ = db.RequestIssues.AsNoTracking().Include(p => p.Locations).Include(p => p.Personnels).Include(p => p.CorporateAccounts);

            int x_index = 0;

            foreach (int req_ in requests_.Select(i => i.RequestIssueID).ToList())
            {
                value.Value = req_;

                rptH.ParameterFields["RequestIDs"].CurrentValues.Add(value);
                x_index++;
            }

            if (x_index == 0)
            {
                return(RedirectToAction("Index", new { custommerr = "Belirttiğiniz Kriterlere Uygun Kayıt(lar) Bulunamadı" }));
            }

            // rptH.SetDataSource([datatable]);
            var cd = new System.Net.Mime.ContentDisposition
            {
                // for example foo.bak
                FileName = "rapor_klimasanHelpDeskAnketler.pdf",

                // always prompt the user for downloading, set to true if you want
                // the browser to try to show the file inline
                Inline = false,
            };

            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            Response.AppendHeader("Content-Disposition", cd.ToString());
            return(File(stream, "application/pdf"));
        }
Exemplo n.º 31
0
        public ActionResult GenerateReport(DateTime FromDate, DateTime ToDate)

        {
            var fromDate = FromDate;
            var toDate   = ToDate;

            var AllApplicants    = new HumanResource.Reports.ApplicantsList.ApplicantDataSet();
            var lstAllApplicants = db.HRApplicants.Where(p => p.DateAdded >= fromDate && p.DateAdded <= toDate)
                                   .ToList();

            foreach (var pat in lstAllApplicants)
            {
                var app = db.HRFileInformations.FirstOrDefault(p => p.ApplicantId != null);
                AllApplicants.Applicant.AddApplicantRow(pat.ApplicantId,
                                                        pat.FirstName + "" + pat.Surname,
                                                        app.DateOfApplication.ToString(),
                                                        pat.Mobile,
                                                        pat.Email,
                                                        pat.NationalId,
                                                        app.PositionAppliedFor
                                                        );
            }

            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Areas/HumanResource/Reports/ApplicantsList/ApplicantReport.rpt")));


            rd.SetDataSource(AllApplicants);
            rd.Subreports["RptReportHeader.rpt"].SetDataSource(CrystalReports.HeaderAndFooterForReports.GetAllReportHeader());
            rd.SetParameterValue("fromDate", FromDate);
            rd.SetParameterValue("toDate", ToDate);

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

            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            string fileName = "Applicants List" + DateTime.Today + ".pdf";

            return(File(stream, "application/pdf", fileName));
        }
Exemplo n.º 32
0
        public ActionResult PrintReport(int id)
        {
            if (Session["empName"] != null)
            {
                string name = Session["empName"].ToString();

                var emp2      = _db.Employee.Where(d => d.employeeName == name).FirstOrDefault();
                var _allowAll = _db.HowCanAcess.Where(s => s.employeeID == emp2.id).FirstOrDefault();
                if (_allowAll.Staticis == true)
                {
                    ReportDocument rd     = new ReportDocument();
                    var            infoes = _db.Info.FirstOrDefault();

                    rd.Load(Path.Combine(Server.MapPath("~/Report/CrystalReport1.rpt")));
                    var emp = _db.Employee.Where(f => f.id == id).FirstOrDefault();
                    rd.SetDataSource(_db.Salaries.Where(f => f.Employee == id.ToString()).Select(p => new
                    {
                        id          = p.id,
                        Employee    = _db.Employee.Where(f => f.id.ToString() == p.Employee).Select(f => f.employeeName).FirstOrDefault(),
                        empSupplyer = p.empSupplyer,
                        salary      = p.salary,
                        month       = _db.Month.Where(f => f.id.ToString() == p.month).Select(f => f.months).FirstOrDefault(),
                        OfficeName  = _db.Offices.Where(f => f.Id.ToString() == emp.OfficeName).Select(f => f.OfficeName).FirstOrDefault(),
                        Date        = p.Date,
                        jobs        = _db.Jobs.Where(f => f.id.ToString() == emp.jobs).Select(f => f.jobs),

                        //info data
                        img       = infoes.Img.Replace(@"~\", ""),
                        Expr3     = infoes.description,
                        Number    = infoes.Number,
                        PlaceName = infoes.PlaceName,
                    }).ToList());


                    Response.Buffer = false;
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    stream.Seek(0, SeekOrigin.Begin);
                    return(File(stream, "aaplication/pdf", "حسابات الموظفين.pdf"));
                }
            }
            return(RedirectToAction("HavntAccess", "Employees"));
        }
        public HttpResponseMessage ExportReport(Users user)
        {
            string       EmailTosend = WebUtility.UrlDecode(user.Email);
            List <Users> model       = new List <Users>();
            var          data        = cX.tbl_Registration;
            var          rd          = new ReportDocument();

            foreach (var details in data)
            {
                Users obj = new Users();
                obj.Email     = details.Email;
                obj.FirstName = details.FirstName;
                obj.LastName  = details.LastName;
                model.Add(obj);
            }

            rd.Load(Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/Reports"), "UserRegistration.rpt"));

            rd.SetDataSource(model);

            using (var stream = rd.ExportToStream(ExportFormatType.PortableDocFormat))
            {
                SmtpClient smtp = new SmtpClient
                {
                    Port = 587,
                    UseDefaultCredentials = true,
                    Host           = "smtp.gmail.com",
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    EnableSsl      = true
                };
                smtp.UseDefaultCredentials = false;
                // to use google smtp to send out the report, update the credential below
                smtp.Credentials = new NetworkCredential("*****@*****.**", "password");
                var message = new System.Net.Mail.MailMessage("*****@*****.**", EmailTosend, "User Registration Details", "Hi Please check your Mail  and find the attachement.");
                message.Attachments.Add(new Attachment(stream, "UsersRegistration.pdf"));

                smtp.Send(message);
            }

            var Message = string.Format("Report Created and sended to your Mail.");
            HttpResponseMessage response1 = Request.CreateResponse(HttpStatusCode.OK, Message);

            return(response1);
        }
Exemplo n.º 34
0
        // GET: InBaoCaoHS
        public ActionResult InDanhSachHSTheoLop(string malop, string manamhoc)
        {
            string a  = Session["malopin"].ToString();
            string b  = Session["manamin"].ToString();
            var    pl = db.Tbl_PhanLop.Where(x => x.maNamHoc == b && x.maLop == a).ToList();

            foreach (var item in pl)
            {
                Tbl_InDanhSachHS inpc = new Tbl_InDanhSachHS();
                inpc.idPhanLop = item.idPhanLop;
                inpc.maLop     = item.maLop;
                inpc.hoTenHS   = item.Tbl_HocSinh.hoTen;
                inpc.maNamHoc  = item.maNamHoc;
                inpc.tenLop    = item.Tbl_LopHoc.tenLop;
                inpc.tenNamHoc = item.Tbl_NamHoc.tenNamHoc;
                inpc.ngaySinh  = Convert.ToDateTime(item.Tbl_HocSinh.ngaySinh);
                inpc.soDTNha   = item.Tbl_HocSinh.soDTNha;
                inpc.diaChi    = item.Tbl_HocSinh.diaChi;
                inpc.gioiTinh  = item.Tbl_HocSinh.gioiTinh;
                db.Tbl_InDanhSachHS.Add(inpc);
                db.SaveChanges();
            }

            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/InDanhSachHS.rpt")));
            rd.Refresh();

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);

            foreach (var item in pl)
            {
                var dss = db.Tbl_InDanhSachHS.ToList().Where(x => x.maLop == a && x.maNamHoc == b).FirstOrDefault();
                db.Tbl_InDanhSachHS.Remove(dss);
                db.SaveChanges();
            }

            return(File(stream, "application/pdf", "InDanhSachHS.pdf"));
        }
        private void GetReportDocument(ReportDocument pReportClientDocument, ReportBase objReportBase)
        {
            LSReportCrystal _LSReportCrystal = new LSReportCrystal();

            _LSReportCrystal.reportBase = objReportBase;
            pReportClientDocument       = _LSReportCrystal.GenerateReport();

            foreach (Section oSection in pReportClientDocument.ReportDefinition.Sections)
            {
                foreach (ReportObject obj in oSection.ReportObjects)
                {
                    FieldObject field;
                    field = pReportClientDocument.ReportDefinition.ReportObjects[obj.Name] as FieldObject;

                    if (field != null)
                    {
                        Font oFon1 = new Font("Arial Narrow", field.Font.Size - 1F);
                        Font oFon2 = new Font("Arial", field.Font.Size - 1F);

                        if (oFon1 != null)
                        {
                            field.ApplyFont(oFon1);
                        }
                        else if (oFon2 != null)
                        {
                            field.ApplyFont(oFon2);
                        }
                    }
                }
            }

            Stream oStream = null;

            byte[] byteArray = null;
            oStream   = pReportClientDocument.ExportToStream(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();
        }
Exemplo n.º 36
0
        public ActionResult GenerateEmployeesHistoryReport(DateTime FromDate, DateTime ToDate)

        {
            var fromDate = FromDate;
            var toDate   = ToDate;

            var Employee            = new HumanResource.Reports.EmployeeHistory.DatasetEmployee();
            var lstEmployeesHistory = db.HRStaffWorkExperiences.Where(p => p.DateAdded >= fromDate && p.DateAdded <= toDate)
                                      .ToList();

            foreach (var emp in lstEmployeesHistory)
            {
                var his = db.HRFileDetails.FirstOrDefault(p => p.StaffId != null);
                Employee.Employee.AddEmployeeRow(emp.StaffId,
                                                 his.FirstName + "" + his.OtherNames,
                                                 emp.Employer,
                                                 emp.BeginDate.ToString(),
                                                 emp.EndDate.ToString(),
                                                 emp.Position,
                                                 emp.Salary.ToString(),
                                                 his.InterviewDate.ToString(),
                                                 his.HireDate.ToString(),
                                                 his.Designation,
                                                 his.JobGroup,
                                                 his.JobGrade);
            }
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Areas/HumanResource/Reports/EmployeeHistory/EmployeeReport.rpt")));

            rd.SetDataSource(Employee);
            rd.Subreports["RptReportHeader.rpt"].SetDataSource(CrystalReports.HeaderAndFooterForReports.GetAllReportHeader());

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

            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            string fileName = "Applicants List" + DateTime.Today + ".pdf";

            return(File(stream, "application/pdf", fileName));
        }
    protected void BtnLoad_Click(object sender, EventArgs e)
    {
        string Path = "";

        if (RbtStudent.Checked == true)
        {
            Path = Server.MapPath("ENROLLMENTFORM.rpt");
            Path = Path.Substring(0, Path.LastIndexOf('\\'));
            Path = Path.Substring(0, Path.LastIndexOf('\\'));
            Path = Path + "\\Reports\\ENROLLMENTFORM.rpt";
            myReportDocument.Load(Path);
            myReportDocument.SetParameterValue("@LinkId", txtStudentId.Text);
            myReportDocument.SetDatabaseLogon("software", "DelFirMENA$idea");
        }
        else
        {
            Path = Server.MapPath("EmployeeProfile.rpt");
            Path = Path.Substring(0, Path.LastIndexOf('\\'));
            Path = Path.Substring(0, Path.LastIndexOf('\\'));
            Path = Path + "\\Reports\\EmployeeProfile.rpt";
            myReportDocument.Load(Path);
            myReportDocument.SetParameterValue("@Personid", TxtStaffFacID.Text);
            myReportDocument.SetDatabaseLogon("software", "DelFirMENA$idea");
        }
        TxtStaffFacID.Text  = "";
        txtStudentName.Text = "";
        txtStudentId.Text   = "";



        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();
    }
        public ActionResult PrintAdvise(string merchantid, DateTime startdate, DateTime enddate)
        {
            if (HttpContext.Session["UID"] != null)
            {
                using (SqlConnection consql = new SqlConnection(ConfigurationManager.ConnectionStrings["MerchantServiceDB"].ConnectionString))
                {
                    consql.Open();

                    SqlCommand cmd = new SqlCommand("sp_rp_load_advise", consql);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@merchantid", merchantid);
                    cmd.Parameters.AddWithValue("@startdate", startdate.Date);
                    cmd.Parameters.AddWithValue("@enddate", enddate.Date);

                    SqlDataAdapter da    = new SqlDataAdapter(cmd);
                    DataTable      REPDT = new DataTable();
                    da.Fill(REPDT);

                    consql.Close();

                    ReportDocument rd = new ReportDocument();
                    rd.Load(Path.Combine(Server.MapPath("~/ReportFiles"), "rp_PaymentAdvise.rpt"));

                    rd.SetDataSource(REPDT);

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


                    Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                    stream.Seek(0, SeekOrigin.Begin);
                    rd.Clone();
                    rd.Dispose();

                    return(File(stream, "application/pdf", merchantid + "_" + enddate.Date.ToString("yyyyMMdd") + ".pdf"));
                }
            }

            else
            {
                return(RedirectToAction("Index", "Portal"));
            }
        }
Exemplo n.º 39
0
        public HttpResponseMessage GetDealerListReport()
        {
            EasyBillingEntities db = new EasyBillingEntities();
            object _null           = null;
            var    mrchnt          = _null;

            var dlr = (from i in db.Dealers
                       select new
            {
                i.Address,
                i.Dealer_code,
                i.Email,
                i.Name,
                i.Phone_number,
                i.State_Name,
                i.Token_number,
                i.Marchent_Token_number
            }).ToList();

            foreach (var dlrsngle in dlr)
            {
                mrchnt = (from i in db.Marchent_Accounts
                          select new
                {
                    Token_number = i.Token_number,
                    GSTIN_Number = i.GSTIN_Number,
                    State_Name = i.State_Name
                }).Where(u => u.Token_number == dlrsngle.Marchent_Token_number).Distinct().ToList();
            }
            ReportDocument rpt = new ReportDocument();

            rpt.Load(Path.Combine(HostingEnvironment.MapPath("~/Reports and dataset/All Reports"), "DealerReport.rpt"));
            rpt.Database.Tables[0].SetDataSource(dlr);
            rpt.Database.Tables[1].SetDataSource(mrchnt);


            Stream s        = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            var    response = new HttpResponseMessage(HttpStatusCode.OK);

            response.Content = new StreamContent(s);
            response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");

            return(response);
        }
Exemplo n.º 40
0
        public ActionResult ReportSales(DateTime startDate, DateTime endDate)
        {
            var company = _companyService.GetQueryable().FirstOrDefault();
            var q       = _cashSalesInvoiceService.GetQueryable().Include("CashBank").Include("Warehouse").Where(x => x.IsPaid && x.SalesDate >= startDate && x.SalesDate <= endDate);

            var query = (from model in q
                         select new
            {
                StartDate = startDate,
                EndDate = endDate,
                model.Code,
                model.Description,
                model.SalesDate,
                ConfirmationDate = model.ConfirmationDate.Value,
                DueDate = model.DueDate.Value,
                model.Discount,
                model.Tax,
                model.Allowance,
                model.CoGS,
                model.Total,
                CashBank = model.CashBank.Name,
                Warehouse = model.Warehouse.Name,
                CompanyName = company.Name,
                CompanyAddress = company.Address,
                CompanyContactNo = company.ContactNo
            }).ToList();

            var rd = new ReportDocument();

            if (!query.Any())
            {
                return(Content(""));
            }

            //Loading Report
            rd.Load(Server.MapPath("~/") + "Reports/General/Sales.rpt");

            // Setting report data source
            rd.SetDataSource(query);

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

            return(File(stream, "application/pdf"));
        }
Exemplo n.º 41
0
        public static Stream Exec(MaintenanceList.TransportDataTable datatable, int language, int year,
                                  string companyName, string companyAddress, string fileName, string user)
        {
            try
            {
                ReportDocument report;
                string         strPath;

                strPath = HttpContext.Current.Request.MapPath("~/FileRpt/TransportMaintenance/TransportMaintenanceList.rpt");
                report  = new ReportDocument();
                report.Load(strPath);
                report.Database.Tables[0].SetDataSource((DataTable)datatable);
                // 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)
                {
                    report.SetParameterValue("currentDate", DateTime.Now.ToString("MMMM dd, yyyy"));
                }
                else
                {
                    report.SetParameterValue("currentDate", DateTime.Now.Year + "年" + DateTime.Now.Month + "月" + DateTime.Now.Day + "日");
                }
                report.SetParameterValue("year", year);
                // set datatable images
                var path = HttpContext.Current.Request.MapPath("~/Images/" + fileName);
                report.SetParameterValue("companyName", companyName ?? "");
                report.SetParameterValue("companyAddress", companyAddress ?? "");
                report.SetParameterValue("imageUrl", path);
                report.SetParameterValue("user", user);

                Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat);
                report.Close();
                report.Dispose();
                GC.Collect();
                return(stream);
            }
            catch (NullReferenceException)
            {
                throw new NullReferenceException();
            }
        }
Exemplo n.º 42
0
        public ActionResult InPhanCongLopTheoNam()
        {
            string a  = (TempData["maphancong"]).ToString();
            var    pc = db.Tbl_PhanCong.Where(x => x.maNamHoc == a).ToList();

            foreach (var item in pc)
            {
                Tbl_InPhanCong inpc = new Tbl_InPhanCong();
                inpc.maGV        = item.maGV;
                inpc.Idphancong  = item.Idphancong;
                inpc.maLop       = item.maLop;
                inpc.maLoai      = item.maLoai;
                inpc.maNamHoc    = item.maNamHoc;
                inpc.tenLop      = item.Tbl_LopHoc.tenLop;
                inpc.tenNamHoc   = item.Tbl_NamHoc.tenNamHoc;
                inpc.hoTen       = item.Tbl_GiaoVien.hoTen;
                inpc.ngayBatDau  = Convert.ToInt32(item.maNamHoc);
                inpc.ngayKetThuc = inpc.ngayBatDau + 1;
                db.Tbl_InPhanCong.Add(inpc);
                db.SaveChanges();
            }

            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/PhanCong.rpt")));
            rd.Refresh();

            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);

            foreach (var item in pc)
            {
                var ab = db.Tbl_InPhanCong.Where(x => x.maNamHoc == a && x.Idphancong == item.Idphancong).FirstOrDefault();
                db.Tbl_InPhanCong.Remove(ab);
                db.SaveChanges();
            }

            return(File(stream, "application/pdf", "PhanCong.pdf"));
        }
Exemplo n.º 43
0
        // GET: /Teacher/
        public ActionResult TWCList()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/CrystalReports"), "TeacherWithCourseReport.rpt"));

            rd.Database.Tables[0].SetDataSource(db.AspNetUsers.Select(a => new { Id = a.Id, FirstName = a.FirstName + " " + a.LastName }).ToList());
            rd.Database.Tables[1].SetDataSource(db.SectionCourses.Select(sc => new{ Id = sc.Id, CourseId = sc.CourseId, TeacherId = sc.TeacherId }).ToList());
            rd.Database.Tables[2].SetDataSource(db.Courses.Select(sc => new{ Id = sc.Id, Title = sc.Title, Class = sc.Lookup1.Values }).ToList());
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "TWCList.pdf"));
        }
Exemplo n.º 44
0
        public ActionResult ReportSalesReturnInvoice(int Id)
        {
            var company = _companyService.GetQueryable().FirstOrDefault();
            //var cashSalesReturnInvoice = _cashSalesInvoiceService.GetObjectById(Id);
            var    q    = _cashSalesReturnDetailService.GetQueryableObjectsByCashSalesReturnId(Id).Include("CashSalesReturn").Include("CashSalesInvoiceDetail").Include("CashSalesInvoice").Include("Item").Include("UoM");
            string user = AuthenticationModel.GetUserName();

            var query = (from model in q
                         select new
            {
                SKU = model.CashSalesInvoiceDetail.Item.Sku,
                Name = model.CashSalesInvoiceDetail.Item.Name,
                UoM = model.CashSalesInvoiceDetail.Item.UoM.Name,
                Quantity = model.Quantity,
                Price = model.CashSalesInvoiceDetail.IsManualPriceAssignment ? model.CashSalesInvoiceDetail.AssignedPrice : model.CashSalesInvoiceDetail.Item.SellingPrice,
                Amount = model,
                Discount = model.CashSalesInvoiceDetail.Discount,
                GlobalDiscount = model.CashSalesInvoiceDetail.CashSalesInvoice.Discount,
                Tax = model.CashSalesInvoiceDetail.CashSalesInvoice.Tax,
                Allowance = model.CashSalesReturn.Allowance,
                Code = model.CashSalesReturn.Code,
                SalesCode = model.CashSalesInvoiceDetail.CashSalesInvoice.Code,
                Date = model.CashSalesReturn.ConfirmationDate.Value,
                contact = "",
                CompanyName = company.Name,
                CompanyAddress = company.Address,
                CompanyContactNo = company.ContactNo,
                User = user,
                Description = model.CashSalesReturn.Description,
            }).ToList();

            var rd = new ReportDocument();

            //Loading Report
            rd.Load(Server.MapPath("~/") + "Reports/General/SalesReturnInvoice.rpt");

            // Setting report data source
            rd.SetDataSource(query);

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

            return(File(stream, "application/pdf"));
        }
Exemplo n.º 45
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["dtTrialBalanceReport"] != null) //&& reportType > 0)
                {
                   // string financialPeriodName = Shared.GetFinancialPeriodName();

                    DataTable dt = (DataTable)Session["dtTrialBalanceReport"];
                    string rptFullPath = Server.MapPath("rptTrialBalance.rpt");
                    ReportDocument rpt = new ReportDocument();

                    rpt.Load(rptFullPath);
                    rpt.SetDataSource(dt);

                    TextObject txtTitle2 = (TextObject)rpt.ReportDefinition.ReportObjects["txtFinancialPeriodName"];
                    txtTitle2.Text = "2011";

                    rpt.Refresh();

                    MemoryStream memStream = (MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

                    Response.Clear();
                    Response.Buffer = true;
                    Response.ContentType = "application/pdf";
                    Response.BinaryWrite(memStream.ToArray());
                    Response.End();

                    memStream.Dispose();
                }
                else
                    Response.Redirect("TrialBalance.aspx", false);

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {
                Session.Remove("dtTrialBalanceReport");
            }
        }
        public ActionResult Index(QuoteAndOrderReportViewModel model)
        {
            //if (!model.fromDate.HasValue) model.fromDate = DateTime.Now.Date;

            List <quote> allqu = new List <quote>();

            allqu = db.quotes.Where(s => s.Quote_Date == model.fromDate).ToList();

            PropertyDescriptorCollection properties =
                TypeDescriptor.GetProperties(typeof(quote));
            DataTable table = new DataTable();

            foreach (PropertyDescriptor prop in properties)
            {
                table.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
            }
            foreach (quote item in allqu)
            {
                DataRow row = table.NewRow();
                foreach (PropertyDescriptor prop in properties)
                {
                    row[prop.Name] = prop.GetValue(item) ?? DBNull.Value;
                }
                table.Rows.Add(row);
            }


            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reporting"), "QuoteAndOrderReport.rpt"));

            rd.SetDataSource(table);
            rd.ReadRecords();
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();


            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "QuoteAndOrderReport.pdf"));
        }
Exemplo n.º 47
0
        public ActionResult ExportReport(int?id)



        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports"), "PagoImprimir.rpt"));
            var tbpago = db.UDP_Vent_tbPago_Imprimir(id).ToList();
            var todo   = (from p in tbpago
                          where p.pago_Id == id
                          select new
            {
                pago_FechaElaboracion = p.pago_FechaElaboracion,
                pago_Id = p.pago_Id,
                fact_Id = p.fact_Id,
                fact_Codigo = p.fact_Codigo,
                clte_Identificacion = p.clte_Identificacion,
                clte_Nombres = p.clte_Nombres,
                tpa_Descripcion = p.tpa_Descripcion,
                pago_SaldoAnterior = (Decimal)p.pago_SaldoAnterior,
                pago_TotalPago = (Decimal)p.pago_TotalPago,
                pago_MontoEfectivo = (Decimal)p.pago_MontoEfectivo,
                pago_TotalCambio = (Decimal)p.pago_TotalCambio,
                pago_Emisor = p.pago_Emisor,
                pago_Titular = p.pago_Titular
            }).ToList();

            rd.SetDataSource(todo);
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            try
            {
                Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                //stream.Seek(0, SeekOrigin.Begin);
                return(File(stream, "application/pdf"));
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 48
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["vwCashRecieptsReport"] != null)
                {
                    DataTable dt = (DataTable)Session["vwCashRecieptsReport"];
                        dt.Rows[0]["AmountText"] = new NumberToWords.NumberToWords().GetAmountWord(decimal.Parse(dt.Rows[0]["Credit"].ToString()), NumberToWords.NumberToWords.ValueTypes.Money);

                    string rptFullPath = Server.MapPath("rptCashReciepts.rpt");
                    ReportDocument rpt = new ReportDocument();

                    rpt.Load(rptFullPath);
                    rpt.SetDataSource(dt);
                    rpt.Refresh();

                    MemoryStream memStream = (MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

                    Response.Clear();
                    Response.Buffer = true;
                    Response.ContentType = "application/pdf";
                    Response.BinaryWrite(memStream.ToArray());
                    Response.End();

                    memStream.Dispose();
                }
                else
                    Response.Redirect("Payments.aspx", false);

            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            finally
            {
                Session.Remove("vwCashRecieptsReport");
            }
        }
Exemplo n.º 49
0
        public virtual string GetReporteHtml()
        {
            ReportDocument reportDocument = new ReportDocument();
            string path = Path.Combine(Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory), "Reportes\\"), ClaseReporte.ResourceName);
            reportDocument.Load(path);
            reportDocument.SetDataSource(GetDatosReporte());

            string str = "";
            using (System.IO.Stream stream = reportDocument.ExportToStream(ExportFormatType.HTML32))
            {

                byte[] bytes = new byte[stream.Length];
                stream.Position = 0;
                stream.Read(bytes, 0, (int)stream.Length);
                StreamReader sr = new StreamReader(stream);

                str = System.Text.Encoding.UTF8.GetString(bytes);

            }

            return str;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataTable dt;

                String sql = "Select * FROM tableAttendance";

                SqlCommand com = new SqlCommand(sql, conn);

                conn.Open();

                SqlDataAdapter da = new SqlDataAdapter(com);
                dt = new DataTable("dt");
                da.Fill(dt);

                ReportDocument rpt = new ReportDocument();
                rpt.Load(Server.MapPath("crystalreportforattendance.rpt"));
                rpt.SetDatabaseLogon("sa", "yugioh", @"JOP-PC\SQLEXPRESS", "ISAttandaceManagementSystem");

                rpt.SetDataSource(dt);

                crvattendance.ReportSource = rpt;
                MemoryStream oStream;
                oStream = (MemoryStream)
                rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                //rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Appointment");
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(oStream.ToArray());
                Response.End();
                rpt.Export();

                conn.Close();
                conn.Dispose();
            }
        }
Exemplo n.º 51
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["dtAccountBalance"] != null) //&& reportType > 0)
            {
                DataTable dt = (DataTable)Session["dtAccountBalance"];
                string rptFullPath = Server.MapPath("rptAccountsBalances.rpt");
                ReportDocument rpt = new ReportDocument();

                rpt.Load(rptFullPath);
                rpt.SetDataSource(dt);
                rpt.Refresh();

                MemoryStream memStream = (MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(memStream.ToArray());
                Response.End();

                memStream.Dispose();
            }
            else
                Response.Redirect("AccountBalance.aspx", false);

        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        finally
        {
            Session.Remove("dtAccountBalance");
        }
    }
        private void PrintPDF()
        {
            ReportDocument rpt_doc = new ReportDocument();
            DataSet ds = new DataSet();
            StringBuilder sqlstr = new StringBuilder();

            sqlstr.Append("select requisition_id,package_no,package_name,part_no,part_name_e part_name,part_spec,require_qty,decode(released_qty,null,require_qty,released_qty) release_qty,");
            sqlstr.Append("issued_qty issue_qty,project_id,rowstate,po_no,contract_no  from jp_pkg_requisition_v");
            sqlstr.Append(string.Format("  where requisition_id in ({0})",GetSeqIdWhereStr()));

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

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

            da.Fill(ds);

            rpt_doc.Load(Request.PhysicalApplicationPath + "\\UI\\Report\\CryPkgXd.rpt");
            rpt_doc.SetDataSource(ds.Tables[0]);

            //rpt_doc.SetParameterValue("CYjz", objJjd.CyDoc);

            //rpt_doc.PrintOptions.PaperOrientation = PaperOrientation.;
            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();
            }
        }
Exemplo n.º 53
0
        public ActionResult ExportUsersList()
        {
            AMSEntities ae = new AMSEntities();
             User uu = ae.Users.Where(e => e.MembershipUserID == WebSecurity.CurrentUserId).Single();
             List<User> users = ae.Users.Where(e => e.CompanyID == uu.CompanyID).ToList();

             var d =(from s in users
                     select new
                     {
                         UserTitle = s.UserTitle ?? null,
                         UserFirstName = s.UserFirstName ?? null,
                         UserLastName = s.UserLastName ?? null,
                         UserEmail = s.UserEmail ?? null,
                         UserPhone = s.UserPhone ?? null,
                                                      }).ToList();

             ReportDocument rd = new ReportDocument();
             rd.Load(Path.Combine(Server.MapPath("~/Reports"), "MyUsers.rpt"));
             rd.SetDataSource(d);

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

             try
             {
                 Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                 stream.Seek(0, SeekOrigin.Begin);
                 return File(stream, "application/pdf", "MyusersList.pdf");
             }

             catch (Exception e)
             {
                 throw;
             }
        }
    protected void Button_Imprimir_Click(object sender, EventArgs e)
    {
        if (!(String.IsNullOrEmpty(HiddenField_ID_CONTRATO.Value)))
        {
            registroContrato _registroContrato = new registroContrato(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
            DataTable tablaInfoContrato = _registroContrato.ObtenerInfoParaImprimirContrato(Convert.ToDecimal(HiddenField_ID_CONTRATO.Value));
            NumToLetra numToLetra = new NumToLetra();
            string salario_en_letras = numToLetra.Convertir(Convert.ToDecimal(TextBox_Salario.Text).ToString(), true);

            if(tablaInfoContrato.Rows.Count <= 0)
            {
                if(_registroContrato.MensajeError != null)
                {
                    Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "No se encontró información para generar el contrato.", Proceso.Error);
                }
                else
                {
                    Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, _registroContrato.MensajeError, Proceso.Error);
                }
            }
            else
            {
                String uspReporte = "";
                String nombreReporte = "";
                string nombre_empresa = null;
                string nit_empresa = null;
                string telefono_empresa = null;
                string direccion_empresa = null;

                if (Session["idEmpresa"].ToString() == "1")
                {
                    nombre_empresa = tabla.VAR_NOMBRE_SERTEMPO;
                    nit_empresa = tabla.VAR_NIT_SERTEMPO;
                    telefono_empresa = tabla.VAR_TELEFONO_SERTEMPO;
                    direccion_empresa = tabla.VAR_DOMICILIO_SERTEMPO;
                }
                else
                {
                    if (Session["idEmpresa"].ToString() == "3")
                    {
                        nombre_empresa = tabla.VAR_NOMBRE_EYS;
                        nit_empresa = tabla.VAR_NIT_EYS;
                        telefono_empresa = tabla.VAR_TELEFONO_EYS;
                        direccion_empresa = tabla.VAR_DOMICILIO_EYS;
                    }
                }

                DataRow filaInfoContrato = tablaInfoContrato.Rows[0];

                if (RadioButton_PRACTICANTE_UNI.Checked)
                {
                    uspReporte = "RPT_CONTRATACION_CONTRATO_APRENDIZ_UNIVERSITARIO";
                    nombreReporte = "RPT_CONTRATACION_CONTRATO_APRENDIZ_UNIVERSITARIO.rpt";
                    uspReporte += " '" + Session["idEmpresa"].ToString() + "'"
                        + ", '" + nombre_empresa + "'"
                        + ", '" + nit_empresa + "'"
                        + ", '" + telefono_empresa + "'"
                        + ", '" + direccion_empresa + "'"
                        + ", '" + TextBox_contrato_aprendiz_universitario_representante_legal.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_universitario_numero_identificacion.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_universitario_nombre_institucion.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_universitario_nit_institucion.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_universitario_especialidad_aprendiz.Text + "'"
                        + ", '" + filaInfoContrato["ID_EMPLEADO"].ToString() + "'"
                        ;
                }
                else if ((RadioButton_SENA_ELECTIVO.Checked) || (RadioButton_SENA_PRODUCTIVO.Checked))
                {
                    uspReporte = "RPT_CONTRATACION_CONTRATO_APRENDIZ_SENA";
                    nombreReporte = "RPT_CONTRATACION_CONTRATO_APRENDIZ_SENA.rpt";
                    uspReporte += " '" + Session["idEmpresa"].ToString() + "'"
                        + ", '" + nombre_empresa + "'"
                        + ", '" + nit_empresa + "'"
                        + ", '" + telefono_empresa + "'"
                        + ", '" + direccion_empresa + "'"
                        + ", '" + TextBox_contrato_aprendiz_sena_representante_legal.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_sena_cargo_r_l.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_sena_numero_documento_r_l.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_sena_especialidad_aprendiz.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_sena_curso_aprendiz.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_nombre_institucion.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_nit_institucion.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_centro_formacion.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_meses_duracion.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_fecha_inicio.Text + "'"
                        + ", '" + TextBox_contrato_aprendiz_fecha_final.Text + "'"
                        + ", '" + filaInfoContrato["ID_EMPLEADO"].ToString() + "'"
                        ;

                }
                else if (DropDownList_Clase_contrato.SelectedValue == ClaseContrato.I.ToString())
                {
                    uspReporte = "RPT_CONTRATACION_CONTRATO_INDEFINIDO";
                    nombreReporte = "RPT_CONTRATACION_CONTRATO_INDEFINIDO.rpt";
                    uspReporte += " '" + Session["idEmpresa"].ToString() + "'"
                        + ", '" + nombre_empresa + "'"
                        + ", '" + nit_empresa + "'"
                        + ", '" + TextBox_contrato_indefinido_identificacion_empleador.Text + "'"
                        + ", '" + TextBox_contrato_indefinido_nombre_empleador.Text + "'"
                        + ", '" + TextBox_contrato_indefinido_ciudad_domicilio_empleador.Text + "'"
                        + ", '" + telefono_empresa + "'"
                        + ", '" + direccion_empresa + "'"
                        + ", '" + salario_en_letras + "'"
                        + ", '" + filaInfoContrato["ID_EMPLEADO"].ToString() + "'"
                        ;
                }
                else
                {
                    if (DropDownList_Clase_contrato.SelectedValue == ClaseContrato.L_C_C_D_A.ToString())
                    {
                    }
                    else
                    {
                        if (DropDownList_Clase_contrato.SelectedValue == ClaseContrato.L_S_C_D_A.ToString())
                        {
                        }
                        else
                        {
                            if (DropDownList_Clase_contrato.SelectedValue == ClaseContrato.O_L.ToString())
                            {

                                if (DropDownList_FORMA_IMPRESION_CONTRATO.SelectedValue == "COMPLETO")
                                {
                                    ImprimirContratoO_L_COMPLETO(filaInfoContrato);
                                }
                                else
                                {
                                    if (DropDownList_FORMA_IMPRESION_CONTRATO.SelectedValue == "PREIMPRESO")
                                    {
                                        uspReporte = "usp_con_reg_contratos_ObtenerInfo_para_imprimir_contrato " + filaInfoContrato["REGISTRO_CONTRATO"].ToString();
                                        nombreReporte = "RPT_CONTRATACION_OBRA_LABOR_PREIMPRESO.rpt ";
                                    }
                                }
                            }
                            else
                            {
                                if (DropDownList_Clase_contrato.SelectedValue == ClaseContrato.T_F.ToString())
                                {
                                }
                                else
                                {
                                    if (DropDownList_Clase_contrato.SelectedValue == ClaseContrato.IN.ToString())
                                    {
                                        uspReporte = "RPT_CONTRATACION_CONTRATO_INTEGRAL";
                                        nombreReporte = "RPT_CONTRATACION_CONTRATO_INTEGRAL.rpt";
                                        uspReporte += " '" + Session["idEmpresa"].ToString() + "'"
                                            + ", '" + nombre_empresa + "'"
                                            + ", '" + direccion_empresa + "'"
                                            + ", '" + TextBox_contrato_integral_porcentaje_parafiscales.Text + "'"
                                            + ", '" + TextBox_contrato_integral_porcentaje_prestacional.Text + "'"
                                            + ", '" + filaInfoContrato["ID_EMPLEADO"].ToString() + "'";
                                    }
                                }
                            }
                        }
                    }
                }

                String cadenaDeConeccion = "";
                if (Session["idEmpresa"].ToString() == "1")
                {
                    cadenaDeConeccion = ConfigurationManager.ConnectionStrings["siser"].ConnectionString;
                }
                else
                {
                    cadenaDeConeccion = ConfigurationManager.ConnectionStrings["sister"].ConnectionString;
                }

                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(cadenaDeConeccion);
                String user = builder.UserID;
                string pass = builder.Password;
                String server = builder.DataSource;
                String db = builder.InitialCatalog;

                SqlConnection conn = new SqlConnection(cadenaDeConeccion);

                try
                {
                    using (SqlCommand comando = new SqlCommand(uspReporte, conn))
                    {
                        using (SqlDataAdapter adaptador = new SqlDataAdapter(comando))
                        {
                            DataSet ds = new DataSet();
                            adaptador.Fill(ds);

                            reporte = new ReportDocument();

                            reporte.Load(Server.MapPath("~/Reportes/Contratacion/" + nombreReporte));
                            reporte.SetDataSource(ds.Tables[0]);
                            reporte.DataSourceConnections[0].SetConnection(server, db, user, pass);

                            using (var mStream = (MemoryStream)reporte.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat))
                            {
                                Response.AddHeader("Content-Disposition", "attachment;FileName=RPT_PDF.pdf");
                                Response.Clear();
                                Response.Buffer = true;
                                Response.ContentType = "application/pdf";
                                Response.BinaryWrite(mStream.ToArray());
                            }
                            Response.End();
                        }
                    }
                }
                catch (Exception ex)
                {
                    Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, ex.Message, Proceso.Error);
                }
                finally
                {
                    if (conn.State != ConnectionState.Closed)
                        conn.Close();
                    conn.Dispose();
                }

            }
        }
        else
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "El contrato no ha sido guardado. Debe diligenciar todos los datos de contrato y luego Guardarlos, para poder imprimir el correspondiente documento.", Proceso.Advertencia);
        }
    }
Exemplo n.º 55
0
        public ActionResult Report(RequestIssue requestıssue, FormCollection formcollection)
        {
            ReportDocument rptH = new ReportDocument();

            rptH.FileName = Server.MapPath("~/RDLC/SurveyReport.rpt");

            rptH.Refresh();
            //rptH.Load();

            var value = new ParameterDiscreteValue();

            var requests_ = db.RequestIssues.AsNoTracking().Include(p => p.Locations).Include(p => p.Personnels).Include(p => p.CorporateAccounts);

            int x_index = 0;
            foreach (int req_ in requests_.Select(i => i.RequestIssueID).ToList())
            {
                value.Value = req_;

                rptH.ParameterFields["RequestIDs"].CurrentValues.Add(value);
                x_index++;
            }

            if (x_index == 0)
            {
                return RedirectToAction("Index", new { custommerr = "Belirttiğiniz Kriterlere Uygun Kayıt(lar) Bulunamadı" });
            }

            // rptH.SetDataSource([datatable]);
            var cd = new System.Net.Mime.ContentDisposition
            {
                // for example foo.bak
                FileName = "rapor_klimasanHelpDeskAnketler.pdf",

                // always prompt the user for downloading, set to true if you want
                // the browser to try to show the file inline
                Inline = false,
            };

            Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.AppendHeader("Content-Disposition", cd.ToString());
            return File(stream, "application/pdf");
        }
        protected void GetReports()
        {
            // Session["PRINTALL"] = null;
            string fType = "PD";
            string fDate = (string)Session["FD"];
            string tDate = (string)Session["TD"];
            string BType = (string)Session["BILLTYPE"];
            string shpType = (string)Session["shpType"];
            string pName = (string)Session["pname"];
            string sqlStmts = "";

            ReportDocument rptDoc = new ReportDocument();
            if (BType == "SB")
            {
                ImpexCube.Billing.XSD.printall ds = new ImpexCube.Billing.XSD.printall(); // .xsd file name
                DataTable dt = new DataTable();
                dt.TableName = "Crystal Report Example";
                sqlStmts = "exec spBillsAll '" + pName + "','" + BType + "','" + shpType + "','" + fDate + "','" + tDate + "'";
                ReportDocument rptObject = new ReportDocument();
                DataSet dataSetName = new DataSet();
                dsTableName = new string[1];
                dsTableName[0] = "spBillsAll";

                ConnectionReports.FillDataSet(sqlStmts, dataSetName, dsTableName);

                dt = dataSetName.Tables[0];

                ds.Tables[0].Merge(dt);
                //rptDoc.Load(@"E:\RAJESH\Live Application\Delhi And Chennai Billing Application\ImpexCube\ImpexCube\Billing\CryInvoice.rpt");

                rptDoc.Load(@"C:\inetpub\wwwroot\pub impexcryst\Billing\CryInvoice.rpt");

                rptDoc.SetDataSource(ds);
                MemoryStream oStream; // using System.IO
                oStream = (MemoryStream)
                rptDoc.ExportToStream(
                CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(oStream.ToArray());
                Response.End();
                //CrystalReportViewer1.ReportSource = rptDoc;
                //string[] a = new string[2];
                //ConnectionReports.ShowReportWithParameter(rptDoc, ds, a,fType);
            }
            else
            {
                ImpexCube.Billing.XSD.dsdebit ds = new ImpexCube.Billing.XSD.dsdebit(); // .xsd file name
                DataTable dt = new DataTable();

                dt.TableName = "Crystal Report Example";
                sqlStmts = "exec spDBBillsAll '" + pName + "','" + BType + "','" + shpType + "','" + fDate + "','" + tDate + "'";

                ReportDocument rptObject = new ReportDocument();
                DataSet dataSetName = new DataSet();
                dsTableName = new string[1];
                dsTableName[0] = "spDBBillsAll";

                ConnectionReports.FillDataSet(sqlStmts, dataSetName, dsTableName);

                dt = dataSetName.Tables[0];

                ds.Tables[0].Merge(dt);
                //  rptDoc.Load(Server.MapPath("CryDebitNote.rpt"));
                rptDoc.Load(@"C:\inetpub\wwwroot\pub impexcryst\Billing\CryDebitNote.rpt");
                rptDoc.SetDataSource(ds);
                MemoryStream oStream; // using System.IO
                oStream = (MemoryStream)
                rptDoc.ExportToStream(
                CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/pdf";
                Response.BinaryWrite(oStream.ToArray());
                Response.End();
                //CrystalReportViewer1.ReportSource = rptDoc;
                //string[] a = new string[2];
                //ConnectionReports.ShowReportWithParameter(rptDoc, ds,a, fType);
            }
        }
 public pdfToCrystalReport(ReportDocument rpt)
 {
     _contentBytes = StreamToBytes(rpt.ExportToStream(ExportFormatType.PortableDocFormat));
 }
Exemplo n.º 58
0
    /// <summary>
    /// 利用 CrystalReport 匯出 PDF 或是 EXCEL
    /// </summary>
    /// <param name="s_FileName">檔名</param>
    /// <param name="s_rptFilePath">rpt檔的路徑</param>
    /// <param name="dt_Source">要列印的資料</param>
    /// <param name="e_Type">PDF or EXCEL</param>
    private void LoadCrystalReport(string s_FileName, string s_rptFilePath, DataTable dt_Source, ExportFormatType e_Type)
    {
        ReportDocument report = new ReportDocument();

        report.Load(s_rptFilePath);
        report.SetDataSource(dt_Source);

        System.IO.Stream stream = report.ExportToStream(e_Type);
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, bytes.Length);
        stream.Seek(0, System.IO.SeekOrigin.Begin);

        //export file  
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("content-disposition", "attachment;filename=" + s_FileName);//檔名
        if (e_Type == ExportFormatType.Excel)
        { Response.ContentType = "application/vnd.ms-excel"; }
        else if (e_Type == ExportFormatType.PortableDocFormat)
        { Response.ContentType = "application/pdf"; }
        Response.OutputStream.Write(bytes, 0, bytes.Length);
        Response.Flush();
        Response.Close();
        report.Close();
    }
        //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();
        }
        protected void CriaPDF()
        {
            Hashtable hash = (Hashtable)Session["HashProducaoMedicoRegulador"];

            DSCabecalhoProducaoMedicoRegulador cabecalho = new DSCabecalhoProducaoMedicoRegulador();
            cabecalho.Tables.Add((DataTable)hash["cabecalho"]);

            DSRelatorioProducaoMedicoRegulador conteudo = new DSRelatorioProducaoMedicoRegulador();
            conteudo.Tables.Add((DataTable)hash["corpo"]);

            ReportDocument repDoc = new ReportDocument();

            repDoc.Load(Server.MapPath("RelatoriosCrystal/CrystalReportViewer_RelatorioProducaoMedicoRegulador.rpt"));
            repDoc.SetDataSource(conteudo.Tables[1]);
            repDoc.Subreports["CrystalReportViewer_CabecalhoProducaoMedicoRegulador.rpt"].SetDataSource(cabecalho.Tables[1]);

            //repDoc.Database.Tables["CabecalhoAgendaPrestador"].SetDataSource((DataTable)hash["cabecalho"]);
            //repDoc.Database.Tables["RelatorioAgendaPrestador"].SetDataSource((DataTable)hash["corpo"]);

            System.IO.Stream s = repDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
            Response.ClearContent();
            Response.ClearHeaders();
            Response.ContentType = "applicattion/octect-stream";
            Response.AddHeader("Content-Disposition", "attachment;filename=RelatorioProducaoMedicosReguladores.pdf");
            Response.AddHeader("Content-Length", s.Length.ToString());
            Response.BinaryWrite(((System.IO.MemoryStream)s).ToArray());
            Response.End();
        }