5.6.数据库安全性分析
安全性:防止不合法使用所造成的数据泄露,更改和破坏。
安全措施:用户身份鉴别 用户权限鉴别 存取控制方面
操作员和管理员对应权限如下:
5.6.1数据库完整性分析
实体完整性:客户,商品,供应商
参照完整性:check约束和外键约束 用户定义完整性:
为保证数据的完整性,我们对各个表建立了几个简单的CHECK约束。 客户表
电话号码tel字段添加check约束,表达式:tel like '[1][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' 邮箱:
邮箱字段 添加check约束mail like '[^0-9]%[@]%[.][c][o][m]' 编码:添加CHECK约束
bianma like '[0-9][0-9][0-9][0-9][0-9][0-9]'
男女性别约束:sex varchar(2) check(sex='男'or sex='女')
9
6.主窗体设计
主窗体界面也是该系统的欢迎界面。应用程序的主窗体必须设计层次清晰的系统菜单和工具栏,其中系统菜单包含系统中所有功能的菜单项,而工具栏主要提供常用功能的快捷访问按钮。企业进销存管理系统采用导航面板,综合了系统菜单和工具栏的优点,而且其界面更加美观,操作更快捷。主窗体的运行效果图如下
(点击查看大图) 程序主窗体界面效果 6.1创建主窗体
创建主窗体的步骤如下:
(1)创建JXCFrame类,在类中创建并初始化窗体对象,为窗体添加桌面面板,并设置背景图片。关键代码如下:
private JDesktopPane desktopPane; private JFrame frame; private JLabel backLabel; private Preferences preferences; //创建窗体的Map类型集合对象
private Map
企
业
进
销
存
管
理
系
统
\
10
frame.addComponentListener(new FrameListener()); //添加窗体事件监听器
frame.getContentPane().setLayout(new BorderLayout()); //设置布局管理器
frame.setBounds(100, 100, 800, 600); //设置窗体位置和大小
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置窗体默认的关闭方式
backLabel = new JLabel(); //背景标签
backLabel.setVerticalAlignment(SwingConstants.TOP); //设置背景标签垂直对齐方式
backLabel.setHorizontalAlignment(SwingConstants.CENTER); //设置背景标签水平对齐方式
updateBackImage(); //调用初始化背景标签的方法
desktopPane = new JDesktopPane(); //创建桌面面板
desktopPane.add(backLabel, new Integer(Integer.MIN_VALUE)); //将背景标签添加到桌面面板中
frame.getContentPane().add(desktopPane); //添加桌面面板到窗体中
JTabbedPane navigationPanel = createNavigationPanel(); //创建导航面板
frame.getContentPane().add(navigationPanel, BorderLayout.NORTH); //添加导航面板到窗体中
frame.setVisible(true); //显示窗体 }
(2)编写updateBackImage()方法,在该方法中初始化背景标签,背景标签使用HTML超文本语言设置了主窗体的背景图片,该图片将随主窗体的大小自动缩放。关键代码如下:
private void updateBackImage() { if (backLabel != null) {
int backw = JXCFrame.this.frame.getWidth(); int backh = frame.getHeight();
backLabel.setSize(backw, backh); //初始化背景标签的大小
backLabel.setText(\ + \
+ JXCFrame.this.getClass().getResource(\ + \//设置背景标签的图像 }
11
}
(3)在类的静态代码段中设置进销存管理系统的外观样式。Swing支持跨平台特性,它可以在不同的操作系统中保持一致的外观风格,但是本系统使用UIManager类的setLookAndFeel()方法设置程序界面使用本地外观,这样可以使程序更像本地应用程序。关键代码如下: static { try {
UIManager.setLookAndFeel(UIManager. getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } }
(4)编写主窗体的main()入口方法,在该方法中创建登录窗体对象,登录窗体会验证登录信息,并显示主窗体界面。关键代码如下:
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new Login(); } }); }
6.2.创建导航面板(1)
创建导航面板的步骤如下:
(1)在JXCFrame类中编写createNavigationPanel()方法,在该方法中创建JTabbedPane选项卡面板对象;为突出选项卡的立体效果,设置其使用BevelBorder边框效果;然后依次创建\基础信息管理\、\库存管理\、\销售管理\、\查询统计\、\进货管理\和\系统管理\选项卡。关键代码如下: private JTabbedPane createNavigationPanel() { //创建导航面板的方法 JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setFocusable(false);
tabbedPane.setBackground(new Color(211, 230, 192));
tabbedPane.setBorder(new BevelBorder(BevelBorder.RAISED)); JPanel baseManagePanel = new JPanel(); //“基础信息管理”面板
baseManagePanel.setBackground(new Color(215, 223, 194)); baseManagePanel.setLayout(new BoxLayout (baseManagePanel, BoxLayout.X_AXIS)); baseManagePanel.add(createFrameButton(\\
baseManagePanel.add(createFrameButton(\\
商
品
信
息
管
理
\
客
户
信
息
管
理
\
12
baseManagePanel.add(createFrameButton(\供
应
\
JPanel depotManagePanel = new JPanel(); //“库存管理”面板
depotManagePanel.setBackground(new Color(215, 223, 194)); depotManagePanel.setLayout(new BoxLayout (depotManagePanel, BoxLayout.X_AXIS)); depotManagePanel.add(createFrameButton(\库
\
depotManagePanel.add(createFrameButton(\价
\
JPanel sellManagePanel = new JPanel(); //“销售管理”面板
sellManagePanel.setBackground(new Color(215, 223, 194)); sellManagePanel.setLayout(new BoxLayout (sellManagePanel, BoxLayout.X_AXIS)); sellManagePanel.add(createFrameButton(\销
\
sellManagePanel.add(createFrameButton(\销
\
JPanel searchStatisticPanel = new JPanel(); //“查询统计”面板
searchStatisticPanel.setBounds(0, 0, 600, 41); searchStatisticPanel.setName(\
searchStatisticPanel.setBackground(new Color(215, 223, 194)); searchStatisticPanel.setLayout(new BoxLayout (searchStatisticPanel, BoxLayout.X_AXIS)); searchStatisticPanel.add(createFrameButton (\客户信息查询\ searchStatisticPanel.add(createFrameButton (\商品信息查询\ searchStatisticPanel.add(createFrameButton (\供应商信息查询\ searchStatisticPanel.add(createFrameButton (\销售信息查询\ searchStatisticPanel.add(createFrameButton (\销售退货查询\ searchStatisticPanel.add(createFrameButton (\入库查询\
searchStatisticPanel.add(createFrameButton (\入库退货查询\ searchStatisticPanel.add(createFrameButton JPanel stockManagePanel = new JPanel(); //“进货管理”面板
13
商
信
存
格
售
售
息
管
理
盘
点
调
整
单
退
货
\
\
\
\
\