Exemple #1
0
        private void FReporteInventario_Load(object sender, EventArgs e)
        {
            CDetallesInventario cDetalles = new CDetallesInventario();

            List <DetallesInventario> listado = new List <DetallesInventario>();

            ReportParameter[] p = new ReportParameter[3];
            CConfiguracion    cConfiguracion = new CConfiguracion();
            Configuracion     c = new Configuracion();

            c = cConfiguracion.ObtenerConfiguracion();
            string informacion = c.NombreEmpresa + " - " + c.Telefono;

            p[1] = new ReportParameter("informacion", informacion);
            p[2] = new ReportParameter("nombrenegocio", c.NombreEmpresa);

            if (tipo == 0)
            {
                p[0]    = new ReportParameter("tipo", "Todos los productos");
                listado = cDetalles.Listado(idinventario);
            }
            else if (tipo == 1)
            {
                p[0]    = new ReportParameter("tipo", "Productos propios");
                listado = cDetalles.ListadoPropio(idinventario);
            }
            else
            {
                p[0]    = new ReportParameter("tipo", "Productos en consignacion");
                listado = cDetalles.ListadoConsignacion(idinventario);
            }

            ReportDataSource rds = new ReportDataSource();

            rds.Name  = "Listado";
            rds.Value = listado;

            this.reportViewer1.LocalReport.DataSources.Add(rds);
            this.reportViewer1.LocalReport.SetParameters(p);
            this.reportViewer1.RefreshReport();

            this.reportViewer1.RefreshReport();
        }
Exemple #2
0
        public int Insertar(Venta venta, List <ProductoPOS> detalles)
        {
            string            consulta   = "insert into Ventas values (@Fecha,@IdCliente_FK,@IdEmpleado_FK,@TipoDocumento,@Correlativo,@IdCorrelativo_FK,@Total,@Efectivo,@Cambio)";
            DynamicParameters parametros = new DynamicParameters();
            int idventa;

            parametros.Add("@Fecha", venta.Fecha, DbType.DateTime);
            parametros.Add("@IdCliente_FK", venta.IdCliente_FK, DbType.Int32);
            parametros.Add("@IdEmpleado_FK", venta.IdEmpleado_FK, DbType.Int32);
            parametros.Add("@TipoDocumento", venta.TipoDocumento, DbType.Int32);
            parametros.Add("@Correlativo", venta.Correlativo, DbType.Int64);
            parametros.Add("@IdCorrelativo_FK", venta.IdCorrelativo_FK, DbType.Int32);
            parametros.Add("@Total", venta.Total, DbType.Decimal);
            parametros.Add("@Efectivo", venta.Efectivo, DbType.Decimal);
            parametros.Add("@Cambio", venta.Cambio, DbType.Decimal);
            cn.Open();
            cn.Execute(consulta, parametros, commandType: CommandType.Text);
            idventa = cn.QuerySingle <int>("Select max(IdVenta) id from ventas", commandType: CommandType.Text);
            cn.Close();

            CCorrelativo correlativo = new CCorrelativo();

            correlativo.ActualizarCorrelativo(venta.IdCorrelativo_FK);

            CDetallesVenta      detalle    = new CDetallesVenta();
            CDetallesInventario inventario = new CDetallesInventario();

            foreach (ProductoPOS p in detalles)
            {
                DetallesVenta det = new DetallesVenta();
                det.Cantidad = p.Cantidad;
                det.IdDetalleInventario_FK = p.IdDetalleInventario;
                det.IdVenta_FK             = idventa;
                det.PrecioVenta            = p.Precio;

                detalle.Insertar(det);

                inventario.disminuirExistencias(det.IdDetalleInventario_FK, det.Cantidad.Value);
            }
            return(idventa);
        }