AlanShan数据库课程设计报告

   

 

1、绪论.... 2

1.1前言... 2

1.2社会背景... 2

1.3超市背景... 3

2、系统可行性研究.... 4

2.1 技术可行性研究... 4

2.2 经济可行性研究... 4

2.3 操作可行性研究... 4

3、系统需求分析.... 6

3.1 用户工作流程... 6

3.2 用户业务需求... 6

系统分析与总体设计.... 7

4.1 系统结构框架... 7

4.2 系统功能设计... 7

5、数据库中的表.... 8

5.1 人员管理表... 8

5.2 商品信息表... 8

5.3 人员信息表... 9

6、程序实现的代码与相关截图.... 10

6.1 主页面... 10

6.2投币... 13

6.3 所有商品... 17

6.4 内部登录... 19

6.4.1 商品的添加... 22

6.4.2 商品信息编辑... 25

6.5  人员添加... 32

7、总结.... 36

 

 


1、绪论

1.1前言

超市需要处理大量的库存信息,还要时刻更新产品的销售信息,不断添加商品信息。面对不同种类的信息,需要合理的数据库结构来保存数据信息,需要有效的程序结构支持各种数据操作的执行。商店自动化的产品管理在欧美等国家早已经实现,也是零售业管理的基础。它最主要的特点是能够实时的和准确的控制店内的销售情况。如果可以能够实时掌握销售流程及销售情况,则可以有效地加速商品的周转率并提高服务质量,而且可以减少产品售价不符等所产生的问题。顾客的消费要求的是希望在超市购物中能基本上都能购得所需的商品,并且还要既保证商品质量还要享受优质,方便的服务。

随着小超市规模的发展不断扩大,商品数量急剧增加,有关商品的各种信息量也成倍增长。超市时时刻刻都需要对商品各种信息进行统计分析。而大型的超市管理系统功能过于强大而造成操作繁琐降低了小超市的工作效率。
超市管理系统是市场上最流行的超市上常用的系统之一,它主要包含以下几个模块:系统权限的设定、原始数据录入、数据的汇总及查询等。从而,实现对进货、销售及员工信息等实现全面、动态、及时的管理。
本文系统的分析了软件开发的背景以过程;首先介绍了软件的开发环境,其次介绍了本软件的详细设计过程:数据库的设计、各个模块的设计和实现,以及具体界面的设计和功能。

1.2社会背景

随着现代科学技术的迅猛发展,计算机技术已经渗透到哥哥领域,成为各行业必不可少的工具,特别是Internet技术的推广和信息高速公路的建立,使IT产业在市场竞争中越发显示出其独特的优势,步入信息化时代,有巨大的数据信息等待加工处理和传输,这使得对书数据库的进一步开发和利用显得尤为迫切。
作为国内市场的一些中小型超市,它们在信息化过程中的步伐要落后于大中型超市,而对于这些企业的资源管理,信息的存储和处理也显得迫切需要,要适应市场竞争,就需要有高效的处理方式和管理方法,因此加快超市的信息化进程是必可少的。

实习期间,我们通过对市场的调查,针对现在各中小型超市对经营业务和人事管理的实际需要,开发了这套超市管理系统。在开发过程中,我们针对当前各超市管理的特点和技术人员的实际水平,采用基于Windows图形用户界面这一易学易用的操作环境,在系统设计过程中,我们尽量采用易懂易读的人机界面,使用户可以在短期内完全掌握。我们又始终发系统的正确性放在首位,力求数据的完整和处理的正确性。在此基础上优化程序代码,加速系统运行和减少对系统资源的占用。

1.3超市背景

在我国超市形成在20世纪90年代初期,现在已经成为我国零售业的一种重要形态,为国民经济的发展发挥了重要的作用。随着超市高速的发展,其经营管理也变得愈加复杂,早期的售货员站柜台的形式早已不能满足现有销售也的发展,这样就迫切地需要引入新的管理技术。

超市形态具有种种优点,但在目前状况下,它仍存在零售业企业所共有的落后的一面,如:不能有效地管理每种商品,收款结算速度慢,容易出现营业差错,不宜进行商品调价,盘点效率低等,而且在超市日常管理中,商品的进、销、存等决策以经验为主,缺乏实时分析功能,管理人员对及时传递资料的要求始终得不到满足。苏辙超市形态的高速发展,其经营管理也变得愈加复杂,日常所需要处理的数据量也逐渐增大,商业运转的中间环节也越来越多,原始的人工管理已无法应对这复杂的市场。为此,在选题过程中,我选择了超市管理系统设计题目,依靠现代化的计算机信息处理技术来管理超市,从而节省了大量的人力、物力,改善了员工的工作条件,减轻了劳动强度,并且能够快速反映出商品的进、销、存等状况和各种反馈信息分析,使管理人员快速对市场的变化做出相应的决策,加快超市经营管理效率。

 

2、系统可行性研究

2.1 技术可行性研究

在IT行业中从业的工作人员一般都要求掌握计算机技术,具有一定的软硬件基础,会使用各种管理软件,熟悉IT产品。因为,有的超市对员工的素质要求比较高,从管理层到下面的销售人员,都要求具有一定的计算机基础,所以在新系统投入使用时,只要对员工进行少量的培训,系统的功能和使用方法就基本上能够是系统顺利运行。

2.2 经济可行性研究

