BuyerWindow.java~6~
上传用户: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.     queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  92.         "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE", null, true, Load.ALL));
  93.     jdbTable1.setDataSet(queryDataSet1);
  94.     queryDataSet1.refresh();
  95.   }
  96.   //增加订货单
  97.   void jButton4_actionPerformed(ActionEvent e) {
  98.     AddOrderForm addOrderForm = new AddOrderForm() ;
  99.     Dimension dlgSize = addOrderForm.getPreferredSize();
  100.     Dimension frmSize = getSize();
  101.     Point loc = getLocation();
  102.     addOrderForm.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  103.     addOrderForm.setModal(true);
  104.     addOrderForm.pack();
  105.     addOrderForm.show();
  106.     queryDataSet1.refresh();
  107.   }
  108.   void jButton3_actionPerformed(ActionEvent e) {
  109.     cancel() ;
  110.   }
  111.   //分项选择
  112.   void jButton2_actionPerformed(ActionEvent e) {
  113.     QueryOrderForm queryOrderForm = new QueryOrderForm() ;
  114.     Dimension dlgSize = queryOrderForm.getPreferredSize();
  115.     Dimension frmSize = getSize();
  116.     Point loc = getLocation();
  117.     queryOrderForm.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  118.     queryOrderForm.setModal(true);
  119.     queryOrderForm.pack();
  120.     queryOrderForm.show();
  121.     switch(queryOrderForm.gettestQuery()){
  122.       case 1:
  123.         String BuyerGoodsName = queryOrderForm.getBuyerGoodsName();
  124.         queryDataSet2.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  125.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerGoodsName = '"+BuyerGoodsName+"'", null, true, Load.ALL));
  126.         jdbTable1.setDataSet(queryDataSet2);
  127.         queryDataSet2.refresh();
  128.         break;
  129.       case 2:
  130.         String BuyerManufacturer = queryOrderForm.getBuyerManufacturer();
  131.         queryDataSet3.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  132.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerManufacturer = '"+BuyerManufacturer+"'", null, true, Load.ALL));
  133.         jdbTable1.setDataSet(queryDataSet3);
  134.         queryDataSet3.refresh();
  135.         break;
  136.       case 3:
  137.         String BuyerDate = queryOrderForm.getBuyerDate();
  138.         queryDataSet4.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  139.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerDate = '"+BuyerDate+"'", null, true, Load.ALL));
  140.         jdbTable1.setDataSet(queryDataSet4);
  141.         queryDataSet4.refresh();
  142.         break;
  143.       case 4:
  144.         String BuyerStatus = queryOrderForm.getBuyerStatus();
  145.         queryDataSet5.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  146.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerStatus = '"+BuyerStatus+"'", null, true, Load.ALL));
  147.         jdbTable1.setDataSet(queryDataSet5);
  148.         queryDataSet5.refresh();
  149.         break;
  150.       default:JOptionPane.showMessageDialog(null,"请选择正确的选项","",JOptionPane.DEFAULT_OPTION);
  151.     }
  152.   }
  153. }