Exemple #1
0
  public void createExcel(String file) {

    String filename = createPath(file);
    System.out.println(filename);

    /*
       try {
       WorkbookSettings ws = new WorkbookSettings();
       ws.setLocale(new Locale("sv", "SE"));
       WritableWorkbook workbook = Workbook.createWorkbook(new File(filename), ws);
       WritableSheet s = workbook.createSheet("Sheet1", 0);
    //writeDataSheet(s);
    workbook.write();
    workbook.close();
    } catch (IOException e) {
    e.printStackTrace();
    } catch (WriteException e) {
    e.printStackTrace();
    }**/

    try {

      File newFile = new File(filename);
      Writer out =
          new BufferedWriter(new OutputStreamWriter(new FileOutputStream(newFile), "UTF8"));
      //	BufferedWrite output = new BufferedWriter(new OutputStreamReader(new
      // FileInputS§tream(filename), "iso-8859-1"));
      // FileWriter fw = new FileWriter(newFile.getAbsoluteFile());
      // BufferedWriter bw = new BufferedWriter(fw);
      // bw.write("Artikel;Antal/st;Pris/st;Total\n");
      out.append("Artikel;Antal/st;Pris/st;Total\n");
      for (Data d : dataList) {
        out.append(d.toString());
        out.append("\n");
        // bw.write(d.toString());
        // bw.write("\n");
      }
      // bw.close();
      out.flush();
      out.close();
    } catch (UnsupportedEncodingException unsuppEn) {
      unsuppEn.printStackTrace();
    } catch (IOException ioE) {
      ioE.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public FrmMainMenu() {
    Data user = new Data();
    String UserID;
    String UserName;
    UserID = user.getUserID().trim();
    UserName = user.getUserName().trim();

    setLookAndFeel();
    initComponents();
    txtUserID.setText(UserID.toString().trim());
    txtUserName.setText(UserName.toString().trim());
    lbDate.setText(date);
    setTime();
    lbYear.setText(user.getActivePeriod());
    checkUserAuthorization();
  }
  void checkUserAuthorization() {
    Data User = new Data();
    mnMasterUser.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "MST-001", Data.typeOfAction.View));
    mnUserFunction.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "MST-002", Data.typeOfAction.View));
    mnMasterBudgetGroup.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "MST-003", Data.typeOfAction.View));
    mnMasterBudgetDetail.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "MST-004", Data.typeOfAction.View));
    mnMasterTitle.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "MST-005", Data.typeOfAction.View));
    mnMasterEmployee.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "MST-006", Data.typeOfAction.View));

    mnTransactionBeginningBalance.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "TSK-001", Data.typeOfAction.View));
    mnTransactionBudgetUsage.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "TSK-002", Data.typeOfAction.View));
    mnTransactionBudgetTransfer.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "TSK-003", Data.typeOfAction.View));
    mnTransactionEndofYear.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "TSK-004", Data.typeOfAction.View));

    mnRptMasterBudget.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "RPT-001", Data.typeOfAction.View));
    mnRptBudgetUsage.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "RPT-002", Data.typeOfAction.View));
    mnRptTrxBudgetUsage.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "RPT-003", Data.typeOfAction.View));
    mnRptTrxBudgetTransfer.setEnabled(
        User.UserRight(txtUserID.getText().trim(), "RPT-004", Data.typeOfAction.View));
  }