超市POS系统架构.docx

上传人:b****5 文档编号:6748186 上传时间:2023-01-09 格式:DOCX 页数:19 大小:295.91KB
下载 相关 举报
超市POS系统架构.docx_第1页
第1页 / 共19页
超市POS系统架构.docx_第2页
第2页 / 共19页
超市POS系统架构.docx_第3页
第3页 / 共19页
超市POS系统架构.docx_第4页
第4页 / 共19页
超市POS系统架构.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

超市POS系统架构.docx

《超市POS系统架构.docx》由会员分享,可在线阅读,更多相关《超市POS系统架构.docx(19页珍藏版)》请在冰豆网上搜索。

超市POS系统架构.docx

超市POS系统架构

超市POS系统架构

一、需求概述

开发一套淮信进销存系统,包括商品信息管理,采购入库,库存盘点,商品销售,综合信息查询等不同的功能模块,需要在不同的功能模块中都显示淮信POS进销存系统的版本信息和对应的功能标题。

二、需求分析

对于软件系统,需要从以下几方面加以认识:

1、软件系统的使用流程

软件系统的使用流程一般包括以下几步:

1)双击系统图标,打开应用软件;

2)在系统登录界面下,输入用户名和密码,登录系统;

3)进入系统主界面,一般由系统菜单和功能区域组成;

4)单击菜单项或者输入快捷按钮切换到具体的子功能界面。

2、功能界面的组成

功能界面本身是一个类,一般由按钮、文本框等控件组成。

每个控件也是一个类。

图1展示了WinForms程序下的进货管理功能模块界面,本例采用控制台程序来模拟类似界面,。

图1采购入库功能界面

软件开发的整体思路是由简单到复杂,层层递进。

目前的任务是在整体上对进销存系统有一个了解,稳扎稳打,为项目的开发打下语言基础。

在具体编码之前,一定要先明确自己要做什么,对于本任务,可按如下步骤来操作:

1、建立登录界面类,要求用户输入用户名和密码(假设均为admin);

2、建立主界面类,接收用户输入,根据输入菜单名称的不同,显示相应的功能菜单;

3、建立各个功能界面类,接收用户输入,返回主界面。

各个类之间的关系如图2所示:

输入0

 

图2各界面间关系

三、实现过程

1、创建名为HcitPosSys的C#控制台应用程序;

2、新建名为SoftwareInfo的类,用来显示软件版本、版权信息等,代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

//此处用静态类声明软件版本信息,注意:

静态类不可以实例化,并且类成员都需要声明static

publicstaticclassSoftWareInfo

