零件交易中心管理系统.doc_第1页
零件交易中心管理系统.doc_第2页
零件交易中心管理系统.doc_第3页
零件交易中心管理系统.doc_第4页
零件交易中心管理系统.doc_第5页
已阅读5页,还剩41页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

湖南工学院 数据库原理 课程设计报告 题目名称: 零件交易中心管理系统专业: 计算机科学与技术 班级: 计科1203班 学号: 1220340312 姓名: 唐寅 指导老师: 陈利平 完成日期: 2014年12月26日 摘 要 现代电子计算机技术的飞速发展,离不开人类科技知识的积累,离不开许许多多热衷于此并呕心沥血的科学家门的探索,正是这一代代的积累才构筑了今天的“信息大厦”。各种各样的软件也很多了,各种各样的需求也很,人们也在不断改进各种软件,掌握1个好的算法是非常的重要,也使我对所学的知识进行了巩固。本课程设计主要是完成一个零件交易管理系统。本系统以一零件贸易公司为对象,为起开发一个简单的交易系统,不同用户之间实现不同的操作。本系统对象主要包括交易员,顾客以及供应商,实现这三个对象的不同功能。本系统选用eclipse 作为开发工具,DBMS选用sql sever2008。只要在所用系统的机子上装上eclipse ,jdk 和基本的微软的办公软件就可以使用。关键词:计算机 零件交易 目录1.需求分析1.1系统分析- 31.2系统目标- 31.3系统功能结构- 42.数据库设计 - 52.1 数据库概念设计- 52.2 数据库逻辑设计- 62.3 数据库物理设计- 73.程序模块设计- 83.1 功能需求- 83.2 用户界面设计- 8 3.3零件交易中心管理系统程序设计(部分代码)-11 3.3.1登陆界面-11 3.3.2系统主页-17 3.3.3查询 -21 3.3.4更新 -29 3.3.5交易 -353.4 调试及运行结果 -38 3.4.1登陆界面 -38 3.4.2主页 -39 3.4.3查询 -39 3.4.4更新 -40 3.4.5交易 -41 4.总结 -42 5.参考文献 -43 1 需求分析 在当今中国市场经济下,零件交易成为许多公司的重要一部分,传统的交易采用“一手交钱,一手交货”方式,这不仅费时费力,而且容易出错。通过零件交易中心系统,供应商和顾客中间只需点击鼠标,就可以申请并完成交易,既提高工作效率,又节省时间,为各公司间的业务有条不絮的进行发挥了重要作用。1.1系统分析1)零件交易中心管理系统主要提供顾客和供应商之间完成零件交易的功能,其中包括供应商信息、顾客信息以及零件信息。此系统可以让供应商增加、删除和修改所提供的零件产品,还可以让顾客增加、删除和修改所需求的零件。交易员可以利用顾客提出的需求信息和供应商提出的供应信息来提出交易的建议,由供应商和顾客进行确认后即完成这笔交易。2) 交易员充当管理员的角色。1.2 系统目标1) 操作简单方便,界面简洁大方2) 方便快捷的交易功能3) 快速查询供应商,顾客和零件的相关信息4) 系统运行稳定,安全可靠1.3 系统功能结构交易员登陆更新 交 易 退出查询零件顾客,零件顾客需求供应商供应顾客供应商交易员确认是否交易删除增加修改删除增加修改2. 数据库设计2.1 数据库概念设计数据库需要表述的信息有以下几种:(1)零件信息(2)供应商信息(3)顾客信息 图1供应商和零件之间的联系(供应) E/R模型(4)交易(三元联系)可以用E/R模型表述该模型的设计,E/R图如图A7所示。 图2 全局E/R模型2.2 数据库逻辑设计通过E/R模型到关系模型的转化,可以得到如下关系模式:(1)零件实体集转换为 关系:spare(零件号,零件重量, 颜色,简介)(2)供应商实体集转换为 关系sup(供应商号,供应商名,供应商地址,供应商电话,简介)(3)顾客实体集转换为 关系Cus(顾客号,顾客名,顾客地址,顾客电话)(4)供应联系转换为 关系Sup_inform(供应商号,零件号,供应量)(5)顾客需求联系转换为 关系cus_inform(顾客号,零件号,需求量)(6)交易员联系转换为 关系bou_man(交易员姓名,交易员号,密码)每个关系模式的主键码都用下划线标出。2.3 数据库物理设计1用SQL实现设计Microsoft SQL Server 2008实现该设计的环境为1) 建立sup表create table sup(供应商号 char(10) primary key,供应商名 char(10) unique,供应商地址 varchar(50),供应商电话 char(10),简介 char(20);2).建立cus表create table cus(顾客号 char(10) primary key,顾客名 char(10),顾客地址 varchar(50),顾客电话 char(10),foreign key (顾客号) references cus(顾客号);3).建立spare表create table spare(零件号 char(10) primary key,零件名 char(10),重量 smallint,颜色 char(10),零件简介 char(50),foreign key (零件号) references spare(零件号),);4).建立sup_inform表create table sup_inform(供应商号 char(10),零件号 char(10),供应量 smallint,primary key(供应商号,零件号),foreign key (供应商号) references sup(供应商号),foreign key (零件号) references spare(零件号),);5).建立cus_inform表create table cus_inform(顾客号 char(10),零件号 char(10),需求量 smallint,primary key(顾客号,零件号),foreign key (顾客号) references cus(顾客号),foreign key (零件号) references spare(零件号),);6).建立bou_man表create table bou_man( 交易员姓名 char(20)primary key, 交易员号 char(10), 密码 char(6) );3.程序模块设计3.1 功能需求1. 交易员登陆界面2. 主页 包括查询,更新,交易三个功能块 1).查询界面 2). 更新包括供应信息和顾客需求信息的增加,修改和删除功能 3).交易界面3.2 用户界面设计 图3 交易员登录界面 图4 主页面 图5 查询界面 图6 更新界面 图7 交易界面3.3零件交易中心管理系统程序设计(部分代码)3.3.1登陆界面 进入此界面后,交易员可输入自己的交易员号和密码登录零件交易中心管理系统package com.ty.ui;import java.sql.*;public class 登陆 extends JFramepublic 登陆() /*createContents();setVisible(true);*/protected static Shell shell;private static Connection connection;private Text text;private Text text_1; static 登陆 mb; static 主页 m;/* * Launch the application. * param args */public static void main(String args) try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); System.out.println(数据库驱动程序注册成功!); String url =jdbc:sqlserver:/localhost:1433;DatabaseName=bourse; String user = 123; String password = 123456; connection = DriverManager.getConnection(url, user, password); System.out.println(数据库连接成功); catch(ClassNotFoundException cnfex) System.out.println(装载驱动程序失败);cnfex.printStackTrace();System.exit(1);catch(SQLException sqlex)System.out.println(连接数据库失败);sqlex.printStackTrace();System.exit(1);try 登陆 window = new 登陆();window.open(); catch (Exception e) e.printStackTrace();/* * Open the window. */public void open() Display display = Display.getDefault();createContents();shell.open();shell.layout();while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep();private void Denglu()String str0 = text.getText().trim(); String str1 = text_1.getText().trim(); if(str0.equals() | str1.equals() ) MessageBox m = new MessageBox(shell); m.setText(提示); m.setMessage(请输入正确的信息); m.open(); return; else try Statement statement1 = connection.createStatement(); ResultSet resultSet1 = statement1.executeQuery(select * from bou_man); ResultSetMetaData rsm =resultSet1.getMetaData(); String string_1 = rsm.getColumnName(2); /获取表第一个字段名称 交易员号 String string_2 = rsm.getColumnName(3); /获取表第二个字段名称 密码 String sql_1 = select *+ from bou_man+ where +string_1 +=+str0+ and +string_2+=+str1+; Statement statement2 = connection.createStatement(); ResultSet resultSet2 = statement2.executeQuery(sql_1); if(!resultSet2.next() JOptionPane.showMessageDialog(null, string_1+或+string_2+错误, 提示, JOptionPane.ERROR_MESSAGE); return; /判断查询结果 m = new 主页(); m.open(); catch(SQLException sqlex) sqlex.printStackTrace(); /* * Create contents of the window. */protected void createContents() shell = new Shell();shell.setImage(SWTResourceManager.getImage(登陆.class, /icons/progress/ani/1.png);shell.setBackgroundImage(SWTResourceManager.getImage(登陆.class, /com/ty/ui/6D3881B2C7D1E53A859D998F5D606C52.jpg);shell.setSize(450, 300);shell.setText(SWT Application);text = new Text(shell, SWT.BORDER);text.setBounds(140, 85, 153, 26);text_1 = new Text(shell, SWT.BORDER | SWT.PASSWORD);text_1.setBounds(140, 125, 153, 23);Button btnNewButton = new Button(shell, SWT.NONE);btnNewButton.addSelectionListener(new SelectionAdapter() Overridepublic void widgetSelected(SelectionEvent e) Denglu(); );btnNewButton.setBounds(87, 178, 80, 27);btnNewButton.setText(u767Bu5F55);Button btnNewButton_1 = new Button(shell, SWT.NONE);btnNewButton_1.addSelectionListener(new SelectionAdapter() Overridepublic void widgetSelected(SelectionEvent e) System.exit(0););btnNewButton_1.setBounds(256, 178, 80, 27);btnNewButton_1.setText(u9000u51FA);Label lblNewLabel = new Label(shell, SWT.NONE);lblNewLabel.setBackgroundImage(SWTResourceManager.getImage(登陆.class, /com/ty/ui/6D3881B2C7D1E53A859D998F5D606C52.jpg);lblNewLabel.setFont(SWTResourceManager.getFont(微软雅黑, 15, SWT.NORMAL);lblNewLabel.setBounds(87, 26, 246, 27);lblNewLabel.setText(u6B22u8FCEu767Bu9646u96F6u4EF6u4EA4u6613u4E2Du5FC3u7CFBu7EDF);Label lblNewLabel_1 = new Label(shell, SWT.NONE);lblNewLabel_1.setBackgroundImage(SWTResourceManager.getImage(登陆.class, /com/ty/ui/6D3881B2C7D1E53A859D998F5D606C52.jpg);lblNewLabel_1.setFont(SWTResourceManager.getFont(微软雅黑, 12, SWT.NORMAL);lblNewLabel_1.setBounds(67, 84, 67, 23);lblNewLabel_1.setText(u4EA4u6613u5458u53F7);Label lblNewLabel_2 = new Label(shell, SWT.NONE);lblNewLabel_2.setBackgroundImage(SWTResourceManager.getImage(登陆.class, /com/ty/ui/6D3881B2C7D1E53A859D998F5D606C52.jpg);lblNewLabel_2.setFont(SWTResourceManager.getFont(微软雅黑, 12, SWT.NORMAL);lblNewLabel_2.setBounds(67, 125, 32, 23);lblNewLabel_2.setText(u5BC6u7801);3.3.2系统主页,分为四个按钮实现查询,更新,交易和退出四个功能 package com.ty.ui;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import javax.swing.JFrame;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.Label;import org.eclipse.wb.swt.SWTResourceManager;import org.eclipse.swt.events.SelectionAdapter;import org.eclipse.swt.events.SelectionEvent;public class 主页 extends JFramestatic JDBC m;private static Connection connection;public 主页() /*createContents();setVisible(true);*/protected Shell shell; /* * Launch the application. * param args */public static void main(String args) try 主页 window = new 主页();window.open(); catch (Exception e) e.printStackTrace();/* * Open the window. */public void open() Display display = Display.getDefault();createContents();shell.open();shell.layout();while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep();/* * Create contents of the window. */protected void createContents() shell = new Shell();shell.setBackgroundImage(SWTResourceManager.getImage(主页.class, /com/ty/ui/12DCF450B3FB9CAF40B0E65507486F0D.jpg);shell.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND);shell.setImage(SWTResourceManager.getImage(主页.class, /icons/progress/ani/2.png);shell.setSize(450, 300);shell.setText(u96F6u4EF6u4EA4u6613u4E2Du5FC3u7CFBu7EDF);Button btnNewButton = new Button(shell, SWT.NONE);btnNewButton.addSelectionListener(new SelectionAdapter() Overridepublic void widgetSelected(SelectionEvent e) /shell.setVisible(false);. try m = new JDBC();/m.open(); catch (SQLException e1) / TODO 自动生成的 catch 块e1.printStackTrace(););btnNewButton.setBounds(77, 86, 80, 27);btnNewButton.setText(u67E5u8BE2);Button btnNewButton_1 = new Button(shell, SWT.NONE);btnNewButton_1.addSelectionListener(new SelectionAdapter() Overridepublic void widgetSelected(SelectionEvent e) 交易 m = new 交易();m.open(););btnNewButton_1.setBounds(77, 172, 80, 27);btnNewButton_1.setText(u4EA4u6613);Button btnNewButton_2 = new Button(shell, SWT.NONE);btnNewButton_2.addSelectionListener(new SelectionAdapter() Overridepublic void widgetSelected(SelectionEvent e) 更新 m = new 更新();m.open(););btnNewButton_2.setBounds(290, 86, 80, 27);btnNewButton_2.setText(u66F4u65B0u6570u636E);Button btnNewButton_3 = new Button(shell, SWT.NONE);btnNewButton_3.addSelectionListener(new SelectionAdapter() Overridepublic void widgetSelected(SelectionEvent e) System.exit(0););btnNewButton_3.setBounds(290, 172, 80, 27);btnNewButton_3.setText(u9000u51FA);Label lblNewLabel = new Label(shell, SWT.NONE);lblNewLabel.setBackgroundImage(SWTResourceManager.getImage(主页.class, /com/ty/ui/12DCF450B3FB9CAF40B0E65507486F0D.jpg);lblNewLabel.setFont(SWTResourceManager.getFont(微软雅黑, 20, SWT.NORMAL);lblNewLabel.setBounds(164, 32, 108, 35);lblNewLabel.setText(u6B22u8FCEu8BBFu95EE); 3.3.3查询 查找sql数据库中各个表的信息 代码如下package com.ty.ui;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.MessageBox;import org.eclipse.swt.widgets.Shell;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.SWT;import org.eclipse.swt.widgets.Text;import java.awt.*;import java.awt.event.*;import java.util.*;import java.sql.*;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextArea;import javax.swing.JTextField;import org.eclipse.swt.widgets.Group;import javax.swing.UIManager;public class JDBC extends JFrameprotected Shell shell;private static Connection connection; /数据库变量定义private Statement statement;/private Statement stmt;private ResultSet resultSet;/private ResultSet resultSet1;private JTable table;private JTextArea area;private JTextField text;private JTextField text1;private JButton button;/private JButton button1;public JDBC() throws SQLException setBackground(UIManager.getColor(InternalFrame.inactiveBorderColor);createContents();setVisible(true);/* * Launch the application. * param args */public static void main(String args) try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); System.out.println(数据库驱动程序注册成功!); String url =jdbc:sqlserver:/localhost:1433;DatabaseName=bourse; String user = 123; String password = 123456; connection = DriverManager.getConnection(url, user, password); System.out.println(数据库连接成功); catch(ClassNotFoundException cnfex) System.out.println(装载驱动程序失败);cnfex.printStackTrace();System.exit(1);catch(SQLException sqlex)System.out.println(连接数据库失败);sqlex.printStackTrace();System.exit(1);try final JDBC window = new JDBC();window.addWindowFocusListener(new WindowAdapter() public void windowclosing(WindowEvent e) window.disconnect();System.exit(0););/window.open(); catch (Exception e) e.printStackTrace();/* * Open the window. * throws SQLException */public void open() throws SQLException Display display = Display.getDefault();createContents();shell.open();shell.layout();while (!shell.isDisposed() if (!display.readAndDispatch() display.sleep(); /* * Create contents of the window. */protected void createContents() throws SQLException/String test = select * from ; text = new JTextField(30); text.setFont(new Font(宋体, Font.PLAIN, 15); text1 = new JTextField(30); text1.setFont(new Font(宋体, Font.PLAIN, 15); button = new JButton(查询); button.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) try getTable(); catch (SQLException e1) / TODO 自动生成的 catch 块e1.printStackTrace(); );/* button1 = new JButton(返回); button1.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) setVisible(false); );*/ JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout(); topPanel.add(text,BorderLayout.WEST); topPanel.add(text1,BorderLayout.CENTER); topPanel.add(button,BorderLayout.EAST);/ topPanel.add(button1,BorderLayout.SOUTH); table = new JTable(); table.setFont(new Font(宋体, Font.PLAIN, 15); table.setBackground(UIManager.getColor(Label.background); table.setToolTipText(u67E5u8BE2); Container ct = getContentPane(); getContentPane().setLayout(new BorderLayout(); ct.add(topPanel,BorderLayout.NORTH); ct.add(table,BorderLayout.CENTER);/ getTable(); setSize(500,400); shell = new Shell();shell.setSize(450, 300);shell.setText(SWT Application);private void getTable()throws SQLExceptiontryString sql= text.getText();String sql1 = text1.getText();String query = select * from +sql;if(sql.equals()JOptionPane.showMessageDialog(null, 请输入正确信息, 提示, JOptionPane.ERROR_MESSAGE);return;if(!sql1.equals()tryStatement statement1 = connection.createStatement();ResultSet resultSet1 = statement1.executeQuery(select * from +sql);Result

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论