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