⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 querybycustomer.java~1~

📁 实现了一个简单的餐饮行业进销存系统
💻 JAVA~1~
字号:
package com.csbook.restaurant;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author pengtao * @version 1.0 */public class QueryByCustomer extends JInternalFrame {  JPanel jPanel1 = new JPanel();  JPanel jPanel2 = new JPanel();  JLabel jLabel1 = new JLabel();  JTextField customer = new JTextField();  GridLayout gridLayout1 = new GridLayout(1,4);  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  BorderLayout borderLayout1 = new BorderLayout();  JPanel jPanel3 = new JPanel();  JPanel jPanel4 = new JPanel();  JCheckBox byTime = new JCheckBox();  GridLayout gridLayout2 = new GridLayout();  GridLayout gridLayout3 = new GridLayout(2,7);  JLabel jLabel4 = new JLabel();  JLabel jLabel5 = new JLabel();  JTextField endMonth = new JTextField();  JLabel jLabel6 = new JLabel();  JTextField endYear = new JTextField();  JLabel jLabel7 = new JLabel();  JLabel jLabel8 = new JLabel();  JTextField startDay = new JTextField();  JLabel jLabel9 = new JLabel();  JTextField startMonth = new JTextField();  JLabel jLabel10 = new JLabel();  JTextField startYear = new JTextField();  JLabel jLabel11 = new JLabel();  JPanel jPanel5 = new JPanel();  JButton ok = new JButton();  JButton cancel = new JButton();  JTextField endDay = new JTextField();  JDesktopPane desktop;  public QueryByCustomer(String title,boolean resizable,boolean closable,boolean maximizable,boolean iconifiable,JDesktopPane desktop) {    super(title,resizable,closable,maximizable,iconifiable);    this.desktop=desktop;    try {      jbInit();      pack();    }    catch(Exception e) {      e.printStackTrace();    }  }  private void jbInit() throws Exception {    jLabel1.setHorizontalAlignment(SwingConstants.LEFT);    jLabel1.setText("客人姓名:");    jLabel1.setVerticalAlignment(SwingConstants.CENTER);    customer.setText("");    customer.setHorizontalAlignment(SwingConstants.CENTER);    jPanel1.setLayout(gridLayout1);    jLabel3.setText("");    jLabel2.setText("");    jPanel2.setLayout(borderLayout1);    byTime.setHorizontalAlignment(SwingConstants.LEFT);    byTime.setText("按时间查询");    byTime.addActionListener(new QueryByCustomer_byTime_actionAdapter(this));    jPanel3.setLayout(gridLayout2);    jPanel4.setLayout(gridLayout3);    jLabel4.setText("起始时间");    jLabel5.setText("日");    jLabel6.setText("月");    jLabel7.setText("年");    jLabel8.setText("结束时间");    jLabel9.setText("日");    jLabel10.setText("月");    jLabel11.setText("年");    ok.setText("确定");    ok.addActionListener(new QueryByCustomer_ok_actionAdapter(this));    startYear.setEditable(false);    startYear.setText("");    startMonth.setEditable(false);    startMonth.setText("");    startDay.setEditable(false);    startDay.setText("");    endDay.setEditable(false);    endDay.setText("");    endMonth.setEditable(false);    endMonth.setText("");    endYear.setEditable(false);    endYear.setText("");    cancel.setText("取消");    cancel.addActionListener(new QueryByCustomer_cancel_actionAdapter(this));    endDay.setEditable(false);    endDay.setText("");    jPanel1.add(jLabel3, null);    jPanel1.add(jLabel1, null);    jPanel1.add(customer, null);    jPanel1.add(jLabel2, null);    this.getContentPane().add(jPanel1, BorderLayout.NORTH);    this.getContentPane().add(jPanel2, BorderLayout.CENTER);    jPanel2.add(jPanel3,  BorderLayout.NORTH);    jPanel3.add(byTime, null);    jPanel2.add(jPanel4, BorderLayout.CENTER);    jPanel4.add(jLabel4, null);    jPanel4.add(startYear, null);    jPanel4.add(jLabel11, null);    jPanel4.add(startMonth, null);    jPanel4.add(jLabel10, null);    jPanel4.add(startDay, null);    jPanel4.add(jLabel9, null);    jPanel4.add(jLabel8, null);    jPanel4.add(endYear, null);    jPanel4.add(jLabel7, null);    jPanel4.add(endMonth, null);    jPanel4.add(jLabel6, null);    jPanel4.add(endDay, null);    jPanel4.add(endDay, null);    jPanel4.add(jLabel5, null);    this.getContentPane().add(jPanel5,  BorderLayout.SOUTH);    jPanel5.add(ok, null);    jPanel5.add(cancel, null);  }  void byTime_actionPerformed(ActionEvent e) {    if(byTime.isSelected()){      this.startYear.setEditable(true);      this.startMonth.setEditable(true);      this.startDay.setEditable(true);      this.endYear.setEditable(true);      this.endMonth.setEditable(true);      this.endDay.setEditable(true);    }    else{       this.startYear.setEditable(false);       this.startMonth.setEditable(false);       this.startDay.setEditable(false);       this.endYear.setEditable(false);       this.endMonth.setEditable(false);       this.endDay.setEditable(false);    }  }  void cancel_actionPerformed(ActionEvent e) {  this.dispose();  }  void ok_actionPerformed(ActionEvent e) {    if(customer.getText().trim().equals(""))    {      JOptionPane.showMessageDialog(this, "顾客姓名不能为空!", "错误",                                    JOptionPane.ERROR_MESSAGE);      return;    }    String startDate;    String endDate;    if(byTime.isSelected()){      int startY = Integer.parseInt(startYear.getText());      int startM = Integer.parseInt(startMonth.getText());      int startD = Integer.parseInt(startDay.getText());      int endY = Integer.parseInt(endYear.getText());      int endM = Integer.parseInt(endMonth.getText());      int endD = Integer.parseInt(endDay.getText());      startDate = startY + "-" + startM + "-" + startD;      endDate = endY + "-" + endM + "-" + endD;    }    else{      startDate = "1980-12-12";      endDate = "2100-12-12";    }    QueryByCusResult dlg = new QueryByCusResult("查询结果",customer.getText(),startDate,endDate);    dlg.setVisible(true);    desktop.add(dlg);    try {            dlg.setSelected(true);    }    catch (java.beans.PropertyVetoException ex) {}  }}class QueryByCustomer_byTime_actionAdapter implements java.awt.event.ActionListener {  QueryByCustomer adaptee;  QueryByCustomer_byTime_actionAdapter(QueryByCustomer adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.byTime_actionPerformed(e);  }}class QueryByCustomer_cancel_actionAdapter implements java.awt.event.ActionListener {  QueryByCustomer adaptee;  QueryByCustomer_cancel_actionAdapter(QueryByCustomer adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.cancel_actionPerformed(e);  }}class QueryByCustomer_ok_actionAdapter implements java.awt.event.ActionListener {  QueryByCustomer adaptee;  QueryByCustomer_ok_actionAdapter(QueryByCustomer adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.ok_actionPerformed(e);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -