Guest User

Untitled

a guest
Mar 12th, 2012
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. /**
  7. *
  8. * @author RC
  9. */
  10. import java.awt.BorderLayout;
  11. import java.sql.Connection;
  12. import java.sql.PreparedStatement;
  13. import java.sql.ResultSet;
  14. import javax.swing.JOptionPane;
  15. import net.proteanit.sql.DbUtils;
  16. import java.sql.*;
  17. import net.sf.jasperreports.engine.design.*;
  18. import net.sf.jasperreports.view.JasperViewer;
  19. import net.sf.jasperreports.engine.*;
  20. import javax.swing.*;
  21. import javax.swing.table.DefaultTableCellRenderer;
  22. import net.sf.jasperreports.engine.xml.JRXmlLoader;
  23.  
  24.  
  25.  
  26. public class FormJFrame extends javax.swing.JFrame {
  27.  
  28.  
  29. Connection conn = null;
  30. ResultSet rs = null;
  31. PreparedStatement pst = null;
  32.  
  33. private void FillCombo(){
  34. String sql = "SELECT * FROM equipment";
  35. try{
  36. pst = conn.prepareStatement(sql);
  37. rs = pst.executeQuery();
  38. while (rs.next()){
  39.  
  40. String nme = rs.getString("Equipment_Name");
  41. comboequip.addItem(nme);
  42. }
  43. }
  44. catch(Exception e){
  45. JOptionPane.showMessageDialog(null, e);
  46. }
  47. }
  48.  
  49.  
  50.  
  51.  
  52. private void UpdateJTable(){
  53. String sql = "SELECT Student_ID,Student_FN, Student_LN, Student_MI, Address, Course, Year, Contact_No, Equipment_Name, Quantity FROM student";
  54. try{
  55. pst = conn.prepareStatement(sql);
  56. rs = pst.executeQuery(sql);
  57. jTable1.setModel(DbUtils.resultSetToTableModel(rs));
  58. }
  59. catch (Exception e){
  60. JOptionPane.showMessageDialog(null, e);
  61. }
  62. }
  63.  
  64.  
  65.  
  66. //PreparedStatement pst2 = null;
  67.  
  68. /**
  69. * Creates new form FormJFrame
  70. */
  71. public FormJFrame() {
  72. initComponents();
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. }
  80.  
  81. /**
  82. * This method is called from within the constructor to initialize the form.
  83. * WARNING: Do NOT modify this code. The content of this method is always
  84. * regenerated by the Form Editor.
  85. */
  86. @SuppressWarnings("unchecked")
  87. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  88. private void initComponents() {
  89.  
  90. jTabbedPane1 = new javax.swing.JTabbedPane();
  91. jPanel1 = new javax.swing.JPanel();
  92. jLabel1 = new javax.swing.JLabel();
  93. jLabel2 = new javax.swing.JLabel();
  94. jLabel3 = new javax.swing.JLabel();
  95. txtlast = new javax.swing.JTextField();
  96. txtfirst = new javax.swing.JTextField();
  97. txtinitial = new javax.swing.JTextField();
  98. jLabel4 = new javax.swing.JLabel();
  99. txtaddress = new javax.swing.JTextField();
  100. jLabel5 = new javax.swing.JLabel();
  101. txtid = new javax.swing.JTextField();
  102. jLabel6 = new javax.swing.JLabel();
  103. jLabel7 = new javax.swing.JLabel();
  104. itemcourse = new javax.swing.JComboBox();
  105. itemyear = new javax.swing.JComboBox();
  106. jLabel8 = new javax.swing.JLabel();
  107. txtcontact = new javax.swing.JTextField();
  108. jLabel9 = new javax.swing.JLabel();
  109. comboequip = new javax.swing.JComboBox();
  110. jLabel10 = new javax.swing.JLabel();
  111. itemquantity = new javax.swing.JComboBox();
  112. cmdadd = new javax.swing.JButton();
  113. jLabel22 = new javax.swing.JLabel();
  114. jDateChooser1 = new com.toedter.calendar.JDateChooser();
  115. jPanel4 = new javax.swing.JPanel();
  116. jScrollPane1 = new javax.swing.JScrollPane();
  117. jTable1 = new javax.swing.JTable();
  118. jLabel11 = new javax.swing.JLabel();
  119. updateid = new javax.swing.JTextField();
  120. jLabel12 = new javax.swing.JLabel();
  121. updatelast = new javax.swing.JTextField();
  122. jLabel13 = new javax.swing.JLabel();
  123. updatefirst = new javax.swing.JTextField();
  124. jLabel14 = new javax.swing.JLabel();
  125. updateinitial = new javax.swing.JTextField();
  126. jLabel15 = new javax.swing.JLabel();
  127. updateaddress = new javax.swing.JTextField();
  128. jLabel16 = new javax.swing.JLabel();
  129. updatecourse = new javax.swing.JTextField();
  130. jLabel17 = new javax.swing.JLabel();
  131. updateyear = new javax.swing.JTextField();
  132. jLabel18 = new javax.swing.JLabel();
  133. updatecontact = new javax.swing.JTextField();
  134. jLabel19 = new javax.swing.JLabel();
  135. updateequip = new javax.swing.JTextField();
  136. jLabel20 = new javax.swing.JLabel();
  137. updatequantity = new javax.swing.JTextField();
  138. cmdupdate = new javax.swing.JButton();
  139. cmddelete = new javax.swing.JButton();
  140. jLabel21 = new javax.swing.JLabel();
  141. txtsearch = new javax.swing.JTextField();
  142. cmdPrintAll = new javax.swing.JButton();
  143. jLabel23 = new javax.swing.JLabel();
  144. updateborrowed = new javax.swing.JTextField();
  145. jPanel3 = new javax.swing.JPanel();
  146. jScrollPane2 = new javax.swing.JScrollPane();
  147. jTable2 = new javax.swing.JTable();
  148. jPanel2 = new javax.swing.JPanel();
  149. jLabel24 = new javax.swing.JLabel();
  150. jLabel27 = new javax.swing.JLabel();
  151. jLabel26 = new javax.swing.JLabel();
  152. jMenuBar1 = new javax.swing.JMenuBar();
  153. jMenu1 = new javax.swing.JMenu();
  154. jMenuItem2 = new javax.swing.JMenuItem();
  155. jMenu2 = new javax.swing.JMenu();
  156. aboutclick = new javax.swing.JMenuItem();
  157.  
  158. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  159. addWindowListener(new java.awt.event.WindowAdapter() {
  160. public void windowOpened(java.awt.event.WindowEvent evt) {
  161. formWindowOpened(evt);
  162. }
  163. });
  164.  
  165. jTabbedPane1.setBackground(new java.awt.Color(102, 102, 102));
  166.  
  167. jLabel1.setText("Last Name:");
  168.  
  169. jLabel2.setText("First Name:");
  170.  
  171. jLabel3.setText("Middle Initial:");
  172.  
  173. txtlast.setBackground(new java.awt.Color(204, 255, 204));
  174.  
  175. txtfirst.setBackground(new java.awt.Color(204, 255, 204));
  176.  
  177. txtinitial.setBackground(new java.awt.Color(204, 255, 204));
  178.  
  179. jLabel4.setText("Address:");
  180.  
  181. txtaddress.setBackground(new java.awt.Color(204, 255, 204));
  182.  
  183. jLabel5.setText("Student ID:");
  184.  
  185. txtid.setBackground(new java.awt.Color(204, 255, 204));
  186.  
  187. jLabel6.setText("Course:");
  188.  
  189. jLabel7.setText("Year:");
  190.  
  191. itemcourse.setBackground(new java.awt.Color(204, 255, 204));
  192. itemcourse.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "BSCS", "BSIT", "NMCA", "BSECE", "BSCoe", "BS Biology", "aCon" }));
  193. itemcourse.setSelectedItem(null);
  194.  
  195. itemyear.setBackground(new java.awt.Color(204, 255, 204));
  196. itemyear.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "I", "II", "III", "IV", "V" }));
  197. itemyear.setSelectedItem(null);
  198.  
  199. jLabel8.setText("Contact No:");
  200.  
  201. txtcontact.setBackground(new java.awt.Color(204, 255, 204));
  202.  
  203. jLabel9.setText("Equipment to Borrow:");
  204.  
  205. comboequip.setBackground(new java.awt.Color(204, 255, 204));
  206.  
  207. jLabel10.setText("Quantity:");
  208.  
  209. itemquantity.setBackground(new java.awt.Color(204, 255, 204));
  210. itemquantity.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
  211.  
  212. cmdadd.setIcon(new javax.swing.ImageIcon("C:\\Users\\RC\\Documents\\NetBeansProjects\\AdzuSGov\\pictures\\Folder-Add-icon.png")); // NOI18N
  213. cmdadd.setText("Add");
  214. cmdadd.addMouseListener(new java.awt.event.MouseAdapter() {
  215. public void mouseClicked(java.awt.event.MouseEvent evt) {
  216. cmdaddMouseClicked(evt);
  217. }
  218. });
  219.  
  220. jLabel22.setText("Date Borrowed:");
  221.  
  222. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  223. jPanel1.setLayout(jPanel1Layout);
  224. jPanel1Layout.setHorizontalGroup(
  225. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  226. .addGroup(jPanel1Layout.createSequentialGroup()
  227. .addGap(20, 20, 20)
  228. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  229. .addGroup(jPanel1Layout.createSequentialGroup()
  230. .addComponent(jLabel22)
  231. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  232. .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
  233. .addGroup(jPanel1Layout.createSequentialGroup()
  234. .addComponent(jLabel5)
  235. .addGap(18, 18, 18)
  236. .addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
  237. .addGroup(jPanel1Layout.createSequentialGroup()
  238. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  239. .addComponent(jLabel1)
  240. .addComponent(jLabel4)
  241. .addComponent(jLabel6)
  242. .addComponent(jLabel8))
  243. .addGap(18, 18, 18)
  244. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  245. .addComponent(txtaddress, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
  246. .addComponent(txtcontact, javax.swing.GroupLayout.PREFERRED_SIZE, 176, javax.swing.GroupLayout.PREFERRED_SIZE)
  247. .addGroup(jPanel1Layout.createSequentialGroup()
  248. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  249. .addComponent(jLabel10)
  250. .addGroup(jPanel1Layout.createSequentialGroup()
  251. .addComponent(txtlast, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
  252. .addGap(18, 18, 18)
  253. .addComponent(jLabel2)
  254. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  255. .addComponent(txtfirst, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)))
  256. .addGap(18, 18, 18)
  257. .addComponent(jLabel3)
  258. .addGap(18, 18, 18)
  259. .addComponent(txtinitial, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
  260. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  261. .addComponent(cmdadd)
  262. .addGroup(jPanel1Layout.createSequentialGroup()
  263. .addComponent(itemcourse, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
  264. .addGap(32, 32, 32)
  265. .addComponent(jLabel7)
  266. .addGap(18, 18, 18)
  267. .addComponent(itemyear, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)))))
  268. .addGroup(jPanel1Layout.createSequentialGroup()
  269. .addComponent(jLabel9)
  270. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  271. .addComponent(comboequip, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
  272. .addGroup(jPanel1Layout.createSequentialGroup()
  273. .addGap(405, 405, 405)
  274. .addComponent(itemquantity, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)))
  275. .addContainerGap(379, Short.MAX_VALUE))
  276. );
  277. jPanel1Layout.setVerticalGroup(
  278. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  279. .addGroup(jPanel1Layout.createSequentialGroup()
  280. .addGap(24, 24, 24)
  281. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  282. .addComponent(jLabel5)
  283. .addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  284. .addGap(18, 18, 18)
  285. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  286. .addComponent(jLabel1)
  287. .addComponent(txtlast, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  288. .addComponent(jLabel2)
  289. .addComponent(txtfirst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  290. .addComponent(jLabel3)
  291. .addComponent(txtinitial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  292. .addGap(18, 18, 18)
  293. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  294. .addComponent(jLabel4)
  295. .addComponent(txtaddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  296. .addGap(18, 18, 18)
  297. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  298. .addComponent(jLabel6)
  299. .addComponent(jLabel7)
  300. .addComponent(itemcourse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  301. .addComponent(itemyear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  302. .addGap(18, 18, 18)
  303. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  304. .addComponent(jLabel8)
  305. .addComponent(txtcontact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  306. .addGap(30, 30, 30)
  307. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  308. .addComponent(jLabel9)
  309. .addComponent(comboequip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  310. .addComponent(jLabel10)
  311. .addComponent(itemquantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  312. .addGap(33, 33, 33)
  313. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  314. .addComponent(jLabel22)
  315. .addGroup(jPanel1Layout.createSequentialGroup()
  316. .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  317. .addGap(79, 79, 79)
  318. .addComponent(cmdadd)))
  319. .addGap(104, 108, Short.MAX_VALUE))
  320. );
  321.  
  322. jTabbedPane1.addTab("Add Information", jPanel1);
  323.  
  324. jTable1.setBackground(new java.awt.Color(204, 255, 204));
  325. jTable1.setModel(new javax.swing.table.DefaultTableModel(
  326. new Object [][] {
  327.  
  328. },
  329. new String [] {
  330. "Student ID", "Last Name", "First Name", "Middle Initial", "Address", "Course", "Year", "Contact No", "Borrowed Equip", "Quantity", "DateBorrowed"
  331. }
  332. ) {
  333. Class[] types = new Class [] {
  334. java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Long.class
  335. };
  336.  
  337. public Class getColumnClass(int columnIndex) {
  338. return types [columnIndex];
  339. }
  340. });
  341. jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
  342. public void mouseClicked(java.awt.event.MouseEvent evt) {
  343. jTable1MouseClicked(evt);
  344. }
  345. });
  346. jScrollPane1.setViewportView(jTable1);
  347.  
  348. jLabel11.setText("Student ID:");
  349.  
  350. updateid.setBackground(new java.awt.Color(204, 255, 204));
  351.  
  352. jLabel12.setText("Last Name:");
  353.  
  354. updatelast.setBackground(new java.awt.Color(204, 255, 204));
  355.  
  356. jLabel13.setText("First Name:");
  357.  
  358. updatefirst.setBackground(new java.awt.Color(204, 255, 204));
  359.  
  360. jLabel14.setText("Middle Initial:");
  361.  
  362. updateinitial.setBackground(new java.awt.Color(204, 255, 204));
  363.  
  364. jLabel15.setText("Address:");
  365.  
  366. updateaddress.setBackground(new java.awt.Color(204, 255, 204));
  367.  
  368. jLabel16.setText("Course:");
  369.  
  370. updatecourse.setBackground(new java.awt.Color(204, 255, 204));
  371.  
  372. jLabel17.setText("Year:");
  373.  
  374. updateyear.setBackground(new java.awt.Color(204, 255, 204));
  375.  
  376. jLabel18.setText("Contact No.");
  377.  
  378. updatecontact.setBackground(new java.awt.Color(204, 255, 204));
  379.  
  380. jLabel19.setText("Borrowed Equipment:");
  381.  
  382. updateequip.setBackground(new java.awt.Color(204, 255, 204));
  383.  
  384. jLabel20.setText("Quantity:");
  385.  
  386. updatequantity.setBackground(new java.awt.Color(204, 255, 204));
  387.  
  388. cmdupdate.setIcon(new javax.swing.ImageIcon("C:\\Users\\RC\\Documents\\NetBeansProjects\\AdzuSGov\\pictures\\Actions-document-edit-icon.png")); // NOI18N
  389. cmdupdate.setText("Update");
  390. cmdupdate.addMouseListener(new java.awt.event.MouseAdapter() {
  391. public void mouseClicked(java.awt.event.MouseEvent evt) {
  392. cmdupdateMouseClicked(evt);
  393. }
  394. });
  395.  
  396. cmddelete.setIcon(new javax.swing.ImageIcon("C:\\Users\\RC\\Documents\\NetBeansProjects\\AdzuSGov\\pictures\\delete-icon.png")); // NOI18N
  397. cmddelete.setText("Delete");
  398. cmddelete.addMouseListener(new java.awt.event.MouseAdapter() {
  399. public void mouseClicked(java.awt.event.MouseEvent evt) {
  400. cmddeleteMouseClicked(evt);
  401. }
  402. });
  403.  
  404. jLabel21.setText("Search Keyword:");
  405.  
  406. txtsearch.addKeyListener(new java.awt.event.KeyAdapter() {
  407. public void keyReleased(java.awt.event.KeyEvent evt) {
  408. txtsearchKeyReleased(evt);
  409. }
  410. });
  411.  
  412. cmdPrintAll.setIcon(new javax.swing.ImageIcon("C:\\Users\\RC\\Documents\\NetBeansProjects\\AdzuSGov\\pictures\\Device-Printer-icon.png")); // NOI18N
  413. cmdPrintAll.setText("Print All");
  414. cmdPrintAll.addMouseListener(new java.awt.event.MouseAdapter() {
  415. public void mouseClicked(java.awt.event.MouseEvent evt) {
  416. cmdPrintAllMouseClicked(evt);
  417. }
  418. });
  419.  
  420. jLabel23.setText("Date Borrowed: ");
  421.  
  422. javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
  423. jPanel4.setLayout(jPanel4Layout);
  424. jPanel4Layout.setHorizontalGroup(
  425. jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  426. .addGroup(jPanel4Layout.createSequentialGroup()
  427. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  428. .addGroup(jPanel4Layout.createSequentialGroup()
  429. .addGap(21, 21, 21)
  430. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  431. .addGroup(jPanel4Layout.createSequentialGroup()
  432. .addComponent(jLabel18)
  433. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  434. .addComponent(updatecontact, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
  435. .addGroup(jPanel4Layout.createSequentialGroup()
  436. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  437. .addGroup(jPanel4Layout.createSequentialGroup()
  438. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  439. .addComponent(jLabel12)
  440. .addComponent(jLabel15)
  441. .addComponent(jLabel16))
  442. .addGap(18, 18, 18)
  443. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  444. .addGroup(jPanel4Layout.createSequentialGroup()
  445. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  446. .addComponent(updateaddress, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
  447. .addGroup(jPanel4Layout.createSequentialGroup()
  448. .addComponent(updatecourse, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
  449. .addGap(30, 30, 30)
  450. .addComponent(jLabel17)
  451. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  452. .addComponent(updateyear, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
  453. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  454. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
  455. .addComponent(updatelast, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
  456. .addGap(18, 18, 18)
  457. .addComponent(jLabel13)
  458. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  459. .addComponent(updatefirst, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
  460. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
  461. .addComponent(jLabel14)
  462. .addGap(12, 12, 12))))
  463. .addGroup(jPanel4Layout.createSequentialGroup()
  464. .addComponent(jLabel11)
  465. .addGap(18, 18, 18)
  466. .addComponent(updateid, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
  467. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
  468. .addComponent(updateinitial, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
  469. .addGroup(jPanel4Layout.createSequentialGroup()
  470. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  471. .addGroup(jPanel4Layout.createSequentialGroup()
  472. .addComponent(jLabel19)
  473. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  474. .addComponent(updateequip, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
  475. .addGap(55, 55, 55)
  476. .addComponent(jLabel20)
  477. .addGap(10, 10, 10)
  478. .addComponent(updatequantity, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
  479. .addGroup(jPanel4Layout.createSequentialGroup()
  480. .addGap(167, 167, 167)
  481. .addComponent(cmdupdate)
  482. .addGap(62, 62, 62)
  483. .addComponent(cmddelete)))
  484. .addGap(38, 38, 38)
  485. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  486. .addComponent(cmdPrintAll)
  487. .addGroup(jPanel4Layout.createSequentialGroup()
  488. .addComponent(jLabel23)
  489. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  490. .addComponent(updateborrowed, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))))))
  491. .addGroup(jPanel4Layout.createSequentialGroup()
  492. .addGap(209, 209, 209)
  493. .addComponent(jLabel21)
  494. .addGap(18, 18, 18)
  495. .addComponent(txtsearch, javax.swing.GroupLayout.PREFERRED_SIZE, 191, javax.swing.GroupLayout.PREFERRED_SIZE)))
  496. .addContainerGap())
  497. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
  498. .addGap(0, 39, Short.MAX_VALUE)
  499. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 873, javax.swing.GroupLayout.PREFERRED_SIZE)
  500. .addGap(74, 74, 74))
  501. );
  502. jPanel4Layout.setVerticalGroup(
  503. jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  504. .addGroup(jPanel4Layout.createSequentialGroup()
  505. .addGap(24, 24, 24)
  506. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  507. .addComponent(jLabel11)
  508. .addComponent(updateid, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  509. .addGap(18, 18, 18)
  510. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  511. .addComponent(jLabel12)
  512. .addComponent(updatelast, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  513. .addComponent(jLabel13)
  514. .addComponent(updatefirst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  515. .addComponent(jLabel14)
  516. .addComponent(updateinitial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  517. .addGap(18, 18, 18)
  518. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  519. .addComponent(jLabel15)
  520. .addComponent(updateaddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  521. .addGap(18, 18, 18)
  522. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  523. .addComponent(jLabel16)
  524. .addComponent(updatecourse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  525. .addComponent(jLabel17)
  526. .addComponent(updateyear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  527. .addGap(18, 18, 18)
  528. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  529. .addComponent(jLabel18)
  530. .addComponent(updatecontact, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  531. .addGap(18, 18, 18)
  532. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  533. .addComponent(jLabel19)
  534. .addComponent(updateequip, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  535. .addComponent(jLabel20)
  536. .addComponent(updatequantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  537. .addComponent(jLabel23)
  538. .addComponent(updateborrowed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  539. .addGap(27, 27, 27)
  540. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  541. .addComponent(cmdupdate)
  542. .addComponent(cmddelete)
  543. .addComponent(cmdPrintAll))
  544. .addGap(18, 18, 18)
  545. .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  546. .addComponent(txtsearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  547. .addComponent(jLabel21))
  548. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  549. .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
  550. .addContainerGap(23, Short.MAX_VALUE))
  551. );
  552.  
  553. jTabbedPane1.addTab("Update Information", jPanel4);
  554.  
  555. jTable2.setModel(new javax.swing.table.DefaultTableModel(
  556. new Object [][] {
  557. {null, null, null, null, null, null, null, null, null, null},
  558. {null, null, null, null, null, null, null, null, null, null},
  559. {null, null, null, null, null, null, null, null, null, null},
  560. {null, null, null, null, null, null, null, null, null, null}
  561. },
  562. new String [] {
  563. "Student ID", "Last Name", "First Name", "Middle Initial", "Address", "Course", "Year", "Contact No.", "Borrowed Equip.", "Quantity"
  564. }
  565. ));
  566. jScrollPane2.setViewportView(jTable2);
  567.  
  568. javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
  569. jPanel3.setLayout(jPanel3Layout);
  570. jPanel3Layout.setHorizontalGroup(
  571. jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  572. .addGroup(jPanel3Layout.createSequentialGroup()
  573. .addGap(38, 38, 38)
  574. .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 877, javax.swing.GroupLayout.PREFERRED_SIZE)
  575. .addContainerGap(71, Short.MAX_VALUE))
  576. );
  577. jPanel3Layout.setVerticalGroup(
  578. jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  579. .addGroup(jPanel3Layout.createSequentialGroup()
  580. .addGap(52, 52, 52)
  581. .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
  582. .addContainerGap(209, Short.MAX_VALUE))
  583. );
  584.  
  585. jTabbedPane1.addTab("Overdue", jPanel3);
  586.  
  587. javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
  588. jPanel2.setLayout(jPanel2Layout);
  589. jPanel2Layout.setHorizontalGroup(
  590. jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  591. .addGap(0, 100, Short.MAX_VALUE)
  592. );
  593. jPanel2Layout.setVerticalGroup(
  594. jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  595. .addGap(0, 100, Short.MAX_VALUE)
  596. );
  597.  
  598. jLabel24.setIcon(new javax.swing.ImageIcon(getClass().getResource("/adzu.png"))); // NOI18N
  599.  
  600. jLabel27.setIcon(new javax.swing.ImageIcon(getClass().getResource("/seal(1).png"))); // NOI18N
  601.  
  602. jLabel26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/glossy_stripe.png"))); // NOI18N
  603. jLabel26.setVerticalAlignment(javax.swing.SwingConstants.TOP);
  604.  
  605. jMenu1.setText("File");
  606.  
  607. jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
  608. jMenuItem2.setText("Exit");
  609. jMenuItem2.addMouseListener(new java.awt.event.MouseAdapter() {
  610. public void mouseClicked(java.awt.event.MouseEvent evt) {
  611. jMenuItem2MouseClicked(evt);
  612. }
  613. });
  614. jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
  615. public void actionPerformed(java.awt.event.ActionEvent evt) {
  616. jMenuItem2ActionPerformed(evt);
  617. }
  618. });
  619. jMenu1.add(jMenuItem2);
  620.  
  621. jMenuBar1.add(jMenu1);
  622.  
  623. jMenu2.setText("Help");
  624.  
  625. aboutclick.setText("About");
  626. aboutclick.addMouseListener(new java.awt.event.MouseAdapter() {
  627. public void mouseClicked(java.awt.event.MouseEvent evt) {
  628. aboutclickMouseClicked(evt);
  629. }
  630. });
  631. aboutclick.addActionListener(new java.awt.event.ActionListener() {
  632. public void actionPerformed(java.awt.event.ActionEvent evt) {
  633. aboutclickActionPerformed(evt);
  634. }
  635. });
  636. jMenu2.add(aboutclick);
  637.  
  638. jMenuBar1.add(jMenu2);
  639.  
  640. setJMenuBar(jMenuBar1);
  641.  
  642. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  643. getContentPane().setLayout(layout);
  644. layout.setHorizontalGroup(
  645. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  646. .addGroup(layout.createSequentialGroup()
  647. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  648. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  649. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  650. .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 991, javax.swing.GroupLayout.PREFERRED_SIZE)
  651. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  652. .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  653. .addContainerGap())
  654. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  655. .addComponent(jLabel26)
  656. .addGap(28, 28, 28)
  657. .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 484, javax.swing.GroupLayout.PREFERRED_SIZE)
  658. .addGap(18, 18, 18)
  659. .addComponent(jLabel27)
  660. .addGap(241, 241, 241))))
  661. );
  662. layout.setVerticalGroup(
  663. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  664. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
  665. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  666. .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  667. .addGap(357, 357, 357))
  668. .addGroup(layout.createSequentialGroup()
  669. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  670. .addComponent(jLabel27)
  671. .addGroup(layout.createSequentialGroup()
  672. .addGap(38, 38, 38)
  673. .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
  674. .addComponent(jLabel26))
  675. .addGap(18, 18, 18)
  676. .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 555, javax.swing.GroupLayout.PREFERRED_SIZE)
  677. .addGap(0, 11, Short.MAX_VALUE))
  678. );
  679.  
  680. pack();
  681. }// </editor-fold>
  682.  
  683. private void formWindowOpened(java.awt.event.WindowEvent evt) {
  684. // TODO add your handling code here:
  685. conn = mysqlconnect.ConnectDB();
  686. UpdateJTable();
  687. FillCombo();
  688. setTitle("Student Government Borrowing System");
  689. setExtendedState(MAXIMIZED_BOTH);
  690. //setUndecorated(true);
  691. setLocationRelativeTo(null);
  692.  
  693.  
  694.  
  695. }
  696.  
  697. private void txtsearchKeyReleased(java.awt.event.KeyEvent evt) {
  698. // TODO add your handling code here:
  699. String sql = "SELECT * FROM student WHERE Student_ID = ? OR Student_LN LIKE ? OR Student_FN LIKE ? OR Student_MI LIKE ? OR Address LIKE ? OR Course LIKE ? OR Year LIKE ? OR Contact_No LIKE ? OR Equipment_Name LIKE ? OR Quantity LIKE ?";
  700. try {
  701. pst = conn.prepareStatement(sql);
  702. pst.setString(1, txtsearch.getText() + "%");
  703. pst.setString(2, txtsearch.getText() + "%");
  704. pst.setString(3, txtsearch.getText() + "%");
  705. pst.setString(4, txtsearch.getText() + "%");
  706. pst.setString(5, txtsearch.getText() + "%");
  707. pst.setString(6, txtsearch.getText() + "%");
  708. pst.setString(7, txtsearch.getText() + "%");
  709. pst.setString(8, txtsearch.getText() + "%");
  710. pst.setString(9, txtsearch.getText() + "%");
  711. pst.setString(10, txtsearch.getText() + "%");
  712.  
  713. rs = pst.executeQuery();
  714. jTable1.setModel(DbUtils.resultSetToTableModel(rs));
  715. } catch (Exception e) {
  716. JOptionPane.showMessageDialog(null, e);
  717. }
  718. }
  719.  
  720. private void cmddeleteMouseClicked(java.awt.event.MouseEvent evt) {
  721. // TODO add your handling code here:
  722. String sql = "DELETE FROM student WHERE Student_ID = ?";
  723. try {
  724. pst = conn.prepareStatement(sql);
  725. pst.setString(1, updateid.getText());
  726. pst.execute();
  727. JOptionPane.showMessageDialog(null, "Deletion Succesful");
  728. UpdateJTable();
  729.  
  730. } catch (Exception e) {
  731. JOptionPane.showMessageDialog(null, e);
  732. }
  733. }
  734.  
  735. private void cmdupdateMouseClicked(java.awt.event.MouseEvent evt) {
  736. // TODO add your handling code here:
  737. String sql = "UPDATE student SET Student_LN = ?, Student_FN = ?, Student_MI = ?, Address = ?, Course = ?, Year = ?, Contact_No = ?, Equipment_Name = ?, Quantity = ? WHERE Student_ID = ?";
  738. try {
  739. pst = conn.prepareStatement(sql);
  740. pst.setString(1, updatelast.getText());
  741. pst.setString(2, updatefirst.getText());
  742. pst.setString(3, updateinitial.getText());
  743. pst.setString(4, updateaddress.getText());
  744. pst.setString(5, updatecourse.getText());
  745. pst.setString(6, updateyear.getText());
  746. pst.setString(7, updatecontact.getText());
  747. pst.setString(8, updateequip.getText());
  748. pst.setString(9, updatequantity.getText());
  749. pst.setString(10, updateid.getText());
  750. pst.executeUpdate();
  751. JOptionPane.showMessageDialog(null, "Update Successful!");
  752. UpdateJTable();
  753.  
  754. } catch (Exception e) {
  755. JOptionPane.showMessageDialog(null, e);
  756. }
  757. }
  758.  
  759. private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {
  760. // TODO add your handling code here:
  761. int row = jTable1.getSelectedRow();
  762. updateid.setText(jTable1.getModel().getValueAt(row, 0).toString());
  763. updatelast.setText(jTable1.getModel().getValueAt(row, 1).toString());
  764. updatefirst.setText(jTable1.getModel().getValueAt(row, 2).toString());
  765. updateinitial.setText(jTable1.getModel().getValueAt(row, 3).toString());
  766. updateaddress.setText(jTable1.getModel().getValueAt(row, 4).toString());
  767. updatecourse.setText(jTable1.getModel().getValueAt(row, 5).toString());
  768. updateyear.setText(jTable1.getModel().getValueAt(row, 6).toString());
  769. updatecontact.setText(jTable1.getModel().getValueAt(row, 7).toString());
  770. updateequip.setText(jTable1.getModel().getValueAt(row, 8).toString());
  771. updatequantity.setText(jTable1.getModel().getValueAt(row, 9).toString());
  772. //updateborrowed.setText(jTable1.getModel().getValueAt(row, 10).toString());
  773.  
  774.  
  775.  
  776.  
  777.  
  778. }
  779.  
  780. private void cmdaddMouseClicked(java.awt.event.MouseEvent evt) {
  781. // TODO add your handling code here:
  782. String sql = "INSERT INTO student (Student_ID, Student_LN, Student_FN, Student_MI, Address, Course, Year, Contact_No, Equipment_Name, Quantity, Date_Borrowed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  783.  
  784.  
  785. try {
  786.  
  787. pst = conn.prepareStatement(sql);
  788. pst.setString(1, txtid.getText());
  789. pst.setString(2, txtlast.getText());
  790. pst.setString(3, txtfirst.getText());
  791. pst.setString(4, txtinitial.getText());
  792. pst.setString(5, txtaddress.getText());
  793. pst.setObject(6, itemcourse.getSelectedItem());
  794. pst.setObject(7, itemyear.getSelectedItem());
  795. pst.setString(8, txtcontact.getText());
  796. pst.setObject(9, comboequip.getSelectedItem());
  797. pst.setObject(10, itemquantity.getSelectedItem());
  798. pst.setDate(11, new java.sql.Date(System.currentTimeMillis()));
  799. if(txtid.getText().trim().equals("")){
  800. JOptionPane.showMessageDialog(null, "Please specify Student ID");
  801. }
  802. else if (txtlast.getText().trim().equals("")){
  803. JOptionPane.showMessageDialog(null, "Please specify Last Name");
  804. }
  805. else if (txtfirst.getText().trim().equals("")){
  806. JOptionPane.showMessageDialog(null, "Please specify First Name");
  807. }
  808. else if (txtinitial.getText().trim().equals("")){
  809. JOptionPane.showMessageDialog(null, "Please specify Middle Inital");
  810. }
  811. else if (txtaddress.getText().trim().equals("")){
  812. JOptionPane.showMessageDialog(null, "Please specify Address");
  813. }
  814. else if (itemcourse.getSelectedItem().equals("")){
  815. JOptionPane.showMessageDialog(null, "Please specify Course");
  816. }
  817. else if (itemyear.getSelectedItem().equals("")){
  818. JOptionPane.showMessageDialog(null, "Please specify Year");
  819. }
  820. else if (txtcontact.getText().trim().equals("")){
  821. JOptionPane.showMessageDialog(null, "Please specify Contact No.");
  822. }
  823. else if (comboequip.getSelectedItem().equals("")){
  824. JOptionPane.showMessageDialog(null, "Please specify Equipment");
  825. }
  826. else if (itemquantity.getSelectedItem().equals("")){
  827. JOptionPane.showMessageDialog(null, "Please specify Quantity");
  828. }
  829. else{
  830.  
  831. pst.execute();
  832. UpdateJTable();
  833. JOptionPane.showMessageDialog(null, "Information Saved!");
  834. txtid.setText("");
  835. txtlast.setText("");
  836. txtfirst.setText("");
  837. txtinitial.setText("");
  838. txtaddress.setText("");
  839. itemcourse.setSelectedItem("");
  840. itemyear.setSelectedItem("");
  841. txtcontact.setText("");
  842. comboequip.setSelectedItem("");
  843. itemquantity.setSelectedItem("");
  844. }
  845.  
  846. } catch (Exception e) {
  847. JOptionPane.showMessageDialog(null, e);
  848. }
  849.  
  850. }
  851.  
  852. private void aboutclickMouseClicked(java.awt.event.MouseEvent evt) {
  853. // TODO add your handling code here:
  854. aboutJFrame a = new aboutJFrame();
  855. a.setVisible(true);
  856.  
  857. }
  858.  
  859. private void aboutclickActionPerformed(java.awt.event.ActionEvent evt) {
  860. // TODO add your handling code here:
  861. aboutJFrame s = new aboutJFrame();
  862. s.setVisible(true);
  863. }
  864.  
  865. private void cmdPrintAllMouseClicked(java.awt.event.MouseEvent evt) {
  866. // TODO add your handling code here:
  867. try{
  868. JasperDesign jasperDesign = JRXmlLoader.load("AdzuSGReport.jrxml");
  869. String sql = "select * from student";
  870. JRDesignQuery newQuery = new JRDesignQuery();
  871. newQuery.setText(sql);
  872. jasperDesign.setQuery(newQuery);
  873. JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
  874. JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, conn);
  875. JasperViewer.viewReport(jasperPrint);
  876.  
  877. } catch (Exception e){
  878. JOptionPane.showMessageDialog(null, e);
  879. }
  880. }
  881.  
  882. private void jMenuItem2MouseClicked(java.awt.event.MouseEvent evt) {
  883. // TODO add your handling code here:
  884. System.exit(0);
  885. }
  886.  
  887. private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
  888. // TODO add your handling code here:
  889. System.exit(0);
  890. }
  891.  
  892. /**
  893. * @param args the command line arguments
  894. */
  895.  
  896.  
  897. public static void main(String args[]) {
  898. /*
  899. * Set the Nimbus look and feel
  900. */
  901. //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  902. /*
  903. * If Nimbus (introduced in Java SE 6) is not available, stay with the
  904. * default look and feel. For details see
  905. * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  906. */
  907. try {
  908. for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  909. if ("Nimbus".equals(info.getName())) {
  910. javax.swing.UIManager.setLookAndFeel(info.getClassName());
  911. break;
  912. }
  913. }
  914. } catch (ClassNotFoundException ex) {
  915. java.util.logging.Logger.getLogger(FormJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  916. } catch (InstantiationException ex) {
  917. java.util.logging.Logger.getLogger(FormJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  918. } catch (IllegalAccessException ex) {
  919. java.util.logging.Logger.getLogger(FormJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  920. } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  921. java.util.logging.Logger.getLogger(FormJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  922. }
  923. //</editor-fold>
  924.  
  925. /*
  926. * Create and display the form
  927. */
  928. java.awt.EventQueue.invokeLater(new Runnable() {
  929.  
  930. public void run(){
  931. new FormJFrame().setVisible(true);
  932. }
  933. });
  934. }
  935.  
  936. // Variables declaration - do not modify
  937. private javax.swing.JMenuItem aboutclick;
  938. private javax.swing.JButton cmdPrintAll;
  939. private javax.swing.JButton cmdadd;
  940. private javax.swing.JButton cmddelete;
  941. private javax.swing.JButton cmdupdate;
  942. private javax.swing.JComboBox comboequip;
  943. private javax.swing.JComboBox itemcourse;
  944. private javax.swing.JComboBox itemquantity;
  945. private javax.swing.JComboBox itemyear;
  946. private com.toedter.calendar.JDateChooser jDateChooser1;
  947. private javax.swing.JLabel jLabel1;
  948. private javax.swing.JLabel jLabel10;
  949. private javax.swing.JLabel jLabel11;
  950. private javax.swing.JLabel jLabel12;
  951. private javax.swing.JLabel jLabel13;
  952. private javax.swing.JLabel jLabel14;
  953. private javax.swing.JLabel jLabel15;
  954. private javax.swing.JLabel jLabel16;
  955. private javax.swing.JLabel jLabel17;
  956. private javax.swing.JLabel jLabel18;
  957. private javax.swing.JLabel jLabel19;
  958. private javax.swing.JLabel jLabel2;
  959. private javax.swing.JLabel jLabel20;
  960. private javax.swing.JLabel jLabel21;
  961. private javax.swing.JLabel jLabel22;
  962. private javax.swing.JLabel jLabel23;
  963. private javax.swing.JLabel jLabel24;
  964. private javax.swing.JLabel jLabel26;
  965. private javax.swing.JLabel jLabel27;
  966. private javax.swing.JLabel jLabel3;
  967. private javax.swing.JLabel jLabel4;
  968. private javax.swing.JLabel jLabel5;
  969. private javax.swing.JLabel jLabel6;
  970. private javax.swing.JLabel jLabel7;
  971. private javax.swing.JLabel jLabel8;
  972. private javax.swing.JLabel jLabel9;
  973. private javax.swing.JMenu jMenu1;
  974. private javax.swing.JMenu jMenu2;
  975. private javax.swing.JMenuBar jMenuBar1;
  976. private javax.swing.JMenuItem jMenuItem2;
  977. private javax.swing.JPanel jPanel1;
  978. private javax.swing.JPanel jPanel2;
  979. private javax.swing.JPanel jPanel3;
  980. private javax.swing.JPanel jPanel4;
  981. private javax.swing.JScrollPane jScrollPane1;
  982. private javax.swing.JScrollPane jScrollPane2;
  983. private javax.swing.JTabbedPane jTabbedPane1;
  984. private javax.swing.JTable jTable1;
  985. private javax.swing.JTable jTable2;
  986. private javax.swing.JTextField txtaddress;
  987. private javax.swing.JTextField txtcontact;
  988. private javax.swing.JTextField txtfirst;
  989. private javax.swing.JTextField txtid;
  990. private javax.swing.JTextField txtinitial;
  991. private javax.swing.JTextField txtlast;
  992. private javax.swing.JTextField txtsearch;
  993. private javax.swing.JTextField updateaddress;
  994. private javax.swing.JTextField updateborrowed;
  995. private javax.swing.JTextField updatecontact;
  996. private javax.swing.JTextField updatecourse;
  997. private javax.swing.JTextField updateequip;
  998. private javax.swing.JTextField updatefirst;
  999. private javax.swing.JTextField updateid;
  1000. private javax.swing.JTextField updateinitial;
  1001. private javax.swing.JTextField updatelast;
  1002. private javax.swing.JTextField updatequantity;
  1003. private javax.swing.JTextField updateyear;
  1004. // End of variables declaration
  1005. }
RAW Paste Data