Пример #1
0
 public static DAORuta getInstance()
 {
     if (DAORuta.r != null)
     {
         return(r);
     }
     else
     {
         r = new DAORuta();
         return(r);
     }
 }
Пример #2
0
        //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);
        }
Пример #3
0
        //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);
            }
        }