public ActionResult PrintOrder(int OrderID)
        {
            //Response.Buffer = false;
            //Response.ClearContent();
            //Response.ClearHeaders();
            //rp.SetDatabaseLogon("Diem", "", "DESKTOP-HA2TCUF", "CoffeeShopDB", false);

            Order order = info.GetOrderByOrderID(OrderID).SingleOrDefault();

            CrystalReport1 rp = new CrystalReport1();

            if (order.Desc == "ServeAtCafe" || order.Desc == "TakeAway")
            {
                string status = "Paid";
                info.UpdateOrderStatus(OrderID, status);
            }
            else
            {
                string Status1 = "Closed", Status2 = "Delivery";
                info.UpdateOrderStatus(OrderID, Status1);
                info.UpdateShipDetailStatus(OrderID, Status2);
            }
            if (order.PosID != 0)
            {
                int PosID = Convert.ToInt32(order.PosID);
                info.UpdateStatusPostion(PosID, "Available");
                //rp.SetParameterValue("@orderid", OrderID);
            }
            rp.SetParameterValue("@OrderID", OrderID);
            Stream stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "OrderCustomer.pdf"));
        }
        public ActionResult PrintReport()
        {
            CrystalReport1 rp = new CrystalReport1();
            //Response.Buffer = false;
            //Response.ClearContent();
            //Response.ClearHeaders();
            //rp.SetDatabaseLogon("Diem", "", "DESKTOP-HA2TCUF", "CoffeeShopDB", false);
            Stream stream = rp.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);
            return(File(stream, "application/pdf", "CustomerList.pdf"));
        }
        public ActionResult GenerateReport1()
        {
            DB50Entities db = new DB50Entities();
            var          c  = db.Report1();

            CrystalReport1 r = new CrystalReport1();

            r.Load();

            Stream s = r.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            return(File(s, "application/pdf"));
        }
        /// <summary>
        /// Download PDF of all employees
        /// </summary>
        /// <returns></returns>
        public ActionResult ExportEmployees()
        {
            List <Employee> allCustomer = new List <Employee>();

            allCustomer = db.Employees.ToList();


            CrystalReport1 rd = new CrystalReport1();

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

            rd.SetDataSource(allCustomer);

            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", "EmployeeList.pdf"));
        }
Example #5
0
        public ActionResult ExportReport()
        {
            CrystalReport1 rd = new CrystalReport1();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/CrystalReport1.rpt")));
            rd.SetDatabaseLogon("sa", "p@ssw0rd");
            rd.SetDataSource(context.Positions.ToList());
            foreach (Table tbl in rd.Database.Tables)
            {
                tbl.LogOnInfo.ConnectionInfo = connectInfo;
                tbl.ApplyLogOnInfo(tbl.LogOnInfo);
            }

            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            ExportOptions           CrExportOptions;
            PdfRtfWordFormatOptions pdfFormatOptions = new PdfRtfWordFormatOptions();

            CrDiskFileDestinationOptions.DiskFileName = "D:\\";
            CrExportOptions = rd.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions         = pdfFormatOptions;
            }

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

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

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

            return(File(str, "application/pdf", savedFileName));
        }
Example #6
0
        public HttpResponseMessage obtenerReportePlatosVendidos(List <dynamic> data)
        {
            DataSet1  ds = new DataSet1();
            DataTable t  = ds.Tables.Add("Items");
            DataRow   r;



            t.Columns.Add("Nombre del plato", Type.GetType("System.String"));
            t.Columns.Add("Cantidad vendida", Type.GetType("System.Int32"));

            for (int i = 0; i < data.Count; i++)
            {
                Debug.WriteLine("paso por aca");
                r = t.NewRow();
                r["Cantidad vendida"] = data[i]["Cantidad"];
                r["Nombre del plato"] = data[i]["Nombre"];
                t.Rows.Add(r);
            }

            CrystalReport1 objRpt = new CrystalReport1();

            objRpt.SetDataSource(ds.Tables[1]);
            Debug.WriteLine(objRpt.ReportSource);
            ReportDocument cryRpt = new ReportDocument();

            cryRpt.Load("C:\\Users\\braya\\Desktop\\bases\\Tarea_corta\\Servidor_API\\CReports\\CrystalReport1.rpt");



            ExportOptions CrExportOptions;
            DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
            PdfRtfWordFormatOptions    CrFormatTypeOptions          = new PdfRtfWordFormatOptions();

            CrDiskFileDestinationOptions.DiskFileName = "C:\\Users\\braya\\Desktop\\bases\\Tarea_corta\\Servidor_API\\CReports\\report.pdf";
            CrExportOptions = objRpt.ExportOptions;
            {
                CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                CrExportOptions.ExportFormatType      = ExportFormatType.PortableDocFormat;
                CrExportOptions.DestinationOptions    = CrDiskFileDestinationOptions;
                CrExportOptions.FormatOptions         = CrFormatTypeOptions;
            }



            Stream stream = objRpt.ExportToStream(ExportFormatType.PortableDocFormat);

            objRpt.Export(CrExportOptions);
            MemoryStream ms = new MemoryStream();

            stream.CopyTo(ms);
            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new ByteArrayContent(ms.ToArray())
            };

            result.Content.Headers.ContentDisposition =
                new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
            {
                FileName = "Report.pdf"
            };
            result.Content.Headers.ContentType =
                new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
            return(result);
        }