因为通过网络传递销售信息可以不受距离的限制,因此可以借阅许多的人力和物力,方便管理,由此可以减少不必要的开支,同时该系统可以提高超市的销售效率,即提高了超市的经济效益,所以从经济上完全是可行的。
(1)超市有能力承担系统开发费用
    开发新系统的工作是一项间距复杂的工作,它的投资主要是人力和物力的投资。对于本系统的开发者来说,其主要投资还是在人力和物力两个方面。如果是企业自己安排人手开发系统的话,其主要的投资还是在人力资源上,从系统的业务需求调查到系统的分析编码制作都是需要巨大的人力投入的。软件企业作为一个简短的高科技产业,其员工要求都比一般企业的要求要高,而且对系统开发及软件产业了解比较多,所以在自我开发管理系统的过程中,企业自己比较容易安排人手,这样就可以为企业借阅大部分的额外开支。同时软件就其它产品来说,属于高端行业,无论是产品的价格还是质量都比较高,而经营产品的经销商或者是商家都要求有雄厚的资金支持。所以,在系统的开发过程中,企业完全有能力承担开发费用。
(2)新系统将为企业带来经济效益
    管理系统是一个信息化、智能化和先进管理理念的集合体。而管理是一个动态过程,在其运行过程中要采取多项措施。所以在管理中获得经济效益是一个综合效益,要对它进行直接定量的分析是比较困难的。一般新系统带来的经济效益是简介的,其最主要的表现就是减少了企业管理费用和人力开支。而其它一些繁琐的食物都通过新系统来加以分析解决,不仅节省了大量的时间,还为企业的各项决策提供了宝贵的资料,为企业带来巨大的经济效益。

2.3 操作可行性研究

本系统采用基于Windows的图形用户界面,而该系统是大家熟悉的操作系统,对于那些有一般的计算机知识的人员就可以轻松上手。而整个超市管理系统采用最友好的交互界面,简介明了,不需要对数据库进行深入的了解。
由此,该系统的操作是可行的,有必要开发该系统。
综合以上三方面,该系统具有很高的开发可行性,无论是从技术上或者经济上还是操作上。


3、系统需求分析

3.1 用户工作流程

当进入系统时我们会看到投币、所有商品、内部登录和人员添加等按钮,当顾客进入超市的时候如果顾客着急赶时间的话可以利用自动售货机来购买自己的商品,当顾客没有太着急时他们可以查看超市里的所有商品,查询此超市里是否有自己所需要的商品,然后进行有目的的选择商品。内部登录是超市内部的管理人员进入的,当超市中新的货物的购进或是要对商品信息进行修改的时对本功能进行操作。人员添加这个是当超市雇用新的超市人员时对本项功能进行操作,以完成对人员信息的录入。

3.2 用户业务需求

(1)该管理软件将对库存产品进行资料管理;

   (2)该管理软件将根据用户的需要对进货、库存情况进行查询,并能打印详细信息;

    (3)该管理软件提供企业人员管理,能够对企业员工的分类管理,新员工的加入以及员工删除,修改进本信息等功能。

 

4  系统分析与总体设计 

4.1 系统结构框架 

一般的超市商品管理系统,主要由五大模块组成,即商品信息管理模块,人事管理模块,销售管理模块,进货管理模块,库存管理模块,此系统也不例外,主要有此五大模块组成。图4-1系统功能结构图。

                                                                                  

    
    

超市管理系统

    
    

                                 

    
    

投币

    
    

                                 

    
    

所有商品

    
    

                                 

    
    

内部登陆

    
    

                                 

    
    

人员添加

    
    

                                 

    
    

查询商品

    
    

                                 

    
    

商品添加

    
    

                                 

    
    

商品编辑

    
    

                                 

    
    

修改

    
    

                                 

    
    

删除

    
    

  

 

图4-1 系统功能结构图

4.2 系统功能设计 

系统功能设计是使整个系统能基本实现超市的进、销、存等管理功能,能让超市管理者更直观的了解超市的经营状况,以做出相应的经营决策。管理信息系统(MIS)就是要对这些资源建立正确的数据库,并进行信息的收集、传送、存储、编制成各种凭证、报表、台帐、图形等信息,同时对这些信息进行维护,通过实测超市的各种运行情况,并利用过去的历史数据预测未来的发展,从超市全局的角度出发进行决策,利用信息控制超市的行为,附注超市完成其目标。 


5、数据库中的表

    在数据库中有商品信息表和人员信息表两个表,这两个表对对商品信息和人员的信息进行管理。其表结构如下所示:

5.1 人员管理表

表5-1人员表

UID

UNAME

UPASSWORD

INT(11)

VARCHAR(20)

VARCHAR(20)

 人员表中有人员ID、人员姓名和人员密码属性;

这个由超市内部自己在数据库中进行管理,存入以上属性相匹配的各种信息,超市可以根据在表中的生存的人员,可以登录超市内部对超市中商品的信息等进行操作。其在数据库中的表如下图:

 

图5-1人员管理表

据图可以知道当我们在对人员进行管理时在相应的时候填入相应的信息。属性uid表示人员的唯一标识,属性uname表示的人员名,属性upassword表示的是人员的登录密码。

5.2 商品信息表

表5 -2商品信息表

P_ID

P_NAME

P_PRICE

P_COUNT

P_DATE

P_TYPE

INT(11)

VARCHAR(20)

DOUBLE(6,2)

INT(11)

VARCHAR(20)

VARCHAR(20)

 商品系你想表中有商品ID、商品名、商品价格、商品数量、商品进货日期和商品种类属性;

当超市在进货时需要填入商品的以上信息,这样有助于超市管理人员和进行管理,也有助于用户在购买商品时对商品信息进行了解,这样用户就能过更好的确定自己的商品需求,可以使超市减少拥堵。

这两个表中能够在商品信息和人员管理进行清晰的管理和操作。 其在数据库中的表如下图所示:

 

图5-2商品信息表

    如上图所示,当我们超市在购进货物时,需要在超市管理数据库中填入如上商品相应的信息。当我们在对商品进行管理时会比较便利,也有益于当顾客需要商品时对商品进行了解。

同时,在这儿需要说明的是属性p_id表示此种商品在此超市的唯一标识码,属性p_name表示的是商品的名,属性p_price表示的是商品的单价,属性P_count表示的是超市的商品库存量,属性p_date表示的是商品的进货时间即购入这种商品是在什么时候。P_type表示的是商品名所对应的类型即这种商品的种类。

5.3 人员信息表

表5-3人员信息

h_id

h_name

h_age

h_sex

h_address

h_tel

Int(11)

Varchar(20)

Int(10)

Varchar(10)

Varchar(50)

Varchar(20)

这个表在数据库中的图示如下:

 

图 5-3 人员信息表

当管理人员进入页面时根据相应的项填入相应的数据,其在数据库中的表结构跟部分人员的信息如上所示。在这儿需要说明的是属性h_id表示超市人员的本超市的id号,h_name表示的是人员的姓名,h_age表示的是年龄,h_sex表示的是年龄,h_address表示的是人员的地址,h_tel表示的是人员的电话号码。

 

 

 

6、程序实现的代码与相关截图

6.1 主页面

    当进入程序时弹出如下页面:

 

图6—1主页面图

当进入主页面时会弹出如上页面,据上图可知当我们进入时可以四个按钮,他们分别是“投币”按钮、“所有商品”按钮、“内部登录”按钮、“人员添加”按钮。当点击“投币”按钮时顾客可以在自动的售货机上选择购买自己需要的商品,当点击“所有商品”按钮时顾客可以查看超市中的所有商品,使得顾客有目的的选择商品,点击“内部登录”按钮时顾客会受到限制,因为这是超市的内部登录按钮需要身份的验证,只能超市内部的工作人员才能登录。“人员添加”按钮,当超市有新人员进入是点击此按钮添加超市人员信息。

程序的代码如下:

  

 public void createPartControl(Composite parent) {

       final Composite container = new Composite(parent, SWT.NONE);    container.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));

       Button button_1 = new Button(container, SWT.NONE);

       button_1.addSelectionListener(new SelectionAdapter() {

           MyInput input=new MyInput();

           public void widgetSelected(SelectionEvent e) {

              ThrowShell.start();

           }

       });

       button_1.setBounds(27, 45, 80, 27);

       button_1.setText("\u6295\u5E01");

       Button button_2 = new Button(container, SWT.NONE);

       button_2.addSelectionListener(new SelectionAdapter() {

           MyInput input=new MyInput();

           public void widgetSelected(SelectionEvent e) {

              input.setName("可选商品");

              input.setToolTipText("可选商品");

              try {    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, ShowAllEditor.ID);

              } catch (PartInitException e1) {

                                e1.printStackTrace();

              }

           }

       });

       button_2.setBounds(27, 175, 80, 27);

       button_2.setText("\u6240\u6709\u5546\u54C1");

       Button button_6 = new Button(container, SWT.NONE);

       button_6.addSelectionListener(new SelectionAdapter() {

           MyInput input=new MyInput();

           public void widgetSelected(SelectionEvent e) {

              HomelaodingShell.start();

              if(HomelaodingShell.a==1){

                  input.setName("欢迎进入");

                  input.setToolTipText("欢迎进入");

                  try {    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, HomeUpInEditor.ID);

                  } catch (PartInitException e1) {

                  e1.printStackTrace();

                  }

              }

           }

       });

       button_6.setBounds(27, 294, 80, 27);

       button_6.setText(" \u5185\u90E8\u767B\u5F55");

       Button button = new Button(container, SWT.NONE);

       button.addSelectionListener(new SelectionAdapter() {

           MyInput input=new MyInput();

           public void widgetSelected(SelectionEvent e) {

              input.setName("人员信息");

              input.setToolTipText("人员信息");

              try {    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, AddHumanEditor.ID);

              } catch (PartInitException e1) {

                                   e1.printStackTrace();

              }

           }

       });

       button.setBounds(27, 408, 80, 27);

       button.setText("\u4EBA\u5458\u6DFB\u52A0");

       createActions();

       initializeToolBar();

       initializeMenu();

    }

    private void createActions() {

           }

    private void initializeToolBar() {

       IToolBarManager toolbarManager = getViewSite().getActionBars()

              .getToolBarManager();

    }

    private void initializeMenu() {

       IMenuManager menuManager = getViewSite().getActionBars()

              .getMenuManager();

    }

    public void setFocus() {

    }

}

 

6.2投币

    当点击“投币”按钮时程序会进入如下页面:

 

图6-2-1投币页面图

当进入这个页面时,顾客只能按照投币口下方的提示投入面额相应的纸币,点击“确定”弹出如下页面:

 

