下主要代码实现查询功能
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedicinecode='"&Text1&"'"
Adodc1.Refresh
.
4.3.3日常管理模块
该模块可以进行用户信息和供应商信息的维护及查询,主要是对药品信息、销售信息、用户信息和供应商信息的查询。
如下是日常管理模块的实现界面:
1.管理者登录界面
图4.14管理员登录界面
2.药品信息查询(类似与仓库管理的药品信息查询)
3.销售记录查询
(一)销售主表查询界面
图4.15查询销售主表的结果界面
(二)销售子表查询界面
图4.16查询销售子表的结果界面
(三)全部信息查询界面
图4.17查询全部信息的结果界面
4.供应商信息查询
(一)输如供应商编码"1002"得查询结果界面
图4.18按供应商编码的查询结果界面
(二)输入所在城市名"上海"得查询结果界面
图4.19按供应商所在城市的查询结果界面
系统主要通过如下主要代码实现查询功能
Adodc1.RecordSource="selectsalenoas销售编码,amountas总额,saledateas销售日期,worknoas销售员编号fromsalemaintablewheresaleno='"&Trim(Text12.Text)&"'"
Adodc1.Refresh
.
.
.
第五章设计总结
在课程设计阶段,首先对医药管理进行了了解,仔细分析了该管理对系统功能的要求,并根据这些功能要求对系统进行定义,确定系统必须做什么。但由于对医药管理了解不多,需求分析难免不够完善,但是基本需求都考虑到了,并用文档准确记录了系统的需求。之后着手对系统的设计工作,首先是概念结构设计,根据需求分析结果总结系统内实体及联系并绘制系统的局部ER图和全局ER图。然后是逻辑结构设计,结合需求分析与概念结构设计把设计好的ER图转换为DBMS(SQLServer2000)所支持的数据模型所符合的逻辑结构。最后运用开发工具VB6.0进行功能的编码实现。
该系统最终能够基本实现绝大多数功能,但是也有很多不做之处,如药品进库信息功能,对新进药品进行入库存储,但是由于进价跟有效期的变化不能只是对该药品的库存量更改。进价可以运用加成定价法更改,但有效期尚未想到解决方案。希望老师给与意见及帮助,使系统功能更加完善。
在这次课程设计中虽然遇到过很多的困难,但我从中学到了很多有用的知识,通过不断的翻阅资料,各个问题的解决使我对系统的设计越来越感兴趣。相信我从这次课程设计所学到的东西可以让我在以后的学习及工作中受益无限。
附录
实验程序源代码
1.登录界面代码:(以销售员登录为例,仓库管理员和日常管理者登录与此类似,不再赘述)
在主界面菜单"销售管理"内编写代码如下:
PrivateSubA1_Click()
登录.Show
登录.Adodc1.RecordSource="select*fromuserinforwherepower='销售'"
登录.Adodc1.Refresh
登录.Option1.Value=True
登录.Option1.Visible=True
登录.Option2.Value=False
登录.Option2.Visible=False
登录.Option3.Value=False
登录.Option3.Visible=False
A=1:B=0:C=0
EndSub
在Text2的GotFocus事件内编写如下代码以确定用户的准确性
PrivateSubText2_GotFocus()
Adodc1.RecordSource="select*fromuserinforwhereuserregname='"&Text1&"'"
Adodc1.Refresh
IfAdodc1.Recordset.EOFThen
MsgBox"无此用户,请重新输入!",,"提示"
Text1.Text=""
Text1.SetFocus
EndIf
EndSub
在Command1的Click事件内编写如下代码检验用户密码
PrivateSubCommand1_Click()
DimxAsString,yAsString
Text1.SetFocus
IfVal(Text2.Text)=Val(Text4.Text)Then
MsgBox"输入正确",,"提示"
Text1.Text=""
Text2.Text=""
UnloadMe
IfA=1Then
FrmMain.A2.Enabled=True
FrmMain.A3.Enabled=True
EndIf
Else
MsgBox"密码错误",,"提示"
EndIf
EndSub
2.前台查询窗体代码
PrivateSubCommand1_Click()
IfOption1Then
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期至fromMedInforwheremedicinename='"&Text1&"'"
Adodc1.Refresh
EndIf
IfOption2Then
SelectCaseCombo1.Text
Case"处方药"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinename药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期至fromMedInforwheremedkindcode='1'"
Adodc1.Refresh
Case"非处方药"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期至fromMedInforwheremedkindcode='2'"
Adodc1.Refresh
Case"中药饮片"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期至fromMedInforwheremedkindcode='3'"
Adodc1.Refresh
Case"中药材"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedkindcode='4'"
Adodc1.Refresh
Case"医疗器械"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期至fromMedInforwheremedkindcode='5'"
Adodc1.Refresh
Case"非药品(保健品)"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期fromMedInforwheremedkindcode='6'"
Adodc1.Refresh
EndSelect
EndIf
IfAdodc1.Recordset.EOFThen
MsgBox"无此信息!",,"提示"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,stocknumas库存量,unitas单位,usefullifeas有效期至fromMedInfor"
Adodc1.Refresh
EndIf
EndSub
3.销售界面代码
PrivateSubCommand1_Click()
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,priceas售价,unitas单位,stocknumas库存量frommedinforwheremedicinecode='"&Text1&"'"
Adodc1.Refresh
IfAdodc1.Recordset.EOFThenMsgBox"无此信息!",,"提示"
IfVal(Text11.Text)-Val(Text2.Text)<0Then
MsgBox"库存不足",,"提示"
Text1.Text="":Text2.Text="":Text1.SetFocus
Else
ResumeNext
Adodc2.Recordset.AddNew
Text12.Text=Text4.Text
Text13.Text=Text7.Text
Text14.Text=Text8.Text
Text15.Text=Text9.Text
Text16.Text=Text10.Text
Text17.Text=Val(Text9.Text)*Val(Text2.Text)
Text18.Text=Text2.Text
Adodc2.Recordset.Update
Adodc2.Recordset.MoveLast
Adodc1.Recordset.Update
Text11.Text=Val(Text11.Text)-Val(Text2.Text)
Adodc1.Recordset.Update
Adodc1.Recordset.MoveLast
x=x+Val(Text17.Text)
EndIf
EndSub
PrivateSubCommand2_Click()
StaticyAsInteger
y=Val(Text4.Text)+1
Text4.Text=y
Text5.Text=Date$
Text6.Text=x
Adodc3.Recordset.AddNew
Text19.Text=Text4.Text
Text20.Text=Text3.Text
Text21.Text=Date$
Text22.Text=Text6.Text
Adodc3.Recordset.Update
Adodc3.Recordset.MoveLast
Text6.SetFocus
EndSub
PrivateSubText6_LostFocus()
x=0
EndSub
4.药品信息查询代码(仓库管理和日常管理的药品查询都用此代码)
OptionExplicit
PrivateSubCommand1_Click()
ResumeNext
IfCommand1.Caption="新增"Then
Command1.Caption="确认"
Adodc1.Recordset.AddNew
Text4.SetFocus
Else
Command1.Caption="新增"
Adodc1.Recordset.Update
Adodc1.Recordset.MoveLast
EndIf
EndSub
PrivateSubCommand2_Click()
ResumeNext
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
IfAdodc1.Recordset.EOFThenAdodc1.Recordset.MoveLast
EndSub
PrivateSubCommand3_Click()
ResumeNext
IfCommand3.Caption="修改"Then
Command3.Caption="确认"
Adodc1.Recordset.Update
Text4.SetFocus
Else
Command3.Caption="修改"
Adodc1.Recordset.Update
Command1.Enabled=True
Command2.Enabled=True
Command5.Enabled=True
EndIf
EndSub
PrivateSubCommand4_Click()
Command3.Caption="修改"
Command1.Caption="添加"
GoToRefreshErr
Adodc1.Refresh
ExitSub
RefreshErr:
MsgBoxErr.Description
EndSub
PrivateSubCommand5_Click()
Frame1.Visible=True
EndSub
PrivateSubCommand6_Click()
IfOption1Then
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedicinecode='"&Text1&"'"
Adodc1.Refresh
EndIf
IfOption2Then
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedicinename='"&Text2&"'"
Adodc1.Refresh
EndIf
IfOption3Then
SelectCaseCombo1.Text
Case"处方药"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedkindcode='1'"
Adodc1.Refresh
Case"非处方药"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedkindcode='2'"
Adodc1.Refresh
Case"中药饮片"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedkindcode='3'"
Adodc1.Refresh
Case"中药材"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedkindcode='4'"
Adodc1.Refresh
Case"医疗器械"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedkindcode='5'"
Adodc1.Refresh
Case"非药品(保健品)"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwheremedkindcode='6'"
Adodc1.Refresh
EndSelect
EndIf
IfOption4Then
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInforwhereusefullife<'"&Trim(Text13)&"'"
Adodc1.Refresh
EndIf
IfAdodc1.Recordset.EOFThen
MsgBox"无此信息!",,"提示"
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInfor"
Adodc1.Refresh
EndIf
EndSub
PrivateSubCommand7_Click()
Adodc1.Recordset.MovePrevious
IfAdodc1.Recordset.BOFThen
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInfor"
Adodc1.Refresh
MsgBox"当前记录为第一条",,"提示"
EndIf
EndSub
PrivateSubCommand8_Click()
Adodc1.Recordset.MoveNext
IfAdodc1.Recordset.EOFThen
Adodc1.RecordSource="selectmedicinecodeas药品编码,medicinenameas药品名称,medkindcodeas药品类别代码,priceas售价,listpriceas厂价,stocknumas库存量,unitas单位,usefullifeas有效期至,ratifycodeas批准文号fromMedInfor"
Adodc1.Refresh
MsgBox"当前记录为最后一条",,"提示"
EndIf
EndSub
PrivateSubOption4_Click()
Combo1.Enabled=False
Text13.Text=Date$
EndSub
5.销售记录查询代码
OptionExplicit
PrivateSubCommand1_Click()
IfOption1Then
Adodc1.RecordSource="selectsalenoas销售编码,amountas总额,saledateas销售日期,worknoas销售员编号fromsalemaintablewheresaleno='"&Trim(Text12.Text)&"'"
Adodc1.Refresh
EndIf
IfOption2Then
Adodc1.RecordSource="selectsalenoas销售编码,medicinecodeAS药品编码,medicinenameas药品名称,numberas数量,unitas单位,priceas单价,amountas总额fromsalechildtablewheresaleno='"&Trim(Text12.Text)&"'"
Adodc1.Refresh
EndIf
IfOption3Then
Adodc1.RecordSource="selectsalemaintable.salenoas销售编码,medicinecodeAS药品编码,medicinenameas药品名称,numberas数量,unitas单位,priceas单价,salechildtable.amountas总额,saledateas销售日期,worknoas销售员编号fromsalemaintable,salechildtablewheresalemaintable.saleno=salechildtable.saleno"
Adodc1.Refresh
EndIf
IfAdodc1.Recordset.EOFThen
MsgBox"无次信息",,"提示"
Adodc1.RecordSource="selectsalemaintable.salenoas销售编码,medicinecodeAS药品编码,medicinenameas药品名称,numberas数量,unitas单位,priceas单价,salechildtable.amountas总额,saledateas销售日期,worknoas销售员编号fromsalemaintable,salechildtablewheresalemaintable.saleno=salechildtable.saleno"
Adodc1.Refresh
EndIf
EndSub
6.供应商信息维护代码及查询代码
对供应商信息的添加、删除等功能实现代码类似于药品信息的添加、删除等操作,在此就不再赘述
PrivateSubCommand6_Click()
IfOption1Then
Adodc1.RecordSource="select*fromfirminforwherefirmcode='"&Text6&"'"
Adodc1.Refresh
EndIf
IfOption2Then
Adodc1.RecordSource="select*fromfirminforwherefirmname='"&Text7&"'"
Adodc1.Refresh
EndIf
IfOption3Then
ResumeNext
Adodc1.RecordSource="Select*FromFirmInforWherecity='"&Trim(Text8.Text)&"'"
Adodc1.Refresh
EndIf
IfAdodc1.Recordset.EOFThen
MsgBox"无此信息",,"提示"
Adodc1.RecordSource="firminfor"
Adodc1.Refresh
EndIf
EndSub
7.用户信息的维护及查询代码
对用户信息的添加、删除等功能实现代码类似于药品信息的添加、删除等操作,在此就不再赘述
PrivateSubCommand5_Click()
Adodc1.RecordSource="selectworknoas职工号,userregnameas用户名,positionas职位,poweras权限,nameas姓名fromuserinforwherename='"&Text6.Text&"'andposition='"&Text7&"'"
Adodc1.Refresh
IfAdodc1.Recordset.EOFThen
MsgBox"无此信息!",,"提示"
Adodc1.RecordSource="selectworknoas职工号,userregnameas用户名,positionas职位,poweras权限,nameas姓名fromuserinfor"
Adodc1.Refresh
Text6.Text=""
Text7.Text=""
Text6.SetFocus
EndIf
EndSub
PrivateSubForm_Load()
Adodc1.RecordSource="selectworknoas职工号,userregnameas用户名,positionas职位,poweras权限,nameas姓名fromuserinfor"
Adodc1.Refresh
EndSub
参考文献
萨师煊、王珊.数据库系统概论.北京:高等教育出版社,2000年
张海藩.软件工程导论.北京:清华大学出版社,2003年
龚沛曾、陆慰民、杨志强.VisualBasic程序设计教程.北京:高等教育出版社,2000年
白尚旺、党伟超.PowerDesigner软件工程技术.北京:电子工业出版社,2004年
??
??
??
??
哈尔滨工业大学数据库课程设计
1
上一篇:
vb试题库自动组卷系统(论文和程序)
下一篇:
4种小菜缓解孕妈咪不适