private void writetodb() { for (int index = 0; index < list.size(); index++) { Attendance detail = list.get(index); if (Login.getUserid() == detail.getId()) { if (detail.getDate().equalsIgnoreCase(date)) ; { if (detail.getIntime() == null) { detail.setIntime(intime); int latemin = DaysDifference.getTimeDifference("09:00:00", intime); if (latemin > 0) { detail.setLatemin(latemin); } } else if (detail.getOuttime() == null) { detail.setOuttime(outtime); } } } } try { AttendanceStorge.writingToUserAttendanceDB(list); } catch (Exception exp) { System.out.println("Cannot write to database"); } setbutton(); }
public InOut() { sdf = new SimpleDateFormat("HH:mm:ss"); list = new ArrayList<Attendance>(); // reading data in list try { list = AttendanceStorge.readingFromUserAttendanceDB(); } catch (Exception e) { JOptionPane.showMessageDialog(btnintime, "File not found"); } // GUI INTERFACE btnadimlogin = new JButton(" Work as Admin "); btninfo = new JButton("Employee Information"); btnintime = new JButton("IN Time"); btnchangepass = new JButton("Change Password"); btnintime.setMaximumSize(btninfo.getMaximumSize()); btnouttime = new JButton("OUT Time"); btnchangepass.setMaximumSize(btninfo.getMaximumSize()); btnouttime.setMaximumSize(btninfo.getMaximumSize()); btnleaverequest = new JButton("Leave Request"); btnleaverequest.setMaximumSize(btninfo.getMaximumSize()); boxbutton = Box.createVerticalBox(); boxbutton.add(Box.createRigidArea(new Dimension(60, 20))); boxbutton.add(btnintime); boxbutton.add(Box.createRigidArea(new Dimension(60, 20))); boxbutton.add(btnouttime); boxbutton.add(Box.createRigidArea(new Dimension(60, 20))); boxbutton.add(btnleaverequest); boxbutton.add(Box.createRigidArea(new Dimension(60, 20))); boxbutton.add(btnchangepass); boxbutton.add(Box.createRigidArea(new Dimension(60, 20))); boxbutton.add(btnadimlogin); btnintime.addActionListener(this); btnouttime.addActionListener(this); btnleaverequest.addActionListener(this); btnchangepass.addActionListener(this); btnadimlogin.addActionListener(this); add(boxbutton, BorderLayout.CENTER); setSize(240, 290); setVisible(true); setTitle("ATTENDENCE"); setLocationRelativeTo(null); setResizable(false); // button enable check initialdata(); }
public void initialdata() { int id = Login.getUserid(); Fetch fetch = new Fetch(id); Date d = new Date(); d.getDate(); DateFormat outdate; outdate = DateFormat.getDateInstance(); date = outdate.format(d); boolean check = false; for (int index = 0; index < list.size(); index++) { Attendance detail = list.get(index); if (Login.getUserid() == detail.getId()) { if (detail.getDate().equalsIgnoreCase(date)) { if (detail.getIntime() != null || detail.getOuttime() != null) { check = true; // } } } } if (check == false) { Attendance ref = new Attendance(id, fetch.getName(), date, null, null, 0); list.add(ref); try { AttendanceStorge.writingToUserAttendanceDB(list); } catch (Exception exp) { System.out.println("Cannot write to database"); } } setbutton(); }