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

📄 serverwindows.java

📁 模拟银行的ATM自动取款机
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;


class isNumber{
   public static boolean isNum(String str){
      int length=str.length();
      boolean b=false;
      for(int i=0;i<=length-1;i++){
         char ch=str.charAt(i);
         if((ch<='9'&&ch>='0')||ch=='.'){
            b=true;
         }
         else{
            b=false;
         }
      }
      return b;
   }
}



public class serverWindows{
   public static void main(String args[]){
      
      Login log=new Login();
      ATMServer server=new ATMServer();
   }
}


class Login extends Frame implements ActionListener{
   private Label title;
   private Label IDInput;
   private Label passwordInput;
   private TextField IDField;
   private TextField passwordField;
   private Button login;
   private Button exit;
   private ManagerOperate manager;
   
   public Login(){
      setBackground(Color.lightGray);
      setLocation(300,300);
      setSize(300,300);
      setLayout(new GridLayout(4,1));
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.PLAIN,24);
      title=new Label("银行管理系统登陆");
      title.setFont(font);
      con0.add(title);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      IDInput=new Label("请输入ID:");
      IDField=new TextField(10);
      con1.add(IDInput);
      con1.add(IDField);
      
      Container con2=new Container();
      con2.setLayout(new FlowLayout());
      passwordInput=new Label("请输入密码:");
      passwordField=new TextField(10);
      passwordField.setEchoChar('*');
      con2.add(passwordInput);
      con2.add(passwordField);
      
      Container con3=new Container();
      con3.setLayout(new FlowLayout());
      login=new Button("确定");
      exit=new Button("退出");
      con3.add(login);
      con3.add(exit);
      login.addActionListener(this);
      exit.addActionListener(this);
      
      add(con0);
      add(con1);
      add(con2);
      add(con3);
      
      setVisible(true);
   }
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="确定"){
         manager=new ManagerOperate();
         int param=manager.CheckCode(IDField.getText(),passwordField.getText());
         if(param==3||param==0){
            LoginError err=new LoginError();
            setVisible(false);
         }
         else{
            setVisible(false);
            Manage mainWin=new Manage(manager);
         }
      }
      if(command=="退出"){
         setVisible(false);
         System.exit(0);
      }
   }
}
      
   
class LoginError extends Frame implements ActionListener{
   Label lab;
   Button back;
   
   public LoginError(){
      
      lab=new Label("ID或密码错误,请重新登录!!");
      back=new Button("返回");
      
      setBackground(Color.lightGray);
      setLocation(300,300);
      setSize(400,150);
      setLayout(new FlowLayout());
      
      Container con1=new Container();
      Font font=new Font("Arial",Font.BOLD,24);
      con1.setFont(font);
      con1.setLayout(new FlowLayout());
      con1.add(lab);
      
      Container con2=new Container();
      con2.setLayout(new FlowLayout());
      con2.add(back);
      
      add(con1,BorderLayout.CENTER);
      add(con2,BorderLayout.SOUTH);
      
      back.addActionListener(this);
      
      setVisible(true);
   }
   
    public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="返回"){
         this.setVisible(false);
         new Login();
      }
   }
}



class Manage extends Frame implements ActionListener{
   Label title;
   Button newManager;
   Button changePassword;
   Button inquireManager;
   Button operateAccount;
   Button inquireDate;
   Button relogin;
   Button delete;
   Button quit;
   Button createUser;
   Button passwordLose;
   Button useAble;
   Button userData;
   private ManagerOperate manager;
   
   public Manage(ManagerOperate manager){
      
      this.manager=manager;
      
      title=new Label("管理员管理窗口");
      createUser=new Button("新建帐户");
      newManager=new Button("新建管理员");
      changePassword=new Button("修改密码");
      inquireManager=new Button("管理员信息");
      relogin=new Button("重新登录");
      passwordLose=new Button("帐户挂失");
      operateAccount=new Button("用户操作");
      quit=new Button("退出系统");
      inquireDate=new Button("管理日志");
      delete=new Button("删除管理员");
      useAble=new Button("帐户启用");
      userData=new Button("帐户日志");
      
      setBackground(Color.lightGray);
      setLocation(200,200);
      setSize(400,400);
      setLayout(new FlowLayout());
      
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.add(title);
      
      Container con1=new Container();
      con1.setLayout(new GridLayout(6,2,30,20));
      Font f=new Font("Arial",Font.PLAIN,16);
      con1.setFont(f);
      con1.add(newManager);
      con1.add(createUser);
      con1.add(changePassword);
      con1.add(relogin);
      con1.add(passwordLose);
      con1.add(useAble);
      con1.add(operateAccount);
      con1.add(inquireManager);
      con1.add(inquireDate);
      con1.add(userData);
      con1.add(delete);
      con1.add(quit);
      
      
      relogin.addActionListener(this);
      newManager.addActionListener(this);
      changePassword.addActionListener(this);
      quit.addActionListener(this);
      operateAccount.addActionListener(this);
      delete.addActionListener(this);
      createUser.addActionListener(this);
      passwordLose.addActionListener(this);
      useAble.addActionListener(this);
      inquireManager.addActionListener(this);
      userData.addActionListener(this);
      inquireDate.addActionListener(this);
      
      add(con0);
      add(con1);
      
      String state=null;
      if(manager.getifmaster()==1) state=new String("(超级管理员)");
      else state=new String("(普通管理员)");
      setTitle("当前在职管理员:"+manager.getname()+state);
      setVisible(true);
      
   }
   
    public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="重新登录"){
         setVisible(false);
         manager.leave();
         Login l=new Login();
         
      }
      if(command=="新建管理员"){
         int i=manager.getifmaster();
         if(i==1){
            new newManager(manager);
            setVisible(false);
         }
         else{
            new noPrompt(manager);
            setVisible(false);
         }
      }
      if(command=="修改密码"){
         new changePassword(manager);
         setVisible(false);
      }
      if(command=="用户操作"){
         new userLogin(manager);
         setVisible(false);
      }
      if(command=="删除管理员"){
         setVisible(false);
         if(manager.getifmaster()==1){
            new deleteManager(manager);
         }
         else{
            new noPrompt(manager);
         }
      }
      if(command=="新建帐户"){
         setVisible(false);
         new newUser(manager);
      }
      if(command=="帐户挂失"){
         setVisible(false);
         new accountLose(manager);
      }
      if(command=="帐户启用"){
         setVisible(false);
         new accountUsable(manager);
      } 
      if(command=="管理员信息"){
         setVisible(false);
         if(manager.getifmaster()==1){
            new managerId(manager);
         }
         else{
            new noPrompt(manager);
         }
      }
      if(command=="帐户日志"){
         if(manager.getifmaster()==1){
            setVisible(false);
            new accountData(manager);
         }
         else{
            setVisible(false);
            new noPrompt(manager);
         }
      }
      if(command=="管理日志"){
         if(manager.getifmaster()==1){
            setVisible(false);
            new operateData(manager);
         }
         else{
            setVisible(false);
            new noPrompt(manager);
         }
      }
      if(command=="退出系统"){
         manager.leave();
         System.exit(0);
      }
   }
}


class deleteManager extends Frame implements ActionListener{
   Label title;
   Label id;
   TextField idField;
   Button enter;
   Button back;
   ManagerOperate manager;
   
   public deleteManager(ManagerOperate manager){
      this.manager=manager;
      
      title=new Label("删除管理员");
      id=new Label("输入ID");
      idField=new TextField(10);
      enter=new Button("确定");
      back=new Button("返回");
      
      setBackground(Color.lightGray);
      setLocation(200,200);
      setSize(400,300);
      setLayout(new GridLayout(3,1));
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.add(title);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(id);
      con1.add(idField);
      
      Container con2=new Container();
      con2.setLayout(new FlowLayout());
      con2.add(enter);
      con2.add(back);
      
      enter.addActionListener(this);
      back.addActionListener(this);
      
      add(con0);
      add(con1);
      add(con2);
      
      setVisible(true);
   }
   
   public void actionPerformed(ActionEvent ae){
      String command=(String)ae.getActionCommand();
      if(command=="确定"){
         if(idField.getText().equals(manager.getid())){
            setVisible(false);
            new deleteError(manager);
         }
         else{
            setVisible(false);
            manager.RemoveManager(idField.getText());
            new Manage(manager);
         }
      }
      if(command=="返回"){
         setVisible(false);
         new Manage(manager);
      }
   }
}




class newManager extends Frame implements ActionListener,ItemListener{//新建管理员窗口
   Label title;
   Label name;
   Label id;
   Label password;
   Label repassword;
   Label idCard;
   Checkbox superManager;
   TextField nameText;
   TextField idText;
   TextField passwordText;
   TextField repasswordText;
   TextField idCardText;
   Button enter;
   Button back;
   ManagerOperate manager;
   
   public newManager(ManagerOperate manager){
      this.manager=manager;
      
      title=new Label("新管理员注册");
      name=new Label("输入姓名");
      id=new Label("输入用户名");
      password=new Label("输入密码");
      repassword=new Label("重新输入密码");
      idCard=new Label("输入身份证号");
      superManager=new Checkbox("设定为超级管理员");
      nameText=new TextField(10);
      idText=new TextField(10);
      passwordText=new TextField(10);
      repasswordText=new TextField(10);
      idCardText=new TextField(20);
      enter=new Button("提交");
      back=new Button("返回");
      
      setBackground(Color.lightGray);
      setLocation(200,200);
      setSize(400,300);
      setLayout(new GridLayout(8,1));
      
      
      Container con0=new Container();
      con0.setLayout(new FlowLayout());
      Font font=new Font("Arial",Font.BOLD,24);
      con0.setFont(font);
      con0.add(title);
      
      Container con1=new Container();
      con1.setLayout(new FlowLayout());
      con1.add(name);
      con1.add(nameText);
      
      Container con2=new Container();
      con2.setLayout(new FlowLayout());
      con2.add(id);
      con2.add(idText);
      
      Container con3=new Container();
      con3.setLayout(new FlowLayout());
      passwordText.setEchoChar('*');
      con3.add(password);
      con3.add(passwordText);
      
      Container con4=new Container();
      con4.setLayout(new FlowLayout());
      con4.add(repassword);
      repasswordText.setEchoChar('*');
      con4.add(repasswordText);
      
      Container con5=new Container();
      con5.setLayout(new FlowLayout());
      con5.add(idCard);
      con5.add(idCardText);
      
      Container con6=new Container();
      con6.setLayout(new FlowLayout());
      con6.add(superManager);
      
      Container con7=new Container();
      con7.setLayout(new FlowLayout());
      con7.add(enter);
      con7.add(back);
      
      add(con0);
      add(con1);
      add(con2);
      add(con3);
      add(con4);
      add(con5);
      add(con6);
      add(con7);
      
      enter.addActionListener(this);
      back.addActionListener(this);
      superManager.addItemListener(this);
      
      setVisible(true);
   }

⌨️ 快捷键说明

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