private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         this.txtMensajeError.Visible = false;
         List <Error> Errores = this.ValidarDatos();
         if (Errores.Count == 0)
         {
             ReporteConsumoMaterial         Datos = this.ObtenerDatos();
             ReporteConsumoMaterial_Negocio Neg   = new ReporteConsumoMaterial_Negocio();
             int IDReporte = Neg.GenerarReporteConsumoMaterial(Comun.Conexion, Datos.FechaInicio, Datos.FechaFin, Comun.IDUsuario, id_sucursal);
             if (IDReporte > 0)
             {
                 //Generar el reporte
                 frmVerReporteConsumoMaterial VerReporte = new frmVerReporteConsumoMaterial(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, "frmNuevoReporte ~ btnGuardar_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void LlenarGrid()
 {
     try
     {
         ReporteConsumoMaterial_Negocio Neg   = new ReporteConsumoMaterial_Negocio();
         List <ReporteConsumoMaterial>  Lista = Neg.ObtenerReportesConsumoMaterial(Comun.Conexion);//Neg.ObtenerReporteGarantias(Comun.Conexion);
         this.GridViewGeneral.AutoGenerateColumns = false;
         this.GridViewGeneral.DataSource          = Lista;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     try
     {
         DateTime Fecha;
         Fecha = dtpFecha.Value;
         ReporteConsumoMaterial_Negocio Neg   = new ReporteConsumoMaterial_Negocio();
         List <ReporteConsumoMaterial>  Lista = Neg.BuscarReportesConsumoMaterial(Comun.Conexion, Fecha);//Neg.ObtenerReporteGarantias(Comun.Conexion);
         this.GridViewGeneral.AutoGenerateColumns = false;
         this.GridViewGeneral.DataSource          = Lista;
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmReportesConsumoMaterial ~ btnBuscar_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void GenerarGarantias()
        {
            try
            {
                reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                reportViewer1.ZoomMode    = ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
                reportViewer1.LocalReport.DataSources.Clear();

                ReporteConsumoMaterial_Negocio repNeg = new ReporteConsumoMaterial_Negocio();
                ReporteConsumoMaterial         Lista  = repNeg.ObtenerDetalleReporteConsumoMaterial(Comun.Conexion.ToString(), IDReporte);
                foreach (ReporteConsumoMaterialDetalle Item in Lista.Detalle)
                {
                    Item.ImagenMetrica = Item.CumpleMetrica ? new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Apply.png")).AbsoluteUri : new Uri(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\descarga.png")).AbsoluteUri;
                }
                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 CONSUMO DE MATERIAL POR PERIODO");
                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", Lista.FechaInicio.ToShortDateString());
                Parametros[6] = new ReportParameter("FechaFin", Lista.FechaFin.ToShortDateString());
                Parametros[7] = new ReportParameter("Sucursal", Lista.Sucursal);
                this.reportViewer1.LocalReport.ReportEmbeddedResource = "StephManager.Informes.Reportes.ConsumoMaterial.rdlc";
                reportViewer1.LocalReport.SetParameters(Parametros);
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ConsumoMaterial", Lista.Detalle));
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void IniciarForm()
 {
     try
     {
         ReporteConsumoMaterial_Negocio PN = new ReporteConsumoMaterial_Negocio();
         this.dtpFechaInicio.Value            = DateTime.Today;
         this.dtpFechaFin.Value               = DateTime.Today;
         this.cmbTipoMobiliario.DataSource    = PN.ObtenerSucursales(Comun.Conexion);
         this.cmbTipoMobiliario.DisplayMember = "Sucursal";
         this.cmbTipoMobiliario.ValueMember   = "id_sucursal";
         this.ActiveControl = this.dtpFechaInicio;
         this.dtpFechaInicio.Focus();
         if (File.Exists(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo)))
         {
             this.pictureBox1.Image = Image.FromFile(Path.Combine(System.Windows.Forms.Application.StartupPath, @"Resources\Documents\" + Comun.UrlLogo));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }