public TransEntruckBill makeBill(Message message, Iterator<String> orderList) {
    for (int i = 0; i < message.length(); i++) {
      if (message.getInform(i).equals("")) {
        return null;
      }
    }

    TransEntruckBill bill = new TransEntruckBill(message, orderList);
    double fee = calculator.calculateFee(bill);
    bill.setPayment(fee);
    dataServer.addBill(bill);
    approver.addBill(bill.submit());
    return bill;
  }
示例#2
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == cancel) {
      this.notifyWatchers(State.YING_START);
    } else if (e.getSource() == confirm) {
      String year = timeInput[0].getSelectedItem().toString();
      String month = timeInput[1].getSelectedItem().toString();
      String day = timeInput[2].getSelectedItem().toString();

      String date = year + "-" + month + "-" + day;

      String hallId = jtf[0].getText();
      String transNum = jtf[1].getText();
      String carId = jtf[2].getText();
      String destination = jtf[3].getText();
      String supervisor = jtf[4].getText();
      String transportor = jtf[5].getText();

      Message message = new Message();
      message.addInform(date);
      message.addInform(hallId);
      message.addInform(transNum);
      message.addInform(destination);
      message.addInform(carId);
      message.addInform(supervisor);
      message.addInform(transportor);

      int row = tableModel.getRowCount();
      ArrayList<String> orderList = new ArrayList<String>();

      for (int i = 0; i < row; i++) {
        orderList.add(tableModel.getValueAt(i, 0).toString());
      }
      HallEntruckBill bill = blServer.makeBill(message, orderList.iterator());

      if (bill != null) {
        jtf[7].setText(String.valueOf(bill.getPayment()));

        this.add(jl[9]);
        this.add(jtf[7]);
        for (int i = 0; i < 8; i++) {
          jtf[i].setEditable(false);
        }
        for (int i = 0; i < 3; i++) {
          timeInput[i].setEditable(false);
        }
        this.remove(confirm);
        this.remove(cancel);
        this.add(over);

        this.repaint();
      } else {
        showMessage("装车单未填写完成");
      }
    }

    if (e.getSource() == add) {
      // 添加单号列表
      String input = jtf[6].getText();
      if (!input.equals("")) {
        Vector<String> vec = new Vector<>();
        vec.add(input);
        tableModel.addRow(vec);
        jtf[6].setText("");
      }
    }

    if (e.getSource() == over) {
      this.notifyWatchers(State.YING_START);
    }
  }