基于电脑及其配件的进销存管理系统模块开发卷宗V1.0.doc
案卷号1日期2012年6月1日基于电脑及其配件的进销存管理系统模块开发卷宗 题 目 基于电脑及其配件的进销存管理系统 专业班级 09软件工程(1)班第一组 组 员指导教师 编 写 人 版 本V1.0 修改情况记录:版本号修改批准人修改人安装日期签收人V0.12012年5月15日V0.22012年5月20日V1.02012年6月1日 一、基础信息管理模块1标题软件系统名称和标识符:基于电脑及其配件的进销存管理系统模块名称和标示符:基本信息管理模块程序员编制签名:黄健帮卷宗的修改文本序号:无修改完成日期:2012-6-1卷宗序号:1编排日期:2012-5-302 模块开发情况表模块标识符BIM模块的描述性名称基础信息管理代码设计计划开始日期2011-12-18实际开始日期2011-12-20计划完成日期2012-01-03实际完成日期2012-01-05模块测试计划开始日期2012-01-03实际开始日期2012-01-06计划完成日期2012-01-04实际完成日期2012-01-07组装测试计划开始日期2012-01-06实际开始日期2012-01-08计划完成日期2012-01-07实际完成日期2012-01-10代码复查日期 / 签字2012-01-11黄健帮源代码行数预计1300实际1353模块标识符BIM项目负责人批准日期 / 签字2012-01-13莫敏智3 功能说明(1)客户信息管理:可以添加、修改和删除客户全称、客户地址、客户简称、邮政编码、电话、传真、联系人、联系电话、E-Mail、开户银行和银行帐号等信息;(2)商品信息管理:可以添加、修改和删除商品名称、简称、产地、单位、规格、包装、批号、供应商全称、备注等信息;(3)供应商信息管理:可以添加、修改和删除供应商全称、简称、邮政编码、地址、电话、传真、联系人、联系人电话、开户银行、电子信箱等信息;4 设计说明a本模块属于系统模块层次中第一层,由进货管理、销售管理、查询统计、库存管理调用;b本模块的处理流程为:管理可以添加、修改和删除客户信息、商品信息和供应商信息,添加各类信息时系统自动和数据库作比对,已存在的信息将不能重复保存,减少冗余。5 源代码清单(1)客户信息管理代码:KeHuTianJiaPanel.javapackage internalFrame.keHuGuanLi;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.ResultSet;import java.sql.SQLException;import javax.swing.JButton;import javax.swing.JComponent;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import keyListener.InputKeyListener;import model.TbKhinfo;import com.lzw.dao.Dao;public class KeHuTianJiaPanel extends JPanel private JTextField keHuQuanCheng;private JTextField yinHangZhangHao;private JTextField kaiHuYinHang;private JTextField EMail;private JTextField lianXiDianHua;private JTextField lianXiRen;private JTextField chuanZhen;private JTextField dianHua;private JTextField youZhengBianMa;private JTextField diZhi;private JTextField keHuJianCheng;private JButton resetButton;public KeHuTianJiaPanel() super();setBounds(10, 10, 460, 300);setLayout(new GridBagLayout();setVisible(true);final JLabel khName = new JLabel();khName.setText("客户全称:");setupComponet(khName, 0, 0, 1, 0, false);keHuQuanCheng = new JTextField();/ 定位全称文本框setupComponet(keHuQuanCheng, 1, 0, 3, 350, true);final JLabel addressLabel = new JLabel("客户地址:");setupComponet(addressLabel, 0, 1, 1, 0, false);diZhi = new JTextField();/ 定位地址文本框setupComponet(diZhi, 1, 1, 3, 0, true);final JLabel jc = new JLabel();jc.setText("客户简称:");setupComponet(jc, 0, 2, 1, 0, false);keHuJianCheng = new JTextField();/ 定位客户简称文本框setupComponet(keHuJianCheng, 1, 2, 1, 100, true);setupComponet(new JLabel("邮政编码:"), 2, 2, 1, 0, false);youZhengBianMa = new JTextField();/ 定位邮政编码文本框setupComponet(youZhengBianMa, 3, 2, 1, 100, true);youZhengBianMa.addKeyListener(new InputKeyListener();setupComponet(new JLabel("电话:"), 0, 3, 1, 0, false);dianHua = new JTextField();/ 定位电话文本框setupComponet(dianHua, 1, 3, 1, 100, true);dianHua.addKeyListener(new InputKeyListener();setupComponet(new JLabel("传真:"), 2, 3, 1, 0, false);chuanZhen = new JTextField();/ 定位传真文本框chuanZhen.addKeyListener(new InputKeyListener();setupComponet(chuanZhen, 3, 3, 1, 100, true);setupComponet(new JLabel("联系人:"), 0, 4, 1, 0, false);lianXiRen = new JTextField();/ 定位联系人文本框setupComponet(lianXiRen, 1, 4, 1, 100, true);setupComponet(new JLabel("联系电话:"), 2, 4, 1, 0, false);lianXiDianHua = new JTextField();/ 定位联系电话文本框setupComponet(lianXiDianHua, 3, 4, 1, 100, true);lianXiDianHua.addKeyListener(new InputKeyListener();setupComponet(new JLabel("E-Mail:"), 0, 5, 1, 0, false);EMail = new JTextField();/ 定位E-Mail文本框setupComponet(EMail, 1, 5, 3, 350, true);setupComponet(new JLabel("开户银行:"), 0, 6, 1, 0, false);kaiHuYinHang = new JTextField();/ 定位开户银行文本框setupComponet(kaiHuYinHang, 1, 6, 1, 100, true);setupComponet(new JLabel("银行账号:"), 2, 6, 1, 0, false);yinHangZhangHao = new JTextField();/ 定位银行账号文本框setupComponet(yinHangZhangHao, 3, 6, 1, 100, true);final JButton saveButton = new JButton("保存");/ 定位保存按钮setupComponet(saveButton, 1, 7, 1, 0, false);saveButton.addActionListener(new SaveButtonActionListener();resetButton = new JButton("重置");/ 定位重置按钮setupComponet(resetButton, 3, 7, 1, 0, false);resetButton.addActionListener(new ChongZheButtonActionListener();/ 设置组件位置并添加到容器中private void setupComponet(JComponent component, int gridx, int gridy,int gridwidth, int ipadx, boolean fill) final GridBagConstraints gridBagConstrains = new GridBagConstraints();gridBagConstrains.gridx = gridx;gridBagConstrains.gridy = gridy;gridBagConstrains.insets = new Insets(5, 1, 3, 1);if (gridwidth > 1)gridBagConstrains.gridwidth = gridwidth;if (ipadx > 0)gridBagConstrains.ipadx = ipadx;if (fill)gridBagConstrains.fill = GridBagConstraints.HORIZONTAL;add(component, gridBagConstrains);/ 保存按钮的事件监听类private final class SaveButtonActionListener implements ActionListener public void actionPerformed(final ActionEvent e) if (diZhi.getText().equals("")| youZhengBianMa.getText().equals("")| chuanZhen.getText().equals("")| yinHangZhangHao.getText().equals("")| keHuJianCheng.getText().equals("")| keHuQuanCheng.getText().equals("")| lianXiRen.getText().equals("")| lianXiDianHua.getText().equals("")| EMail.getText().equals("")| dianHua.getText().equals("")| kaiHuYinHang.getText().equals("") JOptionPane.showMessageDialog(null, "请填写全部信息");return;ResultSet haveUser = Dao.query("select * from tb_khinfo where khname='"+ keHuQuanCheng.getText().trim() + "'");try if (haveUser.next()System.out.println("error");JOptionPane.showMessageDialog(KeHuTianJiaPanel.this,"客户信息添加失败,存在同名客户", "客户添加信息",JOptionPane.INFORMATION_MESSAGE);return; catch (Exception er) er.printStackTrace();ResultSet set = Dao.query("select max(id) from tb_khinfo");String id = null;try if (set != null && set.next() String sid = set.getString(1);if (sid = null)id = "kh1001"else String str = sid.substring(2);id = "kh" + (Integer.parseInt(str) + 1); catch (SQLException e1) e1.printStackTrace();TbKhinfo khinfo = new TbKhinfo();khinfo.setId(id);khinfo.setAddress(diZhi.getText().trim();khinfo.setBianma(youZhengBianMa.getText().trim();khinfo.setFax(chuanZhen.getText().trim();khinfo.setHao(yinHangZhangHao.getText().trim();khinfo.setJian(keHuJianCheng.getText().trim();khinfo.setKhname(keHuQuanCheng.getText().trim();khinfo.setLian(lianXiRen.getText().trim();khinfo.setLtel(lianXiDianHua.getText().trim();khinfo.setMail(EMail.getText().trim();khinfo.setTel(dianHua.getText().trim();khinfo.setXinhang(kaiHuYinHang.getText();Dao.addKeHu(khinfo);JOptionPane.showMessageDialog(KeHuTianJiaPanel.this, "已成功添加客户","客户添加信息", JOptionPane.INFORMATION_MESSAGE);resetButton.doClick();/ 重置按钮的事件监听类private class ChongZheButtonActionListener implements ActionListener public void actionPerformed(final ActionEvent e) keHuQuanCheng.setText("");yinHangZhangHao.setText("");kaiHuYinHang.setText("");EMail.setText("");lianXiDianHua.setText("");lianXiRen.setText("");chuanZhen.setText("");dianHua.setText("");youZhengBianMa.setText("");diZhi.setText("");keHuJianCheng.setText("");KeHuXiuGaiPanel.javapackage internalFrame.keHuGuanLi;import internalFrame.guanli.Item;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JComponent;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import keyListener.InputKeyListener;import model.TbKhinfo;import com.lzw.dao.Dao;public class KeHuXiuGaiPanel extends JPanel private JTextField keHuQuanCheng;private JTextField yinHangZhangHao;private JTextField kaiHuYinHang;private JTextField EMail;private JTextField lianXiDianHua;private JTextField lianXiRen;private JTextField chuanZhen;private JTextField dianHua;private JTextField youZhengBianMa;private JTextField diZhi;private JTextField keHuJianCheng;private JButton modifyButton;private JButton delButton;private JComboBox kehu;public KeHuXiuGaiPanel() setBounds(10, 10, 460, 300);setLayout(new GridBagLayout();setVisible(true);final JLabel khName = new JLabel();khName.setText("客户全称:");setupComponet(khName, 0, 0, 1, 0, false);keHuQuanCheng = new JTextField();keHuQuanCheng.setEditable(false);/ 定位全称文本框setupComponet(keHuQuanCheng, 1, 0, 3, 350, true);final JLabel addressLabel = new JLabel("客户地址:");setupComponet(addressLabel, 0, 1, 1, 0, false);diZhi = new JTextField();/ 定位地址文本框setupComponet(diZhi, 1, 1, 3, 0, true);setupComponet(new JLabel("客户简称:"), 0, 2, 1, 0, false);keHuJianCheng = new JTextField();/ 定位客户简称文本框setupComponet(keHuJianCheng, 1, 2, 1, 130, true);setupComponet(new JLabel("邮政编码:"), 2, 2, 1, 0, false);youZhengBianMa = new JTextField();/ 定位邮政编码文本框setupComponet(youZhengBianMa, 3, 2, 1, 100, true);youZhengBianMa.addKeyListener(new InputKeyListener();setupComponet(new JLabel("电话:"), 0, 3, 1, 0, false);dianHua = new JTextField();/ 定位电话文本框setupComponet(dianHua, 1, 3, 1, 100, true);dianHua.addKeyListener(new InputKeyListener();setupComponet(new JLabel("传真:"), 2, 3, 1, 0, false);chuanZhen = new JTextField();/ 定位传真文本框chuanZhen.addKeyListener(new InputKeyListener();setupComponet(chuanZhen, 3, 3, 1, 100, true);setupComponet(new JLabel("联系人:"), 0, 4, 1, 0, false);lianXiRen = new JTextField();/ 定位联系人文本框setupComponet(lianXiRen, 1, 4, 1, 100, true);setupComponet(new JLabel("联系电话:"), 2, 4, 1, 0, false);lianXiDianHua = new JTextField();/ 定位联系电话文本框setupComponet(lianXiDianHua, 3, 4, 1, 100, true);lianXiDianHua.addKeyListener(new InputKeyListener();setupComponet(new JLabel("E-Mail:"), 0, 5, 1, 0, false);EMail = new JTextField();/ 定位E-Mail文本框setupComponet(EMail, 1, 5, 3, 350, true);setupComponet(new JLabel("开户银行:"), 0, 6, 1, 0, false);kaiHuYinHang = new JTextField();/ 定位开户银行文本框setupComponet(kaiHuYinHang, 1, 6, 1, 100, true);setupComponet(new JLabel("银行账号:"), 2, 6, 1, 0, false);yinHangZhangHao = new JTextField();/ 定位银行账号文本框setupComponet(yinHangZhangHao, 3, 6, 1, 100, true);setupComponet(new JLabel("选择客户"), 0, 7, 1, 0, false);kehu = new JComboBox();kehu.setPreferredSize(new Dimension(230, 21);initComboBox();/ 初始化下拉选择框/ 处理客户信息的下拉选择框的选择事件kehu.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) doKeHuSelectAction(););/ 定位客户信息的下拉选择框setupComponet(kehu, 1, 7, 2, 0, true);modifyButton = new JButton("修改");delButton = new JButton("删除");JPanel panel = new JPanel();panel.add(modifyButton);panel.add(delButton);/ 定位按钮setupComponet(panel, 3, 7, 1, 0, false);/ 处理删除按钮的单击事件delButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) Item item = (Item) kehu.getSelectedItem();if (item = null | !(item instanceof Item)return;int confirm = JOptionPane.showConfirmDialog(KeHuXiuGaiPanel.this, "确认删除客户信息吗?");if (confirm = JOptionPane.YES_OPTION) int rs = Dao.delete("delete tb_khinfo where id='"+ item.getId() + "'");if (rs > 0) JOptionPane.showMessageDialog(KeHuXiuGaiPanel.this,"客户:" + item.getName() + "。删除成功");kehu.removeItem(item););/ 处理修改按钮的单击事件modifyButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) Item item = (Item) kehu.getSelectedItem();TbKhinfo khinfo = new TbKhinfo();khinfo.setId(item.getId();khinfo.setAddress(diZhi.getText().trim();khinfo.setBianma(youZhengBianMa.getText().trim();khinfo.setFax(chuanZhen.getText().trim();khinfo.setHao(yinHangZhangHao.getText().trim();khinfo.setJian(keHuJianCheng.getText().trim();khinfo.setKhname(keHuQuanCheng.getText().trim();khinfo.setLian(lianXiRen.getText().trim();khinfo.setLtel(lianXiDianHua.getText().trim();khinfo.setMail(EMail.getText().trim();khinfo.setTel(dianHua.getText().trim();khinfo.setXinhang(kaiHuYinHang.getText();if (Dao.updateKeHu(khinfo) = 1)JOptionPane.showMessageDialog(KeHuXiuGaiPanel.this, "修改完成");elseJOptionPane.showMessageDialog(KeHuXiuGaiPanel.this, "修改失败"););/ 初始化客户下拉选择框public void initComboBox() List khInfo = Dao.getKhInfos();List<Item> items = new ArrayList<Item>();kehu.removeAllItems();for (Iterator iter = khInfo.iterator(); iter.hasNext();) List element = (List) iter.next();Item item = new Item();item.setId(element.get(0).toString().trim();item.setName(element.get(1).toString().trim();if (items.contains(item)continue;items.add(item);kehu.addItem(item);doKeHuSelectAction();/ 设置组件位置并添加到容器中private void setupComponet(JComponent component, int gridx, int gridy,int gridwidth, int ipadx, boolean fill) final GridBagConstraints gridBagConstrains = new GridBagConstraints();gridBagConstrains.gridx = gridx;gridBagConstrains.gridy = gridy;if (gridwidth > 1)gridBagConstrains.gridwidth = gridwidth;if (ipadx > 0)gridBagConstrains.ipadx = ipadx;gridBagConstrains.insets = new Insets(5, 1, 3, 1);if (fill)gridBagConstrains.fill = GridBagConstraints.HORIZONTAL;add(component, gridBagConstrains);private void doKeHuSelectAction() Item selectedItem;if (!(kehu.getSele