private void LlenarGrid()
 {
     try
     {
         ReporteVentasXSucursal_Negocio Neg   = new ReporteVentasXSucursal_Negocio();
         List <ReportesVentaXSucursal>  Lista = Neg.ObtenerReporteVentasXSucursal(Comun.Conexion, this.Fecha);
         this.dgvReporteVentasXSucursal.AutoGenerateColumns = false;
         this.dgvReporteVentasXSucursal.DataSource          = Lista;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void GenerarReporteVentasXSucursal()
 {
     try
     {
         reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
         reportViewer1.ZoomMode    = ZoomMode.Percent;
         reportViewer1.ZoomPercent = 100;
         reportViewer1.LocalReport.DataSources.Clear();
         ReporteVentasXSucursal_Negocio Neg1         = new ReporteVentasXSucursal_Negocio();
         ReportesVentaXSucursal         DatosReporte = Neg1.ObtenerDetalleReporteVentasXSucursal(Comun.Conexion, IDReporte);
         reportViewer1.LocalReport.EnableExternalImages = true;
         ReportParameter[] Parametros = new ReportParameter[8];
         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 VENTAS POR SUCURSAL");
         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("Sucursal", DatosReporte.NombreSucursal);
         this.reportViewer1.LocalReport.ReportEmbeddedResource = "StephManager.Informes.Reportes.VentasXSucursal.rdlc";
         reportViewer1.LocalReport.SetParameters(Parametros);
         reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", DatosReporte.Detalle2));
         reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", DatosReporte.Detalle1));
         this.reportViewer1.RefreshReport();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.txtMensajeError.Visible = false;
                List <Error> Errores = this.ValidarDatos();

                if (Errores.Count == 0)
                {
                    ReportesVentaXSucursal         Datos = this.ObtenerDatos();
                    ReporteVentasXSucursal_Negocio Neg   = new ReporteVentasXSucursal_Negocio();

                    int IDReporte = Neg.GenerarReporteVentasXSucursal(Comun.Conexion, Datos.FechaInicio, Datos.FechaFin, Comun.IDUsuario, Datos.IDSucursal);
                    //IDReporte = Neg.GenerarReporteVentasXSucursalXFormasPago (Comun.Conexion, Datos.FechaInicio, Datos.FechaFin, IDReporte , Datos.IDSucursal);

                    if (IDReporte > 0)
                    {
                        frmVerReporteVentasXSucursal VerReporte = new frmVerReporteVentasXSucursal(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, "frmNuevoReporteVentasXSucursal ~ btnGuardar_Click");
                MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }