protected void GerarRelatorio(object sender, EventArgs e)
        {
            try
            {
                //Obter o relatorio (caminho)
                string Path = HttpContext.Current.Server.MapPath("/Reports/RelatorioVendas.rdlc");

                //Resgatar as datas
                DateTime dtIni = Convert.ToDateTime(txtDataInicio.Text);
                DateTime dtFim = Convert.ToDateTime(txtDataTermino.Text);

                using (VendaDal d = new VendaDal()) //inicializar
                {
                    ReportDataSource dados = new ReportDataSource("DSRelatorio", d.ListarVendas(dtIni, dtFim));

                    //Mostrar o relatorio
                    ReportViewer.LocalReport.ReportPath = Path;      //caminho do relatório
                    ReportViewer.LocalReport.DataSources.Add(dados); //passando os dados
                    ReportViewer.DataBind();                         //Exibir
                } //dispose (destruir)
            }
            catch (Exception ex)
            {
                lblMensagem.Text = ex.Message;
            }
        }
示例#2
0
    public static void LoadSQLReport(string ReportName, ReportViewer rv)
    {
        rv.ServerReport.ReportServerUrl = new Uri(System.Configuration.ConfigurationManager.AppSettings["SQLReportServer"]);
        rv.ServerReport.ReportPath      = "/" + System.Configuration.ConfigurationManager.AppSettings["SQLReportFolder"] + "/" + ReportName;

        rv.DataBind();
    }
示例#3
0
        protected void btnPesquisa_Click(object sender, EventArgs e)
        {
            try
            {
                //resgatar as datas dos campos..
                string Nome = txtNomeF.Text;


                //pesquisar os produtos no banco de dados...
                Dal.Persistence.FuncionarioDal f     = new Dal.Persistence.FuncionarioDal(); //classe de persistencia...
                List <Dal.Entity.Funcionario>  lista = new List <Dal.Entity.Funcionario>();
                lista = f.FindAll(Nome);
                //exibir o relatorio dentro do ReportViewer...

                //Passo 1) Informar ao reportviewer o caminho do relatorio...
                ReportViewer.LocalReport.ReportPath = HttpContext.Current.Server.
                                                      MapPath("/Reports/RelatorioFunc.rdlc");

                //Passo 2) Preencher o relatorio com os dados (dataset)
                ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSetFunc", lista));
                //exibir o relatório...
                ReportViewer.DataBind();
            }
            catch (Exception ex)
            {
                //imprimir mensagem de erro...
                lblMensagem.Text = ex.Message;
            }
        }
示例#4
0
        protected void btnVerFactura_Click(object sender, EventArgs e)
        {
            ReportViewer.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;
            ReportViewer.LocalReport.ReportPath = Server.MapPath("FacturaVenta.rdlc");
            ReportViewer.LocalReport.DataSources.Clear();

            ReportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("Encabezado", MV.spEncabezado(Convert.ToInt32(Request.QueryString["Ve"].ToString()))));
            ReportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("Cuerpo", MV.spCuerpo(Convert.ToInt32(Request.QueryString["Ve"].ToString()))));

            ReportViewer.DataBind();
        }
示例#5
0
        protected void btnBuscarReporte_Click(object sender, EventArgs e)
        {
            if (!inicio.Text.Equals("") && !fin.Text.Equals(""))
            {
                ReportViewer.ProcessingMode         = Microsoft.Reporting.WebForms.ProcessingMode.Local;
                ReportViewer.LocalReport.ReportPath = Server.MapPath("VentasPorFechas.rdlc");
                ReportViewer.LocalReport.DataSources.Clear();
                string[] f1 = inicio.Text.Split('/');
                string[] f2 = fin.Text.Split('/');
                ReportViewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("Reporte",
                                                                                                           MV.spReporteVenta(DateTime.Parse(f1[1] + "/" + f1[0] + "/" + f1[2]), DateTime.Parse(f2[1] + "/" + f2[0] + "/" + f2[2]))));

                ReportViewer.DataBind();
            }
        }
