コード例 #1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         this.txtMensajeError.Visible = false;
         List <Error> Errores = this.ValidarDatos();
         if (Errores.Count == 0)
         {
             ReporteProductosVendidos Datos = this.ObtenerDatos();
             Reporte_Negocio          Neg   = new Reporte_Negocio();
             int IDReporte = Neg.GenerarReporteProductosVendidos(Comun.Conexion, Datos.FechaInicio, Datos.FechaFin, Comun.IDUsuario);
             if (IDReporte > 0)
             {
                 //Generar el reporte
                 frmVerReporteProductosVendidos VerReporte = new frmVerReporteProductosVendidos(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, "frmNuevoReporteProductosVendidos ~ btnGuardar_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 private ReporteProductosVendidos ObtenerDatos()
 {
     try
     {
         ReporteProductosVendidos DatosAux = new ReporteProductosVendidos();
         DatosAux.FechaInicio = dtpFechaInicio.Value;
         DatosAux.FechaFin    = dtpFechaFin.Value;
         return(DatosAux);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
        /// <summary>
        /// Obtiene el detalle del reporte de productos vendidos por ID
        /// </summary>
        /// <param name="Conexion"></param>
        /// <param name="IDReporte"></param>
        /// <returns></returns>
        public ReporteProductosVendidos ObtenerDetalleReporteProductosVendidos(string Conexion, int IDReporte)
        {
            try
            {
                ReporteProductosVendidos Resultado = new ReporteProductosVendidos();
                DataSet Ds = SqlHelper.ExecuteDataset(Conexion, "Reportes.spCSLDB_get_ReporteProductosVendidosXID", 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 <ReporteProductosVendidosDetalle> Lista = new List <ReporteProductosVendidosDetalle>();
                        ReporteProductosVendidosDetalle        Item;
                        DataTableReader Dr2 = Ds.Tables[1].CreateDataReader();
                        while (Dr2.Read())
                        {
                            Item            = new ReporteProductosVendidosDetalle();
                            Item.IDSucursal = !Dr2.IsDBNull(Dr2.GetOrdinal("IDSucursal")) ? Dr2.GetString(Dr2.GetOrdinal("IDSucursal")) : string.Empty;
                            Item.Sucursal   = !Dr2.IsDBNull(Dr2.GetOrdinal("Sucursal")) ? Dr2.GetString(Dr2.GetOrdinal("Sucursal")) : string.Empty;
                            Item.IDProducto = !Dr2.IsDBNull(Dr2.GetOrdinal("IDProducto")) ? Dr2.GetString(Dr2.GetOrdinal("IDProducto")) : string.Empty;
                            Item.Clave      = !Dr2.IsDBNull(Dr2.GetOrdinal("Clave")) ? Dr2.GetString(Dr2.GetOrdinal("Clave")) : string.Empty;
                            Item.Producto   = !Dr2.IsDBNull(Dr2.GetOrdinal("Producto")) ? Dr2.GetString(Dr2.GetOrdinal("Producto")) : string.Empty;
                            Item.Cantidad   = !Dr2.IsDBNull(Dr2.GetOrdinal("Cantidad")) ? Dr2.GetDecimal(Dr2.GetOrdinal("Cantidad")) : 0;
                            Lista.Add(Item);
                        }
                        Dr2.Close();

                        Resultado.Detalle  = Lista;
                        Resultado.Completo = true;
                    }
                }
                return(Resultado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
 private void btnImpresion_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.dgvReportesProductosVendidos.SelectedRows.Count == 1)
         {
             ReporteProductosVendidos       Datos      = this.ObtenerDatosReporte();
             frmVerReporteProductosVendidos VerReporte = new frmVerReporteProductosVendidos(Datos.IDReporte);
             VerReporte.ShowDialog();
             VerReporte.Dispose();
         }
         else
         {
             MessageBox.Show("Seleccione una fila.", Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         LogError.AddExcFileTxt(ex, "frmReportesProductosVendidos ~ btnImpresion_Click");
         MessageBox.Show(Comun.MensajeError, Comun.Sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #5
0
 /// <summary>
 /// Obtiene el reporte de productos vendidos
 /// </summary>
 /// <param name="Conexion"></param>
 /// <param name="Fecha"></param>
 /// <returns></returns>
 public List <ReporteProductosVendidos> ObtenerReportesProductosVendidos(string Conexion, DateTime Fecha)
 {
     try
     {
         List <ReporteProductosVendidos> Lista = new List <ReporteProductosVendidos>();
         ReporteProductosVendidos        Item;
         SqlDataReader Dr = SqlHelper.ExecuteReader(Conexion, "Reportes.spCSLDB_get_ReportesProductosVendidos", Fecha);
         while (Dr.Read())
         {
             Item             = new ReporteProductosVendidos();
             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;
     }
 }
コード例 #6
0
 private void GenerarReporteProductosVendidos()
 {
     try
     {
         reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
         reportViewer1.ZoomMode    = ZoomMode.Percent;
         reportViewer1.ZoomPercent = 100;
         reportViewer1.LocalReport.DataSources.Clear();
         Reporte_Negocio          Neg          = new Reporte_Negocio();
         ReporteProductosVendidos DatosReporte = Neg.ObtenerDetalleReporteProductosVendidos(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 DE PRODUCTOS VENDIDOS");
         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.ProductosVendidos.rdlc";
         reportViewer1.LocalReport.SetParameters(Parametros);
         reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("ProductosVendidos", DatosReporte.Detalle));
         this.reportViewer1.RefreshReport();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #7
0
 private ReporteProductosVendidos ObtenerDatosReporte()
 {
     try
     {
         ReporteProductosVendidos DatosAux = new ReporteProductosVendidos();
         Int32 RowData = this.dgvReportesProductosVendidos.Rows.GetFirstRow(DataGridViewElementStates.Selected);
         if (RowData > -1)
         {
             int             ID        = 0;
             DataGridViewRow FilaDatos = this.dgvReportesProductosVendidos.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;
     }
 }