图6-2-2选择商品页面

    当进入这个页面时,我们可以根据自己的需求选择自己所需要的商品,确定自己所需要的商品的时候点击购买就可以购买到自己商品

  

 public void createPartControl(Composite parent) {

       Composite container = new Composite(parent, SWT.NONE);    container.setBackgroundImage(SWTResourceManager.getImage(ThrowCoinEditor.class, "/com/szq/image/sy_20120116153900758021.jpg"));    container.setBackground(SWTResourceManager.getColor(SWT.COLOR_CYAN));

       container.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       Composite composite = new Composite(container, SWT.NONE);

    composite.setBackgroundImage(SWTResourceManager.getImage(ThrowCoinEditor.class, "/com/szq/image/QQ\u622A\u56FE20130409184355.jpg"));

       composite.setBounds(23, 10, 173, 249);

       Label label = new Label(container, SWT.NONE);

       label.setFont(SWTResourceManager.getFont("微软雅黑", 12, SWT.NORMAL));

       label.setBounds(73, 278, 61, 40);

       label.setText(" 2.5\u5143");

       Button button = new Button(container, SWT.NONE);

       button.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {

           }

       });

       button.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       button.setBounds(54, 324, 80, 27);

       button.setText(" \u8D2D\u4E70");

       Composite composite_1 = new Composite(container, SWT.NONE);

    composite_1.setBackgroundImage(SWTResourceManager.getImage(ThrowCoinEditor.class, "/com/szq/image/QQ\u622A\u56FE20130409185559.jpg"));

       composite_1.setBounds(258, 71, 180, 139);

       Composite composite_2 = new Composite(container, SWT.NONE);

    composite_2.setBackgroundImage(SWTResourceManager.getImage(ThrowCoinEditor.class, "/com/szq/image/QQ\u622A\u56FE20130409185525.jpg"));

       composite_2.setBounds(539, 77, 114, 133);

       Composite composite_3 = new Composite(container, SWT.NONE);

    composite_3.setBackgroundImage(SWTResourceManager.getImage(ThrowCoinEditor.class, "/com/szq/image/QQ\u622A\u56FE20130409185201.jpg"));

       composite_3.setBounds(38, 431, 160, 133);

       Label lblNewLabel = new Label(container, SWT.NONE);

       lblNewLabel.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       lblNewLabel.setBounds(592, 281, 61, 17);

       lblNewLabel.setText("3.5\u5143");

       Button button_1 = new Button(container, SWT.NONE);

       button_1.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       button_1.setBounds(567, 324, 80, 27);

       button_1.setText("\u8D2D\u4E70");

       Composite composite_4 = new Composite(container, SWT.NONE);

    composite_4.setBackgroundImage(SWTResourceManager.getImage(ThrowCoinEditor.class, "/com/szq/image/QQ\u622A\u56FE20130409185318.jpg"));

       composite_4.setBounds(258, 386, 143, 206);

       Label label_1 = new Label(container, SWT.NONE);

       label_1.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       label_1.setBounds(313, 611, 61, 17);

       label_1.setText("5\u5143");

       Button button_2 = new Button(container, SWT.NONE);

       button_2.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       button_2.setBounds(275, 655, 80, 27);

       button_2.setText(" \u8D2D\u4E70");

       Label label_2 = new Label(container, SWT.NONE);

       label_2.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       label_2.setBounds(313, 281, 61, 17);

       label_2.setText("3.5\u5143");

       Button button_3 = new Button(container, SWT.NONE);

       button_3.addSelectionListener(new SelectionAdapter() {

                     public void widgetSelected(SelectionEvent e) {

           }

       });

       button_3.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       button_3.setBounds(294, 324, 80, 27);

        button_3.setText("\u8D2D\u4E70");

       Label label_3 = new Label(container, SWT.NONE);

       label_3.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       label_3.setBounds(73, 611, 61, 17);

       label_3.setText("4\u5143");

       Button button_4 = new Button(container, SWT.NONE);

       button_4.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       button_4.setBounds(54, 654, 80, 27);

       button_4.setText(" \u8D2D\u4E70");

       Composite composite_5 = new Composite(container, SWT.NONE);

    composite_5.setBackgroundImage(SWTResourceManager.getImage(ThrowCoinEditor.class, "/com/szq/image/QQ\u622A\u56FE20130409185006.jpg"));

       composite_5.setBounds(569, 431, 121, 139);

       Label label_4 = new Label(container, SWT.NONE);

       label_4.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       label_4.setBounds(592, 594, 61, 17);

       label_4.setText(" 3.5\u5143");

       Button button_5 = new Button(container, SWT.NONE);

       button_5.setFont(SWTResourceManager.getFont("仿宋", 12, SWT.NORMAL));

       button_5.setBounds(592, 654, 80, 27);

       button_5.setText("\u8D2D\u4E70 ");

    }

   

}

 

6.3 所有商品

当点击了“所有商品”按钮时会进入如下的页面:

 

图6-3 所有商品页面图

当点击了“所有商品”顾客可以看到超市中的所有上架商品,并且顾客可以根据超市所提供的商品相应的选择商品。这样方便顾客对超市的供货情况进行了解可以很好的满足顾客的需求。

其代码如下所示:

