网上花店后台管理系统
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
网上花店后台管理系统设计报告
1.概述
现如今网上购物越来越趋于大众化,购物种类应有尽有,方便又不受地域的限制,所以我们小组本次的课程设计决定做一个网上花店的管理系统,把在这个系统里的管理员模块详细的展示出来。
本系统以网上花店日常工作为起点,把管理员模块通过对花店的管理表现出来。
管理员管理模块包括查询模块和更新模块。
管理员可以对鲜花,供应商,货物的出入记录进行更新,也可以查询供应商的信息,鲜花的信息,以及顾客的信息。
本次课程设计用SQL 2008、eclipse 等工具开发。
2.设计内容
网上花店管理系统主要功能是用于查询、保存和编辑添加鲜花,供应商的资料、工作人员信息和统计资金、货物的信息,包括供应商、顾客、资金及鲜花等。
用于查询和编辑供应商的基本信息,包括供应商的厂商名、地址和电话等;用于查询和编辑鲜花的基本信息,包括鲜花的名称、颜色、成本价、零售价、送花对象、适用季节以及花的用途等;用于查询和编辑顾客的基本信息,包括顾客的姓名、登陆账号、年龄、联系电话和性别等。
模式图表示如下:
总体设计依据的表格
表2:flower鲜花
表5:customer顾客
表9:netorder网上订购
3.具体设计
关系图:
n
1
各类,函数,成员
鲜花总框架class FlowerManage
是否已登录 flag
与数据库的链接成员 Connection con
Statement st
PreparedStatement p
ResultSet re
private static String DBUrl;
登录面板 JPanel pdenglu=new JPanel();
菜单栏 JMenuItem[] dengluMenuItem
JMenuItem[] checkMenuItem
JMenuItem[] gengxinMenuItem
JMenuItem[] tuichuMenuItem
构造函数 public FlowerManage()
所有面板 public void sevenoperation(){
登录面板 this.dengLuPanel();
供应商查询面板 this.gongyingshangc.setOpaque(false);
顾客查询面板 this.gukec.setOpaque(false);
鲜花查询面板 this.xianhuac.setOpaque(false);
订单查询面板 this.dingdanc.setOpaque(false);
货物更新面板 this.huowug.setOpaque(false);
供应商更新面板 this.gongyingshangg.setOpaque(false);
鲜花更新面板 this.xianhuag.setOpaque(false);
提醒登录面板 this.meidenglu.setOpaque(false);
设置背景public void setBack(){
登录面板具体设置public void dengLuPanel(){
管理框架的菜单设置public void operationmenu(){
事件监听public void actionPerformed(ActionEvent event){ 总框架的重新构建 public void rebuild(){
供应商查询的面板具体设置 public class Gongyingshangc
供应商的更新面板设置 public class Gongyingshangg
鲜花查询面板的具体设置 public class Xianhuac
鲜花更新面板的具体设置 public class Xianhuag
货物更新面板的具体设置 public class Huowug
顾客查询面板的具体设置 public class Gukec
订单查询面板的具体设置 public class Dingdanc 4.设计结果
代码
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement; import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Random;
import javax.swing.BorderFactory; import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
//管理框架
@SuppressWarnings("serial")
public class FlowerManage extends JFrame implements ActionListener { private int flag=0;
private Connection con=null;
private Statement st=null;
private PreparedStatement p=null;
private ResultSet re=null;
private static String DBDriverStr = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static String DBUrl;
//登录面板
private JPanel pdenglu=new JPanel();
private String s;
private JLabel ldenglu=new JLabel("管理员登录");
private JLabel lyonghuming=new JLabel("用户名");
private JTextField tyonghuming=new JTextField();
private JLabel lmima=new JLabel("密码");
private JTextField tmima=new JTextField();
private JLabel lyanzhengma=new JLabel("验证码");
private JTextField tyanzhengma=new JTextField();
private JLabel tjianyanshu=new JLabel();
private JButton bchange=new JButton("看不清,换一张");
private JLabel tixingjian=new JLabel();
private JButton bdenglu=new JButton("登录");
private JButton btuichu=new JButton("退出");
private Gongyingshangc gongyingshangc=new Gongyingshangc(); private Xianhuac xianhuac=new Xianhuac();
private Gukec gukec=new Gukec();
private Dingdanc dingdanc=new Dingdanc();
private Gongyingshangg gongyingshangg=new Gongyingshangg(); private Xianhuag xianhuag=new Xianhuag();
private Huowug huowug=new Huowug();
private Tongzhi meidenglu=new Tongzhi("请先登录");
JMenuBar mymenu=new JMenuBar();
JMenu[] menu={
new JMenu("登陆"),
new JMenu("查询"),
new JMenu("更新"),
new JMenu("退出")
};
JMenuItem[] dengluMenuItem={
new JMenuItem("登陆管理界面"),
};
JMenuItem[] checkMenuItem={
new JMenuItem("供应商信息查询"),
new JMenuItem("顾客信息查询"),
new JMenuItem("订单信息查询"),
new JMenuItem("鲜花信息查询")
};
JMenuItem[] gengxinMenuItem={
new JMenuItem("供应商信息更新"),
new JMenuItem("鲜花信息更新"),
new JMenuItem("货物信息更新")
};
JMenuItem[] tuichuMenuItem={
new JMenuItem("退出管理界面")
};
public FlowerManage(){
this.setSize(500, 500);
this.setTitle("网上鲜花后台管理");
this.setBack();
this.operationmenu();
this.setJMenuBar(mymenu);
this.getContentPane().setLayout(null);
sevenoperation();
}
//所有面板
public void sevenoperation(){
//登录面板
this.dengLuPanel();
this.pdenglu.setOpaque(false);
pdenglu.setBounds(25,25,400,400);
this.getContentPane().add(pdenglu);
this.pdenglu.setLayout(null);
this.pdenglu.setVisible(false);
//供应商查询面板
this.gongyingshangc.setOpaque(false);
gongyingshangc.setBounds(25,25,400,400); this.getContentPane().add(gongyingshangc);
this.gongyingshangc.setLayout(null);
this.gongyingshangc.setVisible(false);
//顾客查询面板
this.gukec.setOpaque(false);
gukec.setBounds(25,25,400,400);
this.getContentPane().add(gukec);
this.gukec.setLayout(null);
this.gukec.setVisible(false);
//鲜花查询面板
this.xianhuac.setOpaque(false);
xianhuac.setBounds(25,25,400,400);
this.getContentPane().add(xianhuac);
this.xianhuac.setLayout(null);
this.xianhuac.setVisible(false);
//订单查询面板
this.dingdanc.setOpaque(false);
dingdanc.setBounds(25,25,400,400);
this.getContentPane().add(dingdanc);
this.dingdanc.setLayout(null);
this.dingdanc.setVisible(false);
//货物更新面板
this.huowug.setOpaque(false);
huowug.setBounds(25,25,400,400);
this.getContentPane().add(huowug);
this.huowug.setLayout(null);
this.huowug.setVisible(false);
//供应商更新面板
this.gongyingshangg.setOpaque(false);
gongyingshangg.setBounds(25,25,400,400);
this.getContentPane().add(gongyingshangg);
this.gongyingshangg.setLayout(null);
this.gongyingshangg.setVisible(false);
//鲜花更新面板
this.xianhuag.setOpaque(false);
xianhuag.setBounds(25,25,400,400);
this.getContentPane().add(xianhuag);
this.xianhuag.setLayout(null);
this.xianhuag.setVisible(false);
//提醒登录面板
this.meidenglu.setOpaque(false);
meidenglu.setBounds(100,100,200,200);
this.getContentPane().add(meidenglu);
this.meidenglu.setLayout(null);
this.meidenglu.setVisible(false);
}
//设置背景
public void setBack(){
((JPanel)this.getContentPane()).setOpaque(false);
ImageIcon img = new ImageIcon("F://workspace for book//BB//src//1.jpg");
JLabel background = new JLabel(img);
this.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
background.setBounds(0, 0,img.getIconWidth(), img.getIconHeight());
}
//登录面板具体设置
public void dengLuPanel(){
this.pdenglu.add(ldenglu);
ldenglu.setBounds(150,25,200,50);
ldenglu.setFont(new Font("隶书",Font.BOLD,22));
this.pdenglu.add(lyonghuming);
lyonghuming.setBounds(50,100,50,30);
this.pdenglu.add(tyonghuming);
tyonghuming.setBounds(150,100,200,30);
this.pdenglu.add(lmima);
lmima.setBounds(50,150,50,30);
this.pdenglu.add(tmima);
tmima.setBounds(150,150,200,30);
this.pdenglu.add(lyanzhengma);
lyanzhengma.setBounds(50,200,50,30);
this.pdenglu.add(tyanzhengma);
tyanzhengma.setBounds(150,200,60,30);
this.pdenglu.add(tjianyanshu);
tjianyanshu.setBounds(220,200,40,30);
this.pdenglu.add(bchange);
bchange.setBounds(270,200,130,30);
bchange.setBackground(Color.PINK);
this.bchange.addActionListener(this);
this.pdenglu.add(tixingjian);
tixingjian.setBounds(110,250,200,30);
this.pdenglu.add(bdenglu);
bdenglu.setBounds(100,300,100,30);
this.bdenglu.addActionListener(this);
this.pdenglu.add(btuichu);
btuichu.setBounds(250,300,100,30);
this.btuichu.addActionListener(this);
this.tjianyanshu.setOpaque(true);
this.tjianyanshu.setBorder(BorderFactory.createLineBorder(Color.pink)); this.tjianyanshu.setBackground(Color.pink);
this.tjianyanshu.setText("47258");
}
//管理框架的菜单设置
public void operationmenu(){
for(int i=0;i<dengluMenuItem.length;i++){
menu[0].add(dengluMenuItem[i]);
dengluMenuItem[i].addActionListener(this);
}
for(int i=0;i<checkMenuItem.length;i++){
menu[1].add(checkMenuItem[i]);
checkMenuItem[i].addActionListener(this);
}
for(int i=0;i<gengxinMenuItem.length;i++){ menu[2].add(gengxinMenuItem[i]);
gengxinMenuItem[i].addActionListener(this);
}
for(int i=0;i<tuichuMenuItem.length;i++){
menu[3].add(tuichuMenuItem[i]);
tuichuMenuItem[i].addActionListener(this);
}
for(int i=0;i<menu.length;i++){
mymenu.add(menu[i]);
}
}
//事件监听
public void actionPerformed(ActionEvent event){ s=event.getActionCommand();
Random r=new Random();
int a;
String str="";
if(flag==1){
this.xianhuac.setVisible(false);
this.dingdanc.setVisible(false);
this.gukec.setVisible(false);
this.gongyingshangg.setVisible(false);
this.xianhuag.setVisible(false);
this.huowug.setVisible(false);
this.gongyingshangg.setVisible(false);
tyonghuming.setText("");
tmima.setText("");
tyanzhengma.setText("");
for(int i=0;i<=4;i++){
a=r.nextInt(9);
str=String.valueOf(a)+str;
}
this.tjianyanshu.setText(str);
}
if(s.equals("登陆管理界面")==true){
this.meidenglu.setVisible(false);
this.pdenglu.setVisible(true);
}
if(s.equals("看不清,换一张")==true){
this.tyanzhengma.setText("");
for(int i=0;i<=4;i++){
a=r.nextInt(9);
str=String.valueOf(a)+str;
}
this.tjianyanshu.setText(str);
}
else if(s.equals("登录")==true){
if(tyanzhengma.getText().equals(tjianyanshu.getText())==false){
this.tixingjian.setText("验证码不正确,请重新输入!");
this.tyanzhengma.setText("");
for(int i=0;i<=4;i++){
a=r.nextInt(9);
str=String.valueOf(a)+str;
}
this.tjianyanshu.setText(str);
}
else{
DBUrl= "jdbc:sqlserver://localhost:1433;" + "databaseName=huadian;user="+tyonghuming.getText()+";password="+tmima.getText( )+";";
try{
Class.forName(DBDriverStr);
con=DriverManager.getConnection(DBUrl);
}
catch(ClassNotFoundException e){
System.err.println("ClassNotFoundException:
"+e.getMessage());
}
catch(SQLException e){
JFrame tishi=new JFrame("提示");
tishi.setSize(400, 100);
JLabel tishil=new JLabel("您的用户名或密码不正确,请重新输入");
tishi.getContentPane().add(tishil);
tishi.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tishi.setVisible(true);
System.out.println("SQLException: "+e.getMessage());
rebuild();
}
flag=1;
this.pdenglu.setVisible(false);
}
}
else if(s.equals("供应商信息查询")==true){ this.xianhuac.setVisible(false);
this.dingdanc.setVisible(false);
this.gukec.setVisible(false);
this.gongyingshangg.setVisible(false);
this.xianhuag.setVisible(false);
this.huowug.setVisible(false);
if(flag==0){
this.meidenglu.setVisible(true);
}
else{
pdenglu.setVisible(false);
this.gongyingshangc.setVisible(true);
}
}
else if(s.equals("退出管理界面")==true){ this.dispose();
}
else if(s.equals("顾客信息查询")==true){ this.xianhuac.setVisible(false);
this.dingdanc.setVisible(false);
this.gongyingshangc.setVisible(false);
this.gongyingshangg.setVisible(false);
this.xianhuag.setVisible(false);
this.huowug.setVisible(false);
this.meidenglu.setVisible(true);
}
else{
pdenglu.setVisible(false);
this.gukec.setVisible(true);
}
}
else if(s.equals("鲜花信息查询")==true){ this.gongyingshangc.setVisible(false);
this.dingdanc.setVisible(false);
this.gukec.setVisible(false);
this.gongyingshangg.setVisible(false);
this.xianhuag.setVisible(false);
this.huowug.setVisible(false);
if(flag==0){
pdenglu.setVisible(false);
this.meidenglu.setVisible(true);
}
else{
this.xianhuac.setVisible(true);
}
}
else if(s.equals("订单信息查询")==true){ this.xianhuac.setVisible(false);
this.gongyingshangc.setVisible(false);
this.gukec.setVisible(false);
this.gongyingshangg.setVisible(false);
this.xianhuag.setVisible(false);
this.huowug.setVisible(false);
this.meidenglu.setVisible(true);
}
else{
pdenglu.setVisible(false);
this.dingdanc.setVisible(true);
}
}
else if(s.equals("供应商信息更新")==true){ this.xianhuac.setVisible(false);
this.dingdanc.setVisible(false);
this.gongyingshangc.setVisible(false);
this.gukec.setVisible(false);
this.xianhuag.setVisible(false);
this.huowug.setVisible(false);
if(flag==0){
this.meidenglu.setVisible(true);
}
else{
pdenglu.setVisible(false);
this.gongyingshangg.setVisible(true);
}
}
else if(s.equals("鲜花信息更新")==true){ this.xianhuac.setVisible(false);
this.dingdanc.setVisible(false);
this.gukec.setVisible(false);
this.gongyingshangg.setVisible(false);
this.gongyingshangc.setVisible(false);
this.huowug.setVisible(false);
if(flag==0){
this.meidenglu.setVisible(true);
}
else{
pdenglu.setVisible(false);
this.xianhuag.setVisible(true);
}
}
else if(s.equals("货物信息更新")==true){
this.xianhuac.setVisible(false);
this.dingdanc.setVisible(false);
this.gukec.setVisible(false);
this.gongyingshangg.setVisible(false);
this.xianhuag.setVisible(false);
this.gongyingshangc.setVisible(false);
if(flag==0){
this.meidenglu.setVisible(true);
}
else{
pdenglu.setVisible(false);
this.huowug.setVisible(true);
}
}
}
public void rebuild(){
this.dispose();
FlowerManage flowerManage1=new FlowerManage();
flowerManage1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); flowerManage1.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
FlowerManage flowerManage=new FlowerManage();
flowerManage.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
flowerManage.setVisible(true);
}
//供应商查询的面板具体设置
@SuppressWarnings("serial")
public class Gongyingshangc extends JPanel implements ActionListener{ private String s1;
private String no;
private String address;
private String changming;
private String tel;
private JLabel gc=new JLabel("供应商信息查询");
private JButton tjcx=new JButton("条件查询");
private JButton qbcx=new JButton("全部查询");
private JPanel tj=new JPanel();
private JLabel lgb1=new JLabel("供应商编号");
private JTextField tgb=new JTextField();
private JButton cx=new JButton("查询");
private JLabel gx=new JLabel("供应商基本详情");
private JButton gybc=new JButton("供应查询");
private JLabel gb2=new JLabel("供应商编号");
private JLabel gb3=new JLabel();
private JLabel cm1=new JLabel("供应商名称");
private JLabel cm2=new JLabel();
private JLabel dz1=new JLabel("地址");
private JLabel dz2=new JLabel();
private JLabel lxdh1=new JLabel("联系电话");
private JComboBox year=new JComboBox();
private JComboBox month=new JComboBox();
private JComboBox day=new JComboBox();
private JLabel lxdh2=new JLabel();
private JLabel gyb=new JLabel("供应商供应表");
private DefaultTableModel mod1=new DefaultTableModel(9,4); private JTable gb1=new JTable(mod1);
private JPanel qb=new JPanel();
private JLabel gyjb=new JLabel("全部供应商基本表");
private JButton qbcg=new JButton("全部供应查询");
private DefaultTableModel mod2=new DefaultTableModel(7,4); private JTable gyb1=new JTable(mod2);
private JLabel gygh=new JLabel("全部供应商供货单");
private DefaultTableModel mod3=new DefaultTableModel(7,5); private JTable gyb2=new JTable(mod3);
private JComboBox year1=new JComboBox();
private JComboBox month1=new JComboBox();
private JComboBox day1=new JComboBox();
public void panel1(){
this.tj.add(lgb1);
lgb1.setBounds(10,0,80,20);
this.tj.add(tgb);
tgb.setBounds(95,0,120,20);
this.tj.add(cx);
cx.setBounds(250,0,80,20);
cx.addActionListener(this);
this.tj.add(gx);
gx.setBounds(10,25,300,30);
gx.setFont(new Font("隶书",Font.BOLD,22));
this.tj.add(gb2);
gb2.setBounds(10,58,90,20);
this.tj.add(gb3);
gb3.setBounds(110,58,90,20);
this.tj.add(cm1);
cm1.setBounds(210,58,90,20);
this.tj.add(cm2);
cm2.setBounds(310,58,90,20);
this.tj.add(dz1);
dz1.setBounds(10,80,90,20);
this.tj.add(dz2);
dz2.setBounds(110,80,90,20);
this.tj.add(lxdh1);
lxdh1.setBounds(210,80,90,20);
this.tj.add(lxdh2);
lxdh2.setBounds(310,80,90,20);
this.tj.add(year);
year.setBounds(220,105,80,20);
year.addItem("2012年");
year.addItem("2013年");
year.addItem("2014年");
this.tj.add(month);
month.setBounds(300,105,50,20);
for(int i=1;i<=12;i++){
month.addItem(String.valueOf(i)+"月");
}
this.tj.add(day);
day.setBounds(350,105,50,20);
for(int i=1;i<=30;i++){
day.addItem(String.valueOf(i)+"日");
}
this.tj.add(gyb);
gyb.setBounds(150,130,100,25);
this.tj.add(gybc);
gybc.setBounds(300,130,100,25);
gybc.addActionListener(this);
this.tj.add(gb1);
gb1.setBounds(10,160,380,190);
mod1.setValueAt("鲜花编号", 0,0 );
mod1.setValueAt("鲜花名", 0,1 );
mod1.setValueAt("数量", 0,2 );
mod1.setValueAt("金额", 0,3 );
gb1.setOpaque(false);
this.tj.setOpaque(false);
this.tj.setVisible(false);
this.tj.setLayout(null);
this.tj.setBounds(0,50,400,350);
}
public void panel2(){
this.qb.add(gyjb);
gyjb.setBounds(10,0,200,28);
gyjb.setFont(new Font("隶书",Font.BOLD,22));
mod2.setValueAt("供应商编号", 0,0 );
mod2.setValueAt("供应商名", 0,1 );
mod2.setValueAt("地址", 0,2 );
mod2.setValueAt("联系电话", 0,3 );
this.qb.add(gyb1);
gyb1.setBounds(10,30,380,115);
gyb1.setOpaque(false);
this.qb.add(gygh);
gygh.setBounds(10,150,190,30);
gygh.setFont(new Font("隶书",Font.BOLD,22));
this.qb.add(year1);
year1.setBounds(220,180,80,25);
year1.addItem("2012年");
year1.addItem("2013年");
year1.addItem("2014年");
this.qb.add(month1);
month1.setBounds(300,180,50,25);
for(int i=1;i<=12;i++){
month1.addItem(String.valueOf(i)+"月");
}
this.qb.add(day1);
day1.setBounds(350,180,50,25);
for(int i=1;i<=30;i++){
day1.addItem(String.valueOf(i)+"日");
}
mod3.setValueAt("供应商编号", 0,0 );
mod3.setValueAt("鲜花编号", 0,1 );
mod3.setValueAt("鲜花名", 0,2 );
mod3.setValueAt("数量", 0,3 );
mod3.setValueAt("金额", 0,4);
this.qb.add(gyb2);
gyb2.setBounds(10,205,380,110);
gyb2.setOpaque(false);
this.qb.add(qbcg);
qbcg.setBounds(310,320,100,25);
qbcg.addActionListener(this);
this.qb.setOpaque(false);
this.qb.setVisible(false);
this.qb.setLayout(null);
this.qb.setBounds(0,50,400,350);
}
public Gongyingshangc(){
this.add(gc);
gc.setFont(new Font("隶书",Font.BOLD,22));
gc.setBounds(100, 0, 300,25);
this.add(tjcx);
tjcx.setBounds(200,25,95,20);
tjcx.addActionListener(this);
this.add(qbcx);
qbcx.setBounds(300,25,100,20);
qbcx.addActionListener(this);
this.add(tj);
panel1();
this.add(qb);
panel2();
}
public void actionPerformed(ActionEvent event){ s1=event.getActionCommand();
try{
if(s1.equals("条件查询")==true){
qb.setVisible(false);
tj.setVisible(true);
}
else if(s1.equals("全部查询")==true){
tj.setVisible(false);
qb.setVisible(true);
st=con.createStatement();
re=st.executeQuery("select * from supplier");
int i=1;
while(re.next()){
mod2.setValueAt(re.getString("Suno"),i,0 );
mod2.setValueAt(re.getString("Suname"),i,1 );
mod2.setValueAt(re.getString("Suaddress"),i,2);
mod2.setValueAt(re.getString("Sutel"),i,3 );
i++;
}
}
else if(s1.equals("查询")==true){
p=con.prepareStatement("select * from supplier where Suno=?");
p.setString(1,tgb.getText());
re=p.executeQuery();
while(re.next()){
no=re.getString("Suno");
gb3.setText(no);
changming=re.getString("Suname");
cm2.setText(changming);
address=re.getString("Suaddress");
dz2.setText(address);
tel=re.getString("Sutel");
lxdh2.setText(tel);
}
}
else if(s1.equals("供应查询")==true){
p=con.prepareStatement("select
Flower.Flno,Flower.Flname,Supqulity,Flretailprice from Supply,flower where Suno=?
and Suptime=? and Supply.Flno=Flower.Flno");
p.setString(1,tgb.getText());
p.setString(2,(String)year.getSelectedItem()+month.getSelectedItem()+day.g etSelectedItem());
re=p.executeQuery();
int i=1;
int shuliang;
while(re.next()){
mod1.setValueAt(re.getString("Flno"),i,0 );
mod1.setValueAt(re.getString("Flname"),i,1 );
shuliang=re.getInt("Supqulity");
mod1.setValueAt(shuliang,i,2);
mod1.setValueAt(re.getDouble("Flretailprice")*shuliang,i,3 );
i++;
}
}
else if(s1.equals("全部供应查询")==true){
p=con.prepareStatement("select
Suno,Flower.Flno,Flower.Flname,Supqulity,Flretailprice from Supply,flower where Suptime=? and Supply.Flno=Flower.Flno");
p.setString(1,(String)year1.getSelectedItem()+month1.getSelectedItem()+day 1.getSelectedItem());
re=p.executeQuery();
int i=1;
int shuliang;
while(re.next()){
mod3.setValueAt(re.getString("Suno"),i,0 );
mod3.setValueAt(re.getString("Flno"),i,1 );
mod3.setValueAt(re.getString("Flname"),i,2);
shuliang=re.getInt("Supqulity");
mod3.setValueAt(shuliang,i,3);
mod3.setValueAt(re.getDouble("Flretailprice")*shuliang,i,4 );
i++;
}
}
}
catch(SQLException e){
e.printStackTrace();
}
}
}
//供应商的更新面板设置
@SuppressWarnings("serial")
public class Gongyingshangg extends JPanel implements ActionListener{ private String s1;
private String no;
private String name;
private String address;
private String changming;
private String tel="";
private JLabel lgysglt=new JLabel("供应商管理");
private JLabel lgysbht=new JLabel("供应商编号");
private JTextField tgysbht=new JTextField();
private JLabel lcsmt=new JLabel("厂商名");
private JTextField tcsmt=new JTextField();
private JLabel ldizhit=new JLabel("地址");
private JTextField tdizhit=new JTextField();
private JLabel llianxidianhuat=new JLabel("联系电话"); private JTextField tlianxidianhuat=new JTextField(); private JButton tianjia=new JButton("添加");
private JLabel gysglsx=new JLabel("修改与删除");
private JLabel lgysbhc=new JLabel("供应商编号");
private JTextField tgysbhc=new JTextField();
private JButton chaxun=new JButton("查询");
private JLabel lgysbhc1=new JLabel("供应商编号"); private JTextField tgysbhc2=new JTextField();
private JLabel lcsmc1=new JLabel("厂商名");
private JTextField tcsmc2=new JTextField();
private JLabel ldizhic1=new JLabel("地址");
private JTextField tdizhic2=new JTextField();
private JLabel llianxidianhuac1=new JLabel("联系电话"); private JTextField tlianxidianhuac2=new JTextField(); private JButton xiugai1=new JButton("修改");
private JButton shanchu1=new JButton("删除");
//Tongzhi xiugai=new Tongzhi("修改成功");
//Tongzhi shanchu=new Tongzhi("删除成功");
public Gongyingshangg(){
this.add(lgysglt);
lgysglt.setFont(new Font("隶书",Font.BOLD,22));
lgysglt.setBounds(150, 0, 200,25);
this.add(lgysbht);
lgysbht.setBounds(0,70,100,25);
this.add(tgysbht);
tgysbht.setBounds(100,70,100,25);
this.add(lcsmt);
lcsmt.setBounds(210,70,60,25);
this.add(tcsmt);
tcsmt.setBounds(270,70,100,25);
this.add(ldizhit);
ldizhit.setBounds(0,105,100,25);
this.add(tdizhit);
tdizhit.setBounds(100,105,100,25);
this.add(llianxidianhuat);
llianxidianhuat.setBounds(210,105,60,25);
this.add(tlianxidianhuat);
tlianxidianhuat.setBounds(270,105,100,25);
this.add(tianjia);
tianjia.setBounds(300,135,80,25);
tianjia.addActionListener(this);
/*this.add(tianjia1);
this.tianjia1.setOpaque(false);
this.tianjia1.setVisible(false);
tianjia1.setBounds(0, 0, 200, 200);*/
this.add(gysglsx);
gysglsx.setFont(new Font("隶书",Font.BOLD,22));
gysglsx.setBounds(20, 168, 200,33);
this.add(lgysbhc);
lgysbhc.setBounds(50, 200, 100,25);
this.add(tgysbhc);
tgysbhc.setBounds(160, 200, 140,25);
this.add(chaxun);
chaxun.setBounds(320, 200, 70,25);
chaxun.addActionListener(this);
this.add(lgysbhc1);
lgysbhc1.setBounds(50, 240,100,25);
this.add(tgysbhc2);
tgysbhc2.setBounds(160, 240, 140,25);
this.add(lcsmc1);
lcsmc1.setBounds(50, 270, 100,25);
this.add(tcsmc2);
tcsmc2.setBounds(160, 270, 140,25);
this.add(ldizhic1);
ldizhic1.setBounds(50, 300, 100,25);
this.add(tdizhic2);
tdizhic2.setBounds(160, 300, 140,25);
this.add(llianxidianhuac1);
llianxidianhuac1.setBounds(50, 330, 100,25);
this.add(tlianxidianhuac2);
tlianxidianhuac2.setBounds(160, 330, 140,25);
this.add(xiugai1);
xiugai1.setBounds(100, 360, 90,25);
xiugai1.addActionListener(this);
this.add(shanchu1);
shanchu1.setBounds(250, 360, 90,25);
shanchu1.addActionListener(this);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
g.drawLine(5, 165, 395, 165);
}
public void actionPerformed(ActionEvent event){ s1=event.getActionCommand();
try{
if(s1.equals("添加")==true){
p=con.prepareStatement("insert into supplier (Suno,Suname,Suaddress,Sutel) values(?,?,?,?)");
p.setString(1,tgysbht.getText());
p.setString(2,tcsmt.getText());
p.setString(3,tdizhit.getText());
p.setString(4,tlianxidianhuat.getText());
p.executeUpdate();
tgysbht.setText("");
tcsmt.setText("");
tdizhit.setText("");
tlianxidianhuat.setText("");
}
else if(s1.equals("查询")==true){
p=con.prepareStatement("select * from supplier where Suno=?");
p.setString(1,tgysbhc.getText());
re=p.executeQuery();
while(re.next()){
no=re.getString("Suno");
tgysbhc2.setText(no);
changming=re.getString("Suname");
tcsmc2.setText(changming);
address=re.getString("Suaddress");
tdizhic2.setText(address);
tel=re.getString("Sutel");
tlianxidianhuac2.setText(tel);
}
}
else if(s1.equals("删除")==true){
p=con.prepareStatement("delete from supplier where Suno=?");
p.setString(1,tgysbhc.getText());
p.executeUpdate();
tgysbhc.setText("");
tgysbhc2.setText("");
tcsmc2.setText("");
tdizhic2.setText("");
tlianxidianhuac2.setText("");
}
else if(s1.equals("修改")==true){
if(tcsmc2.getText().equals(name)==false){
p=con.prepareStatement("update supplier set Suname=? where Suno=?");
p.setString(1,tcsmc2.getText());
p.setString(2,tgysbhc2.getText());
p.executeUpdate();
}
else if(tdizhic2.getText().equals(address)==false){
p=con.prepareStatement("update supplier set Suaddress=? where Suno=?");
p.setString(1,tdizhic2.getText());
p.setString(2,tgysbhc2.getText());
p.executeUpdate();
}
else if(tlianxidianhuac2.getText().equals(tel)==false){
p=con.prepareStatement("update supplier set Sutel=? where Suno=?");
p.setString(1,tlianxidianhuac2.getText());
p.setString(2,tgysbhc2.getText());。