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