コード例 #1
0
  public void calcularComissao() throws ParseException {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

    try {
      Date data1 = dateInicio.getDate();
      Date data2 = dateFim.getDate();
      if (CalcularData.TirarDiferenca(data1, data2) < 0) {
        JOptionPane.showMessageDialog(
            null, "As datas devem ser iguais ou a data final ser superior a data inicial!");
      } else {
        objPed =
            pedDao.comissaoTotalPedido(
                Integer.parseInt(textField.getText()),
                df.parse(dateInicio.getEditor().getText()),
                df.parse(dateFim.getEditor().getText()));
        total = objPed.getTotalPedido();
        porCentCom = Double.parseDouble(textField_2.getText());
        totalCom = (total * porCentCom) / 100;
        JOptionPane.showMessageDialog(null, "Comissão calculada!" + "\nR$ " + totalCom);
        textField_2.setText(String.valueOf(totalCom));
      }
    } catch (NumberFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (DaoException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #2
0
 public void keyPressed(KeyEvent event) {
   if (event.getSource() == txtPesq) {
     try {
       atualizaLista(table, txtPesq.getText().toString());
     } catch (DaoException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
コード例 #3
0
  public static void chamaFuncionario(int idFunc) {
    Funcionario objFunc = new Funcionario();

    FuncionarioDao objDao = new FuncionarioDao();

    try {
      objFunc = objDao.procurarFuncionarioID(idFunc);
    } catch (DaoException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    textField.setText(String.valueOf(idFunc));
    textField_9.setText(objFunc.getNomeFunc());
    textField_1.setText(objFunc.getProfissaoFunc());

    textField_3.setText(String.valueOf(objFunc.getSalarioFunc()));
    textField_3.getText().replace(",", ".");
    textField_3.setEditable(false);

    // Gerar a comissão automaticamente
    textField_2.setText(String.valueOf(objFunc.getComissaoFunc()));
    textField_2.setEditable(false);
  }