Untitled
unknown
java
3 years ago
3.2 kB
1
Indexable
Never
private void displayAppointmentList(int appID) throws FileNotFoundException, IOException { List<Appointment> appointmentList; List<Customer> custList; try ( // return list of appointment with cust details BufferedReader brApp = new BufferedReader(new FileReader(appointmentTxtFile))) { appointmentList = new ArrayList<Appointment>(); BufferedReader brCust = new BufferedReader(new FileReader(custTxtFile)); custList = new ArrayList<Customer>(); Scanner sc = new Scanner(brApp); Scanner scCust = new Scanner(brCust); //skip the previous line for (int i = 0; i < appID; i++) { sc.nextLine(); } String lineIwant = sc.nextLine(); System.out.println(lineIwant); String data[] = lineIwant.split(","); Appointment appointment = new Appointment(); appointment.setAppointmentID(Integer.valueOf(data[0])); appointment.setAppointmentFees(Integer.valueOf(data[1])); appointment.setAppointmentDate(data[2]); appointment.setAppointmentTime(data[3]); appointment.setAppointmentFeedback(data[4]); appointment.setAppointmentStatus(data[5]); appointmentList.add(appointment); //get custID currentCustID = Integer.valueOf(data[6]); for (int i = 0; i < currentCustID; i++) { scCust.nextLine(); } String custDataLine = scCust.nextLine(); String custData[] = custDataLine.split(","); Customer cust = new Customer(Integer.valueOf(custData[0]), custData[1], custData[2], custData[3]); custList.add(cust); lblCustName2.setText(cust.getCustName()); lblDate2.setText(appointment.getAppointmentDate()); lblTime2.setText(appointment.getAppointmentTime()); BufferedReader brTech = new BufferedReader(new FileReader(userTxtFile)); currentTechID= Integer.valueOf(data[7]); Scanner scTech = new Scanner(brTech); for (int i = 0; i <currentTechID;i++){ scTech.nextLine(); //skip the previous line } String techDataLine = scTech.nextLine(); String techData[]= techDataLine.split(","); lblTechnicianName.setText(techData[4]); //store current selected details currentDate = appointment.getAppointmentDate(); currentCustName = cust.getCustName(); currentTechName = techData[4]; currentPhoneNo = cust.getCustPhoneNo(); currentAddress = cust.getCustAddress(); sc.close(); } AppointmentTableModel apptablemodel = new AppointmentTableModel(); //warning: the row number of appList must == row number of custList for the rowcount to display properly apptablemodel.setList(appointmentList, custList); AppointmentTable2.setModel(apptablemodel); }