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

📄 lay1.java

📁 Jbuilder 9下开发的员工电子销售电子卡片的管理系统
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Vector;

public class lay1 extends JFrame
{
  int N=100;
  int product[][]=new int[100][5];
  int sort[]=new int[100];
  int tempp[]=new int[100];

  Container c;
  JPanel pan=new JPanel();
  GridBagLayout gridBagLayout1 = new GridBagLayout();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel2 = new JLabel();
  JLabel jLabel3 = new JLabel();
  JLabel jLabel4 = new JLabel();
  JTextField jTextField1 = new JTextField();
  JTextField jTextField3 = new JTextField();
  JLabel jLabel5 = new JLabel();
  JList jList1 = new JList();
  Vector listdata=new Vector();
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  JLabel jLabel6 = new JLabel();
  JButton jButton3 = new JButton();
  JList jList2 = new JList();
  Vector listresult=new Vector();
  JComboBox jComboBox1 = new JComboBox();


  public lay1()
  {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }

   }

  public void clearclick()
  {
    jComboBox1.setSelectedIndex(0);
    jTextField3.setText("");
    jTextField1.setText("");
  }

  public void sendclick()
  {
    int p=Integer.parseInt(jTextField1.getText().toString());
    int id=jComboBox1.getSelectedIndex()-1;
    int num=Integer.parseInt(jTextField3.getText().toString());
    String data=jTextField1.getText()+"                   "+jComboBox1.getSelectedItem().toString()+"         "+jTextField3.getText();
    try{
      product[p][id] += num;
      listdata.add(data);
      jList1.setListData(listdata);

    }
    catch(Exception e){}

  }

  public void viewresult()
  {
    Vector listresult=new Vector();
    listresult.add("销售员ID      销售数额");
    sort();
    for(int i=0;i<N;i++)
    {
      String str = tempp[i]+"                  " +sort[i];
      listresult.add(str);
    }
    jList2.setListData(listresult);
  }

  public void sort()
  {
    for(int i=0;i<N;i++)
    {
      int temp = 0;
      for (int j = 0; j < 5; j++)
        temp += product[i][j];
      sort[i]= temp;
      tempp[i]=i;
    }

    for(int m=0;m<N;m++)
      for(int n=m+1;n<N;n++)
      {
        int temp;
        if(sort[m]<sort[n])
          {
            temp = sort[m];
            sort[m]=sort[n];
            sort[n]=temp;
            temp=tempp[m];
            tempp[m]=tempp[n];
            tempp[n]=temp;

          }
      }

  }

  public static void main(String args[])
  {
    lay1 liwen=new lay1();
    liwen.addWindowListener(new MyWindowListener());
    liwen.setSize(400,650);
    liwen.setTitle("**公司产品销售情况统计**");
    liwen.show();
  }
  private void jbInit() throws Exception {


    for(int i=0;i<N;i++)
      for (int j = 0; j < 5; j++)
        product[i][j] = 0;
    jComboBox1.addItem("请选择");
    jComboBox1.addItem("商品一");
    jComboBox1.addItem("商品二");
    jComboBox1.addItem("商品三");
    jComboBox1.addItem("商品四");
    jComboBox1.addItem("商品五");



    jButton2.setText("重置");
    jButton2.addActionListener(new lay1_jButton2_actionAdapter(this));
    jButton1.setText("确定");
    jButton1.addActionListener(new lay1_jButton1_actionAdapter(this));
    jTextField1.setText("不大于100");
    jTextField1.addActionListener(new lay1_jTextField1_actionAdapter(this));
    jLabel4.setEnabled(true);
    jLabel4.setFont(new java.awt.Font("Dialog", 1, 20));
    jLabel4.setForeground(Color.black);
    jLabel4.setDebugGraphicsOptions(0);
    jLabel4.setDoubleBuffered(false);
    jLabel4.setText("销售卡片记录");
    jLabel3.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel3.setText("销售数额:");
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel1.setDebugGraphicsOptions(0);
    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel1.setHorizontalTextPosition(SwingConstants.TRAILING);
    jLabel1.setText("销售员ID:");
    this.getContentPane().setLayout(gridBagLayout1);
    this.getContentPane().setBackground(SystemColor.control);
    this.setDefaultCloseOperation(HIDE_ON_CLOSE);
    this.setEnabled(true);
    this.setLocale(java.util.Locale.getDefault());
    this.setResizable(true);
    this.setState(Frame.NORMAL);
    this.setTitle("**公司产品销售情况统计**");
    jLabel2.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel2.setText("产品ID:");
    jLabel2.setVerticalAlignment(SwingConstants.CENTER);
    jLabel6.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel6.setText("本月销售员排行");
    jButton3.setText("查看");
    jButton3.addActionListener(new lay1_jButton3_actionAdapter(this));
    jLabel5.setFont(new java.awt.Font("Dialog", 0, 18));
    jLabel5.setText("本月销售明细");
    jComboBox1.setEnabled(true);
    jComboBox1.setAlignmentX((float) 0.5);
    jComboBox1.setAutoscrolls(false);
    jComboBox1.setDoubleBuffered(false);
    jComboBox1.setPreferredSize(new Dimension(27, 22));
    jComboBox1.setRequestFocusEnabled(true);
    jComboBox1.setToolTipText("");
    jComboBox1.setEditable(false);
    jComboBox1.setLightWeightPopupEnabled(true);
    jComboBox1.setPopupVisible(false);
    jComboBox1.setSelectedIndex(-1);
    jTextField3.setText("");
    this.getContentPane().add(jLabel2,                             new GridBagConstraints(0, 2, 1, 2, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.getContentPane().add(jLabel1,                                            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
            ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(6, 9, 5, 6), 0, 0));
    this.getContentPane().add(new JScrollPane(jList2),                                  new GridBagConstraints(0, 10, 7, -7, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 358, 167));
    this.getContentPane().add(jLabel3,                        new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 0, 8, 0), 0, 0));
    this.getContentPane().add(jButton2,            new GridBagConstraints(2, 5, 1, 2, 0.0, 0.0
            ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 12, 0, 4), 0, 0));
    this.getContentPane().add(jButton1,        new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0
            ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.getContentPane().add(jLabel6,      new GridBagConstraints(1, 9, 2, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(8, 0, 0, 0), 0, -2));
    this.getContentPane().add(new JScrollPane(jList1),        new GridBagConstraints(0, 8, 6, 1, 0.0, 0.0
            ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 4, 0, 0), 354, 143));
            listdata.add("销售员ID        产品ID        销售数额");
    this.getContentPane().add(jLabel4,      new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(13, 0, 1, 0), 0, 0));
    this.getContentPane().add(jLabel5,   new GridBagConstraints(2, 7, 2, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(6, 6, 0, 52), 0, 0));
    this.getContentPane().add(jTextField3,     new GridBagConstraints(2, 4, 3, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 1, 2, 94), 83, 4));
    this.getContentPane().add(jButton3,  new GridBagConstraints(3, 9, 2, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    this.getContentPane().add(jTextField1,  new GridBagConstraints(2, 1, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 2, 0, 1), 85, 3));
    this.getContentPane().add(jComboBox1,      new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 31), 116, 1));
            jComboBox1.setSelectedIndex(0);
  }

  void jButton1_actionPerformed(ActionEvent e) {
 if(jTextField1.getText().length()!=0&&jComboBox1.getSelectedIndex()!=0&&jTextField3.getText().length()!=0)sendclick();
  }

  void jButton2_actionPerformed(ActionEvent e) {clearclick();}


  void jTextField1_actionPerformed(ActionEvent e) {

  }

  void jButton3_actionPerformed(ActionEvent e) {
viewresult();
  }


}

class lay1_jButton1_actionAdapter implements java.awt.event.ActionListener {
  lay1 adaptee;

  lay1_jButton1_actionAdapter(lay1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);
  }
}

class lay1_jButton2_actionAdapter implements java.awt.event.ActionListener {
  lay1 adaptee;

  lay1_jButton2_actionAdapter(lay1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton2_actionPerformed(e);
  }
}

class lay1_jTextField1_actionAdapter implements java.awt.event.ActionListener {
  lay1 adaptee;

  lay1_jTextField1_actionAdapter(lay1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jTextField1_actionPerformed(e);
  }
}

class lay1_jButton3_actionAdapter implements java.awt.event.ActionListener {
  lay1 adaptee;

  lay1_jButton3_actionAdapter(lay1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton3_actionPerformed(e);
  }
}

⌨️ 快捷键说明

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