public void createPartControl(Composite parent) {

       Composite container = new Composite(parent, SWT.NONE);    container.setBackgroundImage(SWTResourceManager.getImage(ShowAllEditor.class, "/com/szq/image/7447430_172514301000_2.jpg"));

       table = new Table(container, SWT.BORDER | SWT.FULL_SELECTION);    table.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW));

       table.setBounds(10, 39, 562, 366);

       table.setHeaderVisible(true);

       table.setLinesVisible(true);

       TableColumn tblclmnNewColumn = new TableColumn(table, SWT.NONE);    tblclmnNewColumn.setImage(SWTResourceManager.getImage(ShowAllEditor.class, "/com/szq/image/QQ\u622A\u56FE20130409194217.jpg"));

       tblclmnNewColumn.setWidth(100);

       tblclmnNewColumn.setText("\u7F16\u53F7");

       TableColumn tableColumn = new TableColumn(table, SWT.NONE);

       tableColumn.setWidth(100);

       tableColumn.setText(" \u5546\u54C1\u540D");

       TableColumn tableColumn_1 = new TableColumn(table, SWT.NONE);

       tableColumn_1.setWidth(100);

       tableColumn_1.setText(" \u5546\u54C1\u4EF7\u683C");

       TableColumn tableColumn_2 = new TableColumn(table, SWT.NONE);

       tableColumn_2.setWidth(100);

       tableColumn_2.setText("\u5546\u54C1\u6570\u91CF");

       TableColumn tableColumn_3 = new TableColumn(table, SWT.NONE);

       tableColumn_3.setWidth(100);

       tableColumn_3.setText(" \u5546\u54C1\u6709\u6548\u671F\u81F3");

       TableColumn tableColumn_4 = new TableColumn(table, SWT.NONE);

       tableColumn_4.setWidth(100);

       tableColumn_4.setText("\u5546\u54C1\u7C7B\u578B");

       String sql="select * from systeminfo";

       List<Map<String, String>> list=jdbcTool.query(sql);

       for(Map<String, String> map:list){

           TableItem tableItem = new TableItem(table, SWT.NONE);

           String[] strs=new String[6];

           strs[0]=map.get("p_id");

           strs[1]=map.get("p_name");

           strs[2]=map.get("p_price");

           strs[3]=map.get("p_count");

           strs[4]=map.get("p_date");

           strs[5]=map.get("p_type");

           tableItem.setText(strs);

          

       }

   }

 


6.4 内部登录

当点击内部登录时弹出如下的页面:

 

图6-4-1登录页面 图

    当进入这个页面时需要身份的验证,这个页面只能是超市内部的人员才能进入,当点击确定的时候就出来如下的页面:

 

图 6-4-2 内部操作 图

当进入这个页面之后就可以对超市中的商品进行添加和编辑操作。其代码如下所示:

public void createPartControl(Composite parent) {

       Composite container = new Composite(parent, SWT.NONE);

    container.setBackgroundImage(SWTResourceManager.getImage(HomeUpInEditor.class, "/com/szq/image/QQ\u622A\u56FE20130414183628.jpg"));

       Button button = new Button(container, SWT.NONE);

    button.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED));

        button.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {

              HomeAddShell.start();   

           }

       });

       button.setBounds(86, 49, 129, 27);

       button.setText(" \u5546\u54C1\u6DFB\u52A0");

       Button button_1 = new Button(container, SWT.NONE);

    button_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED);

       button_1.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {

              HomeCommodityShell.start();

           }

       });

       button_1.setBounds(86, 147, 129, 27);

       button_1.setText(" \u5546\u54C1\u4FE1\u606F\u7F16\u8F91"); 

       final Label lblNewLabel = new Label(container, SWT.NONE);

       lblNewLabel.addMouseListener(new MouseAdapter() {

           public void mouseUp(MouseEvent e) {

              System.out.println("ddddd");

           }

       });

       lblNewLabel.addMouseTrackListener(new MouseTrackAdapter() {

           public void mouseEnter(MouseEvent e) {

    lblNewLabel.setBackgroundImage(SWTResourceManager.getImage(HomeUpInEditor.class, "/com/szq/image/quedinganxia.jpg"));

           }

           public void mouseExit(MouseEvent e) {

    lblNewLabel.setBackgroundImage(SWTResourceManager.getImage(HomeUpInEditor.class, "/com/szq/image/quedingmoren19.jpg"));

           }

       });

    lblNewLabel.setBackgroundImage(SWTResourceManager.getImage(HomeUpInEditor.class, "/com/szq/image/quedingmoren19.jpg"));

       lblNewLabel.setBounds(318, 439, 122, 116);

}

 

6.4.1 商品的添加

当点击商品的添加后进入如下的页面:

 

图 6-4-3 商品添加页面 图

    当进入这个页面时超市管理人员根据相应的项填入相应的商品的信息。其代码如下所示:

public void createPartControl(Composite parent) {

       final Composite container = new Composite(parent, SWT.NONE);

       Label label = new Label(container, SWT.NONE);

       label.setBounds(26, 140, 61, 17);

       label.setText(" \u5546\u54C1\u79CD\u7C7B\uFF1A");

       Label label_1 = new Label(container, SWT.NONE);

       label_1.setBounds(37, 10, 61, 17);

       label_1.setText(" \u5546\u54C1\u540D\uFF1A");

       Label label_2 = new Label(container, SWT.NONE);

       label_2.setBounds(26, 36, 61, 17);

       label_2.setText(" \u5546\u54C1\u4EF7\u683C\uFF1A");

       Label label_3 = new Label(container, SWT.NONE);

       label_3.setBounds(26, 70, 61, 17);

       label_3.setText(" \u5546\u54C1\u6570\u91CF\uFF1A");

       Label label_4 = new Label(container, SWT.NONE);

       label_4.setBounds(0, 104, 87, 17);

       label_4.setText(" \u5546\u54C1\u7684\u6709\u6548\u671F\uFF1A");

       final DateTime dateTime = new DateTime(container, SWT.BORDER);

       dateTime.setBounds(120, 104, 88, 24);

       Button button = new Button(container, SWT.NONE);

       button.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {

              String name=text.getText();

              String price=text_1.getText();

              String count=text_2.getText();

              String date=dateTime.getYear()+"-"+(dateTime.getMonth()+1)+"-"+dateTime.getDay();

              String type=text_4.getText();

if(name==null||name.equals("")||price==null||price.equals("")||count==null||count.equals("")||date==null||date.equals("")||type==null||type.equals("")){

                  MessageBoxbox=new MessageBox(container.getShell(),SWT.ERROR);

                  box.setMessage("您的商品系信息不完全");

                  box.open();

              }else{

                  String sql="insert into systeminfo(p_name,p_price,p_count,p_date,p_type) values('"+name+"','"+price+"','"+count+"','"+date+"','"+type+"')";              

                  int temp=tool.update(sql);

                  if(temp==-1){

                     MessageBoxbox=new MessageBox(container.getShell());

                     box.setMessage("添加商品失败!!!");

                     box.setText("提示信息");

                     box.open();

                  }else{

                     MessageBox box=new MessageBox(container.getShell());

                     box.setMessage("添加商品成功!!!");

                     box.setText("提示信息");

                     text.setText("");

                     text_1.setText("");

                     text_2.setText("");

                     text_4.setText("");

                  }

              }

           }

       });

       button.setBounds(37, 201, 80, 27);

       button.setText(" \u786E\u5B9A");

       Button button_1 = new Button(container, SWT.NONE);

       button_1.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {

              text.setText("");

              text_1.setText("");

              text_2.setText("");

              text_4.setText("");

           }

       });

       button_1.setBounds(161, 201, 80, 27);

       button_1.setText(" \u91CD\u7F6E");

       text = new Text(container, SWT.BORDER);

       text.setBounds(120, 10, 121, 23);

       text_1 = new Text(container, SWT.BORDER);

       text_1.setBounds(117, 39, 124, 23);

       text_2 = new Text(container, SWT.BORDER);

       text_2.setBounds(120, 70, 121, 23);

       text_4 = new Text(container, SWT.BORDER);

    text_4.setBounds(120, 140, 121, 23);   }

6.4.2 商品信息编辑

当点击了“商品信息编辑”时进入如下的页面:

 

图 6-4-4 商品编辑页面 图

    当进入这个页面时超市管理人员可以对商品的信息进行删除、修改、刷新管理。

当鼠标移到要改的商品商品单击左键然后再点击右键时就可以对商品进行相应的操作了。其图如下所示:

 

图6-4-5 商品删除提示 图

当点击删除时会弹出上示图,可以对商品进行删除操作。

以上代码如下:

public HomeCommodityShell(Display display) {

       super(display, SWT.SHELL_TRIM | SWT.APPLICATION_MODAL);    setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));    setBackgroundImage(SWTResourceManager.getImage(HomeCommodityShell.class, "/com/szq/image/sy_201207250917169670.jpg"));

       table = new Table(this, SWT.BORDER | SWT.FULL_SELECTION);

       table.setBackground(SWTResourceManager.getColor(51, 153, 255));    table.setBackgroundImage(SWTResourceManager.getImage(HomeCommodityShell.class, "/com/szq/image/getCA2TT221.jpg"));

       table.setBounds(10, 49, 602, 426);

       table.setHeaderVisible(true);

       table.setLinesVisible(true);

       TableColumn tableColumn = new TableColumn(table, SWT.NONE);

       tableColumn.setWidth(100);

       tableColumn.setText("\u7F16\u53F7");

       TableColumn tableColumn_1 = new TableColumn(table, SWT.NONE);

       tableColumn_1.setWidth(100);

       tableColumn_1.setText(" \u5546\u54C1\u540D");

       TableColumn tableColumn_2 = new TableColumn(table, SWT.NONE);

       tableColumn_2.setWidth(100);

       tableColumn_2.setText(" \u5546\u54C1\u4EF7\u683C");

       TableColumn tableColumn_3 = new TableColumn(table, SWT.NONE);

       tableColumn_3.setWidth(100);

       tableColumn_3.setText("\u5546\u54C1\u6570\u91CF");

       TableColumn tableColumn_4 = new TableColumn(table, SWT.NONE);

       tableColumn_4.setWidth(100);

       tableColumn_4.setText("\u5546\u54C1\u6709\u6548\u671F\u81F3");

       TableColumn tableColumn_5 = new TableColumn(table, SWT.NONE);

       tableColumn_5.setWidth(100);

       tableColumn_5.setText("\u5546\u54C1\u7C7B\u578B");

       String sql1="select * from systeminfo";

       List<Map<String, String>> list1=jdbcTool.query(sql1);

       for(Map<String, String> map:list1){

           TableItem tableItem = new TableItem(table, SWT.NONE);

           String[] strs=new String[6];

           strs[0]=map.get("p_id");

           strs[1]=map.get("p_name");

           strs[2]=map.get("p_price");

           strs[3]=map.get("p_count");

           strs[4]=map.get("p_date");

           strs[5]=map.get("p_type");

           tableItem.setText(strs);

       }

       Menu menu = new Menu(table);

       table.setMenu(menu);

       MenuItem menuItem = new MenuItem(menu, SWT.NONE);

       menuItem.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {            TableItem[] itms=table.getSelection();

              pid=itms[0].getText(0);

              HomeCommodity_1Shell.start();

              table.removeAll();

              String sql1="select * from systeminfo";

              List<Map<String, String>> list1=jdbcTool.query(sql1);

              for(Map<String, String> map:list1){

                  TableItem tableItem = new TableItem(table, SWT.NONE);

                  String[] strs=new String[6];

                  strs[0]=map.get("p_id");

                  strs[1]=map.get("p_name");

                  strs[2]=map.get("p_price");

                  strs[3]=map.get("p_count");

                  strs[4]=map.get("p_date");

                  strs[5]=map.get("p_type");

                  tableItem.setText(strs);

              }

           }

       });

       menuItem.setText(" \u4FEE\u6539");

      

       MenuItem menuItem_1 = new MenuItem(menu, SWT.NONE);

       menuItem_1.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {            TableItem[] items=table.getSelection();

              String sql="delete from systeminfo where p_id='"+items[0].getText(0)+"'";

              MessageBox box=new MessageBox(getShell(),SWT.OK|SWT.CANCEL);

              box.setMessage("确认删除吗???");

              box.setText("温馨提示");

              int temp=box.open();

              if(temp==32){

                  int a =jdbcTool.update(sql);

                  if(a==1){

                     MessageBox box1=new MessageBox(getShell());

                     box1.setMessage("删除成功!!!");

                     box1.setText("温馨提示");

                     box1.open();

                     table.removeAll();

                     String sql1="select * from systeminfo";

                     List<Map<String, String>> list1=jdbcTool.query(sql1);

                     for(Map<String, String> map:list1){

                         TableItem tableItem = new TableItem(table, SWT.NONE);

                         String[] strs=new String[6];

                         strs[0]=map.get("p_id");

                         strs[1]=map.get("p_name");

                         strs[2]=map.get("p_price");

                         strs[3]=map.get("p_count");

                         strs[4]=map.get("p_date");

                         strs[5]=map.get("p_type");

                         tableItem.setText(strs);

                     }

                  }else{

                     MessageBox box2=new MessageBox(getShell(),SWT.ERROR);

                     box2.setMessage("删除失败!!!");

                     box2.setText("温馨提示");

                     box2.open();

                  }

              }else if(temp==256){

              }

           }

       });

       menuItem_1.setText("\u5220\u9664");

      

       MenuItem menuItem_2 = new MenuItem(menu, SWT.NONE);

       menuItem_2.setText("\u5237\u65B0");

       createContents();

   }

 


 

