BuyerWindow.java
上传用户:kingwang
上传日期:2022-08-09
资源大小:1562k
文件大小:8k
源码类别:

百货/超市行业

开发平台:

JavaScript

  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 jButton5 = new JButton();
  32.   private JButton jButton3 = new JButton();
  33.   private JButton jButton4 = 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.     jButton5.setText("退出");
  64.     jButton5.addActionListener(new java.awt.event.ActionListener() {
  65.       public void actionPerformed(ActionEvent e) {
  66.         jButton5_actionPerformed(e);
  67.       }
  68.     });
  69.     jButton3.setText("增加订单");
  70.     jButton3.addActionListener(new java.awt.event.ActionListener() {
  71.       public void actionPerformed(ActionEvent e) {
  72.         jButton3_actionPerformed(e);
  73.       }
  74.     });
  75.     jButton4.setText("更改订单状态");
  76.     jButton4.addActionListener(new java.awt.event.ActionListener() {
  77.       public void actionPerformed(ActionEvent e) {
  78.         jButton4_actionPerformed(e);
  79.       }
  80.     });
  81.     panel1.add(jPanel1,  new XYConstraints(190, 154, -1, -1));
  82.     panel1.add(jdbTable1,  new XYConstraints(1, 0, 399, 238));
  83.     panel1.add(tableScrollPane1,  new XYConstraints(192, 117, -1, -1));
  84.     panel1.add(jButton2,  new XYConstraints(155, 244, 110, 23));
  85.     panel1.add(jButton1, new XYConstraints(8, 244, 128, 22));
  86.     panel1.add(jButton3,   new XYConstraints(9, 274, 128, 20));
  87.     panel1.add(jButton4,      new XYConstraints(155, 274, 111, 21));
  88.     panel1.add(jButton5,  new XYConstraints(292, 274, 106, 22));
  89.     this.getContentPane().add(panel1, BorderLayout.SOUTH);
  90.   }
  91.   public void cancel(){
  92.     dispose() ;
  93.   }
  94.   //浏览全部商品订货单
  95.   void jButton1_actionPerformed(ActionEvent e) {
  96.     initialize () ;
  97.     queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  98.         "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE", null, true, Load.ALL));
  99.     jdbTable1.setDataSet(queryDataSet1);
  100.     queryDataSet1.refresh();
  101.   }
  102.   //增加订货单
  103.   void jButton3_actionPerformed(ActionEvent e) {
  104.     AddOrderForm addOrderForm = new AddOrderForm() ;
  105.     Dimension dlgSize = addOrderForm.getPreferredSize();
  106.     Dimension frmSize = getSize();
  107.     Point loc = getLocation();
  108.     addOrderForm.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  109.     addOrderForm.setModal(true);
  110.     addOrderForm.pack();
  111.     addOrderForm.show();
  112.     queryDataSet1.refresh();
  113.   }
  114.   void jButton5_actionPerformed(ActionEvent e) {
  115.     cancel() ;
  116.   }
  117.   //分项选择
  118.   void jButton2_actionPerformed(ActionEvent e) {
  119.     QueryOrderForm queryOrderForm = new QueryOrderForm() ;
  120.     Dimension dlgSize = queryOrderForm.getPreferredSize();
  121.     Dimension frmSize = getSize();
  122.     Point loc = getLocation();
  123.     queryOrderForm.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  124.     queryOrderForm.setModal(true);
  125.     queryOrderForm.pack();
  126.     queryOrderForm.show();
  127.     switch(queryOrderForm.gettestQuery()){
  128.       case 1:
  129.         initialize () ;
  130.         String BuyerGoodsName = queryOrderForm.getBuyerGoodsName().trim();
  131.         queryDataSet2.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 BuyerGoodsName = '"+BuyerGoodsName+"'", null, true, Load.ALL));
  133.         jdbTable1.setDataSet(queryDataSet2);
  134.         queryDataSet2.refresh();
  135.         break;
  136.       case 2:
  137.         initialize () ;
  138.         String BuyerManufacturer = queryOrderForm.getBuyerManufacturer().trim();
  139.         queryDataSet3.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  140.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerManufacturer = '"+BuyerManufacturer+"'", null, true, Load.ALL));
  141.         jdbTable1.setDataSet(queryDataSet3);
  142.         queryDataSet3.refresh();
  143.         break;
  144.       case 3:
  145.         initialize () ;
  146.         String BuyerDate = queryOrderForm.getBuyerDate().trim();
  147.         queryDataSet4.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  148.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerDate = '"+BuyerDate+"'", null, true, Load.ALL));
  149.         jdbTable1.setDataSet(queryDataSet4);
  150.         queryDataSet4.refresh();
  151.         break;
  152.       case 4:
  153.         initialize () ;
  154.         String BuyerStatus = queryOrderForm.getBuyerStatus().trim();
  155.         queryDataSet5.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT Buyer_TABLE.BuyerID,Buyer_TABLE.BuyerGoodsName,Buyer_TABLE.BuyerGoodsNumber,Buyer_TABLE.BuyerM" +
  156.             "anufacturer,Buyer_TABLE.BuyerDate,Buyer_TABLE.BuyerStatus FROM UML_CS.dbo.Buyer_TABLE WHERE BuyerStatus = '"+BuyerStatus+"'", null, true, Load.ALL));
  157.         jdbTable1.setDataSet(queryDataSet5);
  158.         queryDataSet5.refresh();
  159.         break;
  160.       default:JOptionPane.showMessageDialog(null,"请选择正确的选项","",JOptionPane.DEFAULT_OPTION);
  161.     }
  162.   }
  163.   public void initialize (){
  164.     queryDataSet1.close() ;
  165.     queryDataSet2.close() ;
  166.     queryDataSet3.close() ;
  167.     queryDataSet4.close() ;
  168.     queryDataSet5.close() ;
  169.   }
  170.   void jButton4_actionPerformed(ActionEvent e) {
  171.     UpdateOrderForm updateOrderForm = new UpdateOrderForm() ;
  172.    Dimension dlgSize = updateOrderForm.getPreferredSize();
  173.    Dimension frmSize = getSize();
  174.    Point loc = getLocation();
  175.    updateOrderForm.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
  176.    updateOrderForm.setModal(true);
  177.    updateOrderForm.pack();
  178.    updateOrderForm.show();
  179.     queryDataSet1.refresh();
  180.   }
  181. }