JDBC综合案例-商品销售管理系统控制台版1.0 5

=============com.ruanyuan.test===============

package com.ruanyuan.test;

import java.util.List;

import com.ruanyuan.dao.impl.CategoryDAOImpl;
import com.ruanyuan.dao.impl.GoodDAOImpl;
import com.ruanyuan.entity.Category;
import com.ruanyuan.entity.Good;

public class CategoryManagementSystem {

    /**
     * 添加类别
     */
    public static void insertDate() {
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建类别对象
        Category category=new Category();
        
//        获取键盘输入的数据
        System.out.print("请输入类别名称:");
        String categoryName=Tools.enter.next();
        
//        获取通过类别名称查询的数据
        Category category2=categoryDAOImpl.selectDateName(categoryName);
        
//        如果查询的结果存在就不在进行添加数据操作
        if(category2!=null ) {
            System.err.println("\n该类别已经存在,无法添加!");
            
//        该类别不存在,执行添加操作
        }else {
//            设置对象参数
            category.setCategoryName(categoryName);
            
//            执行添加操作,并且获取返回值
            int count=categoryDAOImpl.inserDate(category);
            
//            如果返回值大于0,说明执行成功,相反未执行成功
            if(count>0) {
                System.out.println("\n添加成功!");
            }else {
                System.err.println("\n添加失败!");
            }
        }
        

    }

    
    
    /**删除类别
     * 
     */
    public static void deleteDate() {
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        获取商品实现类
        GoodDAOImpl goodDAOImpl=new GoodDAOImpl();
//        
//        创建类别对象
        Category category=new Category();

//        获取返回的数据信息
        List<Category> categorys=categoryDAOImpl.selectAllDate();
        
        
//        该类别存在,打印信息
        if(categorys!=null && categorys.size()>0) {
            
//            格式化输出显示所有数据
            System.out.println("\n————————————————");
            System.out.println("类别编号\t 类别名称\n————————————————");
            for (Category category2 : categorys) {
                System.out.println(category2.getCategoryID()+"\t "+category2.getCategoryName());
            }
            
//            获取键盘输入的删除条件:类别编号
            System.out.print("请输入要删除的类别ID:");
            int CategoryID=Tools.enter.nextInt();
            
//            获取输入的类别编号查询的结果
            Category category2 =categoryDAOImpl.selectDateID(String.valueOf(CategoryID));
            
//            存在数据,继续执行修改操作
            if(category2!=null) {
                
//                询问是否真的删除,并获取用户输入的结果
                System.out.println("你确定要删除吗?Y确定 / N取消");
                String delCategoryID=Tools.enter.next();
                
//                确定删除,执行删除操作
                if(delCategoryID.equalsIgnoreCase("Y")) {
                    
//                    判断该类别下有销售信息
                    Good goods=goodDAOImpl.selectDateCategoryID(CategoryID);

//                    有销售信息,不可以删除
                    if(goods!=null) {
                        System.err.println("\n抱歉,该类别下有销售信息,无法删除!");
//                    无销售信息,删除
                    }else {

//                        设置对象参数
                        category.setCategoryID(CategoryID);
                        
//                        执行删除操作,并且获取返回值
                        int count=categoryDAOImpl.deleteDate(category);
                        
//                        如果返回值大于0,说明执行成功,相反未执行成功
                        if(count>0) {
                            System.out.println("\n删除成功!");
                        }else {
                            System.err.println("\n删除失败!");
                        }
                    }
                    
                    
//                取消删除,退出删除操作
                }else {
                    System.out.println("取消删除成功!");
                }
                
//            类别信息不存在
            }else {
                System.err.println("\n抱歉,你要删除的类别信息不存在!");
            }


            
//        数据不存在,无法删除,数据库0条记录
        }else {
            System.err.println("\n抱歉,数据库0条记录!");

        }
    }
    
    
    /**修改类别
     * 
     */
    public static void updateDate() {
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
//        
//        创建类别对象
        Category category=new Category();
        
//        获取所有的类别数据
        List<Category> categorys=categoryDAOImpl.selectAllDate();
        
//        该类别存在,打印数据
        if(categorys!=null && categorys.size()>0) {
            
//            格式化显示所有数据信息
            System.out.println("\n————————————————");
            System.out.println("类别编号\t 类别名称\n————————————————");
            for (Category category2 : categorys) {
                System.out.println(category2.getCategoryID()+"\t "+category2.getCategoryName());
            }
            
//            获取键盘输入的类别编号
            System.out.print("请输入要修改的类别ID:");
            int CategoryID=Tools.enter.nextInt();
            
//            获取输入的类别编号查询的结果
            Category category2 =categoryDAOImpl.selectDateID(String.valueOf(CategoryID));
            
//            存在数据,继续执行修改操作
            if(category2!=null) {
                
//                获取修改的类别名称
                System.out.print("请输入要修改的类别名称:");
                String categoryName=Tools.enter.next();
                
//                设置对象参数
                category.setCategoryID(CategoryID);
                category.setCategoryName(categoryName);
                
//                执行删除操作,并且获取返回值
                int count=categoryDAOImpl.updateDate(category);
                
//                如果返回值大于0,说明执行成功,相反未执行成功
                if(count>0) {
                    System.out.println("\n修改成功!");
                }else {
                    System.err.println("\n修改失败!");
                }
                
//            类别不存在,无法修改
            }else {
                System.err.println("\n抱歉,你要修改的类别信息不存在!");
            }

            
//        数据库0条记录
        }else {
            System.err.println("\n抱歉,数据库0条记录!");

        }
    }
    
    /**
     * 多条件查询
     */
    public static void selectDate() {
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        获取键盘录入的查询条件,类别名称
        System.out.println("请输入你要查询的类别名称 可以模糊查询 ");
        String categoryName=Tools.enter.next();
        
//        获取通过类别名称查询的数据
        List<Category> categorys=categoryDAOImpl.selectDateMore(categoryName);
        
//        如果查询的结果存在,就输出数据
        if(categorys!=null &&categorys.size()>0) {
            
//            格式化输出显示所有数据信息
            System.out.println("\n————————————————");
            System.out.println("类别编号\t 类别名称\n————————————————");
            for (Category category : categorys) {
                System.out.println(category.getCategoryID()+"\t "+category.getCategoryName());
            }
            
//        查询数据不存在,无法操作
        }else {
            System.err.println("\n抱歉,暂无你要查询的类别信息!");
        }


    }

}
——————————————————————————

package com.ruanyuan.test;

import java.util.List;

import com.ruanyuan.dao.impl.CategoryDAOImpl;
import com.ruanyuan.dao.impl.GoodDAOImpl;
import com.ruanyuan.entity.Category;
import com.ruanyuan.entity.Good;

public class CategoryManagementSystem {

    /**
     * 添加类别
     */
    public static void insertDate() {
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建类别对象
        Category category=new Category();
        
//        获取键盘输入的数据
        System.out.print("请输入类别名称:");
        String categoryName=Tools.enter.next();
        
//        获取通过类别名称查询的数据
        Category category2=categoryDAOImpl.selectDateName(categoryName);
        
//        如果查询的结果存在就不在进行添加数据操作
        if(category2!=null ) {
            System.err.println("\n该类别已经存在,无法添加!");
            
//        该类别不存在,执行添加操作
        }else {
//            设置对象参数
            category.setCategoryName(categoryName);
            
//            执行添加操作,并且获取返回值
            int count=categoryDAOImpl.inserDate(category);
            
//            如果返回值大于0,说明执行成功,相反未执行成功
            if(count>0) {
                System.out.println("\n添加成功!");
            }else {
                System.err.println("\n添加失败!");
            }
        }
        

    }

    
    
    /**删除类别
     * 
     */
    public static void deleteDate() {
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        获取商品实现类
        GoodDAOImpl goodDAOImpl=new GoodDAOImpl();
//        
//        创建类别对象
        Category category=new Category();

//        获取返回的数据信息
        List<Category> categorys=categoryDAOImpl.selectAllDate();
        
        
//        该类别存在,打印信息
        if(categorys!=null && categorys.size()>0) {
            
//            格式化输出显示所有数据
            System.out.println("\n————————————————");
            System.out.println("类别编号\t 类别名称\n————————————————");
            for (Category category2 : categorys) {
                System.out.println(category2.getCategoryID()+"\t "+category2.getCategoryName());
            }
            
//            获取键盘输入的删除条件:类别编号
            System.out.print("请输入要删除的类别ID:");
            int CategoryID=Tools.enter.nextInt();
            
//            获取输入的类别编号查询的结果
            Category category2 =categoryDAOImpl.selectDateID(String.valueOf(CategoryID));
            
//            存在数据,继续执行修改操作
            if(category2!=null) {
                
//                询问是否真的删除,并获取用户输入的结果
                System.out.println("你确定要删除吗?Y确定 / N取消");
                String delCategoryID=Tools.enter.next();
                
//                确定删除,执行删除操作
                if(delCategoryID.equalsIgnoreCase("Y")) {
                    
//                    判断该类别下有销售信息
                    Good goods=goodDAOImpl.selectDateCategoryID(CategoryID);

//                    有销售信息,不可以删除
                    if(goods!=null) {
                        System.err.println("\n抱歉,该类别下有销售信息,无法删除!");
//                    无销售信息,删除
                    }else {

//                        设置对象参数
                        category.setCategoryID(CategoryID);
                        
//                        执行删除操作,并且获取返回值
                        int count=categoryDAOImpl.deleteDate(category);
                        
//                        如果返回值大于0,说明执行成功,相反未执行成功
                        if(count>0) {
                            System.out.println("\n删除成功!");
                        }else {
                            System.err.println("\n删除失败!");
                        }
                    }
                    
                    
//                取消删除,退出删除操作
                }else {
                    System.out.println("取消删除成功!");
                }
                
//            类别信息不存在
            }else {
                System.err.println("\n抱歉,你要删除的类别信息不存在!");
            }


            
//        数据不存在,无法删除,数据库0条记录
        }else {
            System.err.println("\n抱歉,数据库0条记录!");

        }
    }
    
    
    /**修改类别
     * 
     */
    public static void updateDate() {
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
//        
//        创建类别对象
        Category category=new Category();
        
//        获取所有的类别数据
        List<Category> categorys=categoryDAOImpl.selectAllDate();
        
//        该类别存在,打印数据
        if(categorys!=null && categorys.size()>0) {
            
//            格式化显示所有数据信息
            System.out.println("\n————————————————");
            System.out.println("类别编号\t 类别名称\n————————————————");
            for (Category category2 : categorys) {
                System.out.println(category2.getCategoryID()+"\t "+category2.getCategoryName());
            }
            
//            获取键盘输入的类别编号
            System.out.print("请输入要修改的类别ID:");
            int CategoryID=Tools.enter.nextInt();
            
//            获取输入的类别编号查询的结果
            Category category2 =categoryDAOImpl.selectDateID(String.valueOf(CategoryID));
            
//            存在数据,继续执行修改操作
            if(category2!=null) {
                
//                获取修改的类别名称
                System.out.print("请输入要修改的类别名称:");
                String categoryName=Tools.enter.next();
                
//                设置对象参数
                category.setCategoryID(CategoryID);
                category.setCategoryName(categoryName);
                
//                执行删除操作,并且获取返回值
                int count=categoryDAOImpl.updateDate(category);
                
//                如果返回值大于0,说明执行成功,相反未执行成功
                if(count>0) {
                    System.out.println("\n修改成功!");
                }else {
                    System.err.println("\n修改失败!");
                }
                
//            类别不存在,无法修改
            }else {
                System.err.println("\n抱歉,你要修改的类别信息不存在!");
            }

            
//        数据库0条记录
        }else {
            System.err.println("\n抱歉,数据库0条记录!");

        }
    }
    
    /**
     * 多条件查询
     */
    public static void selectDate() {
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        获取键盘录入的查询条件,类别名称
        System.out.println("请输入你要查询的类别名称 可以模糊查询 ");
        String categoryName=Tools.enter.next();
        
//        获取通过类别名称查询的数据
        List<Category> categorys=categoryDAOImpl.selectDateMore(categoryName);
        
//        如果查询的结果存在,就输出数据
        if(categorys!=null &&categorys.size()>0) {
            
//            格式化输出显示所有数据信息
            System.out.println("\n————————————————");
            System.out.println("类别编号\t 类别名称\n————————————————");
            for (Category category : categorys) {
                System.out.println(category.getCategoryID()+"\t "+category.getCategoryName());
            }
            
//        查询数据不存在,无法操作
        }else {
            System.err.println("\n抱歉,暂无你要查询的类别信息!");
        }


    }

}
————————————————————

package com.ruanyuan.test;

public class CommodityManagementSystem {

    public static void main(String[] args) {
        
        for(;;) {
            System.out.println("====================登录商品管理系统====================");
//            获取用户信息
            System.out.println("请输入用户名:");
            String userName=Tools.enter.next();
            System.out.println("请输入用户密码:");
            String userPwd=Tools.enter.next();
            
//            如果用户信息验证正确,进入操作系统,相反则提示用户信息有误
            if(userName.equals("admin") && userPwd.equals("admin")) {
                
//                商品管理系统运行
                commodityManagementSystem:for(;;) {
                    
                    System.out.println("====================欢迎登录商品管理系统====================");
//                    商品管理系统操作选项菜单
                    System.out.println("请输入你要操作的数据表选项"
                            + "\n1.类别数据表"
                            + "\n2.职员数据表"
                            + "\n3.商品信息数据表"
                            + "\n4.供货商数据表"
                            + "\n5.销售信息数据表"
                            + "\n6.退出");
//                    获取用户输入的操作选项
                    int choose=Tools.enter.nextInt();
                    
//                    类别数据表操作
                    if(choose==1) {
                        
//                        类别管理系统运行
                        categoryManagerSystem:for(;;) {
                            System.out.println("-------------------------类别管理系统-------------------------------");
//                            类别管理系统操作选项菜单
                            System.out.println("请输入你要进行的操作选项"
                                    + "\n1.添加数据"
                                    + "\n2.删除数据"
                                    + "\n3.修改数据"
                                    + "\n4.多条件查询"
                                    + "\n5.退出");
                            
//                            获取用户输入的操作选项
                            int categroy_choose=Tools.enter.nextInt();
                            
//                            添加数据
                            if(categroy_choose==1) {
                                System.out.println("---------------------------添加数据----------------------------------");
                                
//                                调用类别管理系统的添加数据方法
                                CategoryManagementSystem.insertDate();
                                
//                            删除数据
                            }else if(categroy_choose==2) {
                                System.out.println("---------------------------删除数据----------------------------------");
                                
//                                调用类别管理系统的删除数据方法
                                CategoryManagementSystem.deleteDate();
                                
//                            修改数据
                            }else if(categroy_choose==3) {
                                System.out.println("---------------------------修改数据----------------------------------");
                                
//                                调用类别管理系统的修改数据方法
                                CategoryManagementSystem.updateDate();
                                
//                            多条件查询
                            }else if(categroy_choose==4) {
                                System.out.println("---------------------------多条件查询----------------------------------");
                                
//                                调用类别管理系统的多条件查询数据方法
                                CategoryManagementSystem.selectDate();
                                
//                            退出
                            }else if(categroy_choose==5) {
                                
                                System.out.println("---------------------------退出----------------------------------");
//                                获取用户是否退出
                                System.out.println("确定退出吗?Y确定 /N取消");
//                                获取用户是否退出
                                String exit=Tools.enter.next();
                                
//                                y退出系统
                                if(exit.equalsIgnoreCase("y")) {
                                    System.out.println("退出成功,欢迎下次使用!");
                                    break categoryManagerSystem;
                                    
//                                n取消退出
                                }else {
                                    System.out.println("取消退出!");
                                }
                                
//                            操作选项有错误        
                            }else {
                                System.err.println("操作选项输入有误!重新输入!");
                            }
                        }
                
//                    职员管理系统
                    }else if(choose==2){

//                        类别管理系统运行
                        employeeManagerSystem:for(;;) {
                            System.out.println("-------------------------职员管理系统-------------------------------");
//                            职员管理系统操作选项菜单
                            System.out.println("请输入你要进行的操作选项"
                                    + "\n1.添加数据"
                                    + "\n2.删除数据"
                                    + "\n3.修改数据"
                                    + "\n4.多条件查询"
                                    + "\n5.退出");
                            
//                            获取用户输入的操作选项
                            int employee_choose=Tools.enter.nextInt();
                            
//                            添加数据
                            if(employee_choose==1) {
                                System.out.println("---------------------------添加数据----------------------------------");
                                
//                                调用职员管理系统的添加数据方法
                                EmployeeManagementSystem.insertDate();
                                
//                            删除数据
                            }else if(employee_choose==2) {
                                System.out.println("---------------------------删除数据----------------------------------");
                                
//                                调用职员管理系统的删除数据方法
                                EmployeeManagementSystem.deleteDate();
                                
//                            修改数据
                            }else if(employee_choose==3) {
                                System.out.println("---------------------------修改数据----------------------------------");
                                
//                                调用职员管理系统的修改数据方法
                                EmployeeManagementSystem.updateDate();
                                
//                            多条件查询
                            }else if(employee_choose==4) {
                                System.out.println("---------------------------多条件查询----------------------------------");
                                
//                                调用职员管理系统的多条件查询数据方法
                                EmployeeManagementSystem.selectDate();
                                
//                            退出
                            }else if(employee_choose==5) {
                                
                                System.out.println("---------------------------退出----------------------------------");
//                                获取用户是否退出
                                System.out.println("确定退出吗?Y确定 /N取消");
//                                获取用户是否退出
                                String exit=Tools.enter.next();
                                
//                                y退出系统
                                if(exit.equalsIgnoreCase("y")) {
                                    System.out.println("退出成功,欢迎下次使用!");
                                    break employeeManagerSystem;
                                    
//                                n取消退出
                                }else {
                                    System.out.println("取消退出!");
                                }
                                
//                            操作选项有错误        
                            }else {
                                System.err.println("操作选项输入有误!重新输入!");
                            }
                        }
//                    商品管理系统
                    }else if(choose==3){
                        
//                        类别管理系统运行
                        gooodManagerSystem:for(;;) {
                            System.out.println("-------------------------商品管理系统-------------------------------");
//                            商品管理系统操作选项菜单
                            System.out.println("请输入你要进行的操作选项"
                                    + "\n1.添加数据"
                                    + "\n2.删除数据"
                                    + "\n3.修改数据"
                                    + "\n4.多条件查询"
                                    + "\n5.退出");
                            
//                            获取用户输入的操作选项
                            int good_choose=Tools.enter.nextInt();
                            
//                            添加数据
                            if(good_choose==1) {
                                System.out.println("---------------------------添加数据----------------------------------");
                                
//                                调用商品管理系统的添加数据方法
                                GoodManagementSystem.insertDate();
                                
//                            删除数据
                            }else if(good_choose==2) {
                                System.out.println("---------------------------删除数据----------------------------------");
                                
//                                调用商品管理系统的删除数据方法
                                GoodManagementSystem.deleteDate();
                                
//                            修改数据
                            }else if(good_choose==3) {
                                System.out.println("---------------------------修改数据----------------------------------");
                                
//                                调用商品管理系统的修改数据方法
                                GoodManagementSystem.updateDate();
                                
//                            多条件查询
                            }else if(good_choose==4) {
                                System.out.println("---------------------------多条件查询----------------------------------");
                                
//                                调用商品管理系统的多条件查询数据方法
                                GoodManagementSystem.selectDate();
                                
//                            退出
                            }else if(good_choose==5) {
                                
                                System.out.println("---------------------------退出----------------------------------");
//                                获取用户是否退出
                                System.out.println("确定退出吗?Y确定 /N取消");
//                                获取用户是否退出
                                String exit=Tools.enter.next();
                                
//                                y退出系统
                                if(exit.equalsIgnoreCase("y")) {
                                    System.out.println("退出成功,欢迎下次使用!");
                                    break gooodManagerSystem;
                                    
//                                n取消退出
                                }else {
                                    System.out.println("取消退出!");
                                }
                                
//                            操作选项有错误        
                            }else {
                                System.err.println("操作选项输入有误!重新输入!");
                            }
                        }
                        
//                    供货商管理系统
                    }else if(choose==4){
                        
//                        供货商管理系统运行
                        offerManagerSystem:for(;;) {
                            System.out.println("-------------------------供货商管理系统-------------------------------");
//                            供货商管理系统操作选项菜单
                            System.out.println("请输入你要进行的操作选项"
                                    + "\n1.添加数据"
                                    + "\n2.删除数据"
                                    + "\n3.修改数据"
                                    + "\n4.多条件查询"
                                    + "\n5.退出");
                            
//                            获取用户输入的操作选项
                            int offer_choose=Tools.enter.nextInt();
                            
//                            添加数据
                            if(offer_choose==1) {
                                System.out.println("---------------------------添加数据----------------------------------");
//                                调用供货商管理系统的添加数据方法
                                OfferManagementSystem.insertDate();
                                
//                            删除数据
                            }else if(offer_choose==2) {
                                System.out.println("---------------------------删除数据----------------------------------");
//                                调用供货商管理系统的删除数据方法
                                OfferManagementSystem.deleteDate();
                                
//                            修改数据
                            }else if(offer_choose==3) {
                                System.out.println("---------------------------修改数据----------------------------------");
//                                调用类别管理系统的修改数据方法
                                OfferManagementSystem.updateDate();
                                
//                            多条件查询
                            }else if(offer_choose==4) {
                                System.out.println("---------------------------多条件查询----------------------------------");
//                                调用供货商管理系统的多条件查询数据方法
                                OfferManagementSystem.selectDateMore();
                                
//                            退出
                            }else if(offer_choose==5) {
                                
                                System.out.println("---------------------------退出----------------------------------");
//                                获取用户是否退出
                                System.out.println("确定退出吗?Y确定 /N取消");
                                
//                                获取用户是否退出
                                String exit=Tools.enter.next();
                                
//                                y退出系统
                                if(exit.equalsIgnoreCase("y")) {
                                    System.out.println("退出成功,欢迎下次使用!");
                                    break offerManagerSystem;
                                    
//                                n取消退出
                                }else {
                                    System.out.println("取消退出!");
                                }
//                            操作选项有错误    
                            }else {
                                System.err.println("操作选项输入有误!重新输入!");
                            }
                        }
//                    销售管理系统    
                    }else if(choose==5){
//                        类别管理系统运行
                        salesManagerSystem:for(;;) {
                            System.out.println("-------------------------销售管理系统-------------------------------");
//                            销售管理系统操作选项菜单
                            System.out.println("请输入你要进行的操作选项"
                                    + "\n1.添加数据"
                                    + "\n2.删除数据"
                                    + "\n3.修改数据"
                                    + "\n4.多条件查询"
                                    + "\n5.退出");
                            
//                            获取用户输入的操作选项
                            int sales_choose=Tools.enter.nextInt();
                            
//                            添加数据
                            if(sales_choose==1) {
                                System.out.println("---------------------------添加数据----------------------------------");
                                
//                                调用销售管理系统的添加数据方法
                                SalesManagementSystem.insertDate();
                                
//                            删除数据
                            }else if(sales_choose==2) {
                                System.out.println("---------------------------删除数据----------------------------------");
                                
//                                调用销售管理系统的删除数据方法
                                SalesManagementSystem.deleteDate();
                                
//                            修改数据
                            }else if(sales_choose==3) {
                                System.out.println("---------------------------修改数据----------------------------------");
                                
//                                调用销售管理系统的修改数据方法
                                SalesManagementSystem.updateDate();
                                
//                            多条件查询
                            }else if(sales_choose==4) {
                                System.out.println("---------------------------多条件查询----------------------------------");
                                
//                                调用销售管理系统的多条件查询数据方法
                                SalesManagementSystem.selectDate();
                                
//                            退出
                            }else if(sales_choose==5) {
                                
                                System.out.println("---------------------------退出----------------------------------");
//                                获取用户是否退出
                                System.out.println("确定退出吗?Y确定 /N取消");
//                                获取用户是否退出
                                String exit=Tools.enter.next();
                                
//                                y退出系统
                                if(exit.equalsIgnoreCase("y")) {
                                    System.out.println("退出成功,欢迎下次使用!");
                                    break salesManagerSystem;
                                    
//                                n取消退出
                                }else {
                                    System.out.println("取消退出!");
                                }
                                
//                            操作选项有错误        
                            }else {
                                System.err.println("操作选项输入有误!重新输入!");
                            }
                        }
                        
                    
//                    退出
                    }else if(choose==6){
                        System.out.println("-------------------------退出------------------------------");
                        
//                        获取用户是否退出
                        System.out.println("确定退出吗?Y确定 /N取消");
                        String exit=Tools.enter.next();
//                        y退出系统
                        if(exit.equalsIgnoreCase("y")) {
                            System.out.println("退出成功,欢迎下次使用!");
                            break commodityManagementSystem;
//                        n取消退出
                        }else {
                            System.out.println("取消退出!");
                        }
                    }else{
                        System.err.println("操作选项输入有误!重新输入!");
                    }
                    
                }
                
                
                
//            用户信息有误
            }else {
                System.err.println("账号信息有误,重新输入!");
            }
        }

    }
    

}
————————————————————

package com.ruanyuan.test;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.ruanyuan.dao.impl.EmployeeDAOImpl;
import com.ruanyuan.dao.impl.SalesDAOImpl;
import com.ruanyuan.entity.Employee;
import com.ruanyuan.entity.Sales;

public class EmployeeManagementSystem {
    
    
    /**
     * 添加数据
     */
    public static void insertDate() {
        
//        创建职员实现对象
        EmployeeDAOImpl employeeDAOImpl =new EmployeeDAOImpl();
        
//        创建职员类
        Employee employee=new Employee();
        
//        获取所有数据
        List <Employee> employees =employeeDAOImpl.SelectDateAll();
//        有数据,打印输出
        if(employees!=null) {
            System.err.println("职员编号, 姓名, 密码, 性别, 年龄, 聘用日期, 月薪");
            for (Employee employee2 : employees) {
                System.out.println(employee2.getEmployeeId()+", "+employee2.getEmpName()+", "+employee2.getEmpPwd()
                +", "+employee2.getSex()+", "+employee2.getAge()+", "+employee2.getHirelong()+", "+employee2.getSalary());
            }
            
        }else {
            System.err.println("\n抱歉,数据控为空,请进行添加!");
        }
        
        System.out.println("请输入员工姓名:");
        String employeeName=Tools.enter.next();
        Employee employee3 =employeeDAOImpl.selectDateName(employeeName);
        if(employee3 !=null) {
            System.err.println("\n抱歉,用户重复添加!");
        }else{
//            对象设置名称
            employee.setEmpName(employeeName);
            
            System.out.println("请输入密码:");
            String empPwd=Tools.enter.next();

//            如果密码相同,密码大于6位继续添加
            if(empPwd.length()>6) {
                System.out.println("请再次确认密码:");
                String empPwd2=Tools.enter.next();
                if(empPwd2.equals(empPwd)  ) {
//                    对象设置密码
                    employee.setEmpPwd(empPwd);
                    
                    
                    System.out.println("请输入性别:");
                    String sex=Tools.enter.next();
//                    如果输入的合法,继续添加
                    if(sex.equals("男") ||sex.equals("女")) {
                        employee.setSex(sex);
                        System.out.println("请输入年龄:");
                        int age=Tools.enter.nextInt();
                        if(age>0 && age< 90) {
                            employee.setAge(age);
                            
                            
                            System.out.println("请输入薪水:");
                            int salary =Tools.enter.nextInt();
                            if(salary>0) {
//                                对象设置薪水
                                employee.setSalary(String.valueOf(salary));
                                
//                                对象设置时间
                                Date date=new Date();
                                SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
                                String hireDate=formatter.format(date);
                                employee.setHirelong(hireDate);
                                
//                                执行天添加
                                int count = employeeDAOImpl.insertDate(employee);
                                if(count>0) {
                                    System.err.println("\n添加成功!");
                                }else{
                                    System.err.println("\n添加失败!");
                                }
                                
                            }else {
                                System.err.println("\n抱歉,输入有误!");
                            }
                            
                            
                        }else {
                            System.err.println("\n抱歉,您输入的年龄错误!");
                        }
                
                    }else {
                        System.err.println("\n抱歉,您输入性别错误!");
                    }
                    
                }else {
                    System.err.println("\n抱歉,两次密码不相同!");
                }
                
        
            }else {

                System.err.println("\n抱歉,您输入密码长度不够,不安全!");
            }

        }
        

    }

    
    /**
     * 删除数据
     */
    public static void deleteDate() {
//        创建职员实现对象
        EmployeeDAOImpl employeeDAOImpl =new EmployeeDAOImpl();
        
//        创建销售实现类对象
        SalesDAOImpl salesDAOImpl =new SalesDAOImpl();
        
//        获取所有数据
        List <Employee> employees =employeeDAOImpl.SelectDateAll();

//        有数据,打印输出
        if(employees!=null) {
            System.err.println("职员编号, 姓名, 密码, 性别, 年龄, 聘用日期, 月薪");
            for (Employee employee2 : employees) {
                System.out.println(employee2.getEmployeeId()+", "+employee2.getEmpName()+", "+employee2.getEmpPwd()
                +", "+employee2.getSex()+", "+employee2.getAge()+", "+employee2.getHirelong()+", "+employee2.getSalary());
            }
            System.out.println("请输入你要删除的职员编号:");
            int employeeld =Tools.enter.nextInt();
//            查询用户输入的id是否存在
            Employee employee=employeeDAOImpl.selectDateID(employeeld);
//            存在,继续删除
            if(employee!=null) {
//                询问是否真的删除
                System.out.println("你确定要删除吗?Y确定 / N取消");
                String delEmployeeId=Tools.enter.next();
//                确认删除
                if(delEmployeeId.equalsIgnoreCase("Y")) {
//                    查询该职员下是否销售信息
                    Sales sale=salesDAOImpl.selectDateEmployeeID(employeeld);
//                    有信息,无法删除
                    if(sale!=null) {
                        System.err.println("\n抱歉,该职员下含有销售信息,不能删除!");
//                    没有信息,可以删除
                    }else{
                        int count =employeeDAOImpl.deleteDate(employeeld);
                        if(count>0) {
                            System.out.println("\n删除成功!");
                        }else {
                            System.err.println("\n删除失败!");
                        }
                    }
                }else {
                    System.err.println("取消删除!");
                }
            }
        }else {
            System.err.println("\n抱歉,数据控为空,无法删除!");
        }
    }

    
    /**
     * 修改数据
     */
    public static void updateDate() {
//        创建职员实现对象
        EmployeeDAOImpl employeeDAOImpl =new EmployeeDAOImpl();

//        存储修改条件
        String[] conditions =new String[8];
        
//        获取所有数据
        List <Employee> employees =employeeDAOImpl.SelectDateAll();

//        有数据,打印输出
        if(employees!=null) {
            System.err.println("职员编号, 姓名, 密码, 性别, 年龄, 聘用日期, 月薪");
            for (Employee employee2 : employees) {
                System.out.println(employee2.getEmployeeId()+", "+employee2.getEmpName()+", "+employee2.getEmpPwd()
                +", "+employee2.getSex()+", "+employee2.getAge()+", "+employee2.getHirelong()+", "+employee2.getSalary());
            }
            System.out.println("请输入你要修改的职员编号:");
            int employeeld =Tools.enter.nextInt();
//            查询用户输入的id是否存在
            Employee employee=employeeDAOImpl.selectDateID(employeeld);
            
//            存在,继续修改
            if(employee!=null) {

//                修改职员名称
                System.out.println("是否修改职员名称?Y确定 / N取消");
                String editEmpName=Tools.enter.next();
//                确定修改
                if(editEmpName.equalsIgnoreCase("Y")) {
                    System.out.println("请输入新的职员名称:");
                    String employeeName =Tools.enter.next();
//                    查询用户输入的有没有重名
                    Employee employee2=employeeDAOImpl.selectDateName(employeeName);
//                    重名,无法修改
                    if(employee2!=null) {
                        System.err.println("\n抱歉,重名,无法修改!");
                        conditions[0]=employee.getEmpName();
//                    不重名,修改
                    }else {
                        conditions[0]=employeeName;
                    }
//                取消修改,原值
                }else {
                    conditions[0]=employee.getEmpName();
                }
                
                
//                修改职员密码
                System.out.println("是否修改职员密码?Y确定 / N取消");
                String editEmpPwd=Tools.enter.next();
//                确定修改
                if(editEmpPwd.equalsIgnoreCase("Y")) {
                    System.out.println("请输入新的职员密码:");
                    String empPwd=Tools.enter.next();
//                    如果密码相同,密码大于6位继续添加
                    if(empPwd.length()>6) {
                        System.out.println("请再次确认密码:");
                        String empPwd2=Tools.enter.next();
                        if(empPwd2.equals(empPwd)  ) {
                            
//                            对象设置密码
                            conditions[1]=empPwd;
//                        修改无效,原值
                        }else {
                            conditions[1]=employee.getEmpPwd();
                            System.err.println("\n抱歉,两次密码不相同!");
                
                        }
//                    修改无效,原值
                    }else {
                        conditions[1]=employee.getEmpPwd();
                        System.err.println("\n抱歉,您输入密码长度不够,不安全!修改无效!");
                
                    }
//                取消修改,原值
                }else {
                    conditions[1]=employee.getEmpPwd();
                }
                
                
//                修改职员性别
                System.out.println("是否修改职员性别?Y确定 / N取消");
                String editEmpSex=Tools.enter.next();
//                确定修改
                if(editEmpSex.equalsIgnoreCase("Y")) {
                    System.out.println("请输入新的职员性别:");
                    String empSex =Tools.enter.next();
//                    如果输入的合法,继续添加
                    if(empSex.equals("男") ||empSex.equals("女")) {
//                        获取用户输入的值
                        conditions[2]=empSex;
                        
//                    修改无效,原值
                    }else {
                        conditions[2]=employee.getSex();
                        System.err.println("\n抱歉,您输入性别错误!修改无效!");
                    }
//                
//                取消修改,原值
                }else {
                    conditions[2]=employee.getSex();
                }
                
                
                
//                修改职员年龄
                System.out.println("是否修改职员年龄?Y确定 / N取消");
                String editEmpAge=Tools.enter.next();
//                确定修改
                if(editEmpAge.equalsIgnoreCase("Y")) {
                    System.out.println("请输入新的职员年龄:");
                    int empAge =Tools.enter.nextInt();
                    if(empAge>0 && empAge<100) {
//                        获取用户输入的值
                        conditions[3]=String.valueOf(empAge);
//                    修改无效,原值
                    }else {
                        conditions[3]=String.valueOf(employee.getAge());
                        System.err.println("\n抱歉,您输入年龄有误!修改无效!");
                    }
//            
//                取消修改,原值
                }else {
                    conditions[3]=String.valueOf(employee.getAge());
                }
                
                
//                修改聘用日期
                System.out.println("是否修改职员聘用日期?Y确定 / N取消");
                String editEmpHireDate=Tools.enter.next();
//                确定修改
                if(editEmpHireDate.equalsIgnoreCase("Y")) {
                    System.out.println("请输入新的职员聘用日期(例如:xxxx-xx-xx):");
                    String empHireDate =Tools.enter.next();
//                    获取用户输入的值
                    conditions[4]=empHireDate;
                    
//                取消修改,原值
                }else {
                    conditions[4]=employee.getHirelong();
                }
                
                
//                修改职员月薪
                System.out.println("是否修改职员月薪?Y确定 / N取消");
                String editEmpSalary=Tools.enter.next();
//                确定修改
                if(editEmpSalary.equalsIgnoreCase("Y")) {
                    System.out.println("请输入新的职员月薪:");
                    int empSalary =Tools.enter.nextInt();
                    if(empSalary>0) {
//                        获取用户输入的值
                        conditions[5]=String.valueOf(empSalary);
//                    修改无效,原值
                    }else{
                        conditions[5]=String.valueOf(employee.getSalary());
                        System.err.println("\n抱歉,输入有误!修改无效!");
                    }

//                取消修改,原值
                }else {
                    conditions[5]=String.valueOf(employee.getSalary());
                }
                
//                获取职员id
                conditions[6]=String.valueOf(employeeld);
                
//                执行修改
                int count =employeeDAOImpl.updateDate(conditions[0],conditions[1],conditions[2],conditions[3],conditions[4],conditions[5],conditions[6]);
                
                if(count>0) {
                    System.err.println("\n修改成功!");
                }else{
                    System.err.println("\n修改失败!");
                }
            
            }else {
                System.err.println("\n抱歉,抱歉你输入的职员信息不存在!");
            }
            
        }else {
            System.err.println("\n抱歉,数据控为空,无法修改!");
        }    
        
    }

    
    /**
     * 查询数据
     */
    public static void selectDate() {
        
//        创建职员实现对象
        EmployeeDAOImpl employeeDAOImpl =new EmployeeDAOImpl();

//        存储修改条件
        String[] conditions =new String[8];
        
        System.out.println("员工表可以进行多条件查询的字段有:员工姓名、性别、年龄区间、入职日期区间、薪酬区间");
//        获取员工姓名
        System.out.println("是否根据员工姓名进行多条件查询?Y确定 / N取消");
        String selectName=Tools.enter.next();
//        确定查询,键盘输入的值
        if(selectName.equalsIgnoreCase("Y")) {
            System.out.println("请输入员工姓名:");
            String empName=Tools.enter.next();
            conditions[0]=empName;
//        取消查询,空值
        }else {
            conditions[0]=null;
        }
        
        
//        获取员工性别
        System.out.println("是否根据员工性别进行多条件查询?Y确定 / N取消");
        String selectSex=Tools.enter.next();
//        确定查询,键盘输入的值
        if(selectSex.equalsIgnoreCase("Y")) {
            System.out.println("请输入员工性别:");
            String sex=Tools.enter.next();
            conditions[1]=sex;
//        取消查询,空值
        }else {
            conditions[1]=null;
        }
        
//        获取员工年龄
        System.out.println("是否根据员工年龄进行多条件查询?Y确定 / N取消");
        String selectAge=Tools.enter.next();
//        确定查询,键盘输入的值
        if(selectAge.equalsIgnoreCase("Y")) {
            System.out.println("请输入最小年龄范围:");
            int beginAge=Tools.enter.nextInt();
            System.out.println("请输入最大年龄范围:");
            int endAge=Tools.enter.nextInt();
            conditions[2]=String.valueOf(beginAge);
            conditions[3]=String.valueOf(endAge);
//        取消查询,空值
        }else {
            conditions[2]=null;
            conditions[3]=null;
        }
        
        
//        获取员工入职日期
        System.out.println("是否根据员工入职日期进行多条件查询?Y确定 / N取消");
        String selectHireLong=Tools.enter.next();
//        确定查询,键盘输入的值
        if(selectHireLong.equalsIgnoreCase("Y")) {
            System.out.println("请输入开始入职日期范围:");
            String beginHireLong=Tools.enter.next();
            System.out.println("请输入结束入职日期范围:");
            String endHireLong=Tools.enter.next();
            conditions[4]=beginHireLong;
            conditions[5]=endHireLong;
//        取消查询,空值
        }else {
            conditions[4]=null;
            conditions[5]=null;
        }
        
        
        
//        获取员工薪酬
        System.out.println("是否根据员工薪酬进行多条件查询?Y确定 / N取消");
        String selectSalary=Tools.enter.next();
//        确定查询,键盘输入的值
        if(selectSalary.equalsIgnoreCase("Y")) {
            System.out.println("请输入开始薪酬范围:");
            int beginSalary=Tools.enter.nextInt();
            System.out.println("请输入开始薪酬范围:");
            int endSalary=Tools.enter.nextInt();
            conditions[6]=String.valueOf(beginSalary);
            conditions[7]=String.valueOf(endSalary);
//        取消查询,空值
        }else {
            conditions[6]=null;
            conditions[7]=null;
        }
        
//        获取通过多条件查询的数据
        List<Employee> employees =employeeDAOImpl.selectDateMore(conditions[0],conditions[1],conditions[2],conditions[3],conditions[4],conditions[5],conditions[6],conditions[7]);
//        有数据,打印输出
        if(employees!=null && employees.size()>0) {
            System.err.println("职员编号, 姓名, 密码, 性别, 年龄, 聘用日期, 月薪");
            for (Employee employee2 : employees) {
                System.out.println(employee2.getEmployeeId()+", "+employee2.getEmpName()+", "+employee2.getEmpPwd()
                +", "+employee2.getSex()+", "+employee2.getAge()+", "+employee2.getHirelong()+", "+employee2.getSalary());
            }
//        没有数据,提示无结果
        }else {
            System.err.println("\n抱歉,没有该职员信息!");
        }
        
        
    }

}
————————————————————

package com.ruanyuan.test;

import java.util.List;

import com.ruanyuan.dao.impl.CategoryDAOImpl;
import com.ruanyuan.dao.impl.GoodDAOImpl;
import com.ruanyuan.dao.impl.OffersDAOImpl;
import com.ruanyuan.dao.impl.SalesDAOImpl;
import com.ruanyuan.entity.Category;
import com.ruanyuan.entity.Good;
import com.ruanyuan.entity.Offers;
import com.ruanyuan.entity.Sales;

public class GoodManagementSystem {
    /**
     * 添加数据
     */
    public static void insertDate() {
        
//        创建商品实现对象
        GoodDAOImpl goodDAOImpl= new GoodDAOImpl();
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        创建存储商品对象的集合
        List<Good> goods =goodDAOImpl.selectAllDate();
        
//        创建商品实体类
        Good good =new Good();
        
//        如果有数据,打印输出所有数据
//        如果用户选择了添加,则先展示所有的商品信息
        if(goods!=null && goods.size()>0) {
            
            System.out.println("——————————————————————————————————————————————————————\n商品编号 , 商品名称 , 单价 , 类别编号 , 供货商编号 , 库存\n——————————————————————————————————————————————————————");
            for (Good good2 : goods) {
                Category category =categoryDAOImpl.selectDateID(String.valueOf(good2.getCategoryID()));
                Offers offer=offersDAOImpl.selectDateID(good2.getOfferID());
                System.out.println(good2.getGoodID()+", "+good2.getGoodName()+", "+good2.getPrice()+", "+category.getCategoryName()+", "+offer.getOfferName()+", "+good2.getStockes());
            }
            
//            获取商品名称
            System.out.println("请输入商品名称:");
            String goodName=Tools.enter.next();
            
//            查询商品名称是否存在
            Good good2=goodDAOImpl.selectDateName(goodName);
//            商品名称存在,无法添加 则提示:抱歉,该商品信息已经存在,请重新添加
            if(good2.getGoodName()!=null) {
                System.err.println("抱歉,该商品信息已经存在,请重新添加!");
                
//            商品名称无重复
            }else if(good2.getGoodName()==null){
//                设置实体类商品名称的值
                good.setGoodName(goodName);
                
//                获取价格
                System.out.println("请输入价格:");
                float price =Tools.enter.nextFloat();
//                设置实体类价格的值
                good.setPrice(price);
                
                
//                获取类别的id
//                获取所有的类别信息
                List<Category> categorys=categoryDAOImpl.selectAllDate();
                
//                如果不为空,就打印出所有数据
                if(categorys!=null && categorys.size()>0) {
                    
//                    格式化输出显示所有数据
                    System.out.println("\n————————————————");
                    System.out.println("类别编号\t 类别名称\n————————————————");
                    for (Category category2 : categorys) {
                        System.out.println(category2.getCategoryID()+"\t "+category2.getCategoryName());
                    }
                    
//                    用户输入的类别id
                    System.out.println("请选择商品所属的类别id:");
                    int categoryID=Tools.enter.nextInt();
                    
//                    查询存不存在用户输入的id,谨防非法输入
                    Category category=categoryDAOImpl.selectDateID(String.valueOf(categoryID));
        
//                    存在,设置实体类的值
                    if(category!=null) {
                        good.setCategoryId(categoryID);
                        
//                        获取供货商id
//                        获取所有的供货商信息
                        List<Offers> offers=offersDAOImpl.selectAllDate();
                        
//                        如果供货商的数据不为空,打印出所有数据
                        if(offers!=null && offers.size()>0) {
//                            格式化输出显示所有数据
                            System.out.println("\n———————————————————————————————————————————————————————————————————————");
                            System.out.println("商家编号\t \t商家名称\t 法人\t \t地址\t \t联系电话 \n———————————————————————————————————————————————————————————————————————");
                            for (Offers offers2 : offers) {
                                System.out.println(offers2.getOfferID()+"\t"+offers2.getOfferName()+"\t "+offers2.getLegalIP()+"\t"+offers2.getAddress()+"\t\t"+offers2.getTel());
                            }
                            
//                            获取用户输入供货商id
                            System.out.println("请选择商品所属的供货商id:");
                            int offerID=Tools.enter.nextInt();
                            
//                            查询用户输入的供货商id是否存在
                            Offers offer3=offersDAOImpl.selectDateID(offerID);
                            
//                            存在,设置实体类供货商id的值
                            if(offer3!=null) {
                                good.setOfferId(offerID);
                                
//                                获取库存
                                System.out.println("请输入商品的库存:");
                                int stockes =Tools.enter.nextInt();
//                                设置实体类库存的值
                                good.setStockes(stockes);
                                
//                                获取执行操作结果
                                int count=goodDAOImpl.inserDate(good);
                                
//                                如果返回值大于0,说明执行成功,相反未执行成功
                                if(count>0) {
                                    System.out.println("\n添加成功!");
                                }else {
                                    System.err.println("\n添加失败!");
                                }
                                
//                            不存在用户输入的供货商id
                            }else {
                                System.out.println("\n抱歉,所属的供货商id不存在!");
                            }
                            
                            
//                        供货商空数据
                        }else {
                            System.err.println("\n抱歉,供货商数据库无记录!");
                        }    
                            
                    
//                类别空数据
                }else {
                    System.err.println("\n抱歉,您输入的id不存在!重新添加!");
                }
            
            }//名称无重复
            
        }//输出商品所有数据
        
        }        


    }

    
    /**
     * 删除数据
     */
    public static void deleteDate() {
//        创建商品实现对象
        GoodDAOImpl goodDAOImpl= new GoodDAOImpl();
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        创建销售实现类
        SalesDAOImpl salesDAOImpl=new SalesDAOImpl();
        
//        创建存储商品对象的集合
        List<Good> goods =goodDAOImpl.selectAllDate();
        
//        创建商品实体类
        Good good =new Good();
//        如果有数据,打印输出所有数据
//        如果用户选择了添加,则先展示所有的商品信息
        if(goods!=null && goods.size()>0) {
            System.out.println("——————————————————————————————————————————————————————\n商品编号 , 商品名称 , 单价 , 类别编号 , 供货商编号 , 库存\n——————————————————————————————————————————————————————");
            for (Good good2 : goods) {
                Category category =categoryDAOImpl.selectDateID(String.valueOf(good2.getCategoryID()));
                Offers offer=offersDAOImpl.selectDateID(good2.getOfferID());
                System.out.println(good2.getGoodID()+", "+good2.getGoodName()+", "+good2.getPrice()+", "+category.getCategoryName()+", "+offer.getOfferName()+", "+good2.getStockes());
            }
            
//            获取用户输入的删除条件:商品id
            System.out.println("请输入你要删除的商品id");
            int goodID=Tools.enter.nextInt();
            
            
//            查询用户输入的ID是否存在
            Good good2=goodDAOImpl.selectDateID(goodID);
            
//            存在,进行删除操作
            if(good2!=null) {
                
//                询问用户是否删除
                System.out.println("你确定要删除吗?Y确定 / N取消");
                String delDate=Tools.enter.next();
//                确定删除
                if(delDate.equalsIgnoreCase("Y")) {
                    
//                    查询该商品下是否有信息
                    Sales sale=salesDAOImpl.selectDateGoodID(goodID);
        
//                    有信息,不可删除
                    if(sale!=null) {
                        System.err.println("\n该商品下有销售信息,无法删除!");
                        System.out.println(sale.getGoodld()+"+++"+sale.getSalesld());
                        
//                    无信息,可删除
                    }else {
                        
//                        获取删除条件id 
                        good.setGoodID(goodID);
                        
//                        获取执行操作结果
                        int count=goodDAOImpl.deleteDate(good);
                        
//                        如果返回值大于0,说明执行成功,相反未执行成功
                        if(count>0) {
                            System.out.println("\n删除成功!");
                        }else {
                            System.err.println("\n删除失败!");
                        }
                    }

//                取消删除
                }else {
                    System.out.println("\n取消删除成功!");
                }
                
//            不存在,无法删除
            }else {
                System.err.println("\n抱歉,你要删除的商品信息不存在!");
            }
        
//        数据库为0记录,无法删除
        }else {
            System.err.println("\n抱歉,数据库0记录,无法删除!");
        }
        
        
        
        
        
        
        
    }

    
    /**
     * 修改数据
     */
    public static void updateDate() {
        // TODO 自动生成的方法存根
        
//        创建商品实现对象
        GoodDAOImpl goodDAOImpl= new GoodDAOImpl();
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        创建存储商品对象的集合
        List<Good> goods =goodDAOImpl.selectAllDate();
        

        
//        如果有数据,打印输出所有数据
//        如果用户选择了添加,则先展示所有的商品信息
        if(goods!=null && goods.size()>0) {
            
            System.out.println("——————————————————————————————————————————————————————\n商品编号 , 商品名称 , 单价 , 类别编号 , 供货商编号 , 库存\n——————————————————————————————————————————————————————");
            for (Good good2 : goods) {
                Category category =categoryDAOImpl.selectDateID(String.valueOf(good2.getCategoryID()));
                Offers offer=offersDAOImpl.selectDateID(good2.getOfferID());
                System.out.println(good2.getGoodID()+", "+good2.getGoodName()+", "+good2.getPrice()+", "+category.getCategoryName()+", "+offer.getOfferName()+", "+good2.getStockes());
            }
//            创建商品实体类
            Good good =new Good();
            
//            获取商品ID
            System.out.println("请输入你要修改的商品ID值:");
            int goodID =Tools.enter.nextInt();
            

//            查询商品id是否存在
            Good good2=goodDAOImpl.selectDateID(goodID);
            
//            存在
            if(String.valueOf(good2.getGoodID())!=null) {
                good.setGoodID(goodID);
                
//                获取商品名称
                System.out.println("是否修改商品的商品名称?Y确定 / N取消");
                String editGoodName=Tools.enter.next();
//                如果修改此内容,追加此条件
                if(editGoodName.equalsIgnoreCase("Y")) {
                    System.out.println("请输入商品名称:");
                    String goodName=Tools.enter.next();
                    good.setGoodName(goodName);
//                不修改,保存原值
                }else {
                    good.setGoodName(good2.getGoodName());
                }
                
                
                
//                获取价格
                System.out.println("是否修改商品的价钱?Y确定 / N取消");
                String editPrice=Tools.enter.next();
                
//                如果修改此内容,追加此条件
                if(editPrice.equalsIgnoreCase("Y")) {
                    
                    System.out.println("请输入商品价钱:");
                    float price=Tools.enter.nextFloat();
                    good.setPrice(price);
                    
//                不修改,保存原值
                }else {
                    good.setPrice(good2.getPrice());
                }
                
                
                
//                获取所属类别id
                System.out.println("是否修改商品的所属类别ID?Y确定 / N取消");
                String editCategoryId=Tools.enter.next();
                
//                如果修改此内容,追加此条件
                if(editCategoryId.equalsIgnoreCase("Y")) {
//                    获取返回的数据信息
                    List<Category> categorys=categoryDAOImpl.selectAllDate();
                    
                    
//                    该类别存在,打印信息
                    if(categorys!=null && categorys.size()>0) {
                        
//                        格式化输出显示所有数据
                        System.out.println("\n————————————————");
                        System.out.println("类别编号\t 类别名称\n————————————————");
                        for (Category category2 : categorys) {
                            System.out.println(category2.getCategoryID()+"\t "+category2.getCategoryName());
                        }
                    
                        System.out.println("请输入商品所属类别ID:");
                        int offerID=Tools.enter.nextInt();
                        good.setCategoryId(offerID);
                        
                    }else {
                        good.setCategoryId(good2.getCategoryID());
                        System.err.println("\n抱歉,商品所属类别空数据,无效修改!");
                    }
                    
//                不修改,保存原值
                }else {
                    good.setCategoryId(good2.getCategoryID());
                }
                
                
                
//                获取供货商id
                System.out.println("是否修改商品的供货商类别ID?Y确定 / N取消");
                String editOfferId=Tools.enter.next();
                
//                如果修改此内容,追加此条件
                if(editOfferId.equalsIgnoreCase("Y")) {
//                    获取供货商所有数据
                    List<Offers> offers2 =offersDAOImpl.selectAllDate();
                    
//                    如果有数据,输出数据
                    if(offers2!=null &&offers2.size()>0) {
//                        格式化输出显示所有数据
                        System.out.println("\n———————————————————————————————————————————————————————————————————————");
                        System.out.println("商家编号\t \t商家名称\t 法人\t \t地址\t \t联系电话 \n———————————————————————————————————————————————————————————————————————");
                        for (Offers offers3 : offers2) {
                            System.out.println(offers3.getOfferID()+"\t"+offers3.getOfferName()+"\t "+offers3.getLegalIP()+"\t"+offers3.getAddress()+"\t\t"+offers3.getTel());
                        }
                        System.out.println("请输入商品的供货商ID:");
                        int offerID=Tools.enter.nextInt();
                        good.setOfferId(offerID);
                        
                    }else {
                        good.setOfferId(good2.getOfferID());
                        System.err.println("\n抱歉,商品的供货商空数据,无效修改!");
                    }
//                不修改,保存原值
                }else {
                    good.setOfferId(good2.getOfferID());
                }
                
                
                
//                获取库存
                System.out.println("是否修改商品的库存?Y确定 / N取消");
                String editStockes=Tools.enter.next();
                
//                如果修改此内容,追加此条件
                if(editStockes.equalsIgnoreCase("Y")) {
                    System.out.println("请输入商品库存:");
                    int stockes=Tools.enter.nextInt();
                    good.setStockes(stockes);
                    
//                不修改,保存原值
                }else {
                    good.setStockes(good2.getStockes());
                }

                
//                获取执行操作结果
                int count=goodDAOImpl.updateDate(good);
                
//                如果返回值大于0,说明执行成功,相反未执行成功
                if(count>0) {
                    System.out.println("\n修改成功!");
                }else {
                    System.err.println("\n修改失败!");
                }
                
            }else {
                System.err.println("\n抱歉,您输入的id不存在,重新输入!");
            }
        }
        
        
        
        
        
    }
    
    
    /**
     * 多条件查询数据
     */
    public static void selectDate() {
        
        
//        创建商品实现对象
        GoodDAOImpl goodDAOImpl= new GoodDAOImpl();
        
//        创建类别实现对象
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        存储查询的条件
        String[] conditions =new String[7];
        System.out.println("多条件查询可以根据:商品名称、价钱区间、所属类别、所属供货商、库存区间进行查询");
        
//        获取商品名称
        System.out.println("是否根据商品名称进行多条件查询?Y确定 / N取消");
        String selectGoodName=Tools.enter.next();
//        确定查询
        if(selectGoodName.equalsIgnoreCase("Y")) {
            System.out.println("请输入商品名称:");
            String goodName=Tools.enter.next();
            conditions[0]=goodName;
//        取消查询
        }else {
            conditions[0]=null;
        }
        
        
//        获取价钱区间
        System.out.println("是否根据价钱区间进行多条件查询?Y确定 / N取消");
        String selectPrice=Tools.enter.next();
//        确定查询
        if(selectPrice.equalsIgnoreCase("Y")) {
            System.out.println("请输入开始价格:");
            int beginPrice=Tools.enter.nextInt();
            System.out.println("请输入结束价格:");
            int endPrice=Tools.enter.nextInt();
            conditions[1]=String.valueOf(beginPrice);
            conditions[2]=String.valueOf(endPrice);
//        取消查询
        }else {
            conditions[1]=null;
            conditions[2]=null;
        }
        
//        获取所属类别
        System.out.println("是否根据所属类别进行多条件查询?Y确定 / N取消");
        String selectCategoryID=Tools.enter.next();
//        确定查询
        if(selectCategoryID.equalsIgnoreCase("Y")) {
            System.out.println("请输入商品所属类别:");
            int categoryID=Tools.enter.nextInt();
            conditions[3]=String.valueOf(categoryID);
//        取消查询
        }else {
            conditions[3]=null;
        }
        
//        获取所属供货商
        System.out.println("是否根据所属供货商进行多条件查询?Y确定 / N取消");
        String selectOfferID=Tools.enter.next();
//        确定查询
        if(selectOfferID.equalsIgnoreCase("Y")) {
            System.out.println("请输入商品所属供货商id:");
            int offerID=Tools.enter.nextInt();
            conditions[4]=String.valueOf(offerID);
//        取消查询
        }else {
            conditions[4]=null;
        }
        
        
//        获取库存区间
        System.out.println("是否根据库存区间进行多条件查询?Y确定 / N取消");
        String selectStockes=Tools.enter.next();
//        确定查询
        if(selectStockes.equalsIgnoreCase("Y")) {
            System.out.println("请输入开始库存:");
            int beginStockes=Tools.enter.nextInt();
            System.out.println("请输入结束库存:");
            int endStockes=Tools.enter.nextInt();
            conditions[5]=String.valueOf(beginStockes);
            conditions[6]=String.valueOf(endStockes);
//        取消查询
        }else {
            conditions[5]=null;
            conditions[6]=null;
        }
        
        
//        执行查询操作
        List<Good> goods =goodDAOImpl.selectDateMore(conditions[0], conditions[1], conditions[2],conditions[3],conditions[4],conditions[5],conditions[6]);
//        如果查询结果有数据,打印出来
        if(goods!=null) {
            System.out.println("——————————————————————————————————————————————————————\n商品编号 , 商品名称 , 单价 , 类别编号 , 供货商编号 , 库存\n——————————————————————————————————————————————————————");
            for (Good good2 : goods) {
                Category category =categoryDAOImpl.selectDateID(String.valueOf(good2.getCategoryID()));
                Offers offer=offersDAOImpl.selectDateID(good2.getOfferID());
                System.out.println(good2.getGoodID()+", "+good2.getGoodName()+", "+good2.getPrice()+", "+category.getCategoryName()+", "+offer.getOfferName()+", "+good2.getStockes());
            }
//        没有结果
        }else {
            System.err.println("\n抱歉,没有该商品信息!");
        }
        
        
    }
    
    
}
————————————————————————

package com.ruanyuan.test;

import java.util.List;

import com.ruanyuan.dao.impl.OffersDAOImpl;
import com.ruanyuan.entity.Good;
import com.ruanyuan.entity.Offers;

public class OfferManagementSystem {


    /**
     * 添加供货商
     */
    public static void insertDate() {
        
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        创建供货商对象
        Offers offers=new Offers();
        
//        获取供货商所有数据
        List<Offers> offers2 =offersDAOImpl.selectAllDate();
        
//        如果有数据,输出数据
        if(offers2!=null &&offers2.size()>0) {
//            格式化输出显示所有数据
            System.out.println("\n———————————————————————————————————————————————————————————————————————");
            System.out.println("商家编号\t \t商家名称\t 法人\t \t地址\t \t联系电话 \n———————————————————————————————————————————————————————————————————————");
            for (Offers offers3 : offers2) {
                System.out.println(offers3.getOfferID()+"\t"+offers3.getOfferName()+"\t "+offers3.getLegalIP()+"\t"+offers3.getAddress()+"\t\t"+offers3.getTel());
            }
            
//        没有数据,提示0条记录
        }else {
            System.err.println("\n抱歉,数据库0条记录!");
        }
        
//        获取键盘输入的数据
        System.out.print("请输入公司名称:");
        String offersName=Tools.enter.next();
        
//        通过名称获取数据
        Offers offers4 =offersDAOImpl.selectDateName(offersName);
        
//        如果查询的无数据,继续添加数据
        if(offers4==null) {
            
//            获取键盘输入的参数
            System.out.print("请输入公司法人代表:");
            String legalIP=Tools.enter.next();
            
            System.out.print("请输入公司所在地:");
            String address=Tools.enter.next();
            
            System.out.print("请输入公司电话:");
            String tel=Tools.enter.next();
            
//            设置对象参数
            offers.setOfferName(offersName);
            offers.setLegalIP(legalIP);
            offers.setAddress(address);
            offers.setTel(tel);
            
//            执行添加操作,并且获取返回值
            int count=offersDAOImpl.inserDate(offers);
            
//            如果返回值大于0,说明执行成功,相反未执行成功
            if(count>0) {
                System.out.println("\n添加成功!");
            }else {
                System.err.println("\n添加失败!");
            }
            
//        查询的有数据,说明重名,提示无法添加
        }else {
            System.err.println("\n抱歉,该供货商信息已经存在,请重新添加!");
        }
    
    }
    
    
    /**
     * 删除数据
     */
    public static void deleteDate() {
        // TODO 自动生成的方法存根
        
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        创建供货商对象
        Offers offers=new Offers();
        
//        获取供货商所有数据
        List<Offers> offers2 =offersDAOImpl.selectAllDate();
        
//        如果有数据,输出数据
        if(offers2!=null &&offers2.size()>0) {
//            格式化输出显示所有数据
            System.out.println("\n———————————————————————————————————————————————————————————————————————");
            System.out.println("商家编号\t \t商家名称\t 法人\t \t地址\t \t联系电话 \n———————————————————————————————————————————————————————————————————————");
            for (Offers offers3 : offers2) {
                System.out.println(offers3.getOfferID()+"\t"+offers3.getOfferName()+"\t "+offers3.getLegalIP()+"\t"+offers3.getAddress()+"\t\t"+offers3.getTel());
            }
//            获取键盘输入的数据
            System.out.print("请输入你要删除的公司ID:");
            int offerId=Tools.enter.nextInt();
            
//            查询该供货商是否存在
            Offers offers4 =offersDAOImpl.selectDateID(offerId);
            
//            存在数据
            if(offers4!=null) {
                
//                询问是否真的删除,并获取用户输入的结果
                System.out.println("你确定要删除吗?Y确定 / N取消");
                String delOffersID=Tools.enter.next();
                
//                确定删除,执行删除操作
                if(delOffersID.equalsIgnoreCase("Y")) {
                    
//                    查询该供货商下是否含有销售信息
                    List<Good> goods=offersDAOImpl.selectSaleGood(offerId);
                    if(goods!=null && goods.size()>0) {
                        System.err.println("\n该供货商下含有商品信息,不能删除!");

//                    如果含有销售信息,则提示用户:该供货商下含有商品信息,不能删除
                    }else {
//                        如果该供货商下不含有商品信息,则直接删除
//                        设置对象参数
                        offers.setOfferID(offerId);
                        
//                        执行删除操作,并且获取返回值
                        int count=offersDAOImpl.deleteDate(offers);
                        
//                        如果返回值大于0,说明执行成功,相反未执行成功
                        if(count>0) {
                            System.out.println("\n删除成功!");
                        }else {
                            System.err.println("\n删除失败!");
                        }
                        
                    }
                    
//                取消删除,退出删除操作
                }else {
                    System.out.println("取消删除成功!");
                }
                
//            想要删除的数据,不存在,无法删除
            }else {
                System.err.println("\n抱歉,你要删除的供货商信息不存在!");
            }
            
            
//        没有数据,提示0条记录
        }else {
            System.err.println("\n抱歉,数据库0条记录!");
        }
        
    }
    
    
    /**
     * 修改数据
     */
    public static void updateDate() {
        // TODO 自动生成的方法存根
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        创建供货商对象
        Offers offers=new Offers();
        
        String[] conditions=new String[4];
        
//        获取供货商所有数据
        List<Offers> offers2 =offersDAOImpl.selectAllDate();
        
//        如果有数据,输出数据
        if(offers2!=null &&offers2.size()>0) {
//            格式化输出显示所有数据
            System.out.println("\n———————————————————————————————————————————————————————————————————————");
            System.out.println("商家编号\t \t商家名称\t 法人\t \t地址\t \t联系电话 \n———————————————————————————————————————————————————————————————————————");
            for (Offers offers3 : offers2) {
                System.out.println(offers3.getOfferID()+"\t"+offers3.getOfferName()+"\t "+offers3.getLegalIP()+"\t"+offers3.getAddress()+"\t\t"+offers3.getTel());
            }
//            获取键盘输入的数据
            System.out.print("请输入你要修改的公司ID:");
            int offerId=Tools.enter.nextInt();
            
//            查询该供货商是否存在
            Offers offers4 =offersDAOImpl.selectDateID(offerId);
            
//            存在数据
            if(offers4!=null) {
                
                
                System.out.println("是否修改公司名称?Y修改 / N不修改");
                String editOfferName=Tools.enter.next();
//                修改,获取新值
                if(editOfferName.equalsIgnoreCase("Y")) {
//                    获取键盘输入的数据
                    System.out.print("请输入公司名称:");
                    String offersName=Tools.enter.next();
                    conditions[0]=offersName;
                
//                不修改,存储原来的值
                }else {
                    conditions[0]=offers4.getOfferName();
                }
                

                System.out.print("是否要修改公司法人代表?Y修改 / N不修改");
                String editLegalIP=Tools.enter.next();
//                修改,获取新值
                if(editLegalIP.equalsIgnoreCase("Y")) {
//                    获取键盘输入的数据
                    System.out.print("请输入公司法人代表:");
                    String legalIP=Tools.enter.next();
                    conditions[1]=legalIP;
                    
//                不修改,存储原来的值
                }else {
                    conditions[1]=offers4.getLegalIP();
                }
                
                
                System.out.print("是否要修改公司所在地?Y修改 / N不修改");
                String editAddress=Tools.enter.next();
//                修改,获取新值
                if(editAddress.equalsIgnoreCase("Y")) {
//                    获取键盘输入的数据
                    System.out.print("请输入公司所在地:");
                    String address=Tools.enter.next();
                    conditions[2]=address;
                    
//                不修改,存储原来的值
                }else {
                    conditions[2]=offers4.getAddress();
                }

                
                System.out.print("是否要修改公司电话?Y修改 / N不修改");
                String editTel=Tools.enter.next();
//                修改,获取新值
                if(editTel.equalsIgnoreCase("Y")) {
//                    获取键盘输入的数据
                    System.out.print("请输入公司电话:");
                    String tel=Tools.enter.next();
                    conditions[3]=tel;
                    
//                不修改,存储原来的值
                }else {
                    conditions[3]=offers4.getTel();
                }

//                设置对象参数
                offers.setOfferID(offerId);
                offers.setOfferName(conditions[0]);
                offers.setLegalIP(conditions[1]);
                offers.setAddress(conditions[2]);
                offers.setTel(conditions[3]);
                
                for (int i=0;i<conditions.length;i++) {
                    System.out.println(conditions[i]);
                }
                
//                执行修改操作,并且获取返回值
                int count=offersDAOImpl.updateDate(offers);
                
//                如果返回值大于0,说明执行成功,相反未执行成功
                if(count>0) {
                    System.out.println("\n修改成功!");
                }else {
                    System.err.println("\n修改失败!");
                }
                
//            想要修改的数据,不存在,无法修改
            }else {
                System.err.println("\n抱歉,你要修改的供货商信息不存在!");
            }
            
            
//        没有数据,提示0条记录
        }else {
            System.err.println("\n抱歉,数据库0条记录!");
        }
        
    }
    
    
    /**
     * 多条件查询
     */
    public static void selectDateMore() {
        
//        创建供货商实现对象
        OffersDAOImpl offersDAOImpl=new OffersDAOImpl();
        
//        存放条件范围数据
        String[] conditions =new String[4];
        
//        获取条件
        System.out.println("条件查询的范围:供货商名称、法人代表、公司地址、联系电话");
        
//        获取条件:供货商名称
        System.out.println("是否根据供货商名称进行多条件查询?Y确定 / N取消");
        String selectOfferName=Tools.enter.next();
        
//        如果确定附加此条件,获取键盘输入的值
        if(selectOfferName.equalsIgnoreCase("Y")) {
            System.out.println("请输入供货商名称:");
            String offerName=Tools.enter.next();
            conditions[0]=offerName;
            
//        如果取消附加此条件,条件值为空
        }else {
            conditions[0]=null;
        }
    
//        获取条件:法人代表
        System.out.println("是否根据法人代表进行多条件查询?Y确定 / N取消");
        String selectLegaIP=Tools.enter.next();
        
//        如果确定附加此条件,获取键盘输入的值
        if(selectLegaIP.equalsIgnoreCase("Y")) {
            System.out.println("请输入法人代表:");
            String legaIP=Tools.enter.next();
            conditions[1]=legaIP;
            
//        如果取消附加此条件,条件值为空
        }else {
            conditions[1]=null;
        }
        
//        获取条件:公司地址
        System.out.println("是否根据公司地址进行多条件查询?Y确定 / N取消");
        String selectAddress=Tools.enter.next();
        
//        如果确定附加此条件,获取键盘输入的值
        if(selectAddress.equalsIgnoreCase("Y")) {
            System.out.println("请输入公司地址:");
            String address=Tools.enter.next();
            conditions[2]=address;
//        如果取消附加此条件,条件值为空
        }else {
            conditions[2]=null;
        }
        
//        获取条件:公司电话
        System.out.println("是否根据公司电话进行多条件查询?Y确定 / N取消");
        String selectTel=Tools.enter.next();
        
//        如果确定附加此条件,获取键盘输入的值
        if(selectTel.equalsIgnoreCase("Y")) {
            System.out.println("请输入公司电话:");
            String tel=Tools.enter.next();
            conditions[3]=tel;
            
//        如果取消附加此条件,条件值为空
        }else {
            conditions[3]=null;
        }
        
        
//        获取查询到的数据
        List<Offers> offers=offersDAOImpl.selectDateMore(conditions[0],conditions[1],conditions[2],conditions[3]);
        
//        如果数据表中含有查询的信息,则进行展示
        if(offers!=null && offers.size()>0) {
//            格式化输出显示所有数据
            System.out.println("\n———————————————————————————————————————————————————————————————————————");
            System.out.println("商家编号\t \t商家名称\t 法人\t \t地址\t \t联系电话 \n———————————————————————————————————————————————————————————————————————");
            for (Offers offer : offers) {
                System.out.println(offer.getOfferID()+"\t"+offer.getOfferName()+"\t "+offer.getLegalIP()+"\t"+offer.getAddress()+"\t\t"+offer.getTel());
            }
            
//        如果数据表中没有查询的信息,则提示不存在        
        }else {
            System.err.println("\n抱歉,当前暂无你要的查询信息!");
        }

    }
    

}
——————————————————————