图 6-3-6 商品修改页面 图

当点击了修改时进入如上页面,这样可以对商品信息进行修改。

其代码如下所示:

public HomeCommodity_1Shell(Display display) {

       super(display, SWT.SHELL_TRIM | SWT.APPLICATION_MODAL);    setBackground(SWTResourceManager.getColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT));

       final Label label = new Label(this, SWT.NONE);

       label.setBounds(10, 20, 61, 17);

       label.setText("\u5546\u54C1\u540D\uFF1A");

       text = new Text(this, SWT.BORDER);

       text.setBounds(123, 14, 116, 23);

       Label label_1 = new Label(this, SWT.NONE);

       label_1.setBounds(10, 82, 61, 17);

       label_1.setText(" \u5546\u54C1\u4EF7\u683C\uFF1A");

       text_1 = new Text(this, SWT.BORDER);

       text_1.setBounds(123, 82, 116, 23);

       label_2.setBounds(10, 151, 61, 17);

       label_2.setText(" \u5546\u54C1\u6570\u91CF\uFF1A");

       text_2 = new Text(this, SWT.BORDER);

       text_2.setBounds(123, 151, 116, 23);

       Label label_3 = new Label(this, SWT.NONE);

       label_3.setBounds(10, 223, 88, 17);

       label_3.setText(" \u5546\u54C1\u6709\u6548\u671F\u81F3\uFF1A");

       DateTime dateTime = new DateTime(this, SWT.BORDER);

       dateTime.setBounds(120, 216, 96, 24);

       Label label_4 = new Label(this, SWT.NONE);

       label_4.setBounds(10, 300, 61, 17);

       label_4.setText("\u5546\u54C1\u7C7B\u578B\uFF1A");

       text_3 = new Text(this, SWT.BORDER);

       text_3.setBounds(123, 300, 116, 23);

       String sql="select * from systeminfo where p_id ='"+HomeCommodityShell.pid+"'";

       java.util.List<Map<String, String>> list=jdbcTool.query(sql);

       Map<String, String> map=list.get(0);

           text.setText(map.get("p_name"));

           text_1.setText(map.get("p_price"));

           text_2.setText(map.get("p_count"));

           text_3.setText(map.get("p_type"));

       Button button = new Button(this, SWT.NONE);

       button.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {            String pid=label.getText();

              String pname=text.getText();

              String pprice=text_1.getText();

              String pcount=text_2.getText();

              String ptype=text_3.getText();

              String sql="update systeminfo set p_name='"+pname+"',p_price='"+pprice+"',p_count='"+pcount+"',p_type='"+ptype+"' where p_id='"+pid+"'";

              int temp=jdbcTool.update(sql);

              if(temp==1){

                  MessageBox box=new MessageBox(getShell());

                  box.setMessage("修改成功!!!");

                  box.open();

              }else{

                  MessageBox box=new MessageBox(getShell());

                  box.setMessage("修改失败!!!");

                  box.open();

              }

              dispose();          

           }

       });

       button.setBounds(27, 359, 80, 27);

       button.setText(" \u786E\u5B9A");

       Button button_1 = new Button(this, SWT.NONE);

       button_1.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {

              text.setText("");

              text_1.setText("");

              text_2.setText("");

              text_3.setText("");

           }

       });

       button_1.setBounds(197, 359, 80, 27);

       button_1.setText("\u91CD\u7F6E");

       createContents();

    }

    protected void createContents() {

       setText("修改商品信息");

       setSize(568, 434);

}

