第2篇-Scrum冲刺博客
第 2 篇 冲刺博客之小型超市管理系统
会议照片
昨天已完成的工作:
Sql数据库方面:完成数据库建表,小部分数据的导入。
后台方面:完成数据库连接函数的测试。
前端:登录界面的设计与主界面的小部分设计。
今天计划完成的任务:
Sql数据库方面:待定
后台方面:为前端的各个控件的监听器添加函数
前端方面:主界面的设计完善,添加监听器给后台及数据库调用。
工作中遇到的困难:
因为今天是周末,成员有许多其他安排,加上学业繁忙,具体去实现项目的时间不多,讨论的时间多了一些。
前端面板没实现的情况下后端的操作受限。
项目燃尽图:
每人的代码/文档签入记录:
前端:登录界面签入。后台:数据库链接签入(包括测试函数)。数据库:sql建表语句签入。
详见Issue链接:https://github.com/HappyHeros/SupermarketManagement
运行截图:
(登录界面)
(表间关系)
关键代码:
package com.nuota.view; import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import com.nuota.dao.AdminDao; import com.nuota.model.Admin; import com.nuota.model.UserType; import com.nuota.util.StringUtil; import javax.swing.JLabel; import javax.swing.JOptionPane; import java.awt.Font; import java.awt.Toolkit; import javax.swing.UIManager; import javax.swing.JTextField; import javax.swing.JComboBox; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.ImageIcon; public class LoginJFM extends JFrame { private JPanel contentPane; private JTextField userName_Text; private JTextField passport_Text; private JComboBox userTypebox; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { String lookAndFeel = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(lookAndFeel); //风格设置 LoginJFM frame = new LoginJFM(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public LoginJFM() { setTitle("\u767B\u5F55\u754C\u9762"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 452, 329); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); setLocationRelativeTo(null); //居中显示 JLabel label = new JLabel("\u7528\u6237\u540D\uFF1A"); label.setBounds(95, 103, 56, 16); label.setFont(new Font("宋体", Font.PLAIN, 14)); JLabel label_1 = new JLabel("\u5BC6 \u7801\uFF1A"); label_1.setBounds(95, 151, 56, 16); label_1.setFont(new Font("宋体", Font.PLAIN, 14)); userName_Text = new JTextField(); userName_Text.setBounds(177, 101, 161, 21); userName_Text.setColumns(10); passport_Text = new JTextField(); passport_Text.setBounds(177, 149, 161, 21); passport_Text.setColumns(10); JLabel label_2 = new JLabel("\u7528\u6237\u7C7B\u578B\uFF1A"); label_2.setBounds(125, 193, 60, 17); label_2.setFont(new Font("微软雅黑", Font.PLAIN, 12)); userTypebox = new JComboBox(); userTypebox.setBounds(201, 191, 103, 21); userTypebox.setModel(new DefaultComboBoxModel(new UserType[] {UserType.ADMIN,UserType.TEACHER,UserType.STUDENT})); JButton loginButton = new JButton("\u767B\u5F55"); loginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { loginAct(arg0); } }); loginButton.setBounds(100, 234, 64, 23); JButton exitButton = new JButton("\u9000\u51FA"); exitButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.exit(0); } }); exitButton.setBounds(256, 234, 64, 23); contentPane.setLayout(null); contentPane.add(label_2); contentPane.add(userTypebox); contentPane.add(loginButton); contentPane.add(exitButton); contentPane.add(label); contentPane.add(label_1); contentPane.add(passport_Text); contentPane.add(userName_Text); JLabel lblCh = new JLabel("\u8D85\u5E02\u7BA1\u7406\u7CFB\u7EDF\u767B\u5F55"); lblCh.setIcon(new ImageIcon(LoginJFM.class.getResource("/imgs/maket.png"))); lblCh.setFont(new Font("微软雅黑", Font.BOLD, 18)); lblCh.setBounds(111, 32, 227, 47); contentPane.add(lblCh); } //用户登录操作 protected void loginAct(ActionEvent arg0) { // TODO Auto-generated method stub String userName=userName_Text.getText().toString(); String password=passport_Text.getText().toString(); UserType selectedItem=(UserType)userTypebox.getSelectedItem(); if(StringUtil.isEmpty(userName)) { JOptionPane.showMessageDialog(this, "请输入用户名!"); return; } if(StringUtil.isEmpty(password)) { JOptionPane.showMessageDialog(this, "请输入密码!"); return; } Admin admin =null; //不同的用户类型登录 if("系统管理员".equals(selectedItem.getName())) { AdminDao adminDao=new AdminDao(); Admin adminTmp =new Admin(); adminTmp.setName(userName); adminTmp.setPassword(password); admin =adminDao.login(adminTmp); adminDao.closeDao(); if(admin==null) { JOptionPane.showMessageDialog(this, "用户名密码错误!"); return; }else { JOptionPane.showMessageDialog(this, "【"+selectedItem.getName()+"】:"+admin.getName()+" 登录成功!"); this.dispose();//退出登录界面 MainJFM mainJFM=new MainJFM(selectedItem, admin); // mainJFM.setLocation((int) (width - mainJFM.getWidth()) / 2,(int) (height - mainJFM.getHeight()) / 2);//居中弹出位置 mainJFM.setVisible(true); } }else { } } }
package com.nuota.util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DbUtil { // private String dbUrl="jdbc:mysql://localhost:3306/db_student?useUnicode=true&characterEncoding=utf8";//数据库连接地址 private String dbUrl="jdbc:mysql://localhost:3306/db_student?useUnicode =true&characterEncoding =utf-8 &useSSL =false &serverTimezone=Hongkong";//数据库连接地址 private String dbUserName="root";//数据库用户名 private String dbPassword="root";//数据库密码 private String jdbcName="com.mysql.cj.jdbc.Driver";//Mysql连接驱动 //获取连接 public Connection getCon(){ try { Class.forName(jdbcName); }catch(ClassNotFoundException e) { e.printStackTrace(); } Connection con=null; try { con=DriverManager.getConnection(dbUrl,dbUserName,dbPassword); }catch(SQLException e) { //密码错误等 e.printStackTrace(); } return con; } //关闭数据库 public void closeCon(Connection con) throws Exception { if(con!=null) { con.close(); } } //测试函数 public static void main(String[] args) { DbUtil dbUtil=new DbUtil(); try{ dbUtil.getCon(); System.out.println("成功"); }catch(Exception e) { e.printStackTrace(); System.out.println("失败"); } } }
每日每人总结:
谢伟洁:革命尚未成功,同志仍需努力!
梁迪希:项目开始总是困难的,希望往后越来越走向正轨!
布雷斯:继续努力!
甘永强:撸起袖子加油干,目标冲冲冲!
郑雁昇:项目进一步完成,加油,继续肝!
许峰铭:翻身翻身翻身!咸鱼翻身!