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

📄 chayezhus.java

📁 基于UML的小区物业管理系统设计:1.对小区所有房屋资料的录入和增
💻 JAVA
字号:
package 小区物业管理系统;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.sql.*;
import javax.swing.*;
import javax.swing.JPanel;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.ConnectionDescriptor;
import com.borland.dx.sql.dataset.QueryDataSet;
import com.borland.dx.sql.dataset.Load;
import com.borland.dx.sql.dataset.QueryDescriptor;
import com.borland.dbswing.DBDisposeMonitor;
import com.borland.dbswing.JdbNavToolBar;
import com.borland.dbswing.JdbStatusLabel;
import com.borland.dbswing.TableScrollPane;
import com.borland.dbswing.JdbTable;
import java.awt.Rectangle;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.GridBagLayout;
import java.awt.*;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2008</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class chayezhus extends JFrame {
    JPanel contentPane;
    int change=0;
    DBConnection lianjie=null;
    BorderLayout borderLayout1 = new BorderLayout();
    Database database1 = new Database();
    QueryDataSet queryDataSet1 = new QueryDataSet();
    DBDisposeMonitor dBDisposeMonitor1 = new DBDisposeMonitor();
    JdbNavToolBar jdbNavToolBar1 = new JdbNavToolBar();
    JdbStatusLabel jdbStatusLabel1 = new JdbStatusLabel();
    TableScrollPane tableScrollPane1 = new TableScrollPane();
    JdbTable jdbTable1 = new JdbTable();
    JPanel jPanel1 = new JPanel();
    JButton tijiao = new JButton();
    JLabel jLabel1 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JButton 查 = new JButton();
    JLabel jLabel2 = new JLabel();
    JTextField fanghao = new JTextField();
    JLabel jLabel3 = new JLabel();
    JTextField yezhu = new JTextField();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JTextField huxing = new JTextField();
    JTextField 入住时间 = new JTextField();
    JTextField 电话 = new JTextField();
    JButton zengjia = new JButton();
    JButton shanchu = new JButton();
    JButton xiugai = new JButton();
    JButton jButton6 = new JButton();
    public chayezhus() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        lianjie=new DBConnection();
        contentPane.setLayout(borderLayout1);
        setSize(new Dimension(660, 700));
        setTitle("查看业主信息");
        database1.setConnection(new ConnectionDescriptor(
                "jdbc:borland:dslocal:C:\\物业管理\\小区物业管理系统\\数据库\\database.jds",
                "admin", "admin", false,
                "com.borland.datastore.jdbc.DataStoreDriver"));
        queryDataSet1.setQuery(new QueryDescriptor(database1,
                "select * from zhuhu ", null, true, Load.ALL));
        dBDisposeMonitor1.setDataAwareComponentContainer(this);
        jdbStatusLabel1.setText("jdbStatusLabel1");
        jdbTable1.setDataSet(queryDataSet1);
        jdbTable1.addMouseListener(new chayezhus_jdbTable1_mouseAdapter(this));
        jPanel1.setLayout(null);
        tijiao.setBounds(new Rectangle(124, 571, 88, 23));
        tijiao.setText("提交");
        tijiao.addActionListener(new chayezhus_tijiao_actionAdapter(this));
       //tijiao.addActionListener(new chayezhus_jButton1_actionAdapter(this));
        jLabel1.setText("按照房号进行查询");
        jLabel1.setBounds(new Rectangle(97, 256, 121, 31));
        查.setBounds(new Rectangle(313, 264, 94, 23));
        查.setText("查询");
        查.addActionListener(new chayezhus_查_actionAdapter(this));
        //查.addActionListener(new chayezhus_jButton2_actionAdapter(this));
        tableScrollPane1.setBounds(new Rectangle(97, 48, 395, 187));
        jTextField1.setBounds(new Rectangle(219, 262, 66, 25));
        jLabel2.setText("房号");
        jLabel2.setBounds(new Rectangle(132, 306, 71, 30));
        fanghao.setBounds(new Rectangle(226, 308, 95, 27));
        jLabel3.setText("业主");
        jLabel3.setBounds(new Rectangle(132, 352, 70, 31));
        yezhu.setBounds(new Rectangle(226, 355, 95, 30));
        jLabel4.setText("户型");
        jLabel4.setBounds(new Rectangle(132, 401, 70, 31));
        jLabel5.setText("入住时间");
        jLabel5.setBounds(new Rectangle(132, 452, 69, 32));
        jLabel6.setText("电话");
        jLabel6.setBounds(new Rectangle(132, 504, 70, 30));
        huxing.setBounds(new Rectangle(227, 401, 94, 32));
        入住时间.setBounds(new Rectangle(227, 452, 94, 31));
        电话.setBounds(new Rectangle(227, 504, 94, 29));
        zengjia.setBounds(new Rectangle(402, 308, 91, 31));
        zengjia.setText("增加");
        zengjia.addActionListener(new chayezhus_zengjia_actionAdapter(this));
        shanchu.setBounds(new Rectangle(399, 373, 90, 33));
        shanchu.setText("删除");
        shanchu.addActionListener(new chayezhus_shanchu_actionAdapter(this));
        xiugai.setBounds(new Rectangle(402, 452, 89, 30));
        xiugai.setText("修改");
        xiugai.addActionListener(new chayezhus_xiugai_actionAdapter(this));
        jButton6.setBounds(new Rectangle(244, 574, 81, 23));
        jButton6.setText("退出");
        jButton6.addActionListener(new chayezhus_jButton6_actionAdapter(this));
        contentPane.add(jPanel1, java.awt.BorderLayout.CENTER);
        contentPane.add(jdbNavToolBar1, java.awt.BorderLayout.NORTH);
        contentPane.add(jdbStatusLabel1, java.awt.BorderLayout.SOUTH);
        jPanel1.add(tableScrollPane1, null);
        jPanel1.add(jLabel1, null);
        jPanel1.add(jTextField1, null);
        jPanel1.add(查, null);
        jPanel1.add(jLabel2);
        jPanel1.add(fanghao);
        jPanel1.add(jLabel3);
        jPanel1.add(jLabel4);
        jPanel1.add(jLabel5);
        jPanel1.add(jLabel6);
        jPanel1.add(huxing);
        jPanel1.add(入住时间);
        jPanel1.add(电话);
        jPanel1.add(zengjia);
        jPanel1.add(xiugai);
        jPanel1.add(shanchu);
        jPanel1.add(yezhu);
        jPanel1.add(tijiao, null);
        jPanel1.add(jButton6);
        tableScrollPane1.getViewport().add(jdbTable1);
    }

    public void jButton1_actionPerformed(ActionEvent e) {

}

    public void jButton2_actionPerformed(ActionEvent e) {


    }

    public void jdbTable1_mousePressed(MouseEvent e) {
    int row=jdbTable1.getSelectedRow();
               fanghao.setText(String.valueOf(jdbTable1.getValueAt(row,0)));
               yezhu.setText(String.valueOf(jdbTable1.getValueAt(row,1)));
               huxing.setText(String.valueOf(jdbTable1.getValueAt(row,2)));
               入住时间.setText(String.valueOf(jdbTable1.getValueAt(row,3)));
               电话.setText(String.valueOf(jdbTable1.getValueAt(row,4)));

    }

    public void zengjia_actionPerformed(ActionEvent e) {
change=1;
        fanghao.setText("");
        yezhu.setText("");
        huxing.setText("");
        入住时间.setText("");
        电话.setText("");

    }

    public void shanchu_actionPerformed(ActionEvent e) {
change=2;

    }

    public void xiugai_actionPerformed(ActionEvent e) {
change=3;
    }

    public void jButton6_actionPerformed(ActionEvent e) {
this.dispose();

    }

    public void tijiao_actionPerformed(ActionEvent e) {
        try{

               DBConnection lianjie = new DBConnection();
               Statement stat = lianjie.stat;

       if(change==1)
               {

                       stat.execute("insert into ZHUHU values('" +
                                    fanghao.getText() + "','" +
                                    yezhu.getText() + "','" +
                                    huxing.getText() + "','" +
                                    入住时间.getText() + "','" +
                                    电话.getText() + "')");
                       JOptionPane.showMessageDialog(this,"插入成功");
               }
                       else if(change==2)
               {
                   stat.execute("delete from zhuhu where 房号='"+
                                fanghao.getText()+"'");
                   JOptionPane.showMessageDialog(this,"删除成功");
               }
               else if(change==3)
               {
                   stat.execute("update zhuhu set 业主='"+
                                   yezhu.getText() + "',户型='" +
                                   huxing.getText() + "',入住时间='" +
                                   入住时间.getText() + "',电话='" +
                                   电话.getText() + "'where 房号='"+
                                   fanghao.getText()+"'"
                              );
                   JOptionPane.showMessageDialog(this,"修改成功");

               }
               else
               {
                   JOptionPane.showMessageDialog(this,"请先选择操作方式");
               }
               fanghao.setText("");
                      yezhu.setText("");
                      huxing.setText("");
                      入住时间.setText("");
                      电话.setText("");


    }catch(Exception ee){}
    }

    public void 查_actionPerformed(ActionEvent e) {

        DBConnection lianjie=new DBConnection();
        Statement stat=lianjie.stat;
        try{
            ResultSet rst=stat.executeQuery("select * from ZHUHU where 房号='"+
                         jTextField1.getText()+"'");
            while(rst.next())
            {
                fanghao.setText(rst.getString("房号"));
                yezhu.setText(rst.getString("业主"));
                huxing.setText(rst.getString("户型"));
                入住时间.setText(rst.getString("入住时间"));
                电话.setText(rst.getString("电话"));
            }
            lianjie.close();
        }
       catch(Exception ee){}
    }
}


