图书系统
   
    引言:
    
    做的这个系统可能比较粗糙处理还不是很好,但是基本要求已经实现。代码比较乱,观看需谨慎。
    
    1.注册登录模块描述
    
    注册、登录是一个软件的门户,简洁美观的登录窗口能给用户带来良好的体验,注册和登录的互动也体现出一款软件和用户交互的方式和效率。
   
    2注册登录模块分析
    
    管理人员访问本系统,首先就要注册和登录,注册需要输入账号和密码,点击注册按钮即可注册成功。登录时需要输入先前注册成功的账号和密码,如果密码正确将自动跳转到管理模块页面。
   
3.1模型
(用户登录注册用例图)
3.2数据需求分析
(管理人员注册登录实体-属性图)
    3.3技术需求分析
    
    用户注册登录界面采用了JAVASWING技术,JDBC和Mysql,实现能够将用户输入的账号和密码记录在数据库中并且能够在登陆时从数据库中取出进行对比,当账号密码符合并且正确后用户就可进入到系统管理界面。
   
    4.1模块详细设计
    
    登录模块:用户输入账号和密码,点击登录按钮,系统后台判断用户输入的账号密码和数据库中已经注册过的的登录密码是否一致,若一致,则登录成功,跳转到系统主页面,若不成功,则弹出窗口提示用户的错误,并且用户可以重新输入账号密码。
   
注册模块:用户输入想要注册的账号和密码,点击注册按钮,系统后台将用户输入的账号密码储存到数据库中,自动为其添加用户唯一ID,并且提示用户注册成功。
5.界面设计
6.类设计(核心代码)
    public static Connection connectDB(String DBName,String id,String password) {
    
    
    try {
    
    
    Class.forName(“com.mysql.cj.jdbc.Driver”);
    
    }
    
    catch (Exception e) {
    
    
    System.out.println(“666666666666666666666”);
    
    }
    
    Connection con = null;
    
    String uri =“jdbc:mysql://localhost:3306/bookstore?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=UTC”;
    
    try {
    
    
    con = DriverManager.getConnection(uri,id,password);
    
    }
    
    catch (SQLException e) {
    
    
    System.out.println(e);
    
    }
    
    return con;
    
    }
    
    (数据库链接)
   
    public void writeRegisterModel(Register person){
    
    
    String sqlStr=“insert into register values(?,?,?)”;
    
    int ok=0;
    
    try {
    
    
    preSql=con.prepareStatement(sqlStr);
    
    preSql.setString(1, person.getID());
    
    preSql.setString(2, person.getPassword());
    
    preSql.setString(3, person.getEmail());
    
    ok=preSql.executeUpdate();
    
    con.close();
    
    }
    
    catch (SQLException e){
    
    
    JOptionPane.showMessageDialog(null,“id已被申请”,“警告”,JOptionPane.WARNING_MESSAGE);
    
    }
    
    if(ok!=0){
    
    
    JOptionPane.showMessageDialog(null,“注册成功”,“恭喜”,JOptionPane.WARNING_MESSAGE);
    
    }
    
    }
    
    (注册代码)
   
    public Login queryVerify(Login loginModel){
    
    
    String id= loginModel.getID();
    
    System.out.println(id);
    
    String password= loginModel.getPassword();
    
    String ganli=“guanliyuan”;
    
    String sqlStr=“select id,password from register where id =? and password=?”;
    
    try {
    
    
    preSql=con.prepareStatement(sqlStr);
    
    preSql.setString(1,id);
    
    preSql.setString(2,password);
    
    rs=preSql.executeQuery();
    
    if(rs.next()==true){//登录成功
    
    if (id.equals(ganli)){
    
    
    Windowapp windowapp = new Windowapp();
    
    windowapp.setTitle(“管理界面”);
   
        }
        else {
            WindowUser user = new WindowUser();
        }
    }
    else {
        JOptionPane.showMessageDialog(null,"账号或密码错误","请重新登录",JOptionPane.WARNING_MESSAGE);
    }
    con.close();
}
catch (SQLException e){}
    return loginModel;
}
(登录验证代码)
    7.所有界面布局代码(核心)
    
    void LoginView1(){
    
    
    jf=new JFrame();
    
    ImageIcon ccccc=new ImageIcon(“src/ccccc.jpg”);
    
    JLabel label = new JLabel(ccccc);
    
    label.setSize(ccccc.getIconWidth(),ccccc.getIconHeight());
    
    jf.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE));
    
    login=new Login();
    
    inputID=new JTextField(12);
    
    inputPassword=new JPasswordField(12);
    
    NULL1=new JButton();
    
    buttonLogin=new JButton(“登录”);
    
    buttonRegister=new JButton(“注册”);
    
    buttonRegister.addActionListener(this);
    
    JLabel jLabel1=new JLabel(” WELCOME “);
    
    jLabel1.setFont(new Font(“宋体”,1,50));
    
    box1=Box.createVerticalBox();
    
    box1.add(new JLabel(“ID:”));
    
    box1.add(Box.createVerticalStrut(30));
    
    box1.add(new JLabel(“密码:”));
    
    box2=Box.createVerticalBox();
    
    box2.add(Box.createVerticalStrut(30));
    
    box2.add(inputID);
    
    box2.add(Box.createVerticalStrut(25));
    
    box2.add(inputPassword);
    
    box2.add(Box.createVerticalStrut(8));
    
    box2.add(buttonLogin);
    
    baseBox=Box.createHorizontalBox();
    
    baseBox.add(box1);
    
    baseBox.add(Box.createHorizontalStrut(10));
    
    baseBox.add(box2);
    
    add(baseBox);
    
    buttonLogin.addActionListener(this);
    
    JPanel pan=(JPanel)jf.getContentPane();
    
    pan.add(jLabel1);
    
    pan.setOpaque(false);
    
    pan.setLayout(new FlowLayout());
    
    pan.add(baseBox);
    
    pan.add(buttonRegister);
    
    jf.setTitle(“登录窗口”);
    
    jf.setSize(500,300);
    
    jf.setLocationRelativeTo(null);
    
    jf.setVisible(true);
    
    jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    
    }
    
    (插入背景图)
   
    String name;
    
    String id;
    
    String price;
    
    String chubanDate;
    
    String[] database;
    
    DefaultTableModel model;
    
    JTable table;
    
    String[] header = {“书名”, “出版号”, “价格”,“出版日期”};
    
    String[][] data = null;
    
    model = new DefaultTableModel(data, header);
    
    table = new JTable(model);
    
    table.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    
    Connection con;
    
    con=GetDBConnection.connectDB(“book”,“root”,””);
    
    if (con==null)
    
    return;
    
    Statement sql;
    
    ResultSet rs;
    
    try {
    
    
    sql=con.createStatement();
    
    rs= sql.executeQuery(“select * from bookList”);
    
    while (rs.next()) {
    
    
    data = null;
    
    name = rs.getString(“name”);
    
    id = rs.getString(“ISBN”);
    
    price = rs.getString(“price”);
    
    chubanDate=rs.getString(“chubanDate”);
    
    database= new String[] { name, id, price,chubanDate };
    
    model.addRow(database);
    
    }
    
    con.close();
    
    }
    
    (将数据库内数剧以表格形式输出)
    
    8.评论模块的描述
    
    评论模块是为了让客户收到货物后对我们书籍的描述,评论模块也是一个推销的好方式,好的评论自然会代理好的客户,在设计该模块中,我们设计了管理员只能对评论查看,并不能对其进行删改操作。
   
8.1评论界面和功能代码(核心)
    String name;
    
    String[] database;
    
    DefaultTableModel model;
    
    JTable table;
    
    String[] header = {“往期评论”};
    
    String[][] data = null;
    
    model = new DefaultTableModel(data, header);
    
    table = new JTable(model);
    
    table.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    
    Connection con;
    
    con=GetDBConnection.connectDB(“book”,“root”,””);
    
    if (con==null)
    
    return;
    
    Statement sql;
    
    ResultSet rs;
    
    try {
    
    
    sql=con.createStatement();
    
    rs= sql.executeQuery(“select * from pinglun”);
    
    while (rs.next()) {
    
    
    data = null;
    
    name = rs.getString(“pinglun”);
    
    database= new String[] { name };
    
    model.addRow(database);
    
    }
    
    con.close();
    
    }
    
    catch (SQLException a)
    
    {System.out.println(a);}
    
    frame.add(new JScrollPane(table));
   
    
     总程序代码
    
    
    可在此获取总程序。
   
 
