目录1 问题描述 (1)1.1开发环境 (1)1.2问题理解和分析 (1)2需求分析 (2)2.1需求描述 (2)2.2系统运行环境 (2)3总体设计 (3)3.1功能模块图 (3)3.2结构设计 (3)4数据库设计 (5)4.1数据库概念结构设计 (5)4.2数据库逻辑结构设计 (5)5系统的详细设计与实现 (7)5.1用户登录模块设计 (7)5.2销售系统主界面设计 (8)5.3商品销售录入模块设计 (9)5.4商品进货录入模块设计 (12)5.5库存管理模块设计 (14)6 测试 (16)6.1登录测试用例 (16)6.2修改密码测试用例 (16)6.3添加商品信息测试用例 (16)6.4查询商品信息测试用例 (17)6.5修改商品信息测试用例 (18)6.6删除商品信息测试用例 (18)7 结论 (19)8 参考文献 (20)1 问题描述1.1 开发环境(1)运用已学过的知识进行应用系统的开发,掌握软件设计流程。
(2)通过课程设计,使用SSH技术、Java高级语言、SQL语言等开发应系统,掌握基本的编程方法。
(3)通过课程设计掌握数据库的连接方法,及对数据的查询、修改、插入、删除等操作。
1.2问题理解和分析系统主要完成以下功能(1)向使用者提供商品基本的录入,删除,编辑等基本功能。
(2)向使用者提供商品销售环节中的基本管理功能。
(3)向使用者提供基本的查询功能。
(4)提供打印功能。
2需求分析2.1 需求描述由于销售管理系统是一个用来帮助使用者管理商品销售流程的软件。
使用者通过对销售过程中所涉及到的商品,订单,销售商等资料的录入,便可以轻松实现商品销售流程的管理。
所以,此系统必须向使用者提供一下一些具体功能:(1)软件必须向使用者提供商品基本的录入,删除,编辑等基本功能(2)鉴于商品的不同销售方式(分为订单销售和代理商销售两种形式),软件必须向使用者提供商品销售环节中的基本管理功能,因此必须有订单分销模块和代理商分销模块。
(3)软件必须向使用者提供基本的查询功。
(4)由于是销售管理软件,所以系统安全性必须是要考虑的问题。
因此,必须实现以下两点:A:系统操作员机制。
对系统的使用者,按等级开放管理权限,这样可以在一定程度上保证数据库系统的安全性,避免数据被泄漏,非法更改等。
B:销售数据直接反映了一个销售单位的盈亏状况,鉴于销售数据的重要性,所以必须对这些数据加以保护,在系统崩溃时或者误操作等情况下,可以对数据进行恢复。
这就需要系统提供备份功能。
(5)对于销售数据不能只存储在计算机中,而是需要导出步骤,最后以印刷品的形式出现在使用者面前,该软件设计的最终目的才能得以具体的实现。
所以,打印功能是必不可少的系统功能之一。
2.2 系统运行环境(1)硬件环境。
本系统适用于那种Inter386以上计算机,内存容量为128M,应配备键盘、鼠标、显示器等外部设备。
(2)软件环境。
本系统的设计采用MyEclipse8.5编写。
在Windows7环境下测试通过。
3总体设计3.1 功能模块图功能模块图如图3-1所示。
图3-1 功能模块图3.2 结构设计系统总流程图如图3-2所示。
图3-2 系统流程图4数据库设计4.1 数据库概念结构设计E-R模型图如图4-1所示。
图4-1 E-R模型图4.2 数据库逻辑结构设计表名:liyi (用户表)如表4-1所示。
表名:Supplier(供应商表)如表4-2所示。
表名:Purchase (进货表)如表4-3所示。
表名:sale(销售表)如表4-4所示。
表名:Return (退货表)如表4-5所示。
5系统的详细设计与实现5.1 用户登录模块设计用户登录模块如图5-1所示。
图5-1 用户登录窗口效果图本窗体的任务是通过用户输入密码判断用户是否是合法的用户.它用于管理员按照用户名和密码进行登录。
以免不相关得人进入系统进行不良的操作,而对系统进行破坏,导致整个系统进行瘫痪。
主要代码:public class LoginDialog extends JFrame {private static final long serialVersionUID = 1L;private LoginPanel loginPanel = null;private JButton exitButton = null;private static String userStr;private MainFrame mainFrame;public LoginDialog() {try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());mainFrame = new MainFrame();initialize();}catch (Exception e) {e.printStackTrace();}}private JButton getLoginButton() {if (loginButton == null) {loginButton = new JButton();loginButton.setBounds(new Rectangle(109, 114, 48, 20));loginButton.setIcon(new ImageIcon(getClass().getResource("/res/loginButton.jpg")));loginButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {try {userStr = userField.getText();String passStr = new String(passwordField.getPassword());if (!Dao.checkLogin(userStr, passStr)) {JOptionPane.showMessageDialog(LoginDialog.this,"用户名与密码无法登录", "登录失败",JOptionPane.ERROR_MESSAGE);return;}} catch (Exception e1) {e1.printStackTrace();}MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);mainFrame.setVisible(true);mainFrame.getCzyStateLabel().setText(userStr);setVisible(false);}});}return loginButton;}5.2 销售系统主界面设计销售系统主界面如图5-2所示。
图5-2 销售系统主界面窗口效果图该窗体是本系统的统筹界面。
它是系统的结构匡架,便于对整个系统的观摩、管理.主要使用Label和 panl以及manu等控件实现的。
Image控件使得界面得以美化。
由于每次操作不一定会用到所有的数据库,所以没有必要在每次运行时生成所有的数据库别名。
Session控件提供了动态生成数据库别名的方法,使通过操作选择窗体进行优选择的别名生成成为可能。
主要代码:package com.lzw;import java.awt.*;import javax.swing.border.BevelBorder;import com.lzw.login.LoginDialog;public class MainFrame extends JFrame {private static final long serialVersionUID = 1L;private JPanel frameContentPane = null;private ToolBar getJJToolBarBar() {if (toolBar == null) {toolBar = new ToolBar(getFrameMenuBar());toolBar.setCursor(new Cursor(Cursor.HAND_CURSOR));}return toolBar;}protected MenuBar getFrameMenuBar() {if (frameMenuBar == null) {frameMenuBar = new MenuBar(getDesktopPane(), getStateLabel());}return frameMenuBar;}private DesktopPanel getDesktopPane() {if (desktopPane == null) {desktopPane = new DesktopPanel();}return desktopPane;}public JLabel getStateLabel() {if (stateLabel == null) {stateLabel = new JLabel();stateLabel.setText("当前没有选定窗体");}return stateLabel;}public MainFrame() {super();initialize();}} // @jve:decl-index=0:visual-constraint="6,-5"5.3商品销售录入模块设计商品销售录入模块如图5-3所示。
图5-3 销售录入窗口效果图该窗体以图形化的界面,简单直观的向使用者提供商品销售的录入功能,使用者可以快速的将销售记录录入系统,并进行保存。
主要代码:package com.lzw.iframe;import java.awt.*;import java.awt.event.*;import com.lzw.*;public class XiaoShouDan extends JInternalFrame {private final JTable table;public XiaoShouDan() {super();setMaximizable(true);setIconifiable(true);setClosable(true);getContentPane().setLayout(new GridBagLayout());piaoHao.setFocusable(false);setupComponet(piaoHao, 1, 0, 1, 140, true);setupComponet(new JLabel("客户:"), 2, 0, 1, 0, false);kehu.setPreferredSize(new Dimension(160, 21));kehu.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {doKhSelectAction();}});setupComponet(kehu, 3, 0, 1, 1, true);sp = new JComboBox();sp.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {TbSpinfo info = (TbSpinfo) sp.getSelectedItem();if (info != null && info.getId() != null) {updateTable();}}});table = new JTable();table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);initTable();tjButton.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {initPiaoHao();stopTableCellEditing();for (int i = 0; i < table.getRowCount(); i++) {TbSpinfo info = (TbSpinfo) table.getValueAt(i, 0);if (table.getValueAt(i, 0) == null)return;}DefaultTableModel model = (DefaultTableModel) table.getModel();model.addRow(new Vector());}});setupComponet(tjButton, 4, 4, 1, 1, false);JButton sellButton = new JButton("销售");sellButton.addActionListener(new ActionListener() {if (ysjlStr == null || ysjlStr.isEmpty()) {JOptionPane.showMessageDialog(XiaoShouDan.this, "填写验收结论");return;}if (table.getRowCount() <= 0) {JOptionPane.showMessageDialog(XiaoShouDan.this, "填加销售商品");return;}TbSellMain sellMain = new TbSellMain(id, pzsStr, jeStr,ysjlStr, kehuName, rkDate, czyStr, jsrStr, jsfsStr);Set<TbSellDetail> set = sellMain.getTbSellDetails();int rows = table.getRowCount();for (int i = 0; i < rows; i++) {TbSpinfo spinfo = (TbSpinfo) table.getValueAt(i, 0);String djStr = (String) table.getValueAt(i, 6);String slStr = (String) table.getValueAt(i, 7);Double dj = Double.valueOf(djStr);Integer sl = Integer.valueOf(slStr);TbSellDetail detail = new TbSellDetail();detail.setSpid(spinfo.getId());detail.setTbSellMain(sellMain.getSellId());set.add(detail);}boolean rs = Dao.insertSellInfo(sellMain);if (rs) {JOptionPane.showMessageDialog(XiaoShouDan.this, "销售完成");DefaultTableModel dftm = new DefaultTableModel();table.setModel(dftm);initTable();pzs.setText("0");hpzs.setText("0");hjje.setText("0");}}});setupComponet(sellButton, 5, 4, 1, 1, false);addInternalFrameListener(new initTasks());}private void stopTableCellEditing() {TableCellEditor cellEditor = table.getCellEditor();if (cellEditor != null)cellEditor.stopCellEditing();}}5.4商品进货录入模块设计商品进货录入模块如图5-4图5-4 商品进货录入窗口效果图该窗体以图形化的界面,简单直观的向使用者提供商品的查询功能,使用者可以通过已知商品信息迅速查询到与此种商品相关的代理商信息,同时,也可用过代理商的信息反查处其代理的商品状况。