超市管理系统

上传人:1888****888 文档编号:38440391 上传时间:2021-11-07 格式:DOC 页数:49 大小:530.98KB
收藏 版权申诉 举报 下载
超市管理系统_第1页
第1页 / 共49页
超市管理系统_第2页
第2页 / 共49页
超市管理系统_第3页
第3页 / 共49页
资源描述:

《超市管理系统》由会员分享,可在线阅读,更多相关《超市管理系统(49页珍藏版)》请在装配图网上搜索。

1、 20102010 届毕业论文(设计)届毕业论文(设计) 材材 料料 系 、 部: 数计系 学生姓名: 指导教师: 职称 讲师 专 业: 计算机教育 班 级: 一班 2010 年 5 月I20102010 届毕业论文(设计)课题任务书届毕业论文(设计)课题任务书系: 数计系 专业: 计算机教育 指导教师学生姓名课题名称超市管理系统内容及任务主要内容:通过 visual Basic 6.0 和 SQL SERVER2000 构造出一个小型的超市管理系统。此系统能够实现以下功能:1. 库存管理(包括录入商品、修改和删除商品、查询商品)(1)录入商品(2)修改和删除商品(3)查询商品2. 商品销售(

2、1)销售商品(2)查询销售情况3. 系统设置(1)用户管理(2)修改密码要求:1. 查阅相关的国内外文献,按时提交开题报告;2. 论文内容正确无误,有一定的创新或个人见解;3. 开发的系统必须在计算机上测试通过,程序运行良好;4. 论文必须按照学校规定的统一格式撰写;5. 论文严禁抄袭,引用别人的成果必须在文中注明。II拟达到的要求或技术指标工资管理系统的主要任务是用计算机对各种工资信息进行日常管理,如修改、增加、删除及查询等,针对系统服务对象的具体要求,迅速、准确地完成各种信息的工作。 1可行性 要力求最大限度地满足实际工作的需要,充分考虑各层次、各环节数据处理的实用性,满足小型超市的管理。

3、而且操作简便实用。 2安全性 应用软件与数据库系统的设计要做到安全可靠,防止非法用户的入侵。数据库的备份策略恰当,同时设置多种管理人员。以防他人盗取有用的信息。 3实用性用户界面应当直观、明了、条理清晰。实现了易学、易用、易管理。起止日期工作内容备注进度安排1 月 10 日2 月 12日2 月 14 日2 月 20日2 月 20 日4 月 18日4 月 18 日5 月 10日收集信息以及进行系统整体规划写任务书以及开题报告开始进行系统开发,初步定稿对系统进行进一步修改完善,最后定稿III主要参考资料1叶俊民,汪望珠.面向对象软件工程.第二版.清华大学出版社2戴志诚. SQLServer 200

4、5 数据库系统开发与实例. 电子工业出版社3郑阿奇.SQL Server 教程.清华大学出版社4胡胜利.动态报表在 VB6.0 中的设计和实现.江苏技术师范学院学报5李占宣.数据库中面向复杂应用的查询方法.电脑学习研室意见年 月 日系主管领导意见年 月 日IV株洲师专 200 届毕业论文(设计)指导教师评阅表系: 学生姓名学 号10107120班 级计教一班专 业计算机教育指导教师姓名课题名称超市管理系统评语:(包括以下方面,学习态度工作量完成情况;检索和利用文献能力、外文翻译和计算机应用能力;学术水平或技术水平、综合运用知识能力和创新能力;限 300 字以上)是否同意参加答辩:是 否指导教师

5、评定(满分:20 分)分值: 20指导教师签字:年 月 日V株洲师专 200 届毕业论文(设计)评阅教师评阅表系: 学生姓名学 号10107120班 级计教一班专 业评阅教师姓名课 题评语:(对论文学术评语(包括选题意义;文献利用能力;所用资料、实验数据和计算结果可靠性;创新成果及写作规范化和逻辑性。注意对其中可能存在的剽窃、论据作假等把好关,如果发现请详细说明)针对课题内容给设计者(作者)提出不少于 3 个问题,作为答辩时的必答题1.2.3.选题与文献综述(20 分)分值:创新性(15 分)分值:基础理论和专门知识(35 分)分值:作者写作、表达能力(30 分)分值:综合评价(满分:30 分

6、)分值: 30是否同意参加答辩是 否 评阅人(签名): 年 月 日VI株洲师专 200 届毕业论文(设计)答辩及最终成绩评 定 表系(公章): 学生姓名学号10107120班级计教一班答辩日期5 月课题名称超市管理系统指导教师评 定成 绩 评 定分值教师 1教师 2教师 3教师 4教师 5总 评课题介绍思路清晰,语言表达准确,概念清楚,论点正确,实验方法科学,分析归纳合理,结论严谨,论文(设计)有应用价值。30必答题40答辩表现思维敏捷,回答问题有理论根据,基本概念清楚,主要问题回答准确大、深入,知识面宽。自由提问30答辩评定(满分: 50分)分值: 50答辩小组长签名:指导教师评定分值:评阅

7、教师评定分值:最终评定成绩: 分数: 等级:答辩委员会主任签名: 年 月 日VII株株 洲洲 师师 范范 高高 等等 专专 科科 学学 校校20102010 届毕业设计说明书届毕业设计说明书 题 目 系、部: 数计系 学生姓名: 指导教师: 职称 讲师专 业: 计算机教育 班 级: 计教一班 完成时间: 2010-5-4 VIII摘 要伴随着社会的复杂化,传统的“一支笔,一本帐簿”的物品销售管理方式也慢慢的无法适应形势的变化。随着信息技术的发展,计算机已被广泛的用于社会的各个领域,成为推动社会发展的技术动力。而在计算机应用中,软件的作用十分突出,软件已经发展成为信息技术的核心,主导着信息产品的

8、开发和信息技术市场的进一步的开拓。软件产业已成为社会信息化进程中的一个战略性产业。在软件技术的应用中软件的开发技术尤其是应用型软件产品的开发技术成了重中之重。不断开发适应用户需求、市场需要的新型软件产品。随着社会的发展,软件也在不断的更新换代。随着信息化的发展,为了让管理更快捷、更准确,实现商业活动的信息化管理已经成为各个领域的当务之急。本次课设就是利用 Visual Basic 来开发的应用系统的。我们的这个系统主要是针对小型超市管理行业的,主要是用来对商品销售的商业活动进行管理的。应用本系统,我们可以使商品销售管理简单而有效的运行,这就是计算机的优点。下来我来简单介绍一下我们所开发出来的这

9、个系统,在我们的这个系统中,主要有三大方面的功能,即库存管理、商品销售管理、系统设置管理。另外,利用我们利用文件来对数据进行管理,从而使系统更加完善,功能更加强大。关键词:Visual Basic;文件;超市;系统IXSummaryWith the social complexity, the traditional a pen, a book, Sales management articles can also slow to adapt to changing situations. With the development of information technology, comp

10、uters have been widely used in various fields of society, as the technical driving force for promoting social development. In computer applications, a very prominent role in the software, the software has become the core of information technology, leading the development of information products and

11、information technology market to develop further. Software industry has become the information in the process of a strategic industry. Software applications in the development of software technology, in particular the development of applied software technology has become the top priority. Constantly

12、 develop to meet the customer needs, market needs, new software products. With the development of society, are constantly upgrading the software. With the development of information technology, in order to make management more efficient, more accurate information to achieve commercial activities in

13、various areas of management has become an urgent task.The course design is to use Visual Basic to develop the application system. This system is mainly our supermarket management for small industry is primarily used for sales of goods to manage the commercial activities. Application of this system,

14、we can make product sales management simple and effective operation, which is the computers advantages. I came down briefly what we have developed this system, this system in our three main areas of functionality, inventory management, sales management, and system settings management. In addition, t

15、he use of the data we use to manage documents, making the system more complete, more features.Key words: Visual Basic ;File; Supermarket ;System X目 录 摘摘 要要X第 1 章 绪 论 1第 2 章 系统功能介绍22.1 系统功能总框图22.2 模块功能介绍3第 3 章 系统功能实现43.1 系统登录模块的实现43.2 录入商品模块的实现 53.3 修改和删除商品的实现 73.4 查询商品功能的实现113.5 销售商品功能的实现133.6 查询销售情

16、况功能的实现173.7 用户管理界面 20结 论23致 谢24参考文献25 附 录 26 1第 1 章 绪 论紧张而又繁忙的课程设计过去了,在这一个星期里,让我尝到了以前我没有体验过的辛苦与劳累。经过本次的课程设计,使我克服了很多在程序设计上的弊端和难点,也让我体会到了冲出重围的幸福与喜悦。编写了几百行的代码最后写出一个程序觉得很有成就感。对 Visual Basic 的掌握提高到了一个新的水平,能够利用 Visual Basic 编程平台编写出一个实用的程序,很大程度提高了程序综合设计能力、分析能力和编程能力。世纪之初,以微电子、计算机、软件和通信技术为主导的信息技术革命给我们生存的社会所带

17、来的变化令人目不暇接。我选择超市管理系统,它可以应用在小型的超市管理中,为商品销售的各项管理及信息保存提供了一个良好的操作环境,为这些单位提供了很大的方便。随着科学技术的不断提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。作为计算机应用的一部分,使用计算机对超市管理,具有着手工管理所无法比拟的优点.例如:检索迅速、查找方便、可靠性高、存储量大、保密性好、寿命长、成本低等。这些优点能够极大地提高超市管理的效率,从而使企业取得更大的利润。课程设计结束了,但是它留给我的印象是不可磨灭的。无论我以后会不会涉及这方面的研究,我想,我至少掌握了一

18、种系统的研究方法,我们学习的目的就在于运用,我们运用这种研究方法的时候会很多,我最后要感谢课程设计,它的确教会我很多。 1第 2 章 系统功能介绍2.1 系统功能总框图在本次课程设计中,我所做的课设题目是超市销售管理系统,根据它的基本要求和经过我们查阅相关资料。经过自己的研究,最后我制定出了本系统的总体功能。因为我所做的系统涉及到了销售,所以我们为它设计了三个主要的功能模块,即库存管理模块、商品销售模块、和系统设置模块。另外还有两个文件管理模块,即文件的保存和文件的打开。系统总体功能框图如图 2.1 所示。超市管理系统商品销售系统设置库存管理图 2.1 药品销售管理总框图录入商品修改和删除商品

19、查询商品销售商品查询销售情况用户管理修改密码 22.2 模块功能介绍在系统功能总框图中我们已经介绍了我们这个系统的总体功能模块,即库存管理模块、商品销售模块、和系统设置模块。下面我来具体介绍一下它们。(1)库存管理模块:此模块用来录入商品、修改和删除商品还有查询商品。(2)商品销售模块:此模块主要用来销售商品和查询销售商品的情况。(3)系统管理模块:此模块主要用来管理系统用户中的一些操作,可以管理用户和修改用户的密码。 3第 3 章 系统功能实现3.1 系统登录模块的实现(1)在此模块中,主要实现对用户登录系统的管理。我们知道,对于每个软件应用系统都有其特定的使用人员,尤其是用于商业活动的软件

20、系统,就更应该注意它的保密功能,所以我们必须为我们的系统设计一个用于保护本系统的密码登录功能。如图 4.1 所示为我们超市管理管理系统的登录界面。它所具有的功能是验证用户的登录信息,即用户名和对应的用户密码,检验预进入本系统的用户是不是合法用户。图 3.1 登录界面(2)核心代码Private Sub cmdOk_Click() Dim sql As String Dim rs As ADODB.Recordset Dim strUserName As String Dim intUserKey As Integer On Error GoTo ErrHandler: If Trim(txtU

21、serName.Text = ) Then MsgBox 请输入用户名称!, vbExclamation txtUserName.SetFocus Else sql = select * from Users where UserName = & txtUserName.Text & Set rs = ExeSQL(sql) If rs.EOF = True Then MsgBox 没有此用户,请重新输入用户名!, vbExclamation txtUserName.SetFocus Else If Trim(rs!UserPassword) = Trim(txtUserKey.Text) T

22、hen 4 intUserId = rs!UserID intJobId = rs!JobID rs.Close Me.Hide frmMain.Show Unload Me Else MsgBox 密码不正确,请重新输入密码!, vbExclamation txtUserKey.SetFocus txtUserKey.Text = End If End If End If Exit SubErrHandler: MsgBox 错误号: & Err.Number & 错误描述: & Err.DescriptionEnd Sub3.2 录入商品模块的实现(1)超市管理系统的录入商品功能模块实现录

23、入商品的相关操作,如图 3.2 所示。为药品采购功能界面药品采购功能模块由编号、名称、单价、数量、单位、进货时间还有备注组成,另外还有添加、清除和退出三个按钮。此对话框由 2 个文本框控制数组、1 个组合框、1 个 DTPicker 控件用来显示日期或接受日期输入、3 个按钮构成,实现录入商品功能,主要输入编号、名称、单价、数量、单位进货时间及备注后单击添加即可完成,对库存中进行补充商品。图 3.2 药品采购功能模块(2)主要控件如表 3.3: 5控件属性属性值Textbos(数组)名称TxtproductinfoTextbos(数组)名称TxtsupplierinfoCombobox名称Cb

24、ounit名称CbobirthdayDTPickerFormat1-dtpshortdate名称CmdaddCommandbuttonCaption添加(&A)名称CmdclearCommandbuttonCaption添加(&C)名称CmdexitCommandbuttonCaption添加(&E)表 3.3 录入商品窗口控件属性设置(3)核心代码:Private Sub cmdAdd_Click() Dim i As Integer Dim sql As String Dim monPrice As Currency 判断商品信息的某些项是否为空 For i = 0 To 3 If Tri

25、m(txtProductInfo(i) = Then MsgBox 此项不允许为空!, vbExclamation txtProductInfo(i).SetFocus Exit Sub End If Next i 判断某些项的数据类型是否正确 If IsNumeric(txtProductInfo(0).Text) = False Then MsgBox 商品编号应为数字量!, vbExclamation txtProductInfo(0).SetFocus Exit Sub End If If IsNumeric(txtProductInfo(2).Text) = False Then M

26、sgBox 商品的价格应为数字量!, vbExclamation txtProductInfo(2).SetFocus Exit Sub Else monPrice = txtProductInfo(2).Text End If If IsNumeric(txtProductInfo(3).Text) = False Then MsgBox 商品的数量应为数字量!, vbExclamation txtProductInfo(3).SetFocus Exit Sub End If 将商品信息存入 Products 表 sql = insert Products(ProductID,Product

27、Name,UnitPrice,Unit,Remark) & _ 6 values( & txtProductInfo(0).Text & , & _ txtProductInfo(1).Text & , & monPrice & , sql = sql & cboUnit.Text & , & txtProductInfo(4).Text & ) ExeSQL (sql) 将进货信息存入 ProductIn 表 sql = insert ProductIn values( & txtProductInfo(0).Text & , & _ txtProductInfo(3).Text & , &

28、 dtpInDate.Value & ) ExeSQL (sql) MsgBox 数据添加成功!, vbExclamation InitControlEnd SubPrivate Sub cmdClear_Click() InitControlEnd SubPrivate Sub cmdExit_Click() Unload MeEnd SubPrivate Sub Form_Load() ChangeFormPos frmMain, frmAddProduct cboUnit.AddItem 个 cboUnit.AddItem 箱 cboUnit.AddItem 瓶 cboUnit.AddI

29、tem 盒 cboUnit.AddItem 袋 dtpInDate.Value = NowEnd SubPrivate Sub InitControl() Dim i As Integer For i = 0 To 4 txtProductInfo(i).Text = Next i txtProductInfo(0).SetFocusEnd SubPrivate Sub txtProductInfo_Change(Index As Integer)End Sub3.3 修改和删除商品的实现(1)当商品录入后,根据需求可以修改、删除商品,如图 3.4 所示,为修改和删除商品界面。修改和删除商品功

30、能模块由编号、名称、单价、单位及备注组成,另外还有向前、向后、保存、删除、清除及退出 6 个按钮还有一个 ADO Data 控件。分为前后、保存、删除和退出等功能。 7 图 3.4 修改和删除商品界面 (3)核心代码:Private Sub cmdClear_Click() InitControlEnd SubPrivate Sub cmdDelete_Click() If txtProductInfo(0).Text = Then MsgBox 请选择要删除的商品编号!, vbExclamation txtProductInfo(0).SetFocus Exit Sub End If Exe

31、SQL (delete Products where ProductID = & txtProductInfo(0).Text & ) Adodc1.Refresh InitControlEnd SubPrivate Sub cmdExit_Click() Unload MeEnd SubPrivate Sub cmdNext_Click() If Adodc1.Recordset.EOF = False Then If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst End If Adodc1.Recordset.Mov

32、eNext End If If Adodc1.Recordset.EOF = False Then ReadData End IfEnd SubPrivate Sub cmdPrevious_Click() 8 If Adodc1.Recordset.BOF = False Then If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast End If Adodc1.Recordset.MovePrevious End If If Adodc1.Recordset.BOF = False Then ReadData End I

33、fEnd SubPrivate Sub cmdSave_Click() Dim i As Integer For i = 0 To 2 If Trim(txtProductInfo(i).Text) = Then MsgBox 该项不能空!, vbExclamation txtProductInfo(i).SetFocus Exit Sub End If Next i If IsNumeric(txtProductInfo(2).Text) = False Then MsgBox 该项应为数字量!, vbExclamation txtProductInfo(2).SetFocus Exit S

34、ub End If 向数据库中写数据 WriteData 各控件设置初始值 InitControlEnd SubPrivate Sub ReadData() txtProductInfo(0) = Adodc1.Recordset!ProductID txtProductInfo(1) = Adodc1.Recordset!ProductName txtProductInfo(2) = Adodc1.Recordset!UnitPrice If IsNull(Adodc1.Recordset!Remark) = True Then txtProductInfo(3).Text = Else t

35、xtProductInfo(3) = Adodc1.Recordset!Remark End If cboUnit.Text = Adodc1.Recordset!UnitEnd SubPrivate Sub WriteData() On Error GoTo ErrHandler: 当数据库中没有记录时,直接增加 If Adodc1.Recordset.RecordCount = 0 Then Adodc1.Recordset.AddNew Adodc1.Recordset!ProductID = txtProductInfo(0) FillData 9 Exit Sub End If 查看

36、当前记录是否在数据库中存在 Adodc1.Recordset.MoveFirst Adodc1.Recordset.Find ProductID = & txtProductInfo(0).Text & If Not Adodc1.Recordset.EOF Then 当前记录存在 FillData Exit Sub Else 当前记录部存在 Adodc1.Recordset.AddNew Adodc1.Recordset!ProductID = txtProductInfo(0) FillData Exit Sub End IfErrHandler: 显示错误信息 MsgBox 错误号: &

37、 Err.Number & 错误信息: & Err.Description, vbExclamationEnd SubPrivate Sub FillData() Adodc1.Recordset!ProductName = txtProductInfo(1) Adodc1.Recordset!UnitPrice = txtProductInfo(2) Adodc1.Recordset!Unit = cboUnit.Text Adodc1.Recordset!Remark = txtProductInfo(3) Adodc1.Recordset.Update Adodc1.RefreshEnd

38、 SubPrivate Sub InitControl() Dim i As Integer For i = 0 To 3 txtProductInfo(i).Text = txtProductInfo(0).SetFocus Next i cboUnit.Text = 个End SubPrivate Sub Form_Load() ChangeFormPos frmMain, frmProductQuery Adodc1.ConnectionString = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=

39、False;Initial Catalog=pos;Data Source=40F4D4DCB9DC46C Adodc1.RecordSource = select * from Products Adodc1.CommandType = 1 Adodc1.Refresh cboUnit.AddItem 个 cboUnit.AddItem 箱 cboUnit.AddItem 瓶 cboUnit.AddItem 盒 cboUnit.AddItem 袋 ChangeFormPos frmMain, MeEnd Sub 10Private Sub txtProductInfo_Change(Inde

40、x As Integer)End Sub3.4 查询商品功能的实现(1)超市管理系统的查询功能模块,如图 3.5 所示,为查询商品功能界面。本功能界面由 1 个 ADO Data 控件用来连接数据源;1 个 DataGrid 控件用来显示查询的数据;3 个OptionButton 控件用来选择查询条件;1 个组合框用来选择商品编号,3 个文本框用来输入商品名称,商品价格。图 3.5 查询商品功能模块界面(2)各控件的说明如表 3.6控件属性属性值Textbos名称TxtproductnameTextbos名称txtLowPriceTextbos名称txtHighPriceCombobox名称C

41、boproductid名称OptcodeOptionButtonCaption商品价格名称OptnameOptionButtonCaption商品名称名称OptpriceOptionButtonCaption商品价格表 3.6 11(3)核心代码Private Sub cmdExit_Click() Unload MeEnd SubPrivate Sub cmdQurey_Click() Dim strQuery As String On Error GoTo ErrHandler: 按商品编号查询 If optCode.Value = True Then If Trim(cboProduct

42、Id.Text) = Then strQuery = select * from Products Else strQuery = select * from Products where ProductID = & cboProductId & End If End If 按商品名称查询 If optName.Value = True Then If Trim(txtProductName.Text) = Then strQuery = select * from Products Else strQuery = select * from Products where ProductNam

43、e like % & txtProductName.Text & % End If End If 按商品价格查询 If optPrice.Value = True Then If Trim(txtLowPrice.Text) = And Trim(txtHighPrice.Text) = Then strQuery = select * from Products Else If IsNumeric(txtLowPrice.Text) = False Then MsgBox 价格必须为数字量!, vbExclamation txtLowPrice.SetFocus Exit Sub End I

44、f If IsNumeric(txtHighPrice.Text) = False Then MsgBox 价格必须为数字量!, vbExclamation txtHighPrice.SetFocus Exit Sub End If strQuery = select * from Products where UnitPrice= & txtLowPrice.Text & _ and UnitPrice= & txtHighPrice.Text End If End If Adodc1.CommandType = 1 Adodc1.RecordSource = strQuery Adodc1

45、.Refresh Exit SubErrHandler: MsgBox 错误号: & Err.Number & 错误信息: & Err.Description, vbExclamatioEnd Sub 12Private Sub Form_Load() Dim rs As New ADODB.Recordset Dim sql As String sql = select ProductID from Products Set rs = ExeSQL(sql) rs.MoveFirst While Not rs.EOF cboProductId.AddItem rs!ProductID rs.

46、MoveNext Wend optCode.Value = True ChangeFormPos frmMain, frmProductQueryEnd SubPrivate Sub o_Click()End Sub3.5 销售商品功能的实现(1) 销售商品的界面如图 3.7,本功能界面共有 14 个标签,其中一部分用来显示商品的某些字段的标题,一部分则用来动态显示用户购买的商品信息(窗口上部颜色较深的一条)和操作员号、机器号。窗口上有一个 MSFLexGrid 控件用于显示顾客购买商品列表;5 个文本框分别是用来输入或显示相关信息;4 个按钮用于执行商品录入确认、取消、付款和退出该块。图 3

47、.7 销售商品界面(2)控件主要属性设置如表 3.8 13控件属性属性值Lade1名称LblproductinfoLade1名称LpluseridLade1名称LplmachineidTextBox名称TxtproductidTextBox名称TxtproductQtyTextBox名称TxtsumTextBox名称TxtcashTextBox名称Txtchange名称cmdOkCommandButtonCaption确认(&O)名称CmdcancelCommandButtonCaption取消(&C)名称CmdpaymentCommandButtonCaption付账名称CmdQuitCom

48、mandButtonCaption退出(&Q)名称MsgsaleCols6MSFLexGridRows2 表 3.8(3)主要代码:Dim intBuy As IntegerPrivate Sub cmdCancel_Click() lblProductInfo.Caption = txtProductId.Text = txtProductQty = txtSum.Text = txtCash.Text = txtChange.Text = msgSale.Rows = 1 intBuy = 0 txtProductId.SetFocusEnd SubPrivate Sub cmdOk_Cl

49、ick() Dim sql As String Dim rs As ADODB.Recordset Dim lngIdSpace As Long Dim lngNameSpace As Long Dim lngPriceSpace As Long Dim lngStringLen As Long Dim strProductName As String Dim strProductPrice As String Dim intProductQty As Integer 14 If Trim(txtProductId.Text = ) Then MsgBox 请输入商品编号!, vbExclam

50、ation txtProductId.SetFocus Else If Trim(txtProductQty = ) Then MsgBox 请输入商品数量!, vbExclamation txtProductQty.SetFocus Exit Sub End If sql = select * from Products where ProductID = & txtProductId.Text & Set rs = ExeSQL(sql) If rs.EOF = True Then MsgBox 没有此编号商品,请重新输入商品编号!, vbExclamation txtProductId.

51、SetFocus txtProductId.Text = Exit Sub Else 取出对应商品编号的商品名称 strProductName = rs!ProductName 取出对应商品编号的商品价格 strProductPrice = rs!UnitPrice rs.Close End If End If 将当前购买的商品信息放大显示 lngIdSpace = 8 - Len(txtProductId.Text) lngNameSpace = 15 - 2 * Len(strProductName) lngPriceSpace = 9 - Len(strProductPrice) lbl

52、ProductInfo.Caption = txtProductId & Space(2 * lngIdSpace) & strProductName & Space(2 * lngNameSpace) & strProductPrice & Space(2 * lngPriceSpace) & txtProductQty 商品购卖数量加 1 intBuy = intBuy + 1 在表格中加入商品购买信息 FillGrid strProductName, strProductPriceEnd SubPrivate Sub cmdPayment_Click() Dim sql As Strin

53、g Dim intCount As Integer Dim intProductId As Integer Dim intProductQty As Integer Dim curProductPrice As Currency Dim curSum As Currency For intCount = 1 To intBuy curProductPrice = msgSale.TextMatrix(intCount, 4) intProductQty = msgSale.TextMatrix(intCount, 5) 计算商品价格总和 curSum = curSum + curProduct

54、Price * intProductQty Next intCount 15 For intCount = 1 To intBuy intProductId = msgSale.TextMatrix(intCount, 2) intProductQty = msgSale.TextMatrix(intCount, 5) If frmLogin.intUserId = 0 Then Exit Sub sql = INSERT Sales VALUES( & intProductId & , & frmLogin.intUserId & , & intProductQty & ,GETDATE()

55、 ExeSQL (sql) Next intCount txtSum.Text = curSum txtCash.SetFocusEnd SubPrivate Sub cmdQuit_Click() Unload MeEnd SubPrivate Sub Form_Activate() Dim sql As String Dim rs As ADODB.Recordset sql = select * from MachineUser where UserID = & frmLogin.intUserId & Set rs = ExeSQL(sql) lblMachineId.Caption

56、= rs!MachineID lblUserId.Caption = frmLogin.intUserId txtProductId.SetFocusEnd SubPrivate Sub Form_Load() Dim i As Integer 设置窗体位置 ChangeFormPos frmMain, frmSales intBuy = 0 With msgSale .FormatString = |序号|商品编码|商品名称|商品单价|数量 .ColWidth(0) = 0 .ColWidth(1) = 1100 .ColWidth(2) = 1400 .ColWidth(3) = 1600

57、 .ColWidth(4) = 1600 .ColWidth(5) = 1600 .Rows = 1 End WithEnd SubPrivate Sub msgSale_Click()End SubPrivate Sub txtCash_Change() Dim curCash As Currency 16 If txtCash.Text = Then Exit Sub curCash = txtCash.Text txtChange.Text = curCash - txtSumEnd SubPrivate Sub FillGrid(ByVal strProductName As Stri

58、ng, ByVal curUnitPrice As Currency) With msgSale .Rows = .Rows + 1 .TextMatrix(intBuy, 1) = intBuy .TextMatrix(intBuy, 2) = txtProductId.Text .TextMatrix(intBuy, 3) = strProductName .TextMatrix(intBuy, 4) = curUnitPrice .TextMatrix(intBuy, 5) = txtProductQty.Text End WithEnd Sub3.6 查询销售情况功能的实现(1)查询销

59、售情况窗口主要用于查询员工的销售业绩。用户可以查询所有人员的销售情况,也可查询某一个员工的销售情况,该查询还可以支持按时间段进行查询。本功能界面如图 3.9,有 2 个标签用于说明输入的信息;1 个组合框用于用户选择查询的员工姓名;1 个 CheckBox 控件用来选择是否附加时间作为查询条件;2 个 DTPicker 控件用于输入查询的起始时间,一个【查询】根据用户输入的查询条件向数据库发出查询指令,一个用于退出应用的【退出】按钮;一个 ADO Data 控件用于链接数据库,一个 DataGrid 控件用于显示查询的结果。图 3.9 查询销售情况 17(2)控件主要属性设置如表 3.10控件

60、属性属性值ComboBox名称cboUserNameCheckBox名称chkTimeOTPicker名称dtpStartDateOTPicker名称dtpEndDate名称cmdQueryCommandButtonCaption查询(&Q)名称cmdExitCommandButtonCaption退出(&E)表 3.10(3) 主要代码:Private Sub cmdExit_Click() Unload MeEnd SubPrivate Sub cmdQuery_Click() Dim strCmand As String On Error GoTo ErrHandler 姓名为空查询全部

61、员工的销售情况 If Trim(cboUserName.Text) = Then If chkTime.Value = vbChecked Then If DateDiff(d, dtpStartDate.Value, dtpEndDate.Value) = & dtpStartDate.Value & _ AND Sales.SaleDate= & dtpEndDate.Value & End If Else strCmand = SELECT Users.UserName, Products.ProductName, & _ Products.UnitPrice , Sales.SaleQ

62、uantiy, Sales.SaleDate & _ FROM Products INNER JOIN Sales ON Products.ProductID = Sales.ProductID & _ INNER JOIN Users ON Sales.UserID = Users.UserID End If 18 Else 姓名不为空查询查询当前员工的销售情况 If chkTime.Value = vbChecked Then If DateDiff(d, dtpStartDate.Value, dtpEndDate.Value) = & dtpStartDate.Value & _ AN

63、D Sales.SaleDate= & dtpEndDate.Value & _ and Users.UserName = & cboUserName.Text & End If Else strCmand = SELECT Users.UserName, Products.ProductName, & _ Products.UnitPrice , Sales.SaleQuantiy, Sales.SaleDate & _ FROM Products INNER JOIN Sales ON Products.ProductID = Sales.ProductID & _ INNER JOIN

64、Users ON Sales.UserID = Users.UserID & _ WHERE Users.UserName = & cboUserName.Text & End If End If Adodc2.CommandType = 1 Adodc2.RecordSource = strCmand Adodc2.Refresh Exit SubErrHandler: MsgBox 错误号: & Err.Number & 错误信息: & Err.DescriptionEnd SubPrivate Sub DataGrid2_Click()End SubPrivate Sub Form_Lo

65、ad() Dim sql As String Dim rs As ADODB.Recordset 设置窗体位置 ChangeFormPos frmMain, frmSalesQuery sql = select UserName from Users Set rs = ExeSQL(sql) 19 If rs.EOF = True Then MsgBox 当前数据库中没有信息!, vbExclamation Else rs.MoveFirst Do Until rs.EOF strUserName = rs!UserName cboUserName.AddItem strUserName rs

66、.MoveNext Loop rs.Close End If dtpStartDate.Value = Now dtpEndDate.Value = NowEnd Sub3.7 用户管理界面 (1)用户管理窗口用来对本系统的所有用户进行添加、删除等管理操作。窗口如图3.11,本界面有 4 个标签(Label)用来显示说明消息;3 个文本框(TextBox) ,用来接受用户输入的用户名称和密码;3 个按钮(CommandButton) ,用来完成用户信息保存、删除和退出本模块。图 3.11 用户管理(2)控件主要属性设置如表 3.12控件属性属性值LabelCaption用户名LabelCaption密码LabelCaption密码确认LabelCaption用户权限Textbox名称txtUserName名称txtPassword1TextboxPassWordChar* 20名称txtPassword2TextboxPassWordChar*名称cboAuthorityComboBoxStyle2-Dropdown List名称cmdSaveCommandButtonCaption保

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!