⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 feiyonghuizong.java

📁 物业管理系统
💻 JAVA
字号:
package wuYeGuanLi;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;
import java.io.*;

public class FeiYongHuiZong
    extends JFrame
    implements ActionListener {

  private JLabel date1;
  private JLabel date2;
  private JLabel building;
  private JLabel shouFeiXiangMu;
  private JLabel yeZhu;
  private JLabel shouKuanRen;
  private JLabel money;
  private JTextField date11;
  private JTextField date22;
  private JComboBox building1;
  private JComboBox shouFeiXiangMu1;
  private JComboBox yeZhu1;
  private JTextField shouKuanRen1;
  private JTextArea money1;
  private JButton queryButton;
  private Connection con;
  private Statement stmt;
  private ResultSet rs;

  public static void main(String[] args) {
    FeiYongHuiZong dd = new FeiYongHuiZong();
    dd.setVisible(true);
  }

  public FeiYongHuiZong() {
    setTitle("费用查询");
    setSize(400, 300);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    //获取屏幕大小
    setLocation( (screen.width - 400) / 2, (screen.height - 400) / 2);
    //界面默认在屏幕中间显示
    this.getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    date1 = new JLabel("开始日期");
    date2 = new JLabel("结束日期");
    building = new JLabel("大  楼");
    money = new JLabel("收款合计");

    date11 = new JTextField(12);
    date11.setText("");
    date22 = new JTextField(12);
    date22.setText("");
    building1 = new JComboBox();
    building1.addItem("全部");
    money1 = new JTextArea(1, 12);
    money1.setText("");

    try {
      con = QueryDB.getConnection("wang", "");
      stmt = con.createStatement();

      String query = "SELECT 楼号 FROM building";
      rs = stmt.executeQuery(query);
      while (rs.next()) {
        building1.addItem(rs.getString(1));
      }
    }
    catch (Exception e) {
      //result.setText("Error " + e);
    }

    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.weighty = 1;
    add(date1, gbc, 0, 0, 1, 1);
    add(date2, gbc, 0, 1, 1, 1);
    add(building, gbc, 0, 2, 1, 1);
    //add(shouFeiXiangMu, gbc, 0, 4, 1, 1);
    //add(yeZhu, gbc, 0, 3, 1, 1);
    //add(shouKuanRen,gbc,0,5,1,1);
    add(money, gbc, 0, 6, 1, 1);

    add(date11, gbc, 1, 0, 1, 1);
    add(date22, gbc, 1, 1, 1, 1);
    add(building1, gbc, 1, 2, 1, 1);
    //add(shouFeiXiangMu1, gbc, 1, 4, 1, 1);
    //add(yeZhu1, gbc, 1, 3, 1, 1);
    //add(shouKuanRen1,gbc,1,5,1,1);
    add(money1, gbc, 1, 6, 1, 1);

    queryButton = new JButton("查询");
    queryButton.addActionListener(this);
    add(queryButton, gbc, 1, 7, 1, 1);
  }

  private void add(Component c, GridBagConstraints gbc,
                   int x, int y, int w, int h) {
    gbc.gridx = x;
    gbc.gridy = y;
    gbc.gridwidth = w;
    gbc.gridheight = h;
    getContentPane().add(c, gbc);
  }

  /**
   * actionPerformed
   *
   * @param e ActionEvent
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == queryButton) {
      String beginDate = date11.getText();
      String endDate = date22.getText();
      int tempBeginDate = Integer.parseInt(beginDate);
      //System.out.println(tempBeginDate);
      int  tempEndDate = Integer.parseInt(endDate);
      //System.out.println(tempEndDate);
      int bbc = tempEndDate - tempBeginDate +1;
      //System.out.println(bbc);
      int temp[] = new int[bbc];
      int tempInt[] = new int[bbc];
      String stm[] = new String[bbc];
      int sum = 0;
      String a = (String) building1.getSelectedItem();
      //String b = (String) yeZhu1.getSelectedItem();
      //String c = (String) shouFeiXiangMu1.getSelectedItem();
      try {
        for (int i = 0; i < bbc; i++) {
          temp[i] = tempBeginDate;
          //System.out.println(tempBeginDate);
          if(a.equals("全部")){
            stm[i] = "SELECT 合计 FROM yueHeJi";
          }else{
            stm[i] = "SELECT 合计 FROM yueHeJi,yeZhu "
                + "WHERE yueHeJi.业主代码 = yeZhu.业主代码 "
                + " AND yeZhu.楼号 = '" + a + "'";
            System.out.println(stm[i]);
          }
          ResultSet rs = stmt.executeQuery(stm[i]);
          while (rs.next()) {
            String ss = rs.getString(1);
            System.out.println(ss);
            tempInt[i] = Integer.parseInt(ss);
            //System.out.println(tempInt[i]);
            //System.out.println(temp[0]);
            //System.out.println(temp[1]);
            //System.out.println(temp[i]);
            sum = sum + tempInt[i];
            System.out.println(sum);
            tempBeginDate++;
          }
        }
        rs.close();

      }
      catch (Exception ee) {

      }

      String d = Integer.toString(sum);
      money1.setText(d);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -