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

📄 waiterframe.java~131~

📁 管理dvd碟片的软件
💻 JAVA~131~
字号:
package dvd;

import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class WaiterFrame extends JFrame{
  JPanel jPanel1 = new JPanel();
  JLabel jLabel1 = new JLabel();
  XYLayout xYLayout2 = new XYLayout();
  JButton jButton1 = new JButton();
  JLabel jLabel2 = new JLabel();
  JTextField jtx1 = new JTextField();
  JButton jb2 = new JButton();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JLabel jLabel5 = new JLabel();
  JTextField DVDIDtx = new JTextField();
  JTextField amounttx = new JTextField();
  JButton jb3 = new JButton();
  JPanel jPanel2 = new JPanel();
  XYLayout xYLayout3 = new XYLayout();
  JLabel jLabel7 = new JLabel();
  JLabel jLabel8 = new JLabel();
  JLabel jLabel9 = new JLabel();
  JLabel jLabel6 = new JLabel();

  private Connection connection;
  private   String url = "jdbc:odbc:sql";
  private  int sprice=0;
  private int pprice=0;
  private int remainAmount=0;
  private int count=1;
  GridBagLayout gridBagLayout1 = new GridBagLayout();

  public WaiterFrame() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    this.getContentPane().setLayout(gridBagLayout1);
    jPanel1.setBackground(SystemColor.text);
    jPanel1.setLayout(xYLayout2);
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 25));
    jLabel1.setForeground(Color.magenta);
    jLabel1.setText("销售人员服务窗口");
    jButton1.setBackground(Color.lightGray);
    jButton1.setFont(new java.awt.Font("SansSerif", 0, 18));
    jButton1.setForeground(Color.magenta);
    jButton1.setToolTipText("浏览所有影片相关信息及货品存放位置信息");
    jButton1.setText("影片情况总览");
    jButton1.addActionListener(new WaiterFrame_jButton1_actionAdapter(this));
    jLabel2.setBackground(Color.lightGray);
    jLabel2.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel2.setForeground(Color.magenta);
    jLabel2.setText("查找影片存放位置");
    jtx1.setToolTipText("输入影片ID号");
    jtx1.setText("");
    jb2.setBackground(Color.lightGray);
    jb2.setFont(new java.awt.Font("Dialog", 0, 18));
    jb2.setForeground(Color.magenta);
    jb2.setText("查找");
    jb2.addActionListener(new WaiterFrame_jb2_actionAdapter(this));
    jLabel3.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel3.setForeground(Color.magenta);
    jLabel3.setText("购买影片");
    jLabel4.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel4.setForeground(new Color(255, 159, 76));
    jLabel4.setHorizontalTextPosition(SwingConstants.TRAILING);
    jLabel4.setText("输入影片ID号");
    jLabel5.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel5.setForeground(new Color(255, 152, 76));
    jLabel5.setText("输入顾客购买数量");
    DVDIDtx.setText("");
    amounttx.setText("");
    jb3.setBackground(Color.lightGray);
    jb3.setFont(new java.awt.Font("Dialog", 0, 18));
    jb3.setForeground(Color.magenta);
    jb3.setText("卖出");
    jb3.addActionListener(new WaiterFrame_jb3_actionAdapter(this));
    jPanel2.setBackground(Color.orange);
    jPanel2.setLayout(xYLayout3);
    jLabel7.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel7.setText("服务人员销售规程");
    jLabel8.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel8.setText("1.顾客将选择的影片告知销售人员,销售人员纪录影片ID号");
    jLabel9.setText("");
    jLabel9.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel9.setText("2.销售人员通过查找影片存放位置到库取得相应数量的碟片");
    jLabel6.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel6.setText("3.销售人员将影片Id号及购买数量填入销售表中");
    this.getContentPane().setBackground(SystemColor.text);
    this.getContentPane().add(jPanel1,   new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, -1, 0, 0), 219, 0));
    jPanel1.add(jLabel1,        new XYConstraints(158, 8, -1, -1));
    this.getContentPane().add(jtx1,  new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(28, 12, 6, 17), 116, 6));
    this.getContentPane().add(jLabel2,  new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(22, 27, 0, 12), 1, 14));
    this.getContentPane().add(jLabel3,  new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 74, 0, 33), 5, 3));
    this.getContentPane().add(jLabel4,  new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(14, 60, 0, 0), 17, 2));
    this.getContentPane().add(jLabel5,  new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(13, 60, 0, 0), 9, 4));
    this.getContentPane().add(DVDIDtx,  new GridBagConstraints(2, 4, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(17, 8, 0, 0), 108, 6));
    this.getContentPane().add(amounttx,  new GridBagConstraints(2, 5, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(9, 8, 0, 0), 109, 8));
    this.getContentPane().add(jb2,  new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(26, 21, 0, 105), 9, -3));
    this.getContentPane().add(jb3,  new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 22, 14, 103), 10, -3));
    this.getContentPane().add(jPanel2,  new GridBagConstraints(0, 6, 4, 1, 1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(9, -1, 0, 0), 2, 9));
    jPanel2.add(jLabel7, new XYConstraints(21, 9, 121, 26));
    jPanel2.add(jLabel8, new XYConstraints(145, 4, 380, 27));
    jPanel2.add(jLabel9, new XYConstraints(144, 27, 396, 25));
    jPanel2.add(jLabel6, new XYConstraints(143, 49, 376, 24));
    this.getContentPane().add(jButton1, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0
            ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(1, 29, 10, 9), 32, 5));
  }

  void jButton1_actionPerformed(ActionEvent e) {
   String quire1="select * from part_inf";
    try {
           Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );

           connection = DriverManager.getConnection(
              url );
        }
        catch ( ClassNotFoundException cnfex ) {
           System.err.println(
              "Failed to load JDBC/ODBC driver." );
           cnfex.printStackTrace();
           System.exit( 1 );  // terminate program
        }
        catch ( SQLException sqlex ) {
           System.err.println( "Unable to connect" );
           sqlex.printStackTrace();
        }
    //  this.dispose();
      DVDFrame movieFrame=new DVDFrame(connection,quire1);
      movieFrame.setSize(500,500);
      movieFrame.show();

  }

  void jb2_actionPerformed(ActionEvent e) {
    String  movieID= jtx1.getText().trim();
    String quire2="select shelf_no as 货架号,row_no as 行号,column_no as 列号 from position where DVD_no like'%"+movieID+"%'";
    if(!movieID.equals(""))
    { try {//3
        Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );

        connection = DriverManager.getConnection(  url );
      }//3
      catch ( ClassNotFoundException cnfex ) {//4
        System.err.println(
            "Failed to load JDBC/ODBC driver." );
        cnfex.printStackTrace();
        System.exit( 1 );  // terminate program
      }//4
      catch ( SQLException sqlex ) {//5
        System.err.println( "Unable to connect" );
        sqlex.printStackTrace();
      }//5


DVDFrame movieFrame=new DVDFrame(connection,quire2);
movieFrame.setSize(500,500);
movieFrame.show();
jtx1.setText("");
}
else
   JOptionPane.showMessageDialog(null,"Please enter the role name you want","sorry",JOptionPane.INFORMATION_MESSAGE);
  }

  void jb3_actionPerformed(ActionEvent e) {
    java.util.Date date=new java.util.Date();
    String time=date.toString();
    String  dvdid=  DVDIDtx.getText().trim();
    String  amount1= amounttx.getText().trim();
    Statement sql=null;
    ResultSet rs=null;
    int amount=Integer.parseInt(amount1);
    int profit=0;
    int money=0;
    int remains=0;
    int count=1;
    String sell="select * from sell";

    try {
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    }
    catch(ClassNotFoundException event){}

    try{
      connection = DriverManager.getConnection(  url );
      sql=connection.createStatement();
      String quire="SELECT DVD_no , p_price,s_price,remains FROM DVD where DVD_no="+"'"+dvdid+"'";
      DVDFrame movieFrame=new DVDFrame(connection,quire);
      movieFrame.dispose();
      rs=sql.executeQuery(quire);
      if(!movieFrame.haverecords)
      {
        DVDIDtx.setText("");
        amounttx.setText("");
      }
      while( rs.next() )
      {
        String s = rs.getString(1);
        pprice = (int)rs.getInt("p_price");
        sprice = (int)rs.getInt("s_price");
        remainAmount = (int)rs.getInt("remains");
      }
      money=amount*sprice;
      profit=amount*(sprice-pprice);
      remains=remainAmount-amount;

    }
    catch ( SQLException sqlex ) {
    }

    {  try {//3
         Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );

         connection = DriverManager.getConnection(  url );
       }//3
       catch ( ClassNotFoundException cnfex ) {//4
         System.err.println(
            "Failed to load JDBC/ODBC driver." );
        cnfex.printStackTrace();
        System.exit( 1 );  // terminate program
      }//4
      catch ( SQLException sqlex ) {//5
        System.err.println( "Unable to connect" );
        sqlex.printStackTrace();
      }//5

      DVDFrame movieFrame=new DVDFrame(connection,sell);
      movieFrame.dispose();
      count=movieFrame.number+1;
    }


    try {
      Statement statement = connection.createStatement();
      if(!(dvdid.equals("")||amount1.equals("")))
      {
        String insert ="insert into sell(s_no,s_amount,DVD_no,s_date,s_money,s_profit,remainNumber)"+
            "values('"+count+"','"+amount+"','"+dvdid+"','"+time+"','"+
            money+"','"+profit+"','"+remains+"')";

        if(remains<0){
            JOptionPane.showMessageDialog(null,"本店暂时货源不足,很抱歉","sorry",JOptionPane.INFORMATION_MESSAGE);
            DVDIDtx.setText("");
            amounttx.setText("");
          }
          else{
            connection.nativeSQL(insert);
            int result =statement.executeUpdate(insert);

            if((result==1)&&(remains>=0))
            {
              JOptionPane.showMessageDialog(null,"成功交易","sell DVD success",JOptionPane.INFORMATION_MESSAGE);
              count+=1;
              DVDIDtx.setText("");
              amounttx.setText("");
            }

          }
        }
       else  JOptionPane.showMessageDialog(null,"成功交易","sell DVD success",JOptionPane.INFORMATION_MESSAGE);

      }
      catch ( SQLException sqlex )
      {
      }

      try {
        Statement statement = connection.createStatement();
        String update="update DVD set remains='"+remains+"' where DVD_no='"+dvdid+"'";
        connection.nativeSQL(update);
        int result =statement.executeUpdate(update);
      }
      catch ( SQLException sqlex ) {
      }
    }
  }

  class WaiterFrame_jButton1_actionAdapter implements java.awt.event.ActionListener {
    WaiterFrame adaptee;

    WaiterFrame_jButton1_actionAdapter(WaiterFrame adaptee) {
      this.adaptee = adaptee;
    }
    public void actionPerformed(ActionEvent e) {
      adaptee.jButton1_actionPerformed(e);
    }

  }

  class WaiterFrame_jb2_actionAdapter implements java.awt.event.ActionListener {
    WaiterFrame adaptee;

    WaiterFrame_jb2_actionAdapter(WaiterFrame adaptee) {
      this.adaptee = adaptee;
    }
    public void actionPerformed(ActionEvent e) {
      adaptee.jb2_actionPerformed(e);
    }
  }

  class WaiterFrame_jb3_actionAdapter implements java.awt.event.ActionListener {
    WaiterFrame adaptee;

    WaiterFrame_jb3_actionAdapter(WaiterFrame adaptee) {
      this.adaptee = adaptee;
    }
    public void actionPerformed(ActionEvent e) {
      adaptee.jb3_actionPerformed(e);
    }
  }



⌨️ 快捷键说明

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