Esempio n. 1
0
        private void mostrarProductos()
        {
            int id_cata;

            int.TryParse(txt_idcata.Text, out id_cata);
            l_mensajes.Text = string.Empty;
            ControladorDetalleCata cdc = new ControladorDetalleCata();
            int estado = cdc.ConsultarTodosLosProductos(id_cata);

            switch (estado)
            {
            case 1:
                dgvDetalleCata.Rows.Clear();
                DetalleCata        dc = new DetalleCata();
                List <DetalleCata> listaLosProductos = new List <DetalleCata>();
                listaLosProductos = cdc.obtenerDatostodasProducto();
                for (int c = 0; c < listaLosProductos.Count; c++)
                {
                    object[] registroPrCata = new object[11];
                    registroPrCata[0]  = listaLosProductos[c].Cata.IdCata;
                    registroPrCata[1]  = listaLosProductos[c].Cata.FechaCata;
                    registroPrCata[2]  = listaLosProductos[c].Cata.NombreCata;
                    registroPrCata[3]  = listaLosProductos[c].IdDetalleCata;
                    registroPrCata[4]  = listaLosProductos[c].Producto.IdProd;
                    registroPrCata[5]  = listaLosProductos[c].Producto.NomProd;
                    registroPrCata[6]  = listaLosProductos[c].Producto.Origen;
                    registroPrCata[7]  = listaLosProductos[c].Producto.Porcentaje;
                    registroPrCata[8]  = listaLosProductos[c].Producto.Aroma;
                    registroPrCata[9]  = listaLosProductos[c].Producto.Inclusion;
                    registroPrCata[10] = listaLosProductos[c].Producto.Chocolatero;
                    dgvDetalleCata.Rows.Add(registroPrCata);
                }
                break;

            default:
                l_mensajes.Text = "NO existe Conexión BD. Contacte a ...";
                break;
            }
        }
Esempio n. 2
0
        public int ConsultarTodosLosProductos(int idcata)
        {
            int estado = 2;

            try
            {
                conexion = new SqlConnection(cadenaConexion);
                if (tieneConexion().Equals("OkConexion"))
                {
                    DateTime fechaCata;
                    string   nombreCata;
                    int      idDetalleCata;
                    int      idProd;
                    string   nomProd;
                    string   origen;
                    int      porcentaje;
                    string   aroma;
                    string   inclusion;
                    string   chocolatero;
                    listaLosProductos.Clear();

                    conexion.Open();

                    comando = new SqlCommand("sp_ConsultaDetalleCata", conexion);
                    comando.Parameters.AddWithValue("@id_cata", idcata);
                    comando.CommandType = CommandType.StoredProcedure;
                    lector = comando.ExecuteReader();
                    while (lector.Read())
                    {
                        idcata        = lector.GetInt32(0);
                        fechaCata     = lector.GetDateTime(1);
                        nombreCata    = lector.GetString(2);
                        idDetalleCata = lector.GetInt32(3);
                        idProd        = lector.GetInt32(4);
                        nomProd       = lector.GetString(5);
                        origen        = lector.GetString(6);
                        porcentaje    = lector.GetInt32(7);
                        aroma         = lector.GetString(8);
                        inclusion     = lector.GetString(9);
                        chocolatero   = lector.GetString(10);
                        DetalleCata dc = new DetalleCata();
                        dc.Cata.IdCata          = idcata;
                        dc.Cata.FechaCata       = fechaCata;
                        dc.Cata.NombreCata      = nombreCata;
                        dc.IdDetalleCata        = idDetalleCata;
                        dc.Producto.IdProd      = idProd;
                        dc.Producto.NomProd     = nomProd;
                        dc.Producto.Origen      = origen;
                        dc.Producto.Porcentaje  = porcentaje;
                        dc.Producto.Aroma       = aroma;
                        dc.Producto.Inclusion   = inclusion;
                        dc.Producto.Chocolatero = chocolatero;
                        listaLosProductos.Add(dc);
                    }
                    return(1);
                }
                else
                {
                    return(estado);
                }
            }
            catch (Exception e)
            {
                return(3);
            }
            finally
            {
                conexion.Close();
            }
        }