//ELIMINAR public int eliminarRuta(int cod) { NpgsqlConnection conn = DAORuta.getInstanceDAO(); conn.Open(); String sql = "DELETE FROM \"Ruta\" WHERE \"COD\" = " + cod + ""; NpgsqlCommand cmd = new NpgsqlCommand(sql, conn); int resp = cmd.ExecuteNonQuery(); //CONTROLAR EXCEPTION DE UNIQUE conn.Close(); return(resp); }
//INSERTAR public int insertarRuta(string origen, string destino, int duracion) { NpgsqlConnection conn = DAORuta.getInstanceDAO(); conn.Open(); String sql = "INSERT INTO \"Ruta\" (\"COD\", \"CODSucursal1\", \"CODSucursal2\", \"Costo\") " + "VALUES ((SELECT NEXTVAL('seq')),'" + origen + "', '" + destino + "', '" + duracion + "')"; NpgsqlCommand cmd = new NpgsqlCommand(sql, conn); try { int resp = cmd.ExecuteNonQuery(); //CONTROLAR EXCEPTION DE UNIQUE conn.Close(); return(resp); } catch (Exception e) { conn.Close(); return(0); } }