📄 salereturnpayableframe.java~8~
字号:
tmpBtn.addActionListener(this); } } } //退出方法 public void exit(){ //隐藏窗口 this.setVisible(false); //清空数组的内容 currentAccountLedger = new String[0][13]; //清空列表框的内容 listData1.clear(); //清空文本框的内容 jTextArea1.setText(""); //取得面板上的所有控件 Component[] components = contentPane.getComponents(); //创建临时编辑框控件 JTextField tmpTextField = new JTextField(); for(int i = 0; i < components.length; i++){ if(components[i].getClass().getName().equals("javax.swing.JTextField")){ 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 showSearchCurrentAccountLedger(){ listData1.clear(); //为应付票据列表框加入应付票据数据 for(int i = 0; i < currentAccountLedger.length; i++){ listData1.addElement(currentAccountLedger[i][0]); } } //显示单个应付票据的方法 public void showCurrentAccountLedger(){ //取得当前选择项的位置 int selectedIndex = jList1.getSelectedIndex(); //当列表框不处于选择状态,不显示商品数据 if(selectedIndex == -1){ return; } //显示应付票据的数据 jTextField4.setText(currentAccountLedger[selectedIndex][0]); jTextField5.setText(currentAccountLedger[selectedIndex][1]); jTextField6.setText(currentAccountLedger[selectedIndex][3]); jTextField7.setText(currentAccountLedger[selectedIndex][4]); jTextField8.setText(currentAccountLedger[selectedIndex][5]); jTextField9.setText(currentAccountLedger[selectedIndex][6]); jTextField10.setText(currentAccountLedger[selectedIndex][7]); jTextField11.setText(currentAccountLedger[selectedIndex][8]); jTextField12.setText(onProcesses[Integer.parseInt(currentAccountLedger[selectedIndex][9])]); jTextArea1.setText(currentAccountLedger[selectedIndex][10]); } //清空单个应付票据显示的方法 public void clearCurrentAccountLedger(){ jTextField4.setText(""); jTextField5.setText(""); jTextField6.setText(""); jTextField7.setText(""); jTextField8.setText(""); jTextField9.setText(""); jTextField10.setText(""); jTextField11.setText(""); jTextField12.setText(""); jTextArea1.setText(""); } //列表1的选择事件 void jList1_valueChanged(ListSelectionEvent e) { if(listData1.size() > 0){ this.showCurrentAccountLedger(); }else{ this.clearCurrentAccountLedger(); } } //查询方法 public void search(){ //取得查询选项 int selectedIndex = jComboBox1.getSelectedIndex(); //取得编辑框的变量 String searchValue = jTextField1.getText().trim(); String startDateStr = jTextField2.getText().trim(); String endDateStr = jTextField3.getText().trim(); if (selectedIndex == 0 | selectedIndex == 1 | selectedIndex == 2 | selectedIndex == 3 | selectedIndex == 4) { if (searchValue.length() == 0) { JOptionPane.showMessageDialog(null, "请输入查询值"); return; } switch (selectedIndex) { case 0: //根据票据编号取得记录 currentAccountLedger = stockManagementData.getCurrentAccountLedgerByStringField( ledgerDate, "currentAccountId", searchValue, 2); break; case 1: //根据客户取得记录 currentAccountLedger = stockManagementData.getCurrentAccountLedgerByStringField( ledgerDate, "receiverName", searchValue, 2); break; case 2: //根据开票据用户取得记录 currentAccountLedger = stockManagementData.getCurrentAccountLedgerByStringField( ledgerDate, "documentFiller", searchValue, 2); break; case 3: //根据现金管理员取得记录 currentAccountLedger = stockManagementData.getCurrentAccountLedgerByStringField( ledgerDate, "cashUser", searchValue, 2); break; case 4: if(dataMethod.checkInt(searchValue) == 0){ JOptionPane.showMessageDialog(null, "按完成状态查询时,输入值必须是整数," + "0表示进行,1表示撤消,2表示完成."); return; } //根据完成状态取得记录 currentAccountLedger = stockManagementData.getCurrentAccountLedgerByOnProcess( ledgerDate, 2, 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; } //根据日期取得记录 currentAccountLedger = stockManagementData.getCurrentAccountLedgerByFillDate(ledgerDate, startDate, endDate, 2); } this.showSearchCurrentAccountLedger(); } //单击事件 public void actionPerformed(ActionEvent e) { //取得按钮的动作字符串 String actionCommand = e.getActionCommand().trim(); int selectedIndex = 0; String userName = user.getUserName(); //创建单个往来帐套数组 String[] sperateCurrentAccountLedger = new String[11]; if (actionCommand.equals("search")) { //查询 search(); } if (actionCommand.equals("sign") ) { //检查打开的账套是否当前账套 int result = stockManagementData.isCurrentLedger(ledgerDate); if(result == 0){ JOptionPane.showMessageDialog(null, ledgerDate + "是往期账套,不能进行电子签名操作."); return; } if(jList1.isSelectionEmpty()){ JOptionPane.showMessageDialog(null, "先选择应付票据."); return; } selectedIndex = jList1.getSelectedIndex(); //取得单个往来帐套数组 for(int i = 0; i < sperateCurrentAccountLedger.length; i++){ sperateCurrentAccountLedger[i] = currentAccountLedger[selectedIndex][i]; } //取得备注的内容 sperateCurrentAccountLedger[10] = jTextArea1.getText(); //检查应付票据是否完成 if(Integer.parseInt(sperateCurrentAccountLedger[9]) == 2){ JOptionPane.showMessageDialog(null, "应付票据已完成,不能进行电子签名操作."); return; } //进行电子签名 result = stockManagementData.cashUserSignAccountReceivable(ledgerDate, userName, sperateCurrentAccountLedger); if(result == 1){ JOptionPane.showMessageDialog(null, "电子签名成功."); //更新数组的数据 currentAccountLedger[selectedIndex][6] = userName; currentAccountLedger[selectedIndex][9] = "2"; currentAccountLedger[selectedIndex][10] = sperateCurrentAccountLedger[10]; //更新用户名编辑框的值 jTextField9.setText(userName); //更新完成状态编辑框的值 jTextField12.setText(onProcesses[2]); }else{ JOptionPane.showMessageDialog(null, "电子签名失败."); } } if(actionCommand.equals("printPayCheck")){ selectedIndex = jList1.getSelectedIndex(); if(selectedIndex == -1){ JOptionPane.showMessageDialog(null, "先选择应付票据."); return; } //取得单个往来帐套数组 for(int i = 0; i < sperateCurrentAccountLedger.length; i++){ if(currentAccountLedger[selectedIndex][i] == null){ sperateCurrentAccountLedger[i] = ""; }else{ sperateCurrentAccountLedger[i] = currentAccountLedger[selectedIndex][i]; } } //显示应付票据打印窗口 if(accountReveivablePrintFrame == null){ accountReveivablePrintFrame = new AccountReceivablePrintFrame(); //使窗口居中对齐 setCenterPosition(accountReveivablePrintFrame); accountReveivablePrintFrame.setVisible(true); }else{ accountReveivablePrintFrame.setVisible(true); } //为打印窗口传入数组参数 accountReveivablePrintFrame.setCurrentAccountLedger(sperateCurrentAccountLedger); //显示应付票据内容 accountReveivablePrintFrame.showOnePage(); }else if(actionCommand.equals("exit")){ exit(); } } //使窗口居中的方法 public void setCenterPosition(JFrame frame){ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -