超市管理项目-5 管理员功能实现

1.管理收银员账户

    //修改收银员
    public void executeSale(){
        System.out.println("1.增加收银员  2.修改收银员信息  3.删除收银员信息  4.查询收银员信息");
        int m = sc.nextInt();
        switch (m){
            case 1:
                System.out.println("请输入收银员信息:编号-姓名-密码-性别-手机号-是否在职(1.在;2.不在)");
                String str = sc.next();
                String[] message = str.split("-");
                String sql1 = "insert into employee(number,username,password,sex,phone,role,remark) values (?,?,?,?,?,2,?) ";
                JDBCUntil.updates(sql1,message);
                break;
            case 2:
                System.out.println("请输入要修改的收银员编号:");
                String number = sc.next();
                String sql2 = "select * from employee where number=?";
                List<Sale> list = JDBCUntil.select(sql2,"sale", number);
                for (Sale sale:list){
                    if ("收银员".equals(sale.getCategory())) {
                        System.out.println("请输入要修改的收银员信息:姓名-密码-性别-手机号-是否在职(1.在;2.不在)");
                        String msg1 = sc.next();
                        String[] mess1 =  msg1.split("-");
                        String sql3 = "update employee set username=?,password=?,sex=?,phone=?,remark=? where number='"+number+"'";
                        JDBCUntil.updates(sql3,mess1);
                    }
                }
                break;
            case 3:
                System.out.println("请输入要删除的收银员编号:");
                String number1 = sc.next();
                String sql4 = "delete  from employee where number=?";
                try {
                    JDBCUntil.updates(sql4,number1);
                    System.out.println("删除成功...");
                }catch (Exception e){
                    System.out.println("该编号不存在...");
                }
                break;
            case 4:
                System.out.println("请输入要查询的收银员编号:");
                String number2 = sc.next();
                String sql5 = "select *  from employee where number=?";
                List<Sale> listt = JDBCUntil.select(sql5 , "sale", number2);
                if (listt.size()==0){
                    System.out.println("该编号不存在...");
                }
                else {
                    for (Sale sale:listt){
                        System.out.println(sale.toString());
                    }
                }
                break;
            default:
                break;
        }
    }

2.管理采购员账户

 //修改采购员账户
    public void executeBuyer(){
        System.out.println("1.增加采购员  2.修改采购员信息  3.删除采购员信息  4.查询采购员信息");
        int m = sc.nextInt();
        switch (m){
            case 1:
                System.out.println("请输入采购员信息:编号-姓名-密码-性别-手机号-是否在职(1.在;2.不在)");
                String str = sc.next();
                String[] message = str.split("-");
                String sql1 = "insert into employee(number,username,password,sex,phone,role,remark) values (?,?,?,?,?,3,?) ";
                JDBCUntil.updates(sql1,message);
                System.out.println("添加采购员成功...");
                break;
            case 2:
                System.out.println("请输入要修改的采购员编号:");
                String number = sc.next();
                String sql2 = "select * from employee where number=?";
                List<Sale> list = JDBCUntil.select(sql2,"sale", number);
                for (Sale sale:list) {
                    if ("采购员".equals(sale.getCategory())) {
                        System.out.println("请输入要修改的采购员信息:姓名-密码-性别-手机号-是否在职(1.在;2.不在)");
                        String msg1 = sc.next();
                        String[] mess1 = msg1.split("-");
                        String sql3 = "update employee set username=?,password=?,sex=?,phone=?,remark=? where number='" + number + "'";
                        JDBCUntil.updates(sql3, mess1);
                    } else {
                        System.out.println("该员工不是采购员噢...");
                    }
                }
                break;
            case 3:
                System.out.println("请输入要删除的采购员编号:");
                String number1 = sc.next();
                String sql4 = "delete  from employee where number=?";
                try {
                    JDBCUntil.updates(sql4,number1);
                    System.out.println("删除成功...");
                }catch (Exception e){
                    System.out.println("该编号不存在...");
                }
                break;
            case 4:
                System.out.println("请输入要查询的采购员编号:");
                String number2 = sc.next();
                String sql5 = "select *  from employee where number=?";
                String s = "e";
                try {
                    List<Sale> lists = JDBCUntil.select(sql5 , "sale", number2);
                    for (Sale sale:lists){
                        System.out.println(sale.toString());
                    }
                }catch (Exception e){
                    System.out.println("该编号不存在...");
                }
                break;
            default:
                break;
        }
    }

3.出勤查询

//出勤查询
    public void attendanceQuery(){
        //查询当天
        System.out.println("请输入要查询的范围:");
        System.out.println("1.当天 2.总体 3.2021年4月 ");
        int i = sc.nextInt();
        switch (i){
            case 1:
                String sql = " select * from check_info where work_date=?";
                String s = "attendanceQuery";
                List list1 = JDBCUntil.select(sql, s, JDBCUntil.datas);
                list1.forEach(System.out::println);
                break;
            case 2:
                String sqls = " select * from check_info";
                String ss = "attendanceQuery";
                List list = JDBCUntil.select(sqls, ss);
                list.forEach(System.out::println);
               
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值