1 團隊名稱、團隊成員介紹(需要有照片)
- 團隊成員:郭雅芳
2 項目git位址
3 項目git送出記錄截圖(要展現出每個人的送出記錄、送出說明),老師将點選進去重點考核。

4 項目功能架構圖與主要功能流程圖
- 架構圖
團隊課程設計--購物車 - 流程圖
團隊課程設計--購物車
5 項目運作截圖
6 項目關鍵代碼(不能太多)
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
conn=DriverManager.getConnection(url,userName,password);
st = conn.createStatement();
//通過sql語句,将文本框内的商品資訊加入購物車,并且加入mlist。
String sql="insert into goods(name,price,num,color,size)"
+ " values('"+Text1.getText()+"',"+Double.parseDouble(Text2.getText())+","+Integer.parseInt(Text3.getText())+",'"+Text4.getText()+"','"+Text5.getText()+"')";
st.executeUpdate(sql);
}catch (SQLException e){
e.printStackTrace();
}
mlist.add(new Clothes(Text1.getText(),Double.parseDouble(Text2.getText()),
Integer.parseInt(Text3.getText()),Text4.getText(),Text5.getText()));
//統計加入了多少條商品資訊,顯示到TextArea
goodsNum++;
addGoods();
}
撤銷添加:
private void cancleButtonActionPerformed(java.awt.event.ActionEvent evt) {
if(goodsNum>0){
goodsNum--;
try{
conn=DriverManager.getConnection(url,userName,password);
st = conn.createStatement();
String delName=mlist.get(goodsNum).getName();
String sql = "delete from goods where name = '"+delName+"' ";
System.out.println(sql);
st.executeUpdate(sql);
}catch (SQLException e){
e.printStackTrace();
}
addGoods();
}
}
使用者界面:
組合框擷取資料庫中商品資訊
private static void addComboxItem(){
try{
conn=DriverManager.getConnection(url,userName,password);
st = conn.createStatement();
String sql="select * from goods";
rs=st.executeQuery(sql);
while(rs.next()){
list.add(new Clothes(rs.getString("name"),rs.getDouble("price"),rs.getInt("num"),rs.getString("color"),rs.getString("size")));
}
}catch (SQLException e){
e.printStackTrace();
}
System.out.println();
for(int i=0;i<list.size();i++){
String a=list.get(i).getName();
//addItem方法加入組合框清單中
clothesComboBox.addItem(a);
}
顯示商品:
private void clothesComboBoxActionPerformed(java.awt.event.ActionEvent evt)
{ //獲得你選中的下拉框的位置
int i=clothesComboBox.getSelectedIndex();
//如何i大于零,則将資訊顯示購物車界面
if(i>=0) {
jLabel6.setText(list.get(i).getName());
jLabel7.setText(Double.toString(list.get(i).getPrice()));
jLabel8.setText(Integer.toString(list.get(i).getNum()));
jLabel9.setText(list.get(i).getColor());
jLabel10.setText(list.get(i).getSize());
}
}
加入購物車:
private void addButtonActionPerformed(java.awt.event.ActionEvent evt)
{ //建立一個GoodDao table;
GoodsDao goodDao = new Jtable(jTable1);
try{
count=Integer.parseInt(jTextField1.getText());
}catch(NumberFormatException e){
System.out.println(e);
}
int i=clothesComboBox.getSelectedIndex();
if(i>=0) {
String name=list.get(i).getName();
double price=list.get(i).getPrice();
Goods good = new Goods(name,price,count);
boolean flag = goodDao.save(good);
if(flag){
JOptionPane.showMessageDialog(null, "添加成功");
}else{
JOptionPane.showMessageDialog(null, "添加失敗!");
}
sum+=list.get(i).getPrice()*count;
}
}
7 尚待改進或者新的想法
- 改進:圖形界面太過簡單、管理界面不能顯示已存在資料庫的資訊。通過管理界面傳回使用者界面,組合框沒有導入商品資訊。删除商品時,結算需要相應扣錢。
8 團隊成員任務配置設定,團隊成員課程設計部落格連結(以表格形式呈現),标明組長
郭雅芳:管理者界面、使用者界面