Beispiel #1
0
        public static void Eliminar(usuarios A)
        {
            SqlCommand cmd = new SqlCommand(string.Format("Delete from Articulo where idArticulo='{0}'"), cnx);

            try
            {
                cnx.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("Eliminado");
                cnx.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            { cnx.Close(); }
        }
Beispiel #2
0
        public static void Modificar(usuarios A)
        {
            SqlCommand cmd = new SqlCommand(string.Format("Update Articulo set Nombre='{0}', Precio='{1}' where idarticulo='{2}'"), cnx);

            try
            {
                cnx.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("Modificado");
                cnx.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            { cnx.Close(); }
        }
Beispiel #3
0
        public static void Insertar(usuarios A)
        {
            SqlCommand cmd = new SqlCommand(string.Format("insert into usuarios (id_usuario,nombre,apellido,usuario,contraseña,tipo_usuario ) values ('{0}','{1}','{2}','{3}','{4}','{5}')", A.Id_usuario, A.Nombre, A.Apellido, A.Usuario, A.Contraseña, A.Tipo_usuario), cnx);

            try
            {
                cnx.Open();
                cmd.ExecuteNonQuery();
                MessageBox.Show("Registrado");
                cnx.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            { cnx.Close(); }
        }
Beispiel #4
0
        public static DataTable Buscar(usuarios A)
        {
            SqlCommand cmd = new SqlCommand(string.Format("select * from Articulo where nombre LIKE '%{0}%'", A.Nombre), cnx);

            try
            {
                cnx.Open();
                SqlDataAdapter DA = new SqlDataAdapter(cmd);
                D = new DataSet();
                DA.Fill(D, "Articulo");
                cnx.Close();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            { cnx.Close(); }

            return(D.Tables["Articulo"]);
        }