Ejemplo n.º 1
0
        public List <Product> ConsulProductsEnabled()
        {
            List <Product> products = new List <Product>();
            string         query    = "Call CompararProducto()";

            DBConection connection = new DBConection();


            connection.Connection().Open();

            MySqlDataAdapter commandDatabase = new MySqlDataAdapter(query, connection.Connection());

            DataSet dataSet = new DataSet();

            commandDatabase.Fill(dataSet, "Product");

            foreach (DataTable tabla in dataSet.Tables)
            {
                foreach (DataRow dr in tabla.Rows)
                {
                    Product product = new Product(dr.ItemArray[0].ToString(), Convert.ToInt32(dr.ItemArray[1].ToString()));

                    products.Add(product);
                }
            }

            connection.Connection().Close();
            return(products);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Metodo encargado de consultar a la base de datos los usuarios
        /// </summary>
        /// <returns>Lista de usuarios</returns>
        ///
        public List <User> ConsultUsersList()
        {
            List <User> users = new List <User>();

            string query = "Call ConsultarListaUsuarios()";

            DBConection connection = new DBConection();


            connection.Connection().Open();

            MySqlDataAdapter commandDatabase = new MySqlDataAdapter(query, connection.Connection());

            DataSet dataSet = new DataSet();

            commandDatabase.Fill(dataSet, "User");

            foreach (DataTable tabla in dataSet.Tables)
            {
                foreach (DataRow dr in tabla.Rows)
                {
                    User user = new User(Int32.Parse(dr.ItemArray[0].ToString()), dr.ItemArray[1].ToString(), dr.ItemArray[2].ToString(), dr.ItemArray[3].ToString(), dr.ItemArray[4].ToString(), dr.ItemArray[5].ToString());

                    users.Add(user);
                }
            }

            connection.Connection().Close();

            return(users);
        }