📄 returnticketjpanel.java
字号:
confirmButton.setText(resourceMap.getString("confirmButton.text")); // NOI18N confirmButton.setName("confirmButton"); // NOI18N cancelButton.setAction(actionMap.get("cancel")); // NOI18N cancelButton.setFont(resourceMap.getFont("confirmButton.font")); // NOI18N cancelButton.setText(resourceMap.getString("cancelButton.text")); // NOI18N cancelButton.setName("cancelButton"); // NOI18N javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(34, 34, 34) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel6) .addGap(18, 18, 18) .addComponent(deductComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(48, 48, 48) .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(returnFareTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(jLabel2) .addComponent(jLabel1) .addComponent(jLabel4)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(10, 10, 10) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(ticketFareTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(beginPointTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel3) .addGap(18, 18, 18) .addComponent(endPointTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(ticketIdTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 525, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(isInsurancedCheckBox)) .addContainerGap(27, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(327, Short.MAX_VALUE) .addComponent(confirmButton) .addGap(26, 26, 26) .addComponent(cancelButton) .addGap(195, 195, 195)) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {beginPointTextField, endPointTextField, returnFareTextField, ticketFareTextField, ticketIdTextField}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(23, 23, 23) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel4) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(ticketIdTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(beginPointTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(endPointTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ticketFareTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(isInsurancedCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7) .addComponent(returnFareTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(deductComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel6)) .addGap(40, 40, 40) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cancelButton) .addComponent(confirmButton)) .addGap(26, 26, 26)) ); }// </editor-fold>//GEN-END:initComponents private void returnInitState() { this.ticketIdTextField.setText(""); this.beginPointTextField.setText(""); this.endPointTextField.setText(""); this.ticketFareTextField.setText(""); this.isInsurancedCheckBox.setSelected( false); this.reasonTextArea.setText(""); this.deductComboBox.setSelectedIndex(0); this.returnFareTextField.setText(""); } private void getTicketInfo(String id){ String sql = "select * from ticket_sell where id = '" + id + "'"; try { ResultSet rs = stmt.executeQuery(sql); if (rs.first()) { this.ticketIdTextField.setText(rs.getString(1)); this.beginPointTextField.setText(rs.getString(4)); this.endPointTextField.setText(rs.getString(5)); this.ticketFareTextField.setText(((Double) rs.getDouble(2)) .toString()); this.returnFareTextField.setText(((Double) rs.getDouble(2)) .toString()); this.ti.setFare(rs.getDouble(2)); String tmp_is_insured = rs.getString(3); this.isInsurancedCheckBox.setSelected(tmp_is_insured .equals("是") ? true : false); } else { javax.swing.JOptionPane.showMessageDialog(this, "读取车票信息失败,请重新扫描再次读取!", "错误", 0/* error */); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } private void deductComboBoxActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: //添加退钱比率 switch(this.deductComboBox.getSelectedIndex()){ case 0: this.ti.setReturn_rate(1.0); break; case 1: this.ti.setReturn_rate(0.8); break; } this.returnFareTextField.setText( String.valueOf( (this.ti.getReturn_rate() * this.ti.getFare() ) )); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField beginPointTextField; private javax.swing.JButton cancelButton; private javax.swing.JButton confirmButton; private javax.swing.JComboBox deductComboBox; private javax.swing.JTextField endPointTextField; private javax.swing.JCheckBox isInsurancedCheckBox; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextArea reasonTextArea; private javax.swing.JTextField returnFareTextField; private javax.swing.JTextField ticketFareTextField; private javax.swing.JTextField ticketIdTextField; // End of variables declaration//GEN-END:variables Connection conn = Database.getConn(); Statement stmt = Database.createStmt(conn); TicketInfo ti = new TicketInfo(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -