美文网首页
人事管理系统

人事管理系统

作者: 吴鹏608 | 来源:发表于2018-01-24 15:49 被阅读0次
    java
    package com.company;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.Scanner;
    
    /**
     * Created by ttc on 18-1-23.
     */
    public class personmanagement {
        public static void main(String[] args) throws SQLException {
            while (true){
                System.out.println("欢迎使用用户管理系统");
                System.out.println("==================================");
                System.out.println("用户登录----------------1");
                System.out.println("用户注册----------------2");
                System.out.println("退出程序----------------3");
                Scanner scanner = new Scanner(System.in);
                String input = scanner.next();
    
                if (input.equals("1")) {
                    System.out.println("用户登录页面");
                    System.out.println("=================================");
                    System.out.println("请输入您的用户名");
                    String username = scanner.next();
                    System.out.println("请输入您的密码");
                    int password = scanner.nextInt();
    
                    Sort sort = null;
                    sort = JDBCDemoFinal.loc(username,password);
    
                    if (sort != null) {
                        System.out.println("登录成功");
                        System.out.println("===============================");
                        System.out.println("欢迎登录主页");
                        if (sort.getRole() == 0){
                            System.out.println(username+"您好!"+"\t\t"+"您的权限是:普通用户");
                            System.out.println("====================================");
                            System.out.println("修改自己的信息----------------------1");
                            System.out.println("查询自己的信息----------------------2");
                            System.out.println("程序退出----------------------------3");
                            String input1 = scanner.next();
                            if (input1.equals("1")){
                                System.out.println("您现在的信息是:");
                                System.out.println(sort);
    
                                System.out.println("请输入要修改的用户名");
                                String name = scanner.next();
                                sort.setUsername(name);
                                System.out.println("请输入要修改的密码");
                                int key = scanner.nextInt();
    
                                sort.setUsername(name);
                                sort.setPassword(key);
                                JDBCDemoFinal.updateSort(sort);
                                System.out.println("修改成功");
                                System.out.println("修改后的信息是"+sort);
    
    
                            }
                            else if (input1.equals("2")){
                                JDBCDemoFinal.getSortByID(sort.getSid());
                                System.out.println(sort);
                            }
                            else {
    
                            }
                        }
                        else {
                            System.out.println(username+"您好!"+"\t\t"+"您的权限是:管理员用户");
                            System.out.println("========================================");
                            System.out.println("添加用户---------------------------1");
                            System.out.println("删除用户---------------------------2");
                            System.out.println("修改用户---------------------------3");
                            System.out.println("查询用户---------------------------4");
                            System.out.println("程序退出---------------------------5");
    
                            String input1 = scanner.next();
                            if (input1.equals("1")){
                                System.out.println("请输入名字");
                                String name = scanner.next();
                                System.out.println("请输入用户名");
                                String uname = scanner.next();
                                System.out.println("请输入密码");
                                int key = scanner.nextInt();
                                System.out.println("请输入邮箱");
                                String mail = scanner.next();
    //                        System.out.println("请输入生日");
    
                                Sort sort1 = new Sort();
                                sort1.setSname(name);
                                sort1.setUsername(uname);
                                sort1.setPassword(key);
                                sort1.setMail(mail);
    
                                JDBCDemoFinal.AddSort(sort1);
                                System.out.println("添加用户成功");
                                System.out.println(sort1);
                            }
                            else if (input1.equals("2")){
                                System.out.println("请输入要删除的用户ID");
                                int id = scanner.nextInt();
                                JDBCDemoFinal.deleteSortByID(id);
                                System.out.println("删除成功");
                            }
                            else if (input1.equals("3")){
                                System.out.println("请输入要修改的ID");
                                int id = scanner.nextInt();
                                System.out.println("请输入要修改的用户名");
                                String username1 = scanner.next();
                                System.out.println("请输入要修改的密码");
                                int key = scanner.nextInt();
    
                                Sort sort1 = JDBCDemoFinal.getSortByID(id);
                                sort1.setUsername(username1);
                                sort1.setPassword(key);
                                JDBCDemoFinal.updateSort(sort1);
                                System.out.println("修改成功");
                                System.out.println(sort1);
    
                            }
                            else if (input1.equals("4")){
                                System.out.println("查询全部用户---------------1");
                                System.out.println("查询指定ID用户---------------2");
                                System.out.println("查询指定姓名用户---------------3");
                                System.out.println("请输入您的命令");
                                int key = scanner.nextInt();
                                if (key == 2){
                                    System.out.println("请输入ID");
                                    int key1 = scanner.nextInt();
                                    Sort sort1 = JDBCDemoFinal.getSortByID(key1);
                                    System.out.println(sort1);
                                }
                                else if (key == 1){
                                    System.out.println("全部信息表");
                                    List<Sort> sortList = JDBCDemoFinal.getAllSorts();
                                    for (Sort sort1:sortList){
                                        System.out.println(sort1);
                                    }
                                }
                                else if (key == 3){
                                    System.out.println("请输入要查询的姓名");
                                    String name = scanner.next();
                                    List<Sort> sortList = JDBCDemoFinal.getSortBysname(name);
                                    for (Sort sort1:sortList){
                                        System.out.println(sort1);
                                    }
    
                                }
                            }
                            else if (input1.equals("5")){
                                System.out.println("退出程序");
                                break;
                            }
    
                        }
    
                    } else {
                        System.out.println("登录失败");
                    }
    
    
                }
                else if (input.equals("2")){
                    System.out.println("欢迎来到用户注册页面");
                    System.out.println("=============================");
                    System.out.println("请输入用户名");
                    String name = scanner.next();
                    System.out.println("请输入密码");
                    int password = scanner.nextInt();
    
                    Sort sort1 = new Sort();
                    sort1.setUsername(name);
                    sort1.setPassword(password);
                    JDBCDemoFinal.AddSort(sort1);
                    System.out.println("注册成功");
                    System.out.println("================================");
                }
                else {
                    System.out.println("退出程序");
                    break;
                }
            }
            
        }
    
    }
    

    相关文章

      网友评论

          本文标题:人事管理系统

          本文链接:https://www.haomeiwen.com/subject/rouuaxtx.html