UserManagement.java~6~
上传用户:liming9091
上传日期:2014-10-27
资源大小:3376k
文件大小:4k
源码类别:

Java编程

开发平台:

Java

  1. package uml_gaokai;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. import com.borland.dbswing.*;
  5. import com.borland.jbcl.layout.*;
  6. import com.borland.dx.sql.dataset.*;
  7. import java.awt.event.*;
  8. import java.sql.*;
  9. /**
  10.  * <p>Title: </p>
  11.  * <p>Description: </p>
  12.  * <p>Copyright: Copyright (c) 2003</p>
  13.  * <p>Company: </p>
  14.  * @author unascribed
  15.  * @version 1.0
  16.  */
  17. public class UserManagement extends JDialog {
  18.   private JPanel panel1 = new JPanel();
  19.   private XYLayout xYLayout1 = new XYLayout();
  20.   private JdbTable jdbTable1 = new JdbTable();
  21.   private QueryDataSet queryDataSet1 = new QueryDataSet();
  22.   private Database database1 = new Database();
  23.   private TableScrollPane tableScrollPane1 = new TableScrollPane();
  24.   private JButton jButton1 = new JButton();
  25.   private JButton jButton2 = new JButton();
  26.   private JButton jButton3 = new JButton();
  27.   private JButton jButton4 = new JButton();
  28.   private JButton jButton5 = new JButton();
  29.   public UserManagement(Frame frame, String title, boolean modal) {
  30.     super(frame, title, modal);
  31.     try {
  32.       jbInit();
  33.       pack();
  34.     }
  35.     catch(Exception ex) {
  36.       ex.printStackTrace();
  37.     }
  38.   }
  39.   public UserManagement() {
  40.     this(null, "", false);
  41.   }
  42.   private void jbInit() throws Exception {
  43.     panel1.setLayout(xYLayout1);
  44.     database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:gaokaiSQL", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
  45.     queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT [user].userID,[user].userName,[user].userPassword,[user].userAddress,[user].userAuthority,[use" +
  46.       "r].userGender,[user].userAge FROM [UML_CS].[dbo].[user]", null, true, Load.ALL));
  47.     jButton1.setText("增加用户");
  48.     jButton1.addActionListener(new java.awt.event.ActionListener() {
  49.       public void actionPerformed(ActionEvent e) {
  50.         jButton1_actionPerformed(e);
  51.       }
  52.     });
  53.     jButton2.setText("修改用户");
  54.     jButton3.setText("删除用户");
  55.     jButton3.addActionListener(new java.awt.event.ActionListener() {
  56.       public void actionPerformed(ActionEvent e) {
  57.         jButton3_actionPerformed(e);
  58.       }
  59.     });
  60.     jButton4.setText("查看用户");
  61.     jButton4.addActionListener(new java.awt.event.ActionListener() {
  62.       public void actionPerformed(ActionEvent e) {
  63.         jButton4_actionPerformed(e);
  64.       }
  65.     });
  66.     jButton5.setText("退出");
  67.     getContentPane().add(panel1);
  68.     panel1.add(jdbTable1,              new XYConstraints(-1, 0, 389, 253));
  69.     panel1.add(tableScrollPane1,  new XYConstraints(215, 192, -1, -1));
  70.     panel1.add(jButton2,  new XYConstraints(4, 290, 99, 25));
  71.     panel1.add(jButton3,  new XYConstraints(109, 290, 104, 26));
  72.     panel1.add(jButton1,  new XYConstraints(112, 255, 100, 26));
  73.     panel1.add(jButton4,     new XYConstraints(2, 255, 99, 27));
  74.     panel1.add(jButton5,  new XYConstraints(316, 292, 72, 24));
  75.   }
  76.   void jButton4_actionPerformed(ActionEvent e) {
  77.     jdbTable1.setDataSet(queryDataSet1) ;
  78.   }
  79.   //增加用户
  80.   void jButton1_actionPerformed(ActionEvent e) {
  81.     Registration registration = new Registration() ;
  82.      Dimension dlgSize = registration.getPreferredSize();
  83.      Dimension frmSize = getSize();
  84.      Point loc = getLocation();
  85.      registration.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  86.      registration.setModal(true);
  87.      registration.pack();
  88.      registration.show();
  89.   }
  90.   void jButton3_actionPerformed(ActionEvent e) {
  91.     DeleteUser deleteUser = new DeleteUser() ;
  92.     Dimension dlgSize = deleteUser.getPreferredSize();
  93.     Dimension frmSize = getSize();
  94.     Point loc = getLocation();
  95.     deleteUser.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  96.     deleteUser.setModal(true);
  97.     deleteUser.pack();
  98.     deleteUser.show();
  99.   }
  100. }