6.5  人员添加

当点击了“人员添加”的时候会弹出如下页面:

 

图 6-5 人员添加 图

当进入这个页面时对相应的项填入相应的值然后点击“确定”按钮保存超市人员的信息。其相关代码如下所示:

public void createPartControl(Composite parent) {

    final Composite container = new Composite(parent, SWT.NONE);    container.setBackgroundImage(SWTResourceManager.getImage(AddHumanEditor.class, "/com/szq/image/sy_201207250917169670.jpg"));    container.setBackground(SWTResourceManager.getColor(SWT.COLOR_GREEN));

       Label label = new Label(container, SWT.NONE);

       label.setBounds(51, 22, 61, 17);

       label.setText(" \u4EBA\u5458\u59D3\u540D\uFF1A");

       text = new Text(container, SWT.BORDER);

       text.setBounds(141, 22, 117, 23);

       Label lblNewLabel = new Label(container, SWT.NONE);

       lblNewLabel.setBounds(51, 68, 61, 17);

       lblNewLabel.setText("\u5E74\u9F84\uFF1A");

       text_1 = new Text(container, SWT.BORDER);

       text_1.setBounds(141, 68, 117, 23);

       Label label_1 = new Label(container, SWT.NONE);

       label_1.setBounds(51, 123, 61, 17);

       label_1.setText(" \u6027\u522B\uFF1A");

       text_2 = new Text(container, SWT.BORDER);

       text_2.setBounds(141, 123, 117, 23);

       Label label_2 = new Label(container, SWT.NONE);

       label_2.setBounds(51, 168, 61, 17);

       label_2.setText(" \u5730\u5740\uFF1A");

       text_3 = new Text(container, SWT.BORDER);

       text_3.setBounds(141, 168, 296, 23);

       Label label_3 = new Label(container, SWT.NONE);

       label_3.setBounds(51, 228, 61, 17);

       label_3.setText("\u7535\u8BDD\uFF1A");

       text_4 = new Text(container, SWT.BORDER);

       text_4.setBounds(141, 222, 117, 23);

       Button button = new Button(container, SWT.NONE);

       button.addSelectionListener(new SelectionAdapter() {

           public void widgetSelected(SelectionEvent e) {

              String name=text.getText();

              String age=text_1.getText();

              String sex=text_2.getText();

              String address=text_3.getText();

              String tel=text_4.getText(); if(name==null||name.equals("")||age==null||age.equals("")||sex==null||sex.equals("")||address==null||address.equals("")||tel==null||tel.equals("")){

              MessageBox box=new MessageBox(container.getShell(),SWT.ERROR);

                  box.setMessage("您的人员信息不完全");

                  box.open();

              }else{

                  String sql="insert into human(h_name,h_age,h_sex,h_address,h_tel) values('"+name+"','"+age+"','"+sex+"','"+address+"','"+tel+"')";

                  int temp=tool.update(sql);

                  if(temp==-1){

                     MessageBox box=new MessageBox(container.getShell());

                     box.setMessage("添加人员失败!!!");

                     box.setText("提示信息");

                     box.open();

                  }else{

                     MessageBox box=new MessageBox(container.getShell());

                     box.setMessage("添加人员成功!!!");

                     box.setText("提示信息");

                     box.open();

                     text.setText("");

                     text_1.setText("");

                     text_2.setText("");

                     text_3.setText("");

                     text_4.setText("");

                  }

              }

           }

       });

       button.setBounds(97, 298, 80, 27);

       button.setText("\u786E\u5B9A");

       Button button_1 = new Button(container, SWT.NONE);

       button_1.addSelectionListener(new SelectionAdapter() {         public void widgetSelected(SelectionEvent e) {

              text.setText("");

              text_1.setText("");

              text_2.setText("");

              text_3.setText("");

              text_4.setText("");

           }

       });

       button_1.setBounds(265, 298, 80, 27);

       button_1.setText("\u91CD\u7F6E");      }

7、总结

随着时代的变化我们的信息的获取越来越广泛,对于超市的管理也越来越多样化、全面化和完整化。由于这方面的变化与需求超市企业MIS建设具有较大、较深的需求,而物业信息网络及管理信息组织与建设的最终目标是为超市企业化现代化管理提供高效、快捷的信息服务。建设一个满足超市生产、经营和管理需要的信息网络和管理信息系统是十分困难和必要的,其中搞好信息资源的组织、开发与利用尤为重要。

本程序的设计与开发就是基于以上的需求,应对超市的管理多样化问题所做的关于数据库的课程设计,在这个程序中我们可以看到,当顾客进入超市时他们会遇到各种的问题,但是当他们进入超市如果看到这个应用程序的话他么会对于这个装有此等程序的超市来说,他们给了顾客一种更人性化、更便捷与清晰的感觉,是的顾客对于这个超市的第一映象是优秀的,这样可以为我们超市赚取更多的回头顾客。满足顾客的需求是各种行业的盈利基础,超市也不为例。

对于这个程序的设计感谢老师给我们这个机会,让我们可以在实际中给我们体会与检验自己的专业知识,使得我们的知识更牢固与更实际化,也使得我们对未来更有信心、更有挑战的勇气,这是非光学不实际应用所不能体会的,这也是我们走向社会、走向未来的一笔财富。

posted @ 2013-09-14 13:30  Chengo  阅读(398)  评论(0编辑  收藏  举报