public static List <clsProducto> Buscar_PorMarca(string parametroMarca)
        {
            List <clsProducto> x = new List <clsProducto>();

            SqlConnection conexion;

            conexion = new SqlConnection(mdlVariables.CadenaDeConexion);

            SqlCommand comando;

            comando             = new SqlCommand("usp_Producto_Buscar_PorMarca", conexion);
            comando.CommandType = System.Data.CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@parMarca", parametroMarca);
            conexion.Open();
            SqlDataReader contenedor;

            contenedor = comando.ExecuteReader();
            while (contenedor.Read() == true)
            {
                clsProducto MiObjeto;
                MiObjeto = new clsProducto(Convert.ToInt16(contenedor["IdProducto"]), contenedor["Nombre_Prod"].ToString(), contenedor["Marca_Prod"].ToString());

                if (contenedor["Descripccion_Prod"] != DBNull.Value)
                {
                    MiObjeto.DescripcionProd = contenedor["Descripcion_Prod"].ToString();
                }

                x.Add(MiObjeto);
            }
            conexion.Close();

            return(x);
        }
 private void btGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         clsProducto nuevoProducto;
         nuevoProducto = new clsProducto(txtNombre.Text, txtMarca.Text);
         nuevoProducto.DescripcionProd = txtDescripcion.Text;
         nuevoProducto.InsertarProducto();
         MessageBox.Show("Producto Registrado");
     }
     catch (Exception ErrorRegProd)
     {
         MessageBox.Show(ErrorRegProd.Message);
     }
 }
        public static List <clsProducto> Listar_Todos()
        {
            List <clsProducto> x        = new List <clsProducto>();
            SqlConnection      conexion = new SqlConnection(mdlVariables.CadenaDeConexion);
            SqlCommand         cmd      = new SqlCommand("usp_Producto_Listar_Todos", conexion);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            conexion.Open();
            SqlDataReader contenedor;

            contenedor = cmd.ExecuteReader();

            while (contenedor.Read() == true)
            {
                clsProducto MiObjeto;
                MiObjeto = new clsProducto(Convert.ToInt16(contenedor["IdProducto"]), contenedor["Nombre_Prod"].ToString(), contenedor["Marca_Prod"].ToString());

                x.Add(MiObjeto);
            }
            conexion.Close();
            return(x);
        }
Beispiel #4
0
 public clsPrecio(clsProducto parIdProducto, clsMedida parIdMedida, decimal parPrecio)
 {
     IdProducto = parIdProducto;
     IdMedida   = parIdMedida;
     Precio     = parPrecio;
 }