Пример #1
0
        private void CargarTablaDetalleFacturas(int idFactura, string criterio)
        {
            try
            {
                var dt   = new DataTable();
                var rows = objDeF.ConsultarPorIdFactura(-1, "");
                gvwDetalleFactura.DataSource = null;
                gvwDetalleFactura.DataBind();
                if (idFactura != -1)
                {
                    rows = objDeF.ConsultarPorIdFactura(idFactura, criterio);
                }

                //dt.Columns.Add("idFactura", typeof(System.String));
                dt.Columns.Add("idProducto", typeof(System.String));
                dt.Columns.Add("codProducto", typeof(System.String));
                dt.Columns.Add("CantidadProducto", typeof(System.String));
                dt.Columns.Add("Regresado", typeof(System.String));

                foreach (Vista_ProductosPorDetalleFactura r in rows)
                {
                    // Crear una fila por cada unidad del producto.
                    int cantidadDeProductos = r.CantidadProducto;
                    int cantidadDeDevueltos = r.CantidadDevuelta;

                    for (int i = 0; i < cantidadDeProductos; i++)
                    {
                        var tempCategoria = new CAT_CATEGORIA();

                        tempCategoria.idCategoria = r.IdCategoria;
                        tempCategoria             = objCat.ConsultarPorIdCategoria(tempCategoria);
                        // Crear la fila, asignar valores y agregarla.
                        DataRow fila = dt.NewRow();
                        //fila["idFactura"] = r.idFactura;
                        fila["idProducto"] = r.NombreProducto + ", " + tempCategoria.Nombre;

                        fila["codProducto"] = r.CodigoNumerico;
                        // La catidad siempre va ser 1.
                        fila["CantidadProducto"] = "1";
                        // Ver si esta marcado.
                        if (cantidadDeDevueltos > 0)
                        {
                            fila["Regresado"] = "true";
                            cantidadDeDevueltos--;
                        }
                        else
                        {
                            fila["Regresado"] = "false";
                        }
                        dt.Rows.Add(fila);
                    }
                }
                gvwDetalleFactura.DataSource = dt;
                gvwDetalleFactura.DataBind();
            }
            catch (Exception ex)
            {
                var err = ex.Message;
            }
        }
Пример #2
0
        private void CargarTablaFacturas(string criterio)
        {
            try
            {
                var dt   = new DataTable();
                var rows = objFact.ConsultarPorNoFactura(criterio);

                dt.Columns.Add("idFactura", typeof(System.String));
                dt.Columns.Add("NoFactura", typeof(System.String));
                //dt.Columns.Add("CodTabla", typeof(System.String));
                dt.Columns.Add("montoFactura", typeof(System.String));
                dt.Columns.Add("estado", typeof(System.String));
                dt.Columns.Add("totalPiezas", typeof(System.String));
                dt.Columns.Add("idCliente", typeof(System.String));
                dt.Columns.Add("idTipoMetal", typeof(System.String));
                dt.Columns.Add("nombreUsuario", typeof(System.String));
                //dt.Columns.Add("fechaCreacion", typeof(System.String));
                //dt.Columns.Add("fechaLiquidacion", typeof(System.String));

                foreach (FAC_FACTURA r in rows)
                {
                    var tempCliente   = new CLI_CLIENTES();
                    var tempCategoria = new CAT_CATEGORIA();
                    tempCliente.idCliente     = r.idCliente;
                    tempCliente               = objCli.ConsultarPorId(tempCliente).FirstOrDefault();
                    tempCategoria.idCategoria = r.idCategoriaMetal;
                    tempCategoria             = objCat.ConsultarPorIdCategoria(tempCategoria);

                    DataRow fila = dt.NewRow();

                    fila["idFactura"] = r.idFactura;
                    fila["NoFactura"] = r.NoFactura;
                    //fila["CodTabla"] = r.CodTabla;
                    fila["montoFactura"]  = r.montoFactura;
                    fila["estado"]        = EstadoFacturaEnLetras(r.estado);
                    fila["totalPiezas"]   = r.totalPiezas;
                    fila["idCliente"]     = tempCliente.NombreEncargado;
                    fila["idTipoMetal"]   = tempCategoria.Nombre;
                    fila["nombreUsuario"] = obtenerNombreUsuarioPorId(r.idUsuario);
                    //fila["fechaCreacion"] = r.fechaCreacion;
                    //fila["fechaLiquidacion"] = r.fechaLiquidacion;
                    dt.Rows.Add(fila);
                }
                gvwFacturas.DataSource = dt;
                gvwFacturas.DataBind();
            }
            catch (Exception ex)
            {
                var err = ex.Message;
            }
        }