class chayezhus_查_actionAdapter implements ActionListener {
    private chayezhus adaptee;
    chayezhus_查_actionAdapter(chayezhus adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.查_actionPerformed(e);
    }
}


class chayezhus_jButton6_actionAdapter implements ActionListener {
    private chayezhus adaptee;
    chayezhus_jButton6_actionAdapter(chayezhus adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton6_actionPerformed(e);
    }
}


class chayezhus_shanchu_actionAdapter implements ActionListener {
    private chayezhus adaptee;
    chayezhus_shanchu_actionAdapter(chayezhus adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.shanchu_actionPerformed(e);
    }
}


class chayezhus_xiugai_actionAdapter implements ActionListener {
    private chayezhus adaptee;
    chayezhus_xiugai_actionAdapter(chayezhus adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.xiugai_actionPerformed(e);
    }
}


class chayezhus_tijiao_actionAdapter implements ActionListener {
    private chayezhus adaptee;
    chayezhus_tijiao_actionAdapter(chayezhus adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.tijiao_actionPerformed(e);
    }
}


class chayezhus_jdbTable1_mouseAdapter extends MouseAdapter {
    private chayezhus adaptee;
    chayezhus_jdbTable1_mouseAdapter(chayezhus adaptee) {
        this.adaptee = adaptee;
    }

    public void mousePressed(MouseEvent e) {
        adaptee.jdbTable1_mousePressed(e);
    }
}


class chayezhus_zengjia_actionAdapter implements ActionListener {
    private chayezhus adaptee;
    chayezhus_zengjia_actionAdapter(chayezhus adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.zengjia_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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