Manage Legal Notices - View
[habeas.git] / src / habeas / Utility.java
index 6ca96e5..0e6d9eb 100644 (file)
@@ -175,7 +175,9 @@ public class Utility {
         ArrayList<Object> notice = new ArrayList<>();
         try {
             Connection conn = DriverManager.getConnection(JDBC + connectionURL);
-            PreparedStatement st = conn.prepareStatement("SELECT * FROM legalnotices WHERE id=?;");
+            PreparedStatement st = conn.prepareStatement("SELECT legalnotices.*, clients.ClientName "
+                    + "FROM legalnotices "
+                    + "INNER JOIN clients WHERE ClientId=clients.id AND legalnotices.id=?;");
             st.setInt(1, selid);
             ResultSet rs = st.executeQuery();
             while (rs.next()) {
@@ -195,6 +197,7 @@ public class Utility {
                 notice.add (getValidDate (rs, "BillDate"));
                 notice.add (rs.getBoolean ("ClarificationPending"));
                 notice.add (rs.getString("ClarificationRemarks"));
+                notice.add (rs.getString("ClientName"));
             }
            return notice;
         } catch (SQLException ex) {
@@ -340,6 +343,42 @@ public class Utility {
             return false;
         }
 
+    }
+
+    static boolean updateNoticeClarificationDetails(int selected_id, boolean 
+            clarification_pending, String clarification_remarks) {
+        try {
+            Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+            PreparedStatement st = conn.prepareStatement ("UPDATE legalnotices"
+                    + " SET ClarificationPending=?, ClarificationRemarks=? "
+                    + "WHERE id=?;");
+            st.setBoolean(1, clarification_pending);
+            st.setString(2, clarification_remarks);
+            st.setInt (3, selected_id);
+            st.execute();
+            conn.close ();
+            return true;
+        } catch (SQLException ex) {
+            Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+            return false;
+        }
+        
+    }
+
+    static boolean deleteNotice(int r) {
+        try {
+            Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+            PreparedStatement st = conn.prepareStatement("DELETE FROM legalnotices"
+                    + " WHERE id=?;");
+            st.setInt(1, r);
+            st.execute();
+            conn.close();
+            return true;
+        } catch (SQLException ex) {
+            Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+            return false;
+        }
+        
     }
     public Utility () {