--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ <Property name="title" type="java.lang.String" value="Draft Status"/>
+ <Property name="locationByPlatform" type="boolean" value="true"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="checkDraftCreated" max="32767" attributes="0"/>
+ <Component id="checkDraftApproved" pref="224" max="32767" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace pref="195" max="32767" attributes="0"/>
+ <Component id="buttonUpdate" min="-2" pref="92" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="buttonCancel" min="-2" pref="80" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="checkDraftCreated" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="unrelated" max="-2" attributes="0"/>
+ <Component id="checkDraftApproved" min="-2" max="-2" attributes="0"/>
+ <EmptySpace pref="22" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="3" attributes="0">
+ <Component id="buttonUpdate" alignment="3" min="-2" max="-2" attributes="0"/>
+ <Component id="buttonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JCheckBox" name="checkDraftCreated">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Draft Created"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="checkDraftApproved">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Draft Approved"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JButton" name="buttonUpdate">
+ <Properties>
+ <Property name="mnemonic" type="int" value="85"/>
+ <Property name="text" type="java.lang.String" value="Update"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonUpdateActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="buttonCancel">
+ <Properties>
+ <Property name="mnemonic" type="int" value="99"/>
+ <Property name="text" type="java.lang.String" value="Cancel"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+</Form>
--- /dev/null
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package habeas;
+
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author hari
+ */
+public class DraftStatusDialog extends javax.swing.JDialog {
+
+ private int selectednotice_id;
+
+ /**
+ * Creates new form DraftStatusDialog
+ */
+
+ public DraftStatusDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ }
+
+ public void setDraftStatus (boolean created, boolean approved) {
+ checkDraftCreated.setSelected(created);
+ checkDraftApproved.setSelected(approved);
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ checkDraftCreated = new javax.swing.JCheckBox();
+ checkDraftApproved = new javax.swing.JCheckBox();
+ buttonUpdate = new javax.swing.JButton();
+ buttonCancel = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Draft Status");
+ setLocationByPlatform(true);
+
+ checkDraftCreated.setText("Draft Created");
+
+ checkDraftApproved.setText("Draft Approved");
+
+ buttonUpdate.setMnemonic('U');
+ buttonUpdate.setText("Update");
+ buttonUpdate.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonUpdateActionPerformed(evt);
+ }
+ });
+
+ buttonCancel.setMnemonic('c');
+ buttonCancel.setText("Cancel");
+ buttonCancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonCancelActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(checkDraftCreated, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(checkDraftApproved, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+ .addContainerGap(195, Short.MAX_VALUE)
+ .addComponent(buttonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(checkDraftCreated)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(checkDraftApproved)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonUpdate)
+ .addComponent(buttonCancel))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
+ // TODO add your handling code here:
+ dispose ();
+ }//GEN-LAST:event_buttonCancelActionPerformed
+
+ private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
+ // TODO add your handling code here:
+ boolean rt = Utility.updateLegalNoticeDraftStatus (selectednotice_id,
+ checkDraftCreated.isSelected(), checkDraftApproved.isSelected());
+
+ if (rt == false)
+ JOptionPane.showMessageDialog(this, ERROR_UPDATING);
+ else
+ dispose ();
+ }//GEN-LAST:event_buttonUpdateActionPerformed
+ private static final String ERROR_UPDATING = "Error updating";
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ /* Set the Nimbus look and feel */
+ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
+ /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+ * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(DraftStatusDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //</editor-fold>
+
+ /* Create and display the dialog */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ DraftStatusDialog dialog = new DraftStatusDialog(new javax.swing.JFrame(), true);
+ dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ dialog.setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton buttonCancel;
+ private javax.swing.JButton buttonUpdate;
+ private javax.swing.JCheckBox checkDraftApproved;
+ private javax.swing.JCheckBox checkDraftCreated;
+ // End of variables declaration//GEN-END:variables
+
+ void setSelectedNotice(int selid) {
+ selectednotice_id = selid;
+ }
+}
*/
package habeas;
+import java.awt.Frame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import java.util.ArrayList;
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
import javax.swing.table.DefaultTableModel;
/**
int selid = getSelectedNotice ();
if (selid == -1) return;
- System.out.println (selid);
+ DraftStatusDialog frm = new DraftStatusDialog((Frame) this.getParent(), true);
+ ArrayList<Object> notice = Utility.getNoticeDetails (selid);
+ if (notice == null) return;
+
+ frm.setDraftStatus((boolean)notice.get(4), (boolean)notice.get(5));
+ frm.setSelectedNotice (selid);
+ frm.setVisible(true);
}//GEN-LAST:event_menuDraftStatusActionPerformed
static ArrayList<Object> getClientDetails(int r) {
ArrayList<Object> res = new ArrayList <>();
try {
- Connection conn = DriverManager.getConnection("jdbc:sqlite:"+connectionURL);
+ Connection conn = DriverManager.getConnection(JDBC+connectionURL);
PreparedStatement st = conn.prepareStatement("SELECT * FROM clients WHERE id=?;");
st.setInt(1, r);
ResultSet rs = st.executeQuery();
if ("".equals(client_name))
return false;
try {
- Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
PreparedStatement st = conn.prepareStatement("INSERT INTO clients (ClientName,"
+ "ClientAddress, ContactPerson, MailID, ContactNumber) VALUES (?, ?, ?, ?, ?);");
st.setString(1, client_name);
static boolean deleteClient(int r) {
try {
- Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
PreparedStatement st = conn.prepareStatement("DELETE FROM clients WHERE id=?;");
PreparedStatement st2 = conn.prepareStatement("DELETE FROM legalnotices WHERE ClientId=?;");
st.setInt(1, r);
if ("".equals(client_name))
return false;
try {
- Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
PreparedStatement st = conn.prepareStatement("UPDATE clients SET "
+ "ClientName=?, ClientAddress=?,"
+ "ContactPerson=?, MailID=?, ContactNumber=? WHERE id=?;");
entrustment_date == null || client == null)
return false;
try {
- Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
PreparedStatement st = conn.prepareStatement("INSERT INTO legalnotices"
+ " (ReferenceNumber, Description, EntrustmentDate, ClientId) "
+ "VALUES (?, ?, ?, ?);");
static ArrayList<Object> getNotices() {
ArrayList<Object> notices = new ArrayList<>();
try {
- Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT id, ReferenceNumber, Description "
+ "FROM legalnotices;");
return null;
}
+ }
+ static java.util.Date getValidDate (ResultSet rs, String datefield) throws SQLException {
+ // Since resultset.getDate returns a java.sql.Date, we need a way to get
+ // the date in java.util.Date which is usable in our application. Hence
+ // this helper function. Since we don't want a valid Date object if the
+ // field is null, we are using this if clause
+ if (rs.getDate(datefield) == null)
+ return null;
+ else
+ return (new java.util.Date(rs.getLong(datefield)*1000));
+ }
+
+ static ArrayList<Object> getNoticeDetails(int selid) {
+ ArrayList<Object> notice = new ArrayList<>();
+ try {
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+ PreparedStatement st = conn.prepareStatement("SELECT * FROM legalnotices WHERE id=?;");
+ st.setInt(1, selid);
+ ResultSet rs = st.executeQuery();
+ while (rs.next()) {
+ notice.add(rs.getString("ReferenceNumber"));
+ notice.add(rs.getString("Description"));
+ notice.add(getValidDate(rs, "EntrustmentDate"));
+ notice.add (rs.getInt ("ClientId"));
+ notice.add (rs.getBoolean("DraftCreated"));
+ notice.add (rs.getBoolean("DraftApproved"));
+ notice.add (rs.getBoolean("NoticeSent"));
+ notice.add (getValidDate(rs, "SentDate"));
+ notice.add (rs.getString("RPADReference"));
+ notice.add (rs.getBoolean("NoticeDelivered"));
+ notice.add (getValidDate(rs, "DeliveryDate"));
+ notice.add (rs.getString("BillStatus"));
+ notice.add (rs.getInt ("BillAmount"));
+ notice.add (getValidDate (rs, "BillDate"));
+ notice.add (rs.getBoolean ("ClarificationPending"));
+ notice.add (rs.getString("ClarificationRemarks"));
+ }
+ return notice;
+ } catch (SQLException ex) {
+ Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+ return null;
+ }
+
+
+ }
+ private static final String JDBC = "jdbc:sqlite:";
+
+ static boolean updateLegalNoticeDraftStatus(int selectednotice_id, boolean created, boolean approved) {
+ try {
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
+ PreparedStatement st = conn.prepareStatement("UPDATE legalnotices "
+ + "SET DraftCreated=?, DraftApproved=? WHERE id=?;");
+ st.setBoolean(1, created);
+ st.setBoolean(2, approved);
+ st.setInt (3, selectednotice_id);
+ st.execute();
+ conn.close();
+ return true;
+ } catch (SQLException ex) {
+ Logger.getLogger(Utility.class.getName()).log(Level.SEVERE, null, ex);
+ return false;
+ }
+
}
public Utility () {
public static ArrayList<Object> getClientsNameAndId () {
ArrayList<Object> data = new ArrayList<>();
try {
- Connection conn = DriverManager.getConnection("jdbc:sqlite:" + connectionURL);
+ Connection conn = DriverManager.getConnection(JDBC + connectionURL);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT id, ClientName from clients;");
while (rs.next()) {