Example #1
0
        public DataTable getAllCategories()
        {
            string query = "Select * from categorias";

            cmd.CommandText = query;
            dt = function.queryCmd(cmd);
            return(dt);
        }
Example #2
0
        public string create()
        {
            string message;
            string query = @"INSERT INTO productos values(@nombre, @categoria_id, @precio, @stock)";

            cmd.Parameters.Clear();
            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@nombre", this.getNombre());
            cmd.Parameters.AddWithValue("@categoria_id", this.getCategoria_id());
            cmd.Parameters.AddWithValue("@precio", this.getPrecio());
            cmd.Parameters.AddWithValue("@stock", this.getStock());
            try
            {
                function.queryCmd(cmd);
                message = "SUCCESS";
            }
            catch
            {
                message = "ERROR";
            }
            return(message);
        }
Example #3
0
        public DataTable getUserById(int num, string nombre)
        {
            string     busqueda = @"Select * from Usuarios where numero_empleado = @num and nombre  = @nombre";
            SqlCommand cmd      = new SqlCommand();

            cmd.CommandText = busqueda;
            cmd.Parameters.AddWithValue("@num", num);
            cmd.Parameters.AddWithValue("@nombre", nombre);
            DataTable result = new DataTable();

            result = function.queryCmd(cmd);
            return(result);
        }
Example #4
0
        public int getId(string nombre)
        {
            Helpers.dbConection function = new Helpers.dbConection();
            int        id;
            string     query = @"select id from categorias where nombre = @catNombre";
            SqlCommand cmd   = new SqlCommand();
            DataTable  dt    = new DataTable();

            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@catNombre", nombre);
            dt = function.queryCmd(cmd);
            id = Int32.Parse(dt.Rows[0]["id"].ToString());
            return((int)id);
        }