?? stockmanageaccountentrycheckframe.java
字號:
tmpTextField = (JTextField)components[i]; //清空編輯框的內容 tmpTextField.setText(""); } } } //設置用戶的方法 public void setUser(User user) { this.user = user; } //設置賬套的方法 public void setLedgerDate(String ledgerDate) { this.ledgerDate = ledgerDate; } protected void processWindowEvent(WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { exit(); } } //顯示查詢會計分錄的方法 public void showSearchAccountEntryLedger(){ listData1.clear(); //為會計分錄列表框加入會計分錄數據 for(int i = 0; i < accountEntryLedgers.length; i++){ listData1.addElement(accountEntryLedgers[i][0]); } } //顯示單個會計分錄的方法 public void showAccountEntryLedger(){ //取得當前選擇項的位置 int selectedIndex = jList1.getSelectedIndex(); //當列表框不處于選擇狀態,不顯示數據 if(selectedIndex == -1){ return; } //顯示會計分錄的數據 jTextField4.setText(accountEntryLedgers[selectedIndex][0]); jTextField5.setText(accountEntryLedgers[selectedIndex][1]); jTextField6.setText(accountEntryLedgers[selectedIndex][2]); jTextField7.setText(accountEntryLedgers[selectedIndex][3]); jTextField8.setText(accountEntryLedgers[selectedIndex][4]); jTextField9.setText(accountEntryLedgers[selectedIndex][5]); jTextField10.setText(onProcesses[Integer.parseInt(accountEntryLedgers[selectedIndex][6])]); jTextArea1.setText(accountEntryLedgers[selectedIndex][7]); //顯示會計分錄明細數據 this.showAccountEntrySubLedger(); } //顯示會計分錄明細數據的方法 public void showAccountEntrySubLedger(){ //取得當前選擇項的位置 int selectedIndex = jList1.getSelectedIndex(); int serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]); accountEntrySubLedgers = stockManagementData.getAccountEntrySubLedgerByLinkSerialId(ledgerDate, serialId); //將數組數據轉換為表格數據 accountEntrySubLedgerObjects = new Object[accountEntrySubLedgers.length][5]; double total = 0; for(int i = 0; i < accountEntrySubLedgers.length; i++){ accountEntrySubLedgerObjects[i][0] = new Integer(accountEntrySubLedgers[i][0]); accountEntrySubLedgerObjects[i][1] = new Integer(accountEntrySubLedgers[i][1]); int debitCredit = Integer.parseInt(accountEntrySubLedgers[i][2]); accountEntrySubLedgerObjects[i][2] = debitCreditStrs[debitCredit]; accountEntrySubLedgerObjects[i][3] = dataMethod.transferAccountName(accountEntrySubLedgers[i][3]); double amount = dataMethod.round(Double.parseDouble(accountEntrySubLedgers[i][4])); accountEntrySubLedgerObjects[i][4] = new Double(amount); if(debitCredit == 0){ total += amount; }else{ total -= amount; } } //顯示借貸平衡數字 jTextField11.setText(String.valueOf(dataMethod.round(total))); //顯示表格的內容 this.showTableData(accountEntrySubLedgerObjects); } //顯示表格內容的方法 public void showTableData(Object[][] detail){ //設置表格的標題 aeslTableModel.setColumnNames(colNames); //設置表格的數據 aeslTableModel.setData(detail); //設置表格的列編輯狀態,所有列不能編輯 aeslTableModel.setColumnEditState(1); jTable1 = new JTable(aeslTableModel); //設置表格的字體 jTable1.setFont(dialog13); //將數據表格加入數據滾動框 jScrollPane3.getViewport().add(jTable1, null); //為表格科目標識列加入下拉列表框 javax.swing.table.TableColumn debitCreditColumn = jTable1.getColumnModel().getColumn(2); JComboBox comboBox = new JComboBox(new String[] {"借","貸"}); debitCreditColumn.setCellEditor(new DefaultCellEditor(comboBox)); //設置列的寬度 jTable1.getColumnModel().getColumn(0).setPreferredWidth(20); jTable1.getColumnModel().getColumn(1).setPreferredWidth(20); jTable1.getColumnModel().getColumn(2).setPreferredWidth(20); jTable1.getColumnModel().getColumn(3).setPreferredWidth(120); jTable1.getColumnModel().getColumn(4).setPreferredWidth(20); } //清空單個會計分錄顯示的方法 public void clearAccountEntryLedger(){ jTextField4.setText(""); jTextField5.setText(""); jTextField6.setText(""); jTextField7.setText(""); jTextField8.setText(""); jTextField9.setText(""); jTextField10.setText(""); jTextField11.setText(""); jTextArea1.setText(""); accountEntrySubLedgers = new String[0][5]; accountEntrySubLedgerObjects = new Object[0][5]; this.showTableData(accountEntrySubLedgerObjects); } //列表1的選擇事件 void jList1_valueChanged(ListSelectionEvent e) { if(listData1.size() > 0){ this.showAccountEntryLedger(); }else{ this.clearAccountEntryLedger(); } } //查詢方法 public void search(){ //取得查詢選項 int selectedIndex = jComboBox2.getSelectedIndex(); int accountNameSelectedIndex = jComboBox1.getSelectedIndex(); //創建科目查詢字符串數組 String[] accountNamesSearch = {"存貨", "現金", "管理費用", ""}; String accountNameSearch = accountNamesSearch[accountNameSelectedIndex]; //取得編輯框的變量 String searchValue = jTextField1.getText().trim(); String startDateStr = jTextField2.getText().trim(); String endDateStr = jTextField3.getText().trim(); if (selectedIndex == 0 | selectedIndex == 1 | selectedIndex == 2 | selectedIndex == 3) { if (searchValue.length() == 0) { JOptionPane.showMessageDialog(null, "請輸入查詢值"); return; } switch (selectedIndex) { case 0: //根據關聯標識取得記錄 accountEntryLedgers = stockManagementData.getAccountEntryLedgerByStringField( ledgerDate, accountNameSearch, "linkId", searchValue); break; case 1: //根據記賬用戶取得記錄 accountEntryLedgers = stockManagementData.getAccountEntryLedgerByStringField( ledgerDate, accountNameSearch, "filler", searchValue); break; case 2: //根據審核用戶取得記錄 accountEntryLedgers = stockManagementData.getAccountEntryLedgerByStringField( ledgerDate, accountNameSearch, "auditUser", searchValue); break; case 3: if(dataMethod.checkInt(searchValue) == 0){ JOptionPane.showMessageDialog(null, "按完成狀態查詢時,輸入值必須是整數," + "0表示進行,1表示撤消,2表示完成."); return; } //根據完成狀態取得記錄 accountEntryLedgers = stockManagementData.getAccountEntryLedgerByOnProcess( ledgerDate, accountNameSearch, Integer.parseInt(searchValue)); break; } }else{ java.sql.Timestamp startDate = dataMethod.transferDate(startDateStr); java.sql.Timestamp endDate = dataMethod.transferEndDate(endDateStr); if(startDate == null | endDate == null){ JOptionPane.showMessageDialog(null, "日期輸入錯誤,正確的日期格式是" + "yyyy-mm-dd(年-月-日),如2004-1-1"); return; } //根據日期取得記錄 accountEntryLedgers = stockManagementData.getAccountEntryLedgerByFillDate( ledgerDate, startDate, endDate, accountNameSearch); } this.showSearchAccountEntryLedger(); } //單擊事件 public void actionPerformed(ActionEvent e) { //取得按鈕的動作字符串 String actionCommand = e.getActionCommand().trim(); int selectedIndex = 0; int serialId = 0; String userName = user.getUserName(); String remark = jTextArea1.getText().trim(); if (actionCommand.equals("sign") | actionCommand.equals("unSign") | actionCommand.equals("cancel") | actionCommand.equals("restore") ) { //檢查打開的賬套是否當前賬套 int result = stockManagementData.isCurrentLedger(ledgerDate); if(result == 0){ JOptionPane.showMessageDialog(null, ledgerDate + "是往期賬套,不能進行電子簽名和撤消操作."); return; } if(jList1.isSelectionEmpty()){ JOptionPane.showMessageDialog(null, "先選擇會計分錄序號."); return; } selectedIndex = jList1.getSelectedIndex(); serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]); //檢查會計分錄是否上期轉入 String linkId = accountEntryLedgers[selectedIndex][1].trim(); if(linkId.equals("上期轉入")){ JOptionPane.showMessageDialog(null, "該會計分錄是上期轉入分錄,不能進行電子簽名和撤消操作."); return; } } if(actionCommand.equals("sign") | actionCommand.equals("unSign")){ if(Integer.parseInt(accountEntryLedgers[selectedIndex][6]) == 1){ JOptionPane.showMessageDialog(null, "會計分錄已撤消,不能進行電子簽名操作."); return; } } if(actionCommand.equals("cancel") | actionCommand.equals("restore")){ if(Integer.parseInt(accountEntryLedgers[selectedIndex][6]) == 2){ JOptionPane.showMessageDialog(null, "會計分錄已完成,不能進行撤消和恢復操作."); return; } } if (actionCommand.equals("search")) { //查詢 search(); }else if(actionCommand.equals("sign")){ //進行電子簽名 int result = stockManagementData.signAccountEntryLedger(ledgerDate, "auditUser", userName, serialId, 2,remark); if(result == 1){ JOptionPane.showMessageDialog(null, "電子簽名成功."); //更新數組的數據 accountEntryLedgers[selectedIndex][3] = userName; accountEntryLedgers[selectedIndex][6] = "2"; accountEntryLedgers[selectedIndex][7] = remark; //更新編輯框的值 jTextField7.setText(userName); jTextField10.setText(onProcesses[2]); }else{ JOptionPane.showMessageDialog(null, "電子簽名失敗."); } }else if(actionCommand.equals("unSign")){ //取消電子簽名 int result = stockManagementData.signAccountEntryLedger(ledgerDate, "auditUser", "", serialId, 0, remark); if(result == 1){ JOptionPane.showMessageDialog(null, "取消電子簽名成功."); accountEntryLedgers[selectedIndex][3] = ""; accountEntryLedgers[selectedIndex][6] = "0"; accountEntryLedgers[selectedIndex][7] = remark; //更新編輯框的值 jTextField7.setText(""); jTextField10.setText(onProcesses[0]); }else{ JOptionPane.showMessageDialog(null, "取消電子簽名失敗."); } }else if(actionCommand.equals("cancel")){ //撤消會計分錄 int result = stockManagementData.cancelOrRestoreAccountEntryLedger( ledgerDate, serialId, 1, remark); if(result == 1){ JOptionPane.showMessageDialog(null, "會計分錄撤消成功."); //更新數組的數據 accountEntryLedgers[selectedIndex][6] = "1"; accountEntryLedgers[selectedIndex][7] = remark; //更新編輯框的值 jTextField10.setText(onProcesses[1]); }else{ JOptionPane.showMessageDialog(null, "會計分錄撤消失敗."); } }else if(actionCommand.equals("restore")){ //恢復會計分錄的完成狀態 int result = stockManagementData.cancelOrRestoreAccountEntryLedger( ledgerDate, serialId, 0, remark); if(result == 1){ JOptionPane.showMessageDialog(null, "會計分錄恢復成功."); //更新數組的數據 accountEntryLedgers[selectedIndex][6] = "0"; accountEntryLedgers[selectedIndex][7] = remark; //更新編輯框的值 jTextField10.setText(onProcesses[0]); }else{ JOptionPane.showMessageDialog(null, "會計分錄恢復失敗."); } }else if(actionCommand.equals("exit")){ exit(); } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -