java课程设计完整版
- 格式:doc
- 大小:161.50 KB
- 文档页数:15
面向对象程序设计
课程设计报告
设计题目:__
商品销售管理系统
专业班级: ______ _______
学生姓名: _______ ___________
学生学号: _____________________
指导教师:
完成日期: ____ __2011年7月3日____ _
目录
一 系统功能介绍及界面展示 ..... 2
1.1登陆界面 .................... 2 1.2 修改界面 ............................................2
1.3 查询界面 ............................................3
1.4 删除界面 ............................................3
1.5 添加界面 ............................................4
二 数据库展示 ................. 4 2.1 用户登入表............... 4
2.2 商品信息表.................... 5
三 系统源代码展示 ............. 5
一 系统功能介绍及界面展示
1.1 登陆界面(限制人员登入,只有通过正确的用户名及密码方可登入)
1.2 修改界面(通过查询商品代码修改商品信息)
1.3 查询界面(通过商品代码可以查询商品信息)
1.4 删除界面(通过商品代码可以删除商品信息)
1.5 添加界面(可以添加新商品信息)
二 数据库展示
2.1 用户登入表(记录用户名及密码)
表中列名 数据类型 可否为空 说明
ID char not null(主键) 用户名
Pwd char not null 密码
二 商品信息表(记录商品信息)
表中列名 数据类型 可否为空 说明
spdm char Not null(外主键) 商品代码
spmc char Not null(外主键) 商品名称
spxh char Not null 商品型号
三 系统源代码展示
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
class date extends Panel implements ActionListener
{ Box base,box1,box2;
Label l2,l3,l4;
Button button,button1;
TextField text1,text2,text3;
Panel p1,p2;
date()
{ text1=new TextField(27);
text2=new TextField(27);
text3=new TextField(27);
l2=new Label("输入要查询的商品代码");
l3=new Label("商品名称");
l4=new Label("商品型号");
p1=new Panel();
p2=new Panel();
button=new Button("查询");
button1=new Button("修改");
p1.add(l2);
p1.add(text1);
p1.add(button);
add(p1,BorderLayout.NORTH);
box1=Box.createVerticalBox();
box1.add(l3);
box1.add(Box.createVerticalStrut(10));
box1.add(l4);
box2=Box.createVerticalBox();
box2.add(text2); box2.add(Box.createVerticalStrut(10));
box2.add(text3);
base=Box.createHorizontalBox();
base.add(box1);
base.add(Box.createHorizontalStrut(10));
base.add(box2);
p2.add(base);
p2.add(button1);
add(p2,BorderLayout.CENTER);
button.addActionListener(this);
button1.addActionListener(this);
setVisible(true);
setBounds(200,200,200,200);
validate();
}
public void actionPerformed(ActionEvent e)
{ String spdm=text1.getText();
if(e.getSource()==button)
{
if (spdm.equals("")) {
JOptionPane.showMessageDialog(null,"商 品 代 码 不 能
为 空 !");
}
String sql="select * from goods where 商品代码='"+spdm+"'";
try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url="jdbc:sqlserver://localhost:1433;databaseName=w2";
Connection con=DriverManager.getConnection(url,"sa","");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(sql);
if(rs.next())
{String dm=rs.getString(1);
String mc=rs.getString(2);
String xh=rs.getString(3);
text2.setText(mc);
text3.setText(xh);
}
else
{
JOptionPane.showMessageDialog(this, "该商品不存在!", "提示框",JOptionPane.WARNING_MESSAGE);
text1.setText(null);
return;
}
}catch(Exception e6){System.out.print(e6);} }
if(e.getSource()==button1)
{
String mc=text2.getText();
String xh=text3.getText();
String sql2="update goods set 商品名称='"+mc+"', 商品型号='"+xh+"' where 商品代码='"+spdm+"'";
try{Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url="jdbc:sqlserver://localhost:1433;databaseName=w2";
Connection con=DriverManager.getConnection(url,"sa","");
Statement stmt=con.createStatement();
stmt.executeUpdate(sql2);
}
catch(Exception e6){JOptionPane.showMessageDialog(this, "修改失败!","提示框", JOptionPane.WARNING_MESSAGE);
text1.setText(null);
text2.setText(null);
text3.setText(null);}
}
}
}
class Lete extends Panel implements ActionListener
{
Button button;
TextField text;
Label label;
Panel p1;
String sqlstr;
ResultSet res;
Lete() {
label = new Label("请 输 入 商 品 代 码 :");
text = new TextField(20);
button = new Button("删 除");
p1 = new Panel();
p1.add(label);
p1.add(text);
p1.add(button);
add(p1, BorderLayout.NORTH);
text.addActionListener(this);
button.addActionListener(this);
setBounds(0,0,560,400);
setVisible(true);
}