{

publicstaticstringuserName;//软件当前用户

publicstaticvoidShowHeader()

{

Console.WriteLine("======================================================");

Console.WriteLine("淮信HcitPos进销存管理系统版本号:

V1.0.2009.4");Console.WriteLine("======================================================");

}

publicstaticvoidShowFooter()

{

Console.WriteLine();

Console.WriteLine("您好,{0},当前系统时间为{1}",userName,DateTime.Now);

Console.WriteLine("版权所有:

2009-2010联系方式:

12345678");

Console.WriteLine();

}

}

}

3、新建名为FrmLogin的类,(Form即界面的英文表述,此处用Frm前缀表示这是一个界面类),逻辑代码如下所示,具体功能实现参见注释:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassFrmLogin

{

privatestringuserName;

privatestringpassword;

//默认构造函数

publicFrmLogin()

{

}

//1.用户名和密码显示区,空了行才要求用户输入用户名和密码,主要是为了界面美观

//本功能比较独立,所以单独放在一个方法里,这就是模块化编程的思想

privatevoidShowLoginInfo()

{

for(inti=0;i<5;i++)

Console.WriteLine();

Console.Write("用户名:

");

userName=Console.ReadLine();

Console.Write("密码:

");

password=Console.ReadLine();

}

//2.验证用户名和密码功能,供主程序循环调用

publicboolValidateUserInfo()

{

//1.访问数据库来获取用户名、密码信息,模拟为admin,admin

//2.校验是否合法

if(userName=="admin"&&password=="admin")

{

//将用户名信息保存在静态字段中

SoftWareInfo.userName=userName;

returntrue;

}

returnfalse;

}

//3.显示登录界面

publicvoidShow()

{

SoftWareInfo.ShowHeader();

ShowLoginInfo();

}

}

}

注意SoftWareInfo.userName=userName;这句代码,这样在其他界面中也能访问到登录的用户信息。

4、双击“Program.cs”文件,修改该文件为:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

classProgram

{

staticvoidMain(string[]args)

{

FrmLoginfrm=newFrmLogin();

frm.Show();

}

}

}

键运行程序,界面如图4.11所示:

图4.11登录界面

注意,本步骤体现了软件开发流程,在完成一个功能类后,应该首先测试该功能是否可用,当代码出错的时候,方便发现错误和解决错误,这也是一个层次递进的开发过程。

5、添加“FrmMain”类(主界面类),代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassFrmMain

{

//1.显示主界面

publicvoidShow()

{

SoftWareInfo.ShowHeader();

for(inti=0;i<5;i++)

{

Console.WriteLine();

}

Console.WriteLine("请选择子功能模块:

\n1.商品信息维护\n2.采购入库\n3.库存盘点\n4.商品销售\n5.综合查询");//\n的作用为换行

for(inti=0;i<5;i++)

{

Console.WriteLine();

}

SoftWareInfo.ShowFooter();

}

//2.获取用户输入

publicintGetUserInput()

{

returnint.Parse(Console.ReadLine());

}

}

}

6、修改Program.cs文件,代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

classProgram

{

staticvoidMain(string[]args)

{

//1.显示登录界面

FrmLoginfrm=newFrmLogin();

frm.Show();

//2.验证用户名和密码

if(frm.ValidateUserInfo())

{

//3.密码正确,显示主界面

FrmMainfrmMain=newFrmMain();

frmMain.Show();

}

else

{

//4.密码错误,退出系统

Console.WriteLine("错误的用户名和密码!

");

Console.WriteLine("系统关闭!

");

}

}

}

}

7、运行程序,输入用户名admin和密码admin后,界面如图4.12所示:

图4.12主界面

8、添加“FrmGoodsInfo”(商品信息类)、“FrmPurchase”(采购类)、“FrmStoreCheck”(盘点类)、“FrmSale”(商品销售类)、“FrmQuery”(商品查询类),代码类似,分别如下:

FrmGoodsInfo(商品信息类):

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassFrmGoodsInfo

{

publicvoidShow()

{

//按退出,返回到主界面

do

{

//清屏

Console.Clear();

//一直循环显示

SoftWareInfo.ShowHeader();

for(inti=0;i<5;i++)

Console.WriteLine();

Console.WriteLine("商品信息维护功能\n按键返回上一级");

for(inti=0;i<5;i++)

Console.WriteLine();

SoftWareInfo.ShowFooter();

}while(Console.ReadLine()!

="0");

}

}

}

FrmPurchase(采购类):

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassFrmPurchase

{

publicvoidShow()

{

//按退出,返回到主界面

do

{

Console.Clear();

SoftWareInfo.ShowHeader();

for(inti=0;i<5;i++)

Console.WriteLine();

Console.WriteLine("采购入库功能\n按键返回上一级");

for(inti=0;i<5;i++)

Console.WriteLine();

SoftWareInfo.ShowFooter();

}while(Console.ReadLine()!

="0");

}

}

}

其他3个类代码也类似,只需Console.WriteLine("采购入库功能\n按键返回上一级");改成当前类功能,具体操作时,可以用(拷贝),(粘贴)形式。

注意,这样实现的程序,代码冗余量大,一处出错,5个类都要修改。

例如,在开始实现时,并没有加入循环,只是直接显示信息,而后为了提高拟真度,加入了do…while循环,一次就要修改5个,操作非常繁琐。

如何避免这种情况呢?

在下一章将介绍解决方案。

另外一种减少代码冗余量的方法是把代码:

for(inti=0;i<5;i++)

Console.WriteLine();

移动到SoftwaverInfo类中的ShowHeader()和ShowFooter()方法中。

9、修改”FrmMain.cs”文件,实现根据用户输入,显示子功能界面,修改后代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassFrmMain

{

//1.显示主界面

publicvoidShow()

{

SoftWareInfo.ShowHeader();

for(inti=0;i<5;i++)

{

Console.WriteLine();

}

Console.WriteLine("请选择子功能模块:

\n1.商品信息维护\n2.采购入库\n3.库存盘点\n4.商品销售\n5.综合查询");

for(inti=0;i<5;i++)

{

Console.WriteLine();

}

SoftWareInfo.ShowFooter();

}

//2.获取用户输入

publicintGetUserInput()

{

returnint.Parse(Console.ReadLine());

}

//3.程序处理过程,显示主界面,根据用户输入,显示其他界面

publicvoidProcess()

{

while(true)

{

//清除屏幕,重绘

Console.Clear();

Show();

switch(GetUserInput())

{

case1:

FrmGoodsInfofrmGoodsInfo=newFrmGoodsInfo();

frmGoodsInfo.Show();

break;

case2:

FrmPurchasefrmPurchase=newFrmPurchase();

frmPurchase.Show();

break;

case3:

FrmStoreCheckfrmStoreCheck=newFrmStoreCheck();

frmStoreCheck.Show();

break;

case4:

FrmSalefrmSale=newFrmSale();

frmSale.Show();

break;

case5:

FrmQueryfrmQuery=newFrmQuery();

frmQuery.Show();

break;

default:

Console.WriteLine("输入错误,请重新输入!

");

break;

}

}

}

}

}

这里采用了while(true)的死循环模式,实际上,windows操作系统正是一个类似的循环程序,在循环中实现等待用户输入、刷新windows窗口等功能,这也是大多数windows软件的核心原理。

当然,实际软件复杂度要软高于本模拟任务。

10、修改“Program.cs”文件,完整代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

classProgram

{

staticvoidMain(string[]args)

{

//1.显示登录界面

FrmLoginfrm=newFrmLogin();

frm.Show();

//2.验证用户名和密码

if(frm.ValidateUserInfo())

{

//3.密码正确,显示主界面

FrmMainfrmMain=newFrmMain();

frmMain.Show();

frmMain.Process();

}

else

{

//4.密码错误,退出系统

Console.WriteLine("错误的用户名和密码!

");

Console.WriteLine("系统关闭!

");

}

}

}

}

在实际的windows窗体程序开发中,其逻辑要比目前模式复杂,一般会增加一个Application类来负责应用程序的运行。

11、程序子功能模块运行效果如图4.13所示,按<0>键可以返回主界面。

图4.13子功能界面

至此,HcitPost进销存系统架构已经模拟完成,用户操作步骤如下:

1)在输入用户名和密码后,进入程序主界面;

2)在主界面通过输入对应选项,即可进入相应子界面;

