Пример #1
0
        private void cargarLista(ListBox lista, string nombreTabla)
        {
            lstProductos.Items.Clear();
            cont = 0;
            oDato.leerTabla("Producto");
            //SE LEE EL OBJETO DATAREADER PARA CARGAR EN EL ARREGLO
            while (oDato.pLector.Read())
            {
                aProd[cont] = new Producto();
                if (!oDato.pLector.IsDBNull(0))
                {
                    aProd[cont].pIdProducto = oDato.pLector.GetInt32(0);
                }
                if (!oDato.pLector.IsDBNull(1))
                {
                    aProd[cont].pIdMarca = oDato.pLector.GetInt32(1);
                }
                if (!oDato.pLector.IsDBNull(2))
                {
                    aProd[cont].pNomProducto = oDato.pLector.GetString(2);
                }
                if (!oDato.pLector.IsDBNull(3))
                {
                    aProd[cont].pPrecio_unitario = oDato.pLector.GetDouble(3);
                }
                if (!oDato.pLector.IsDBNull(4))
                {
                    aProd[cont].pStock = oDato.pLector.GetInt32(4);
                }
                if (!oDato.pLector.IsDBNull(5))
                {
                    aProd[cont].pActivo = oDato.pLector.GetBoolean(5);
                }
                cont++;
            }
            //MUY IMPORTANTE!! CERRAR LA CONEXION QUE EL DATA READER MANTUVO ABIERTA
            oDato.pLector.Close();
            oDato.desconectar();

            //CARGAMOS LISTA CON LOS OBJETOS DEL ARREGLO
            for (int i = 0; i < cont; i++)
            {
                lstProductos.Items.Add(aProd[i].ToString());
            }
        }
Пример #2
0
        private void cargarLista(string nombreTabla)
        {
            c = 0;
            lstCliente.Items.Clear();
            oDato.leerTabla(nombreTabla);
            while (oDato.pLector.Read())
            {
                Cliente C = new Cliente();
                if (!oDato.pLector.IsDBNull(0))
                {
                    C.pIdCliente = oDato.pLector.GetInt32(0);
                }
                if (!oDato.pLector.IsDBNull(1))
                {
                    C.pApellido = oDato.pLector.GetString(1);
                }
                if (!oDato.pLector.IsDBNull(2))
                {
                    C.pNombre = oDato.pLector.GetString(2);
                }
                if (!oDato.pLector.IsDBNull(3))
                {
                    C.pDireccion = oDato.pLector.GetString(3);
                }
                if (!oDato.pLector.IsDBNull(4))
                {
                    C.pTelFijo = oDato.pLector.GetString(4);
                }
                if (!oDato.pLector.IsDBNull(5))
                {
                    C.pTelCel = oDato.pLector.GetString(5);
                }
                if (!oDato.pLector.IsDBNull(6))
                {
                    C.pCorreo = oDato.pLector.GetString(6);
                }
                if (!oDato.pLector.IsDBNull(7))
                {
                    C.pTipoDoc = oDato.pLector.GetInt32(7);
                }
                if (!oDato.pLector.IsDBNull(8))
                {
                    C.pNroDoc = oDato.pLector.GetString(8);
                }
                if (!oDato.pLector.IsDBNull(9))
                {
                    C.pSexo = oDato.pLector.GetInt32(9);
                }
                if (!oDato.pLector.IsDBNull(10))
                {
                    C.pFechaNac = oDato.pLector.GetDateTime(10);
                }
                if (!oDato.pLector.IsDBNull(11))
                {
                    C.pEstado = oDato.pLector.GetBoolean(11);
                }
                ac[c] = C;
                c++;
            }
            oDato.pLector.Close();
            oDato.desconectar();

            for (int i = 0; i < c; i++)
            {
                lstCliente.Items.Add(ac[i].ToString());
            }
            lstCliente.SelectedIndex = -1;
        }
Пример #3
0
        private void cargarLista(string nombreTabla)
        {
            c = 0;
            lstMascotas.Items.Clear();
            adm.leerTabla(nombreTabla);
            while (adm.pLector.Read())
            {
                //Creamos un objeto Mascota
                Mascota m = new Mascota();
                if (!adm.pLector.IsDBNull(0))
                {
                    m.pIdMascota = adm.pLector.GetInt32(0);
                }
                if (!adm.pLector.IsDBNull(1))
                {
                    m.pIdCliente = adm.pLector.GetInt32(1);
                }
                if (!adm.pLector.IsDBNull(2))
                {
                    m.pNombre = adm.pLector.GetString(2);
                }
                if (!adm.pLector.IsDBNull(3))
                {
                    m.pTipoMascota = adm.pLector.GetInt32(3);
                }
                if (!adm.pLector.IsDBNull(4))
                {
                    m.pSexo = adm.pLector.GetBoolean(4);
                }
                if (!adm.pLector.IsDBNull(5))
                {
                    m.pRaza = adm.pLector.GetInt32(5);
                }
                if (!adm.pLector.IsDBNull(6))
                {
                    m.pFechaNac = adm.pLector.GetDateTime(6);
                }
                if (!adm.pLector.IsDBNull(7))
                {
                    m.pPeso = adm.pLector.GetInt32(7);
                }
                if (!adm.pLector.IsDBNull(8))
                {
                    m.pObservacion = adm.pLector.GetString(8);
                }
                if (!adm.pLector.IsDBNull(9))
                {
                    m.pEstado = adm.pLector.GetBoolean(9);
                }

                //Agregamos el objeto Mascota al arreglo de Mascotas
                masc[c] = m;
                c++;
            }
            adm.pLector.Close();
            adm.desconectar();

            //Cargamos el ListBox con el contenido del arreglo de Mascotas
            for (int i = 0; i < c; i++)
            {
                lstMascotas.Items.Add(masc[i].ToString());
            }
            lstMascotas.SelectedIndex = -1;
        }