private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         this.txtMensajeError.Visible = false;
         List <Error> Errores = this.ValidarDatos();
         if (Errores.Count == 0)
         {
             ReporteMonedero         Datos = this.ObtenerDatos();
             Reporte_NegocioMonedero Neg   = new Reporte_NegocioMonedero();
             int IDReporte = Neg.GenerarReporteMonedero(Comun.Conexion, Datos.FechaInicio, Datos.FechaFin, Comun.IDUsuario);
             if (IDReporte > 0)
             {
                 frmVerReporteMonedero VerReporte = new frmVerReporteMonedero(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, "frmNuevoReporteMonedero ~ btnGuardar_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
        private ReporteMonedero ObtenerDatosReporte()
        {
            try
            {
                ReporteMonedero DatosAux = new ReporteMonedero();
                Int32           RowData  = this.dgvReportesTrabajosRealizados.Rows.GetFirstRow(DataGridViewElementStates.Selected);
                if (RowData > -1)
                {
                    int             ID        = 0;
                    DataGridViewRow FilaDatos = this.dgvReportesTrabajosRealizados.Rows[RowData];
                    int.TryParse(FilaDatos.Cells["IDReporte"].Value.ToString(), out ID);
                    DatosAux.IDReporte = ID;

                    DateTime FechaInicio = DateTime.MinValue;
                    DateTime FechaFin    = DateTime.MinValue;
                    DateTime.TryParse(FilaDatos.Cells["FechaInicio"].Value.ToString(), out FechaInicio);
                    DateTime.TryParse(FilaDatos.Cells["FechaFin"].Value.ToString(), out FechaFin);
                }
                return(DatosAux);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private ReporteMonedero ObtenerDatos()
 {
     try
     {
         ReporteMonedero DatosAux = new ReporteMonedero();
         DatosAux.FechaInicio = dtpFechaInicio.Value;
         DatosAux.FechaFin    = dtpFechaFin.Value;
         return(DatosAux);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// Método para obtener el detalle de los trabajos realizados
        /// </summary>
        /// <param name="Conexion">Cadena de conexión a la BD</param>
        /// <param name="IDReporte">ID del Reporte al que se quiere acceder</param>
        /// <returns>Retorna una lista con el detalle del trabajo realizado seleccionado.</returns>
        public ReporteMonedero ObtenerDetalleReporteMonedero(string Conexion, int IDReporte)
        {
            try
            {
                ReporteMonedero Resultado = new ReporteMonedero();
                DataSet         Ds        = SqlHelper.ExecuteDataset(Conexion, "Reportes.spCSLDB_get_ReporteMonederoXID", IDReporte);
                if (Ds != null)
                {
                    if (Ds.Tables.Count == 2)
                    {
                        DataTableReader Dr = Ds.Tables[0].CreateDataReader();
                        while (Dr.Read())
                        {
                            Resultado.FechaInicio = !Dr.IsDBNull(Dr.GetOrdinal("FechaInicio")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaInicio")) : DateTime.MinValue;
                            Resultado.FechaFin    = !Dr.IsDBNull(Dr.GetOrdinal("FechaFin")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaFin")) : DateTime.MinValue;
                            break;
                        }
                        Dr.Close();

                        List <ReporteMonederoDetalle> Lista = new List <ReporteMonederoDetalle>();
                        ReporteMonederoDetalle        Item;
                        DataTableReader Dr2 = Ds.Tables[1].CreateDataReader();
                        while (Dr2.Read())
                        {
                            Item = new ReporteMonederoDetalle();
                            Item.IDTransaccion = !Dr2.IsDBNull(Dr2.GetOrdinal("IDTransaccion")) ? Dr2.GetInt32(Dr2.GetOrdinal("IDTransaccion")) : 0;
                            Item.Descripcion   = !Dr2.IsDBNull(Dr2.GetOrdinal("Descripcion")) ? Dr2.GetString(Dr2.GetOrdinal("Descripcion")) : string.Empty;
                            Item.Resta         = !Dr2.IsDBNull(Dr2.GetOrdinal("Resta")) ? Dr2.GetBoolean(Dr2.GetOrdinal("Resta")) : false;
                            Item.Monto         = !Dr2.IsDBNull(Dr2.GetOrdinal("Monto")) ? Dr2.GetDecimal(Dr2.GetOrdinal("Monto")) : 0;
                            Lista.Add(Item);
                        }
                        Dr2.Close();

                        Resultado.Detalle  = Lista;
                        Resultado.Completo = true;
                    }
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
 private void btnImpresion_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvReportesTrabajosRealizados.SelectedRows.Count == 1)
         {
             ReporteMonedero       Datos      = this.ObtenerDatosReporte();
             frmVerReporteMonedero VerReporte = new frmVerReporteMonedero(Datos.IDReporte);
             VerReporte.ShowDialog();
             VerReporte.Dispose();
         }
         else
         {
             MessageBox.Show("Seleccione una fila.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmReporteMonedero ~ btnImpresion_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 /// <summary>
 /// Método para obtener los trabajos realizados
 /// </summary>
 /// <param name="Conexion">Cadena de conexión a la BD</param>
 /// <param name="Fecha">Filtro para buscar los reportes realizados entre dos fechas</param>
 /// <returns>Retorna una lista con el IDReporte, la fecha de Inicio y la fecha de termino</returns>
 public List <ReporteMonedero> ObtenerReporteMonedero(string Conexion, DateTime Fecha)
 {
     try
     {
         List <ReporteMonedero> Lista = new List <ReporteMonedero>();
         ReporteMonedero        Item;
         SqlDataReader          Dr = SqlHelper.ExecuteReader(Conexion, "Reportes.spCSLDB_get_ReporteMonedero", Fecha);
         while (Dr.Read())
         {
             Item             = new ReporteMonedero();
             Item.IDReporte   = !Dr.IsDBNull(Dr.GetOrdinal("IDReporte")) ? Dr.GetInt32(Dr.GetOrdinal("IDReporte")) : 0;
             Item.FechaInicio = !Dr.IsDBNull(Dr.GetOrdinal("FechaInicio")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaInicio")) : DateTime.MinValue;
             Item.FechaFin    = !Dr.IsDBNull(Dr.GetOrdinal("FechaFin")) ? Dr.GetDateTime(Dr.GetOrdinal("FechaFin")) : DateTime.MinValue;
             Lista.Add(Item);
         }
         Dr.Close();
         return(Lista);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #7
0
 private void GenerarReporteMonedero()
 {
     try
     {
         reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
         reportViewer1.ZoomMode    = ZoomMode.Percent;
         reportViewer1.ZoomPercent = 100;
         reportViewer1.LocalReport.DataSources.Clear();
         Reporte_NegocioMonedero Neg          = new Reporte_NegocioMonedero();
         ReporteMonedero         DatosReporte = Neg.ObtenerDetalleReporteMonedero(Comun.Conexion, IDReporte);
         reportViewer1.LocalReport.EnableExternalImages = true;
         ReportParameter[] Parametros = new ReportParameter[7];
         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 MONEDERO");
         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());
         this.reportViewer1.LocalReport.ReportEmbeddedResource = "StephManager.Informes.Reportes.Monedero.rdlc";
         reportViewer1.LocalReport.SetParameters(Parametros);
         reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ReporteMonedero", DatosReporte.Detalle));
         this.reportViewer1.RefreshReport();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }