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

Java编程

开发平台:

Java

  1. package uml_gaokai;
  2. import java.awt.*;
  3. import javax.swing.*;
  4. import com.borland.dx.sql.dataset.*;
  5. import com.borland.dbswing.*;
  6. import com.borland.jbcl.layout.*;
  7. import java.awt.event.*;
  8. /**
  9.  * <p>Title: </p>
  10.  * <p>Description: </p>
  11.  * <p>Copyright: Copyright (c) 2003</p>
  12.  * <p>Company: </p>
  13.  * @author unascribed
  14.  * @version 1.0
  15.  */
  16. public class BuyerWindow extends JDialog {
  17.   private JPanel panel1 = new JPanel();
  18.   private Database database1 = new Database();
  19.   private QueryDataSet queryDataSet1 = new QueryDataSet();
  20.   private QueryDataSet queryDataSet2 = new QueryDataSet();
  21.   private QueryDataSet queryDataSet3 = new QueryDataSet();
  22.   private QueryDataSet queryDataSet4 = new QueryDataSet();
  23.   private QueryDataSet queryDataSet5 = new QueryDataSet();
  24.   private XYLayout xYLayout1 = new XYLayout();
  25.   private JPanel jPanel1 = new JPanel();
  26.   private XYLayout xYLayout2 = new XYLayout();
  27.   private JdbTable jdbTable1 = new JdbTable();
  28.   private TableScrollPane tableScrollPane1 = new TableScrollPane();
  29.   private JButton jButton1 = new JButton();
  30.   private JButton jButton2 = new JButton();
  31.   private JButton jButton3 = new JButton();
  32.   private JButton jButton4 = new JButton();
  33.   private JButton jButton5 = new JButton();
  34.   public BuyerWindow(Frame frame, String title, boolean modal) {
  35.     super(frame, title, modal);
  36.     try {
  37.       jbInit();
  38.       pack();
  39.     }
  40.     catch(Exception ex) {
  41.       ex.printStackTrace();
  42.     }
  43.   }
  44.   public BuyerWindow() {
  45.     this(null, "", false);
  46.   }
  47.   private void jbInit() throws Exception {
  48.     panel1.setLayout(xYLayout1);
  49.     database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:gaokaiSQL", "sa", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));
  50.     jPanel1.setLayout(xYLayout2);
  51.     jButton1.setText("查看全部订货单");
  52.     jButton1.addActionListener(new java.awt.event.ActionListener() {
  53.       public void actionPerformed(ActionEvent e) {
  54.         jButton1_actionPerformed(e);
  55.       }
  56.     });
  57.     jButton2.setText("分项查询");
  58.     jButton2.addActionListener(new java.awt.event.ActionListener() {
  59.       public void actionPerformed(ActionEvent e) {
  60.         jButton2_actionPerformed(e);
  61.       }
  62.     });
  63.     jButton3.setText("退出");
  64.     jButton3.addActionListener(new java.awt.event.ActionListener() {
  65.       public void actionPerformed(ActionEvent e) {
  66.         jButton3_actionPerformed(e);
  67.       }
  68.     });
  69.     jButton4.setText("增加订单");
  70.     jButton4.addActionListener(new java.awt.event.ActionListener() {
  71.       public void actionPerformed(ActionEvent e) {
  72.         jButton4_actionPerformed(e);
  73.       }
  74.     });
  75.     jButton5.setText("更改订单状态");
  76.     panel1.add(jPanel1,  new XYConstraints(190, 154, -1, -1));
  77.     panel1.add(jdbTable1,  new XYConstraints(1, 0, 399, 238));
  78.     panel1.add(tableScrollPane1,  new XYConstraints(192, 117, -1, -1));
  79.     panel1.add(jButton2,  new XYConstraints(155, 244, 110, 23));
  80.     panel1.add(jButton1, new XYConstraints(8, 244, 128, 22));
  81.     panel1.add(jButton4,   new XYConstraints(9, 274, 128, 20));
  82.     panel1.add(jButton5,      new XYConstraints(155, 274, 111, 21));
  83.     panel1.add(jButton3,  new XYConstraints(292, 274, 106, 22));
  84.     this.getContentPane().add(panel1, BorderLayout.SOUTH);
  85.   }
  86.   public void cancel(){
  87.     dispose() ;
  88.   }
  89.   //浏览全部商品订货单
  90.   void jButton1_actionPerformed(ActionEvent e) {
  91.     initialize () ;
  92.     queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  93.         "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE", null, true, Load.ALL));
  94.     jdbTable1.setDataSet(queryDataSet1);
  95.     queryDataSet1.refresh();
  96.   }
  97.   //增加订货单
  98.   void jButton4_actionPerformed(ActionEvent e) {
  99.     AddOrderForm addOrderForm = new AddOrderForm() ;
  100.     Dimension dlgSize = addOrderForm.getPreferredSize();
  101.     Dimension frmSize = getSize();
  102.     Point loc = getLocation();
  103.     addOrderForm.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  104.     addOrderForm.setModal(true);
  105.     addOrderForm.pack();
  106.     addOrderForm.show();
  107.     queryDataSet1.refresh();
  108.   }
  109.   void jButton3_actionPerformed(ActionEvent e) {
  110.     cancel() ;
  111.   }
  112.   //分项选择
  113.   void jButton2_actionPerformed(ActionEvent e) {
  114.     QueryOrderForm queryOrderForm = new QueryOrderForm() ;
  115.     Dimension dlgSize = queryOrderForm.getPreferredSize();
  116.     Dimension frmSize = getSize();
  117.     Point loc = getLocation();
  118.     queryOrderForm.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  119.     queryOrderForm.setModal(true);
  120.     queryOrderForm.pack();
  121.     queryOrderForm.show();
  122.     switch(queryOrderForm.gettestQuery()){
  123.       case 1:
  124.         initialize () ;
  125.         String BuyerGoodsName = queryOrderForm.getBuyerGoodsName().trim();
  126.         queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  127.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerGoodsName = '"+BuyerGoodsName+"'", null, true, Load.ALL));
  128.         jdbTable1.setDataSet(queryDataSet2);
  129.         queryDataSet2.refresh();
  130.         break;
  131.       case 2:
  132.         initialize () ;
  133.         String BuyerManufacturer = queryOrderForm.getBuyerManufacturer().trim();
  134.         queryDataSet3.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  135.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerManufacturer = '"+BuyerManufacturer+"'", null, true, Load.ALL));
  136.         jdbTable1.setDataSet(queryDataSet3);
  137.         queryDataSet3.refresh();
  138.         break;
  139.       case 3:
  140.         initialize () ;
  141.         String BuyerDate = queryOrderForm.getBuyerDate().trim();
  142.         queryDataSet4.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  143.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerDate = '"+BuyerDate+"'", null, true, Load.ALL));
  144.         jdbTable1.setDataSet(queryDataSet4);
  145.         queryDataSet4.refresh();
  146.         break;
  147.       case 4:
  148.         initialize () ;
  149.         String BuyerStatus = queryOrderForm.getBuyerStatus().trim();
  150.         queryDataSet5.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  151.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerStatus = '"+BuyerStatus+"'", null, true, Load.ALL));
  152.         jdbTable1.setDataSet(queryDataSet5);
  153.         queryDataSet5.refresh();
  154.         break;
  155.       default:JOptionPane.showMessageDialog(null,"请选择正确的选项","",JOptionPane.DEFAULT_OPTION);
  156.     }
  157.   }
  158.   public void initialize (){
  159.     queryDataSet1.close() ;
  160.     queryDataSet2.close() ;
  161.     queryDataSet3.close() ;
  162.     queryDataSet4.close() ;
  163.     queryDataSet5.close() ;
  164.   }
  165. }