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

📄 gongziguanli.txt

📁 实现简单的工资管理。比较简单。希望对大家有用
💻 TXT
📖 第 1 页 / 共 2 页
字号:
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
/////////////////////////////////////////////////
class Wage extends Panel
{  String s1,s2;
   double s3,s4,s5,s6,s7,s8,s9,s10,s11,s12;
    Wage(String s1,String s2,double s3,double s4,double s5,double s6,double s7,double s8,double s9,double s10,double s11,double s12)
     { this.s1=s1; this.s2=s2; this.s3=s3; this.s4=s4; this.s5=s5; this.s6=s6; 
       this.s7=s7; this.s8=s8; this.s9=s9; this.s10=s10; this.s11=s11; this.s12=s12;}
}
/////////////////
class z2 extends JFrame implements ActionListener
{  
    LinkedList list=null;
    public JFrame f;
    PrintJob p=null;
    Graphics g=null;
    public Container con;  
    JLabel L1 = new JLabel("编    号:",JLabel.CENTER), L2 = new JLabel("姓    名:",JLabel.CENTER), L3 = new JLabel("基本工资:",JLabel.CENTER),
           L4 = new JLabel("职务工资:",JLabel.CENTER),L5 = new JLabel("奖    金:",JLabel.CENTER), L6 = new JLabel("误餐补贴:",JLabel.CENTER),
           L7 = new JLabel("高寒补贴:",JLabel.CENTER), L8 = new JLabel("应发工资:",JLabel.CENTER), L9 = new JLabel("扣    款:",JLabel.CENTER),
           L10 = new JLabel("房    租:",JLabel.CENTER),L11 = new JLabel("水 电 费:",JLabel.CENTER),L12 = new JLabel("实发工资:",JLabel.CENTER);
    JTextField T1 = new JTextField("编号"),T2 = new JTextField("姓名"),T3 = new JTextField("0"),
               T4 = new JTextField("0"),T5 = new JTextField("0"),T6 = new JTextField("0"),
               T7= new JTextField("0"), T8= new JTextField(), T9= new JTextField("0"),
               T10 = new JTextField("0"),T11 = new JTextField("0"),T12 = new JTextField();
    JLabel L14 = new JLabel("职工工资管理系统",JLabel.CENTER); 
    JTextField T15= new JTextField();JLabel L15= new JLabel("统计结果为:",JLabel.CENTER);
    JTextArea showT= new JTextArea(9,33);
    JButton  b_add=new JButton("提交录入");
    JButton  b_modify=new JButton("提交修改");
    JButton  b_move=new JButton("提交删除");
    JButton  b_xun=new JButton("提交查询");
    JButton  b_print=new JButton("提交打印");
    JButton  b_show=new JButton("提交显示");
    JButton  b_tongji=new JButton("提交统计");
    JButton  b_back=new JButton("提交退出");
  z2()
    {   super("职工工资管理窗口");
        list=new LinkedList();
        con=getContentPane();
        JScrollPane pane=new JScrollPane(showT);
        showT.setEditable(false);
        T8.setEditable(false);
        T12.setEditable(false);
        T15.setEditable(false);
        L1.setBackground(Color.yellow);
        L1.setForeground(Color.red);
        L2.setBackground(Color.yellow);
        L2.setForeground(Color.red);        
        L3.setBackground(Color.yellow);
        L3.setForeground(Color.red);
        L4.setBackground(Color.yellow);
        L4.setForeground(Color.red);
        L5.setBackground(Color.yellow);
        L5.setForeground(Color.red);
        L6.setBackground(Color.yellow);
        L6.setForeground(Color.red);
        L7.setBackground(Color.gray);
        L7.setForeground(Color.red);
        L8.setBackground(Color.gray);
        L8.setForeground(Color.red);
        L9.setBackground(Color.gray);
        L9.setForeground(Color.red);
        L10.setBackground(Color.gray);
        L10.setForeground(Color.red);
        L11.setBackground(Color.gray);
        L11.setForeground(Color.red);
        L12.setBackground(Color.gray);
        L12.setForeground(Color.red);
        L14.setBackground(Color.yellow);
        L14.setForeground(Color.red);
        L14.setFont(new Font("宋体",Font.BOLD,30));
        L15.setBackground(Color.yellow);
        L15.setForeground(Color.red);

        T8.setForeground(Color.blue);
        T8.setBackground(Color.pink);
        T12.setBackground(Color.pink);
        T12.setForeground(Color.blue);
        T15.setForeground(Color.blue);
        T15.setBackground(Color.pink);
        showT.setForeground(Color.red);
        showT.setBackground(Color.pink);
        b_add.setForeground(Color.red);
        b_add.setBackground(Color.pink);
        b_xun.setForeground(Color.red);
        b_xun.setBackground(Color.pink);
        b_move.setForeground(Color.red);
        b_move.setBackground(Color.pink);
        b_show.setForeground(Color.red);
        b_show.setBackground(Color.pink);
        b_modify.setForeground(Color.red);
        b_modify.setBackground(Color.pink);
        b_show.setForeground(Color.red);
        b_show.setBackground(Color.pink);
        b_print.setForeground(Color.red);
        b_print.setBackground(Color.pink);
        b_tongji.setForeground(Color.red);
        b_tongji.setBackground(Color.pink);
        b_back.setForeground(Color.red);
        b_back.setBackground(Color.pink);

       JPanel save=new JPanel(), p2=new JPanel(),p3=new JPanel(),
              p4=new JPanel(), p5=new JPanel(), p6=new JPanel();
       save.setLayout(new GridLayout(4,5));
       save.add(L1);save.add(T1);save.add(L2);save.add(T2); save.add(L3);save.add(T3);
       save.add(L4);save.add(T4);save.add(L5);save.add(T5); save.add(L6);save.add(T6);
       save.add(L7);save.add(T7);save.add(L8);save.add(T8); save.add(L9);save.add(T9);
       save.add(L10);save.add(T10);save.add(L11);save.add(T11);save.add(L12);save.add(T12);
         p6.add(L14);
         p2.setLayout(new GridLayout(2,2));
         p3.setLayout(new GridLayout(2,2));
         p3.add(L15);p3.add(T15); 
         p4.setLayout(new GridLayout(8,1));
         p4.add(b_add);p4.add(b_modify);p4.add(b_move);p4.add(b_xun);
         p4.add(b_print);p4.add(b_show);p4.add(b_tongji);p4.add(b_back);
         p5.add(pane);
         JSplitPane split_one,split_two,split_three,split_four,split_five;
      split_one=new JSplitPane(JSplitPane.VERTICAL_SPLIT,p6,p4);
      split_two=new JSplitPane(JSplitPane.VERTICAL_SPLIT,p4,save); 
      split_three=new JSplitPane(JSplitPane.VERTICAL_SPLIT,save,p3);
      split_four=new  JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,split_three,p5);
       con.add(split_one,BorderLayout.NORTH);
       con.add(split_two,BorderLayout.CENTER);
       con.add(split_three,BorderLayout.SOUTH);
       con.add(split_four,BorderLayout.EAST);
       b_add.addActionListener(this);
       b_xun.addActionListener(this);
       b_move.addActionListener(this);
       b_show.addActionListener(this);
       b_modify.addActionListener(this);
       b_print.addActionListener(this);
       b_tongji.addActionListener(this);
       b_back.addActionListener(this);
   }
     public void actionPerformed(ActionEvent e)
       { 
//添加方法
      if(e.getSource()==b_add)
        {   T15.setText(null);
           String ss1=null,ss2=null;double ss3=0,ss4=0,ss5=0,ss6=0,ss7=0,ss8=0,ss9=0,ss10=0,ss11=0,ss12=0;
            ss1=T1.getText(); ss2=T2.getText();             
            ss3=Double.valueOf(T3.getText()).doubleValue(); 
            ss4=Double.valueOf(T4.getText()).doubleValue(); 
            ss5=Double.valueOf(T5.getText()).doubleValue(); 
            ss6=Double.valueOf(T6.getText()).doubleValue();  
            ss7=Double.valueOf(T7.getText()).doubleValue();  
            ss9=Double.valueOf(T9.getText()).doubleValue();  
            ss10=Double.valueOf(T10.getText()).doubleValue();  
            ss11=Double.valueOf(T11.getText()).doubleValue();
            ss8=ss3+ss4+ss5+ss6+ss7;   
            ss12=ss8-ss9-ss10-ss11;
            Wage cus=new Wage(ss1,ss2,ss3,ss4,ss5,ss6,ss7,ss8,ss9,ss10,ss11,ss12);
         if(cus.s1.equals("编号"))
             {  JOptionPane.showMessageDialog(null,"输入的职工工资信息有误!!!");}
         else{
                try{FileInputStream come_in11=new FileInputStream("zhigong1.txt");
                    ObjectInputStream in11=new ObjectInputStream(come_in11);
                    list=(LinkedList)in11.readObject(); //////
                     in11.close();
                     }
                catch(ClassNotFoundException event){}
                catch(IOException event){}
                  boolean b=true;
                  int number11=list.size();
               P: for(int i=0;i<number11;i++)
                 {   
                   Wage cus_1=(Wage)list.get(i);
                  if(cus_1.s1.equals(ss1))
                     {  b=false;break P;}
                 }
               if(b==false)
                 {JOptionPane.showMessageDialog(null,"此职工工资信息已录入!!!");}
               else
                 {   list.add(cus);
                    try{  FileOutputStream file1=new FileOutputStream("zhigong1.txt");
                          ObjectOutputStream out1=new ObjectOutputStream(file1);
                          out1.writeObject(list); out1.close();
                        }
                    catch(IOException event){}
                 }
              }
         T1.setText("编号");T2.setText("姓名");T3.setText("0");T4.setText("0");
         T5.setText("0");T6.setText("0");T7.setText("0");
         T9.setText("0");T10.setText("0"); T11.setText("0");
         }
//修改方法
     else if(e.getSource()==b_modify)            
          {         T15.setText(null);
                 String ss1_1=null,ss2_1=null;double ss3_1=0,ss4_1=0,ss5_1=0,ss6_1=0,
                        ss7_1=0,ss8_1=0,ss9_1=0,ss10_1=0,ss11_1=0,ss12_1=0;
                  ss1_1=T1.getText(); ss2_1=T2.getText();
                  ss3_1=Double.valueOf(T3.getText()).doubleValue(); 
                  ss4_1=Double.valueOf(T4.getText()).doubleValue(); 
                  ss5_1=Double.valueOf(T5.getText()).doubleValue(); 
                  ss6_1=Double.valueOf(T6.getText()).doubleValue();  
                  ss7_1=Double.valueOf(T7.getText()).doubleValue();  
                  ss9_1=Double.valueOf(T9.getText()).doubleValue();  
                  ss10_1=Double.valueOf(T10.getText()).doubleValue();  
                  ss11_1=Double.valueOf(T11.getText()).doubleValue();
                  ss8_1=ss3_1+ss4_1+ss5_1+ss6_1+ss7_1;   
                  ss12_1=ss8_1-ss9_1-ss10_1-ss11_1;
           Wage cus_2=new Wage(ss1_1,ss2_1,ss3_1,ss4_1,ss5_1,ss6_1,ss7_1,ss8_1,ss9_1,ss10_1,ss11_1,ss12_1);
       if(cus_2.s1.equals("编号"))
             {  JOptionPane.showMessageDialog(null,"输入的修改信息有误!!!");}
         else{
                 int number2=list.size();
              for(int i=0;i<number2;i++)
               {   Wage mov_2=(Wage)list.get(i);
                  if(mov_2.s1.equals(ss1_1)){list.remove(i);}
                  try{FileOutputStream file2=new FileOutputStream("zhigong1.txt");
                      ObjectOutputStream out2  =new ObjectOutputStream(file2);
                      out2.writeObject(list);//
                      out2.close();
                    }
                  catch(IOException event){}
                }
              list.add(cus_2);
              try{  FileOutputStream file21=new FileOutputStream("zhigong1.txt");
                    ObjectOutputStream out21=new ObjectOutputStream(file21);
                    out21.writeObject(list); out21.close();
                 }
              catch(IOException event){}
            }
         T1.setText("编号");T2.setText("姓名");T3.setText("0");T4.setText("0");
         T5.setText("0");T6.setText("0");T7.setText("0");
         T9.setText("0");T10.setText("0"); T11.setText("0");
        }
//删除方法
       else if(e.getSource()==b_move)
          {  T15.setText(null);
            String ss13 = JOptionPane.showInputDialog(z2.this, "输入要删除职工的编号:" );           
            String m="确定要删除"+ss13+"的工资信息吗?";
         int ok=JOptionPane.showConfirmDialog(this,m,"确认",
                  JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);
           if(ok==JOptionPane.YES_OPTION)
           {
            try{FileInputStream come_in31=new FileInputStream("zhigong1.txt");
                ObjectInputStream in31=new ObjectInputStream(come_in31);
                list=(LinkedList)in31.readObject(); //////
                 in31.close();
                 }
            catch(ClassNotFoundException event){}
            catch(IOException event){}
               boolean b3=true;int a3=0;
             int number3=list.size();

⌨️ 快捷键说明

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