3)在子界面输入“0”,则返回主界面,重复步骤2);

4)用户通过点击控制台窗口右上角的“X”图标退出系统。

通过本案例,可以发现,在实际项目开发时,很难一次将程序功能写好,程序编写是一个不断设计、编码、调试到再设计、再编码、再调试的过程,整个过程螺旋上升,逐渐逼近用户需求。

项目完善与提高:

1、在以上项目的基础上,新建一个名为Form的类,作为各个子模块的基类,具体代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassForm

{

publicvoidShow(stringtitle)

{

//按退出,返回到主界面

do

{

//清屏

Console.Clear();

//一直循环显示

SoftWareInfo.ShowHeader();

for(inti=0;i<5;i++)

Console.WriteLine();

Console.WriteLine("{0}\n按键返回上一级",title);

for(inti=0;i<5;i++)

Console.WriteLine();

SoftWareInfo.ShowFooter();

}while(Console.ReadLine()!

="0");

}

}

}

2、删除商品信息维护类的Show方法,修改代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassFrmGoodsInfo:

Form

{

}

}

同理,删除采购入库、库存盘点、商品销售、综合查询等类的Show方法,并在类名后添加“:

Form”,实现对Form类的继承。

3、为了更清楚表示继承的关系,在VS2005的解决方案资源管理器中,右击HcitPosSys项目,在弹出菜单中执行“添加”→“新建项”,如图5.1所示。

图5.1添加新项

4、在弹出的添加新项对话框中,选择“类关系图”,点击添加按钮,如图5.2所示。

图5.2选择类关系图

5、从VS2005解决方案资源管理器对话框中选择Form类,将之拖动到类设计器上。

同理将FormGoodsInfo、FormPurchase、FrmStoreCheck、FrmSale、FrmQuery等类也拖动到类设计器上,如图5.3所示,这种结构称为类图。

图5.3继承类

6、修改FrmMain主界面类的代码如下:

usingSystem;

usingSystem.Collections.Generic;

usingSystem.Text;

namespaceHcitPosSys

{

publicclassFrmMain

{

//1.显示主界面

publicvoidShow()

{

SoftWareInfo.ShowHeader();

for(inti=0;i<5;i++)

{

Console.WriteLine();

}

Console.WriteLine("请选择子功能模块:

\n1.商品信息维护\n2.采购入库\n3.库存盘点\n4.商品销售\n5.综合查询");

for(inti=0;i<5;i++)

{

Console.WriteLine();

}

SoftWareInfo.ShowFooter();

}

//2.获取用户输入

publicintGetUserInput()

{

returnint.Parse(Console.ReadLine());

}

//3.程序处理过程,显示主界面,根据用户输入,显示其他界面

publicvoidProcess()

{

while(true)

{

//清除屏幕,重绘

Console.Clear();

Show();

switch(GetUserInput())

{

case1:

FrmGoodsInfofrmGoodsInfo=newFrmGoodsInfo();

frmGoodsInfo.Show("商品信息维护功能");

break;

case2:

FrmPurchasefrmPurchase=newFrmPurchase();

frmPurchase.Show("采购入库功能");

break;

case3:

FrmStoreCheckfrmStoreCheck=newFrmStoreCheck();

frmStoreCheck.Show("库存盘点功能");

break;

case4:

FrmSalefrmSale=newFrmSale();

frmSale.Show("商品销售功能");

break;

case5:

FrmQueryfrmQuery=newFrmQuery();

frmQuery.Show("综合查询功能");

break;

default:

Console.WriteLine("输入错误,请重新输入!

");

break;

}

}

}

}

}

通过继承,可以实现代码重用,提高了软件模块的可复用性和可扩充性。

注意,只有声明为public和protected的类成员,才能被派生类访问,另外,不能同时继承两个以上的类。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1