?? stockmanageaccountentrycreateframe.java
字號:
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 linkId = ""; String remark = jTextArea1.getText().trim(); if (actionCommand.equals("create") | actionCommand.equals("update") | actionCommand.equals("cancelAccountEntry") | actionCommand.equals("restore") ) { //檢查打開的賬套是否當前賬套 int result = stockManagementData.isCurrentLedger(ledgerDate); if(result == 0){ JOptionPane.showMessageDialog(null, ledgerDate + "是往期賬套,不能進行電子簽名和撤消操作."); return; } } if (actionCommand.equals("update") | actionCommand.equals("cancelAccountEntry") | actionCommand.equals("restore") ) { if(jList1.isSelectionEmpty()){ JOptionPane.showMessageDialog(null, "先選擇會計分錄序號."); return; } selectedIndex = jList1.getSelectedIndex(); //檢查會計分錄是否上期轉入 linkId = accountEntryLedgers[selectedIndex][1].trim(); if(linkId.equals("上期轉入")){ JOptionPane.showMessageDialog(null, "該會計分錄是上期轉入分錄,不能進行修改、撤消和恢復操作."); return; } if(Integer.parseInt(accountEntryLedgers[selectedIndex][6]) == 2){ JOptionPane.showMessageDialog(null, "會計分錄已完成,不能進行修改、撤消和恢復操作."); return; } } if (actionCommand.equals("search")) { //查詢 search(); }else if(actionCommand.equals("create")){ action = "create"; this.clearAccountEntryLedger(); this.checkBtn(true); this.checkSubBtn(true); }else if(actionCommand.equals("update")){ action = "update"; this.checkBtn(true); }else if(actionCommand.equals("ok")){ //創建會計分錄數據表的單個記錄數組 String[] accountEntryLedger = new String[8]; //取得會計分錄的值 accountEntryLedger[1] = jTextField5.getText().trim(); //相關票據標識 accountEntryLedger[2] = user.getUserName(); //記賬用戶 accountEntryLedger[3] = ""; //審核用戶 accountEntryLedger[4] = jTextField8.getText().trim(); //記賬日期 accountEntryLedger[5] = null; //審核日期 accountEntryLedger[6] = "0"; //完成狀態 accountEntryLedger[7] = remark; //備注 int result = 0; if(action.equals("create") | action.equals("update")){ //檢查明細賬是否為空 if(accountEntrySubLedgerObjects.length == 0){ JOptionPane.showMessageDialog(null, "明細賬數據表為空,不可以創建會計分錄."); return; } //檢查借貨是否平衡 this.recountBalance(); double total = Double.parseDouble(jTextField11.getText().trim()); if(total != 0){ JOptionPane.showMessageDialog(null, "明細賬借貸不平衡,不可以創建和更新會計分錄."); return; } //檢查記賬日期是否正確 if(dataMethod.transferDate(accountEntryLedger[4]) == null){ JOptionPane.showMessageDialog(null, "記賬日期輸入錯誤,正確的日期格式是" + "yyyy-mm-dd(年-月-日),如2004-1-1"); return; } //轉換表格數據 this.transferTableData(); } if(action.equals("create")){ //創建添加的會計分錄數組 String[] accountEntryLedgerForCreate = new String[7]; System.arraycopy(accountEntryLedger, 1, accountEntryLedgerForCreate, 0, 7); //創建添加的會計分錄的明細數組 String[][] accountEntrySubLedgersForCreate = new String[accountEntrySubLedgers.length][3]; for(int i = 0; i < accountEntrySubLedgers.length; i++){ System.arraycopy(accountEntrySubLedgers[i], 2, accountEntrySubLedgersForCreate[i], 0, 3); } //添加會計分錄 result = stockManagementData.createAccountEntry(ledgerDate, accountEntryLedgerForCreate, accountEntrySubLedgersForCreate); if(result == 1){ JOptionPane.showMessageDialog(null, "會計分錄添加成功,請重新執行查詢操作顯示新的會計分錄."); }else{ JOptionPane.showMessageDialog(null, "會計分錄添加失敗,請檢查輸入值是否大于字段范圍."); } }else if (action.equals("update")){ selectedIndex = jList1.getSelectedIndex(); //序號、記帳用戶保持不變 accountEntryLedger[0] = accountEntryLedgers[selectedIndex][0]; accountEntryLedger[2] = accountEntryLedgers[selectedIndex][2]; //更新會計分錄,更新會計分錄后將會計分錄的完成狀態設為進行 result = stockManagementData.updateAccountEntry(ledgerDate, accountEntryLedger, accountEntrySubLedgers); if(result == 1){ JOptionPane.showMessageDialog(null, "會計分錄更新成功."); //更新會計分錄數組 accountEntryLedgers[selectedIndex][1] = accountEntryLedger[1]; //關聯標識 accountEntryLedgers[selectedIndex][3] = ""; //審核用戶 accountEntryLedgers[selectedIndex][4] = accountEntryLedger[4]; //記賬日期 accountEntryLedgers[selectedIndex][5] = ""; //審核日期 accountEntryLedgers[selectedIndex][6] = "0"; //完成狀態 accountEntryLedgers[selectedIndex][7] = remark; //備注 //更新編輯框的狀態 jTextField7.setText(""); jTextField9.setText(""); jTextField10.setText(onProcesses[0]); }else{ JOptionPane.showMessageDialog(null, "會計分錄更新失敗."); } } this.checkSubBtn(false); this.checkBtn(false); }else if(actionCommand.equals("cancel")){ this.jList1_valueChanged(null); this.checkBtn(false); this.checkSubBtn(false); }else if(actionCommand.equals("cancelAccountEntry")){ selectedIndex = jList1.getSelectedIndex(); serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]); //撤消會計分錄 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")){ selectedIndex = jList1.getSelectedIndex(); serialId = Integer.parseInt(accountEntryLedgers[selectedIndex][0]); //恢復會計分錄的完成狀態 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("createSub")){ //為會計分錄明細表添加一個空行 int objectsLength = accountEntrySubLedgerObjects.length; Object[][] tempObjs = new Object[objectsLength + 1][5]; System.arraycopy(accountEntrySubLedgerObjects, 0, tempObjs, 0, objectsLength); tempObjs[objectsLength][0] = new Integer(0); tempObjs[objectsLength][1] = new Integer(0); tempObjs[objectsLength][2] = "借"; tempObjs[objectsLength][3] = ""; tempObjs[objectsLength][4] = new Double(0); accountEntrySubLedgerObjects = tempObjs; this.showTableData(accountEntrySubLedgerObjects); }else if(actionCommand.equals("deleteSub")){ if(jTable1.getSelectedRowCount() == 0){ JOptionPane.showMessageDialog(null, "請選擇明細記錄."); return; } //刪除選擇的記錄 int tableSelectedIndex = jTable1.getSelectedRow(); Object[][] tempObjs = new Object[accountEntrySubLedgerObjects.length - 1][5]; int line = 0; for(int i = 0; i < accountEntrySubLedgerObjects.length; i++){ if(i == tableSelectedIndex){ continue; }else{ for(int j = 0; j < 5; j++){ tempObjs[line][j] = accountEntrySubLedgerObjects[i][j]; } line++; } } accountEntrySubLedgerObjects = tempObjs; this.showTableData(accountEntrySubLedgerObjects); }else if(actionCommand.equals("exit")){ exit(); } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -