private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.txtMensajeError.Visible = false;
                List <Error> Errores = this.ValidarDatos();

                if (Errores.Count == 0)
                {
                    ReporteComprasCliente         Datos = this.ObtenerDatos();
                    Reporte_NegocioComprasCliente Neg   = new Reporte_NegocioComprasCliente();
                    int IDReporte = Neg.GenerarReporteComprasCliente(Comun.Conexion, Datos.FechaInicio, Datos.FechaFin, Datos.IDCliente, Comun.IDUsuario);
                    if (IDReporte > 0)
                    {
                        frmVerReporteComprasCliente VerReporte = new frmVerReporteComprasCliente(IDReporte);
                        VerReporte.ShowDialog();
                        VerReporte.Dispose();
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("Ocurrió un error al generar el reporte.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    this.MostrarMensajeError(Errores);
                }
            }
            catch (Exception ex)
            {
                LogError.AddExcFileTxt(ex, "frmNuevoReporteComprasCliente ~ btnGuardar_Click");
                MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
 private void LlenarGrid()
 {
     try
     {
         Reporte_NegocioComprasCliente Neg   = new Reporte_NegocioComprasCliente();
         List <ReporteComprasCliente>  Lista = Neg.ObtenerReporteComprasCliente(Comun.Conexion, this.Fecha);
         this.dgvReporteComprasCliente.AutoGenerateColumns = false;
         this.dgvReporteComprasCliente.DataSource          = Lista;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void GenerarReporteComprasCliente()
        {
            try
            {
                reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                reportViewer1.ZoomMode    = ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
                reportViewer1.LocalReport.DataSources.Clear();
                Reporte_NegocioComprasCliente Neg          = new Reporte_NegocioComprasCliente();
                ReporteComprasCliente         DatosReporte = Neg.ObtenerDetalleReporteComprasCliente(Comun.Conexion, IDReporte);

                reportViewer1.LocalReport.EnableExternalImages = true;
                ReportParameter[] Parametros = new ReportParameter[9];
                Parametros[0] = new ReportParameter("Empresa", Comun.NombreComercial);
                Parametros[1] = new ReportParameter("Eslogan", Comun.Eslogan);
                Parametros[2] = new ReportParameter("Direccion", Comun.Direccion);
                Parametros[3] = new ReportParameter("TituloReporte", "REPORTE DE VISITAS DE CLIENTE");
                if (File.Exists(@"Resources\Documents\" + Comun.UrlLogo.ToLower()))
                {
                    string Aux = new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo.ToLower())).AbsoluteUri;
                    Parametros[4] = new ReportParameter("UrlLogo", new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo.ToLower())).AbsoluteUri);
                }
                else
                {
                    Parametros[4] = new ReportParameter("UrlLogo", new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\Default.jpg")).AbsoluteUri);
                }
                Parametros[5] = new ReportParameter("FechaInicio", DatosReporte.FechaInicio.ToShortDateString());
                Parametros[6] = new ReportParameter("FechaFin", DatosReporte.FechaFin.ToShortDateString());
                Parametros[7] = new ReportParameter("IDCliente", DatosReporte.IDCliente);

                Parametros[8] = new ReportParameter("NombreCliente", DatosReporte.Nombre);
                this.reportViewer1.LocalReport.ReportEmbeddedResource = "StephManager.Informes.Reportes.ComprasCliente.rdlc";
                reportViewer1.LocalReport.SetParameters(Parametros);
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ReporteComprasCliente", DatosReporte.Detalle));
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }