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(); }
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); }
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); }