示例#6
0
        protected void btnDisplay_Click(object sender, EventArgs e)
        {
            if (Utils.LoggedUser == null)
            {
                Response.Redirect("~/login");
            }
            if (Utils.CheckPermission(5, 15, Utils.LoggedUser.Roles) < 1)
            {
                ClientScript.RegisterStartupScript(GetType(), "alert", "lmis.notification.error('" + GetGlobalResourceObject("MessagesResource", "X_NotAuthorized") + @"');", true);

                return;
            }
            var mr = Mgr.ListRequestLog().Where(w =>
                                                (w.PortalUserName == ddlUsesr.SelectedValue || ddlUsesr.SelectedValue == "All") &&
                                                (w.RequestType.desc == ddlRequestType.SelectedValue || ddlRequestType.SelectedValue == "All") &&

                                                (ddlStatus.SelectedValue == "Pending" ? w.Approval == Approval.Pending : w.Approval == w.Approval) &&
                                                (ddlStatus.SelectedValue == "Approved" ? w.Approval == Approval.Approved : w.Approval == w.Approval) &&
                                                (ddlStatus.SelectedValue == "Rejected" ? w.Approval == Approval.Rejected : w.Approval == w.Approval) &&
                                                (ddlTransactionType.SelectedValue == "New" ? w.DeleteDate == null && w.UpdateDate == null : w.PostDate == w.PostDate) &&
                                                (ddlTransactionType.SelectedValue == "Updated" ? w.UpdateDate != null && w.DeleteDate == null : w.UpdateDate == w.UpdateDate) &&
                                                (ddlTransactionType.SelectedValue == "Deleted" ? w.DeleteDate != null : w.DeleteDate == w.DeleteDate) &&
                                                (
                                                    ((string.IsNullOrEmpty(txtFrom.Text) ? w.PostDate == w.PostDate : w.PostDate.Date >= DateTime.Parse(txtFrom.Text).Date) &&
                                                     (string.IsNullOrEmpty(txtTo.Text) ? w.PostDate == w.PostDate : w.PostDate.Date <= DateTime.Parse(txtTo.Text).Date)) ||
                                                    ((string.IsNullOrEmpty(txtFrom.Text) ? w.UpdateDate == w.UpdateDate : w.UpdateDate.HasValue && w.UpdateDate.Value.Date >= DateTime.Parse(txtFrom.Text).Date) &&
                                                     (string.IsNullOrEmpty(txtTo.Text) ? w.UpdateDate == w.UpdateDate : w.UpdateDate.HasValue && w.UpdateDate.Value.Date <= DateTime.Parse(txtTo.Text).Date)) ||
                                                    ((string.IsNullOrEmpty(txtFrom.Text) ? w.DeleteDate == w.DeleteDate : w.DeleteDate.HasValue && w.DeleteDate.Value.Date >= DateTime.Parse(txtFrom.Text).Date) &&
                                                     (string.IsNullOrEmpty(txtTo.Text) ? w.DeleteDate == w.DeleteDate : w.DeleteDate.HasValue && w.DeleteDate.Value.Date <= DateTime.Parse(txtTo.Text).Date))
                                                )
                                                ).Select(s => new { PortalUserName = s.PortalUserName, Date = s.PostDate, RequestTypeDesc = s.RequestType.desc, Status = (s.Approval == Approval.Approved ? "Approved" : (s.Approval == Approval.Pending ? "Pending" : "Rejected")), TransactionType = (s.DeleteDate != null ? "Deleted" : (s.UpdateDate != null ? "Updated" : "New")) });



            ReportViewer.LocalReport.ReportPath = "BackEnd\\rdlc\\TransactionHistory.rdlc";


            ReportViewer.LocalReport.DataSources.Clear();
            ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", mr));


            ReportViewer.DataBind();
            ReportViewer.LocalReport.Refresh();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ClienteEnderecoDAL        d     = new ClienteEnderecoDAL();
                    List <ClienteEnderecoDTO> lista = d.FindAll();

                    ReportDataSource ds = new ReportDataSource("DataSetClientes", lista);

                    ReportViewer.LocalReport.DataSources.Clear();
                    ReportViewer.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("/Report/ReportClientes.rdlc");
                    ReportViewer.LocalReport.DataSources.Add(ds);
                    ReportViewer.DataBind();
                }
                catch (Exception ex)
                {
                    lblMensagem.Text = "Erro ao gerar relatório de clientes. \n" + ex.Message;
                }
            }
        }
        public void RunReport(string sRDL)
        {
            try
            {
                RdlDocument rdl = new RdlDocument();
                rdl.LoadRdl(sRDL);

                DbProviderFactory dbf = DbProviderFactories.GetFactory();
                using (IDbConnection con = dbf.CreateConnection())
                {
                    using (IDbCommand cmd = con.CreateCommand())
                    {
                        rdl.BuildCommand(cmd);
                        sReportSQL = Sql.ExpandParameters(cmd);

                        using (DbDataAdapter da = dbf.CreateDataAdapter())
                        {
                            ((IDbDataAdapter)da).SelectCommand = cmd;
                            dtReport = new DataTable();
                            {
                                da.Fill(dtReport);

                                // 07/12/2006 Paul.  Every date cell needs to be localized.
                                foreach (DataRow row in dtReport.Rows)
                                {
                                    foreach (DataColumn col in dtReport.Columns)
                                    {
                                        if (col.DataType == typeof(System.DateTime))
                                        {
                                            // 07/13/2006 Paul.  Don't try and translate a NULL.
                                            if (row[col.Ordinal] != DBNull.Value)
                                            {
                                                row[col.Ordinal] = T10n.FromServerTime(row[col.Ordinal]);
                                            }
                                        }
                                    }
                                }

                                /*
                                 * http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=444154&SiteID=1
                                 * Brian Hartman - MSFT  06 Jun 2006, 10:22 PM UTC
                                 * LocalReport has a limitation that the report definition can't be changed once the report has been processed.
                                 * In winforms, you can use the ReportViewer.Reset() method to force the viewer to create a new instance of
                                 * LocalReport and workaround this issue.  But this method is currently not on the webforms version of report viewer.
                                 * We hope to add it in an upcoming service pack, but for now,
                                 * you must workaround this issue by creating a new instance of the ReportViewer.
                                 */
                                /*
                                 * // 07/09/2006 Paul.  Creating a new viewer solves the reset problem, but breaks ReportViewer pagination.
                                 * rdlViewer = new ReportViewer();
                                 * rdlViewer.ID                  = "rdlViewer";
                                 * rdlViewer.Font.Names          = new string[] { "Verdana" };
                                 * rdlViewer.Font.Size           = new FontUnit("8pt");
                                 * rdlViewer.Height              = new Unit("100%");
                                 * rdlViewer.Width               = new Unit("100%");
                                 * rdlViewer.AsyncRendering      = false;
                                 * rdlViewer.SizeToReportContent = true;
                                 * divReportView.Controls.Clear();
                                 * divReportView.Controls.Add(rdlViewer);
                                 */

                                // 06/21/2006 Paul.  The DataSource Name must match the value in the report.
                                string           sDataSetName = rdl.SelectNodeValue("Body/ReportItems/Table/DataSetName");
                                ReportDataSource rds          = new ReportDataSource(sDataSetName, dtReport);
                                rdlViewer.ProcessingMode = ProcessingMode.Local;
                                // 06/25/2006 Paul.  The data sources need to be cleared, otherwise the report will not refresh.
                                rdlViewer.LocalReport.DataSources.Clear();
                                rdlViewer.LocalReport.DataSources.Add(rds);
                                rdlViewer.LocalReport.DisplayName = rdl.SelectNodeAttribute(String.Empty, "Name");

                                // 07/13/2006 Paul.  The ReportViewer is having a problem interpreting the date functions.
                                // To solve the problem, we should go through all the parameters and replace the date functions with values.
                                rdl.ReportViewerFixups();
                                StringReader sr = new StringReader(rdl.OuterXml);
                                rdlViewer.LocalReport.LoadReportDefinition(sr);
                                // 06/25/2006 Paul.  Refresh did not work, clear the data sources instead.
                                //rdlViewer.LocalReport.Refresh();
                                rdlViewer.DataBind();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = Utils.ExpandException(ex);
            }
        }