コード例 #1
0
 public static DAOTelefono getInstance()
 {
     if (DAOTelefono.r != null)
     {
         return(r);
     }
     else
     {
         r = new DAOTelefono();
         return(r);
     }
 }
コード例 #2
0
        //ELIMINAR Telefono de Taller
        public int eliminarTelefonoTaller(int cod)
        {
            NpgsqlConnection conn = DAOTelefono.getInstanceDAO();

            conn.Open();

            String        sql  = "DELETE FROM \"Telefono\" WHERE \"FK-TallerT\" = " + cod + "";
            NpgsqlCommand cmd  = new NpgsqlCommand(sql, conn);
            int           resp = cmd.ExecuteNonQuery(); //CONTROLAR EXCEPTION DE UNIQUE

            conn.Close();

            return(resp);
        }
コード例 #3
0
        //INSERTAR Telefono de Empleado
        public int insertarTelefonoEmp(int numero, int fkE)
        {
            NpgsqlConnection conn = DAOTelefono.getInstanceDAO();

            conn.Open();

            String sql = "INSERT INTO \"Telefono\" (\"COD\", \"Numero\", \"FK-Empleado\") " +
                         "VALUES ((SELECT NEXTVAL('seq'))," + numero + ", " + fkE + ")";
            NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);

            try
            {
                int resp = cmd.ExecuteNonQuery(); //CONTROLAR EXCEPTION DE UNIQUE
                conn.Close();
                return(resp);
            }
            catch
            {
                conn.Close();
                return(0);
            }
        }
コード例 #4
0
        //MODIFICAR Telefono de Taller
        public int modificarTelefonoTaller(int fk, int numero)
        {
            NpgsqlConnection conn = DAOTelefono.getInstanceDAO();

            conn.Open();

            String sql = "UPDATE \"Telefono\" SET \"Numero\"='" + numero + "'" +
                         "WHERE \"FK-TallerT\"= " + fk + "";

            NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);

            try
            {
                int resp = cmd.ExecuteNonQuery(); //CONTROLAR EXCEPTION DE UNIQUE
                conn.Close();
                return(resp);
            }
            catch
            {
                conn.Close();
                return(0);
            }
        }