Example #7
0
        private void enviarPDF(int id, int tipo)
        {
            i.recoverInvoice(id);

            DataRow dr = u.singleUser(i.Refuser);

            u.recoverUser(i.Refuser);

            DataTable user = new DataTable();

            user.Columns.Add("iduser", Type.GetType("System.Int32"));
            user.Columns.Add("nombre", Type.GetType("System.String"));
            user.Columns.Add("apellidos", Type.GetType("System.String"));
            user.Columns.Add("email", Type.GetType("System.String"));
            user.Columns.Add("telefono", Type.GetType("System.Int32"));
            DataRow drf = user.NewRow();

            drf[0] = dr[0];
            drf[1] = dr[1];
            drf[2] = dr[2];
            drf[3] = dr[3];
            drf[4] = dr[4];
            user.Rows.Add(drf);


            dr = i.singleInvoice(i.Idinvoice);
            DataTable invo = new DataTable();

            invo.Columns.Add("idinvoice", Type.GetType("System.Int32"));
            invo.Columns.Add("mes", Type.GetType("System.Int32"));
            invo.Columns.Add("año", Type.GetType("System.Int32"));
            drf    = invo.NewRow();
            drf[0] = dr[0];
            drf[1] = dr[2];
            drf[2] = dr[3];
            invo.Rows.Add(drf);

            InvoiceItem ii    = new InvoiceItem();
            DataTable   items = ii.mostrarDatos(i.Idinvoice);

            items.Columns[0].ColumnName = "idinvoiceitem";
            items.Columns[1].ColumnName = "nombre";
            items.Columns[2].ColumnName = "precio";


            DataTable emp = new DataTable();

            emp.Columns.Add("nombre", Type.GetType("System.String"));
            emp.Columns.Add("direccion", Type.GetType("System.String"));
            emp.Columns.Add("telefono", Type.GetType("System.String"));
            emp.Columns.Add("email", Type.GetType("System.String"));
            emp.Columns.Add("cif", Type.GetType("System.String"));
            drf    = emp.NewRow();
            drf[0] = Propiedades.getNombreEmpresa();
            drf[1] = Propiedades.getDireccion();
            drf[2] = Propiedades.getTelefono();
            drf[3] = Propiedades.getEmail();
            drf[4] = Propiedades.getCif();
            emp.Rows.Add(drf);

            if (tipo == 0)
            {
                CrystalReport1 report = new CrystalReport1();
                report.Database.Tables["items"].SetDataSource(items);
                report.Database.Tables["usuario"].SetDataSource(user);
                report.Database.Tables["invoice"].SetDataSource(invo);
                report.Database.Tables["empresa"].SetDataSource(emp);
                Stream tmp = report.ExportToStream(ExportFormatType.PortableDocFormat);
                enviarMensaje(tmp);
            }
            else
            {
                CrystalReport2 report = new CrystalReport2();
                report.Database.Tables["items"].SetDataSource(items);
                report.Database.Tables["usuario"].SetDataSource(user);
                report.Database.Tables["invoice"].SetDataSource(invo);
                report.Database.Tables["empresa"].SetDataSource(emp);
                Stream tmp = report.ExportToStream(ExportFormatType.PortableDocFormat);
                enviarMensaje(tmp);
            }
        }