package com.ruanyuan.test;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.ruanyuan.dao.impl.CategoryDAOImpl;
import com.ruanyuan.dao.impl.EmployeeDAOImpl;
import com.ruanyuan.dao.impl.GoodDAOImpl;
import com.ruanyuan.dao.impl.OffersDAOImpl;
import com.ruanyuan.dao.impl.SalesDAOImpl;
import com.ruanyuan.entity.Category;
import com.ruanyuan.entity.Employee;
import com.ruanyuan.entity.Good;
import com.ruanyuan.entity.Offers;
import com.ruanyuan.entity.Sales;

public class SalesManagementSystem {
    
    
    /**
     * 添加数据
     */
    public static void insertDate() {
//        创建销售实现类
        SalesDAOImpl salesDAOImpl=new SalesDAOImpl();
        
//        创建商品实现类
        GoodDAOImpl goodDAOImpl=new GoodDAOImpl();
        
//        创建供货商实现类
        OffersDAOImpl offerDAOImpl=new OffersDAOImpl();
        
//        创建类别实现类
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建职员实现类
        EmployeeDAOImpl employeeDAOImpl=new EmployeeDAOImpl();
        
//        创建销售对象
        Sales sale=new Sales();
        
        
//        查询销售所有数据
        List<Sales> sales=salesDAOImpl.selectDateAll();
        if(sales!=null && sales.size()>0) {
            System.out.println("销售id, 当日销量, 商品编号, 职员编号, 销售日期");
            for (Sales sales2 : sales) {
                Good goods=goodDAOImpl.selectDateID(sales2.getGoodld());
                Employee employees=employeeDAOImpl.selectDateID(sales2.getEmployeeld());
                System.out.println(sales2.getSalesld()+", "+sales2.getSellAmount()+", "+goods.getGoodName()+", "+employees.getEmpName()+", "+sales2.getSellDate());
            }
            
//            获取用户输入的销售id
            System.out.println("请输入要选择销售ID:");
            int salesld=Tools.enter.nextInt();
//            查询用户输入的id是否存在
            Sales selectSale =salesDAOImpl.selectDateID(salesld);
//            存在,继续添加
            if(selectSale==null) {
                sale.setSalesld(salesld);
                
//                获取当日销售数量
                System.out.println("——————————————————————————————————————————————————————————————————");
                System.out.println("请输入当日销量:");
                int sellAmount=Tools.enter.nextInt();
                sale.setSellAmount(sellAmount);
                
//                查询商品所有数据
                List<Good> goods =goodDAOImpl.selectAllDate();
                if(goods!=null && goods.size()>0) {
                    System.out.println("——————————————————————————————————————————————————————————————————");
                    System.out.println("商品编号 , 商品名称 , 单价 , 类别编号 , 供货商编号 , 库存");
                    for (Good good2 : goods) {
                        Category category =categoryDAOImpl.selectDateID(String.valueOf(good2.getCategoryID()));
                        Offers offer=offerDAOImpl.selectDateID(good2.getOfferID());
                        System.out.println(good2.getGoodID()+", "+good2.getGoodName()+", "+good2.getPrice()+", "
                                        +category.getCategoryName()+", "+offer.getOfferName()+", "+good2.getStockes());
                    }
//                    获取用户输入的商品id
                    System.out.println("请输入要选择商品ID:");
                    int goodld=Tools.enter.nextInt();
//                    查询用户输入的id是否存在
                    Good selectGood =goodDAOImpl.selectDateID(goodld);
//                    存在,继续添加
                    if(selectGood!=null) {
                        sale.setGoodld(goodld);
                        
//                        查询职员所有数据
                        List<Employee> employees=employeeDAOImpl.SelectDateAll();
                        if(employees!=null && employees.size()>0) {
                            System.out.println("——————————————————————————————————————————————————————————————————");
                            System.out.println("职员编号, 姓名, 密码, 性别, 年龄, 聘用日期, 薪资");
                            for (Employee employees2 : employees) {
                                System.out.println(employees2.getEmployeeId()+", "+employees2.getEmpName()
                                                +", "+employees2.getEmpPwd()+", "+employees2.getSex()+", "
                                                +", "+employees2.getAge()+", "+employees2.getHirelong()
                                                +", "+employees2.getSalary());
                            }
//                            获取用户输入的职员id
                            System.out.println("请输入选择职员ID:");
                            int employeeld=Tools.enter.nextInt();
//                            查询,用户输入id的是否存在
                            Employee selecEmployee=employeeDAOImpl.selectDateID(employeeld);
//                            存在,继续添加
                            if(selecEmployee!=null) {
                                sale.setEmployeeld(employeeld);
//                            不存在,重新添加
                            }else {
                                System.err.println("\n抱歉,你输入的职员ID不存在,重新添加!");
                            }
//                        职员0数据
                        }else {
                            System.err.println("\n抱歉,职员数据库0条记录!");
                        }
                        
//                        获取销售日期
                        System.out.println("——————————————————————————————————————————————————————————————————");
                        Date date = new Date(); 
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
                        String sellDate=formatter.format(date);
                        sale.setSellDate(sellDate);
                        
                        
//                        执行添加操作
                        int count =salesDAOImpl.insetDate(sale);
//                        受影响行数大于0执行成功,否则执行失败
                        if(count>0) {
                            System.out.println("\n添加成功!");
                        }else {
                            System.err.println("\n添加失败!");
                        }
                        
//                    不存在,重新添加
                    }else {
                        System.err.println("\n抱歉,你输入的商品ID不存在,重新添加!");
                    }
//                商品0数据
                }else {
                    System.err.println("\n抱歉,商品数据库0条记录!");
                }
                
//            不存在,重新添加
            }else {
                System.err.println("\n抱歉,你输入的销售ID重复,重新添加!");
            }
//        销售0数据
        }else {
            System.err.println("\n抱歉,销售数据库0条记录!");
        }
        

        

        
        

        

    }

    
    /**
     * 删除数据
     */
    public static void deleteDate() {
        // TODO 自动生成的方法存根
        
//        创建销售实现类
        SalesDAOImpl salesDAOImpl=new SalesDAOImpl();
        
//        创建商品实现类
        GoodDAOImpl goodDAOImpl=new GoodDAOImpl();
        
//        创建职员实现类
        EmployeeDAOImpl employeeDAOImpl=new EmployeeDAOImpl();
        
//        创建销售对象
        Sales sale=new Sales();
        
        
//        查询销售所有数据
        List<Sales> sales=salesDAOImpl.selectDateAll();
        if(sales!=null && sales.size()>0) {
            System.out.println("销售id, 当日销量, 商品编号, 职员编号, 销售日期");
            for (Sales sales2 : sales) {
                Good goods=goodDAOImpl.selectDateID(sales2.getGoodld());
                Employee employees=employeeDAOImpl.selectDateID(sales2.getEmployeeld());
                System.out.println(sales2.getSalesld()+", "+sales2.getSellAmount()+", "+goods.getGoodName()+", "+employees.getEmpName()+", "+sales2.getSellDate());
            }
//            获取用户输入的销售id
            System.out.println("请输入要删除的销售ID:");
            int salesld=Tools.enter.nextInt();
//            查询用户输入的id是否存在
            Sales selectSale =salesDAOImpl.selectDateID(salesld);
//            存在,继续删除
            if(selectSale!=null) {
                System.out.println("你确定要删除吗?Y确定 / N取消");
                String delSales=Tools.enter.next();
                if(delSales.equalsIgnoreCase("Y")) {
                    
//                    设置对象的值
                    sale.setSalesld(salesld);
                    
//                    执行删除操作
                    int count =salesDAOImpl.deleteDate(sale);
                    
//                    受影响行数大于0执行成功,否则执行失败
                    if(count>0) {
                        System.out.println("\n删除成功!");
                    }else {
                        System.err.println("\n删除失败!");
                    }
                    
                }else {
                    System.out.println("\n取消删除成功!");
                }
        
            }else {
                System.err.println("\n抱歉,你要删除的销售信息不存在!");
            }
            
        }
        
    }
    
    
    /**
     * 修改数据
     */
    public static void updateDate() {
        // TODO 自动生成的方法存根
        
//        创建销售实现类
        SalesDAOImpl salesDAOImpl=new SalesDAOImpl();
        
//        创建商品实现类
        GoodDAOImpl goodDAOImpl=new GoodDAOImpl();
        
//        创建供货商实现类
        OffersDAOImpl offerDAOImpl=new OffersDAOImpl();
        
//        创建类别实现类
        CategoryDAOImpl categoryDAOImpl=new CategoryDAOImpl();
        
//        创建职员实现类
        EmployeeDAOImpl employeeDAOImpl=new EmployeeDAOImpl();
        
//        创建销售对象
        Sales sale=new Sales();
        
        
//        查询销售所有数据
        List<Sales> sales=salesDAOImpl.selectDateAll();
        if(sales!=null && sales.size()>0) {
            System.out.println("销售id, 当日销量, 商品编号, 职员编号, 销售日期");
            for (Sales sales2 : sales) {
                Good goods=goodDAOImpl.selectDateID(sales2.getGoodld());
                Employee employees=employeeDAOImpl.selectDateID(sales2.getEmployeeld());
                System.out.println(sales2.getSalesld()+", "+sales2.getSellAmount()+", "+goods.getGoodName()+", "+employees.getEmpName()+", "+sales2.getSellDate());
            }
//            获取用户输入的销售id
            System.out.println("请输入要修改的销售ID:");
            int salesld=Tools.enter.nextInt();
//            查询用户输入的id是否存在
            Sales selectSale =salesDAOImpl.selectDateID(salesld);
//            存在,继续修改
            if(selectSale!=null) {
//                设置销售编号
                sale.setSalesld(salesld);
                
                
//                获取当日销量
                System.out.println("是否修改当日销量?Y确定 / N取消");
                String editSaleAmount=Tools.enter.next();
//                如果确定,继续修改
                if(editSaleAmount.equalsIgnoreCase("Y")) {
                    System.out.println("请输入新的销售数量:");
                    int sellAmount=Tools.enter.nextInt();
                    sale.setSellAmount(sellAmount);
//                取消修改,原来的信息
                }else {
                    sale.setSellAmount(selectSale.getSellAmount());
                }
                
                
//                获取商品编号
                System.out.println("是否修改所属商品编号?Y确定 / N取消");
                String editSalesGoodID=Tools.enter.next();
//                如果确定,继续修改
                if(editSalesGoodID.equalsIgnoreCase("Y")) {
                    List<Good> goods =goodDAOImpl.selectAllDate();
                    if(goods!=null && goods.size()>0) {
                        System.out.println("——————————————————————————————————————————————————————————————————");
                        System.out.println("商品编号 , 商品名称 , 单价 , 类别编号 , 供货商编号 , 库存");
                        for (Good good2 : goods) {
                            Category category =categoryDAOImpl.selectDateID(String.valueOf(good2.getCategoryID()));
                            Offers offer=offerDAOImpl.selectDateID(good2.getOfferID());
                            System.out.println(good2.getGoodID()+", "+good2.getGoodName()+", "+good2.getPrice()+", "
                                            +category.getCategoryName()+", "+offer.getOfferName()+", "+good2.getStockes());
                        }
                        
                        System.out.println("请输入新的商品编号:");
                        int goodld=Tools.enter.nextInt();
//                        查询用户输入的id是否存在
                        Good selectGood =goodDAOImpl.selectDateID(goodld);
//                        存在,继续修改
                        if(selectGood!=null) {
                            sale.setGoodld(goodld);
//                        不存在,重新修改
                        }else {
                            System.err.println("\n抱歉,你要修改的信息不存在!");
                        }
                    }else {
                        System.out.println("\n抱歉,数据为空,无法修改商品编号!");
                    }
        
                    
//                取消修改,原来的信息
                }else {
                    sale.setGoodld(selectSale.getGoodld());
                }
                
                

                
//                获取职员编号
                System.out.println("是否修改职员信息?Y确定 / N取消");
                String editSalesEmployeeID=Tools.enter.next();
//                如果确定,继续修改
                if(editSalesEmployeeID.equalsIgnoreCase("Y")) {
//                    查询职员所有数据
                    List<Employee> employees=employeeDAOImpl.SelectDateAll();
                    if(employees!=null && employees.size()>0) {
                        System.out.println("——————————————————————————————————————————————————————————————————");
                        System.out.println("职员编号, 姓名, 密码, 性别, 年龄, 聘用日期, 薪资");
                        for (Employee employees2 : employees) {
                            System.out.println(employees2.getEmployeeId()+", "+employees2.getEmpName()
                                            +", "+employees2.getEmpPwd()+", "+employees2.getSex()+", "
                                            +", "+employees2.getAge()+", "+employees2.getHirelong()
                                            +", "+employees2.getSalary());
                        }
                        System.out.println("请输入新的职员编号:");
                        int employeeld=Tools.enter.nextInt();
//                        查询用户输入的id是否存在
                        Employee selectEmployee =employeeDAOImpl.selectDateID(employeeld);
//                        存在,继续修改
                        if(selectEmployee!=null) {
                            sale.setEmployeeld(employeeld);
//                        不存在,重新修改
                        }else {
                            System.err.println("\n抱歉,你要修改的信息不存在!");
                        }
                    }else{
                        System.err.println("\n抱歉,数据为空,无法修改职员信息!");
                    }

                    
//                取消修改,原来的信息
                }else {
                    sale.setEmployeeld(selectSale.getEmployeeld());
                }
                
//                执行添加操作
                int count =salesDAOImpl.updateDate(sale);
//                受影响行数大于0执行成功,否则执行失败
                if(count>0) {
                    System.out.println("\n修改成功!");
                }else {
                    System.err.println("\n修改失败!");
                }
                
            }else {
                System.err.println("\n抱歉,你要修改的销售信息不存在");
            }
            
            
        }
    }
    
    
    /**
     * 查询数据
     */
    public static void selectDate() {
        // TODO 自动生成的方法存根
        
//        创建销售实现类
        SalesDAOImpl salesDAOImpl=new SalesDAOImpl();
        
//        创建商品实现类
        GoodDAOImpl goodDAOImpl=new GoodDAOImpl();
        
        
//        创建职员实现类
        EmployeeDAOImpl employeeDAOImpl=new EmployeeDAOImpl();
        
//        存储查询条件
        String[] conditions=new String[6];
        
        System.out.println("多条件查询可以根据:数量区间、商品名称、职员姓名、销售日期区间");
        
//        查询数量区间
        System.out.println("是否根据数量区间进行多条件查询?Y确定/N取消");
        String selectSaleAmount=Tools.enter.next();
        if(selectSaleAmount.equalsIgnoreCase("Y")) {
//            提示用户输入
            System.out.println("请输入开始数量:");
            int beginSaleAmount=Tools.enter.nextInt();
            System.out.println("请输入结束数量:");
            int endSaleAmount=Tools.enter.nextInt();
//            修改,获取条件,用户输入的
            conditions[0]=String.valueOf(beginSaleAmount);
            conditions[1]=String.valueOf(endSaleAmount);
        }else {
//            不修改,获取条件,为空
            conditions[0]=null;
            conditions[1]=null;
        }
        
//        查询商品名称
        System.out.println("是否根据商品名称进行多条件查询?Y确定/N取消");
        String selectGoodName=Tools.enter.next();
        if(selectGoodName.equalsIgnoreCase("Y")) {
//            提示用户输入
            System.out.println("请输入商品名称:");
            String goodName=Tools.enter.next();
            Good good=goodDAOImpl.selectDateName(goodName);
//            修改,获取条件,用户输入的
            conditions[2]=String.valueOf(good.getGoodID());
            
        }else {
//            不修改,获取条件,为空
            conditions[2]=null;
        }
        
//        查询职员姓名
        System.out.println("是否根据职员姓名进行多条件查询?Y确定/N取消");
        String selectEmployeeName=Tools.enter.next();
        if(selectEmployeeName.equalsIgnoreCase("Y")) {
//            提示用户输入
            System.out.println("请输入职员姓名:");
            String employeeName=Tools.enter.next();
            Employee employee=employeeDAOImpl.selectDateName(employeeName);
//            修改,获取条件,用户输入的
            conditions[3]=String.valueOf(employee.getEmployeeId());
        }else {
//            不修改,获取条件,为空
            conditions[3]=null;
        }
        
//        查询销售日期区
        System.out.println("是否根据销售日期区间进行多条件查询?Y确定/N取消");
        String selectSaleDate=Tools.enter.next();
//        确定修改
        if(selectSaleDate.equalsIgnoreCase("Y")) {
//            提示用户输入
            System.out.println("请输入开始销售日期(2000-12-12):");
            String beginSaleDate=Tools.enter.next();
            System.out.println("请输入结束销售日期(2001-12-12):");
            String endSaleDate=Tools.enter.next();
//            修改,获取条件,用户输入的
            conditions[4]=beginSaleDate;
            conditions[5]=endSaleDate;
            System.out.println(conditions[4]+"----"+conditions[5]);
        }else {
//            不修改,获取条件,为空
            conditions[4]=null;
            conditions[5]=null;
        }
        
//        获取通过多条件查询的数据
        List<Sales> sales=salesDAOImpl.selectDateMore(conditions[0],conditions[1],conditions[2],conditions[3],conditions[4],conditions[5]);
//        如果有数据,打印输出
        if(sales!=null && sales.size()>0) {
//            格式化打印输出
            System.out.println("——————————————————————————————————————————————————————————————————");
            System.out.println("销售id, 当日销量, 商品编号, 职员编号, 销售日期");
            for (Sales sales2 : sales) {
//                将编号显示为名称
                Good goods=goodDAOImpl.selectDateID(sales2.getGoodld());
                Employee employees=employeeDAOImpl.selectDateID(sales2.getEmployeeld());
//                格式化输出
                System.out.println(sales2.getSalesld()+", "+sales2.getSellAmount()+", "+goods.getGoodName()+", "+employees.getEmpName()+", "+sales2.getSellDate());
            }
//        没有,提示用户无数据
        }else {
            System.err.println("\n抱歉,当前暂无你要的查询信息!");
        }
    }

}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

假客套

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值