示例#1
0
        public void actualizar(MCargo obj)
        {
            conexion();
            string       query = "UPDATE cargo SET cargo= '" + obj.cargo + "' WHERE pk_cargo = '" + obj.pk_cargo + "'";
            MySqlCommand cmd   = new MySqlCommand(query, con);

            cmd.ExecuteNonQuery();

            cmd.Dispose();
            con.Close();
        }
示例#2
0
        public MCargo insertar(MCargo obj)
        {
            conexion();
            string       query = "INSERT INTO cargo(cargo )VALUES('" + obj.cargo + "')";
            MySqlCommand cmd   = new MySqlCommand(query, con);

            cmd.ExecuteNonQuery();

            cmd.Dispose();
            con.Close();
            return(obj);
        }
示例#3
0
        public MCargo modificar(int pk)
        {
            conexion();
            string          query  = "SELECT * FROM cargo WHERE pk_cargo = '" + pk + "'";
            MySqlCommand    cmd    = new MySqlCommand(query, con);
            MySqlDataReader cursor = cmd.ExecuteReader();

            MCargo obj = new MCargo();

            if (cursor.HasRows)
            {
                while (cursor.Read())
                {
                    obj.pk_cargo = Convert.ToInt32(cursor["pk_cargo"].ToString());
                    obj.cargo    = cursor["cargo"].ToString();
                }
            }

            cursor.Dispose();
            cmd.Dispose();
            con.Close();

            return(obj);
        }