VB(仓库管理系统源代码)
仓库管理系统(VB+Access+源代码)
精心整理仓库管理系统项目的建立这是本人利用闲暇之余在VB6.0上制作的一个简陋的类库管系统,现图文结合的方式一步一步展现制作过程。
由于本人是个初学者,里面存在很多不足之处望得到高手们的指导。
此文可作供初学者们学习交流。
作者联系方式:E-mail最终运行效果打开软件出现如下登录界面输入系统预设用户名及密码(1 1)单击“登录”或单击“新用户”添加新用户进入如下主界面:建立工程1、创建标准EXE2、按“打开”3、添加MDI窗体——打开4、编辑菜单在空白处右击——点击“菜单编辑器”在“标题”里输入“系统”,在“名称”里输入“Sys”(注意此处不能为汉字)点击“下一个”再点击“”“确定”退到MDI界面点击“系统”——“退出”如下,然后编写代码。
代码如下:PrivateSubExit_Click()EndEndSub数据库的建立VB6.0中可以创建Access数据库。
如下建立一个“用户表”的数据库,用来存放用户信息及一些出入库管理信息。
如下图单击“外接程序”再单击“可视化数据管理器”出现如图点击“文件”——“新建”——“MicrosoftAccess”——“Version2.0MDB”输入数据库名,“保存”出现如下图在数据窗口中右击——“新建表”,最终如下往数据表里添加数据在这里就不罗嗦了,请查阅相关书籍。
精心整理精心整理登录界面窗口的建立最终界面如下:1、Adodc1的添加过程为:单击“工程”——“部件”出现下图所示,选择“控件”下的“MicrosoftADODataControl6.0(OLEDB)”单击“确定”在工具栏中会出现“”图标,单击它并拖动到相应位置即可。
其它元件不在一一说明。
2、本窗体代码如下:PrivateSubCommand1_Click() ' “登录”、“确定”按钮IfCommand1.Caption=" 确定"AndCommand2.Caption=" 取消"Then ' 如果为“确定”则添加新用户IfText1.Text=""Then ' 提示用户输入用户名MsgBox" 请输入用户名!",," 登录信息提示:"ExitSubElse 'DimusenameAsString ' 检测用户名是否已经存在DimstrSAsStringusename=Trim(Text1.Text)strS="select*from 用户登录信息表where 用户名='"&usename&"'"mandType=adCmdTextAdodc1.RecordSource=strSAdodc1.RefreshMsgBox" 您输入的用户已存在 !",," 登录提示信息:"Text1.Text=""Text2.Text=""Text3.Text=""Text1.SetFocusExitSubEndIfEndIfIfText2.Text=""Then ' 提示用户密码不能为空MsgBox" 密码不能为空!",," 登录提示信息:"Text2.SetFocusExitSubEndIfIfText3.Text=""ThenMsgBox" 请再次输入密码!",," 登录提示信息:"Text3.SetFocusExitSubEndIfIfText2.Text<>Text3.TextThenMsgBox" 两次输入的密码不一致,请确认!",," 登录提示信息:"Text2.Text=""Text3.Text=""Text2.SetFocus精心整理精心整理ExitSubElseMsgBox(" 添加新用户成功,现在您可以登陆系统了!")Label3.Visible=FalseText3.Visible=FalseCommand1.Caption=" 登录"Command2.Caption=" 退出"EndIfElse ' “登录”按钮,用户登录DimstrSnoAsStringDimstrSelectAsStringstrSno=Trim(Text1.Text) ' 检测用户名是否存在strSelect="select 密码from 用户登录信息表where 用户名='"&strSno&"'"mandType=adCmdTextAdodc1.RecordSource=strSelectAdodc1.RefreshMsgBox" 用户名不存在,请重新输入!",," 登录提示信息:"Text1.Text=""Text2.Text=""Text1.SetFocusExitSubEndIfForm1.Hide'UnloadMeForm2.Show'MsgBox" 登陆成功!",," 登录提示信息:"ElseMsgBox" 密码不正确,请重新输入!",," 登录提示信息:"Text2.Text=""Text2.SetFocusEndIfEndIfEndSubPrivateSubCommand2_Click() ' “退出”或“取消”按钮IfCommand2.Caption=" 取消"ThenLabel3.Visible=FalseText3.Visible=FalseCommand1.Caption=" 登录"Command2.Caption=" 退出"Text1.Text=""Text2.Text=""Text1.SetFocusElseEnd'UnloadMeEndIfEndSub精心整理精心整理PrivateSubCommand3_Click() ' “新用户”按钮Label3.Visible=TrueText3.Visible=TrueText1.Text=""Text2.Text=""Text3.Text=""Command1.Caption=" 确定"Command2.Caption=" 取消"Text1.SetFocusEndSubPrivateSubCommand3_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)Label6.Visible=TrueEndSubPrivateSubCommand3_MouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)Label6.Visible=FalseEndSubPrivateSubForm_Load()Label3.Visible=FalseText3.Visible=FalseEndSubPrivateSubTimer1_Timer() ' 时间time1控件的time事件代码,用来' 显示向左移动的欢迎字幕IfLabel4.Left+Label4.Width>0Then ' 当标签右边位置大于0时,标签向左移Label4.MoveLabel4.Left-80Else ' 否则标签从头开始Label4.Left=Form1.ScaleWidthEndIfIfLabel5.Left+Label5.Width>0ThenLabel5.MoveLabel5.Left-80ElseLabel5.Left=Form1.ScaleWidthEndIfEndSub主界面窗体如下:代码:PrivateSubAddNew_Click() Frame1.Visible=TrueFrame2.Visible=FalseEndSubPrivateSubCHKPMCHX_Click()Frame2.Caption=" 出库信息"DimpmAsString精心整理精心整理DimnAsStringpm=InputBox(" 产品名"," 请输入",0)n="select*from 出库表where 品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubCHKXHCHX_Click()Frame2.Caption=" 出库信息"DimXHAsStringDimnAsStringXH=InputBox(" 产品型号"," 请输入",0)n="select*from 出库表where 型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndSubPrivateSubCKCZ_Click()'Form2.HideForm6.ShowEndSubPrivateSubCKJSHR_Click()Frame2.Caption=" 出库信息"DimJSHRAsStringDimnAsStringJSHR=InputBox(" 经手人"," 请输入",0)n="select*from 出库表where 经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubCKSHJ_Click()Frame2.Caption=" 出库信息"DimCHKRQAsStringDimnAsStringCHKRQ=InputBox(" 出库日期,格式为:月/日/年如:12/1/2011"," 请输入",0) n="select*from 出库表where 出库日期='"&CHKRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubCKZCX_Click()Frame2.Caption=" 出库信息" 精心整理精心整理DimZBAsStringZB="select*from 出库表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid1EndSubPrivateSubCommand1_Click()IfText1.Text=""Then ' 提示用户输入用户名MsgBox" 请输入用户名!",," 登录信息提示:"ExitSubElse 'DimusenameAsString ' 检测用户名是否已经存在DimstrSAsStringusename=Trim(Text1.Text)strS="select*from 用户登录信息表where 用户名='"&usename&"'"mandType=adCmdTextAdodc1.RecordSource=strSAdodc1.RefreshMsgBox" 您输入的用户已存在!",," 登录提示信息:"Text1.Text=""Text2.Text=""Text3.Text=""Text1.SetFocusExitSubEndIfEndIfIfText2.Text=""Then ' 提示用户密码不能为空MsgBox" 密码不能为空!",," 登录提示信息:"Text2.SetFocusExitSubEndIfIfText3.Text=""ThenMsgBox" 请再次输入密码!",," 登录提示信息:"Text3.SetFocusExitSubEndIfIfText2.Text<>Text3.TextThenMsgBox" 两次输入的密码不一致,请确认!",," 登录提示信息:"Text2.Text=""Text3.Text=""Text2.SetFocusExitSubElseeDimXAsInteger 精心整理精心整理X=MsgBox(" 成功添加新用户,是否要重新登录!",vbYesNo+vbQuestion+vbDefaultButton1," 提示信息!") IfX=vbYesThenUnloadMeForm3.ShowEndIf'MsgBox(" 成功添加新用户!")'Label3.Visible=False'Text3.Visible=False'Command1.Caption=" 登录"'Command2.Caption=" 退出"EndIfFrame1.Visible=FalseFrame2.Visible=TrueText1.Text=""Text2.Text="'"Text3.Text=""'Form3.ShowEndSubPrivateSubCommand2_Click()Frame1.Visible=FalseFrame2.Visible=TrueEndSubPrivateSubCXDL_Click()Form3.Show'UnloadMeEndSubPrivateSubExit_Click()EndUnloadForm1UnloadForm2UnloadForm3UnloadForm4UnloadForm5UnloadForm6UnloadForm7UnloadForm8EndSubPrivateSubForm_Load()UnloadForm1Frame1.Visible=FalseCallInitGrid0Me.Height=MDIForm1.Height-1060 Me.Width=MDIForm1.Width-560Me.Top=MDIForm1.TopMe.Left=MDIForm1.LeftEndSub精心整理精心整理PrivateSubGHCZ_Click()'Form2.HideForm8.ShowEndSubPrivateSubGHPMCX_Click()Frame2.Caption=" 归还信息"DimpmAsStringDimnAsStringpm=InputBox(" 产品名"," 请输入",0)n="select*from 归还表where 品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubGHRCX_Click()Frame2.Caption=" 归还信息"DimJCRAsStringDimnAsStringJCR=InputBox(" 归还人"," 请输入",0)n="select*from 归还表where 归还人='"&JCR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubGHSJCX_Click()Frame2.Caption=" 归还信息"DimJCRQAsStringDimnAsStringJCRQ=InputBox(" 归还日期,格式为:月/日/年如:12/1/2011"," 请输入",0) n="select*from 归还表where 归还日期='"&JCRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubGHXHCX_Click()Frame2.Caption=" 归还信息"DimXHAsStringDimnAsStringXH=InputBox(" 产品型号"," 请输入",0) n="select*from 归还表where 型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.Refresh精心整理精心整理CallInitGrid2EndSubPrivateSubGHZCX_Click()Frame2.Caption=" 归还信息"DimZBAsStringZB="select*from 归还表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCCZ_Click()'Form2.HideForm7.ShowEndSubPrivateSubJCHPMCHX_Click()Frame2.Caption=" 借出信息"DimpmAsStringDimnAsStringpm=InputBox(" 产品名"," 请输入",0)n="select*from 借出表where 品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCHXHCHX_Click()Frame2.Caption=" 借出信息"DimXHAsStringDimnAsStringXH=InputBox(" 产品型号"," 请输入",0) n="select*from 借出表where 型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCRCX_Click()Frame2.Caption=" 借出信息"DimJCRAsStringDimnAsStringJCR=InputBox(" 借出人"," 请输入",0) n="select*from 借出表where 借出人='"&JCR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.Refresh精心整理精心整理CallInitGrid2EndSubPrivateSubJCSHJCX_Click()Frame2.Caption=" 借出信息"DimJCRQAsStringDimnAsStringJCRQ=InputBox(" 借出日期,格式为:月/日/年如:12/1/2011"," 请输入",0) n="select*from 借出表where 借出日期='"&JCRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCZCX_Click()Frame2.Caption=" 借出信息"DimZBAsStringZB="select*from 借出表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid2EndSubPrivateSubJSHRCHX_Click()Frame2.Caption=" 归还信息"DimJSHRAsStringDimnAsStringJSHR=InputBox(" 经手人"," 请输入",0)n="select*from 归还表where 经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJSHRCX_Click()Frame2.Caption=" 借出信息"DimJSHRAsStringDimnAsStringJSHR=InputBox(" 经手人"," 请输入",0)n="select*from 借出表where 经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubPMCX_Click()Frame2.Caption=" 库存信息" 精心整理精心整理DimpmAsStringDimnAsStringpm=InputBox(" 产品名"," 请输入",0)n="select*from 库存表where 品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid0EndSubPrivateSubRKCZ_Click()'Form2.HideForm5.ShowEndSubPrivateSubRKJSHR_Click()Frame2.Caption=" 入库信息"DimJSHRAsStringDimnAsStringJSHR=InputBox(" 经手人"," 请输入",0)n="select*from 入库表where 经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubRKPMCHX_Click()Frame2.Caption=" 入库信息"DimpmAsStringDimnAsStringpm=InputBox(" 产品名"," 请输入",0)IfLen(pm)>0Thenn="select*from 入库表where 品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndIfCallInitGrid1EndSubPrivateSubRKSHJ_Click()Frame2.Caption=" 入库信息"DimRKRQAsStringDimnAsStringRKRQ=InputBox(" 入库日期,格式为:月/日/年如:12/1/2011"," 请输入",0) n="select*from 入库表where 入库日期='"&RKRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.Refresh精心整理精心整理CallInitGrid1EndSubPrivateSubRKXHCHX_Click()Frame2.Caption=" 入库信息"DimXHAsStringDimnAsStringXH=InputBox(" 产品型号"," 请输入",0)IfLen(XH)>0Thenn="select*from 入库表where 型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndIfCallInitGrid1EndSubPrivateSubRKZCX_Click()Frame2.Caption=" 入库信息"DimZBAsStringZB="select*from 入库表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid1EndSubPrivateSubTimer1_Timer()IfLabel4.Left+Label4.Width>0Then ' 当标签右边位置大于0时,标签向左移Label4.MoveLabel4.Left-80Else ' 否则标签从头开始Label4.Left=Form2.ScaleWidthEndIfIfLabel5.Left+Label5.Width>0ThenLabel5.MoveLabel5.Left-80ElseLabel5.Left=Form2.ScaleWidthEndIfIfLabel6.Left+Label6.Width>0ThenLabel6.MoveLabel6.Left-80ElseLabel6.Left=Form2.ScaleWidthEndIfIfLabel7.Left+Label7.Width>0Then Label7.MoveLabel7.Left-80ElseLabel7.Left=Form2.ScaleWidthEndIfEndSub精心整理精心整理PrivateSubXGMM_Click()'Form2.HideForm4.ShowEndSubPrivateSubXHCX_Click()Frame2.Caption=" 库存信息"DimXHAsStringDimnAsStringXH=InputBox(" 产品型号"," 请输入",0) IfLen(XH)>0Then'AndVal(XH)<>0n="select*from 库存表where 型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndIfCallInitGrid0EndSubPrivateSubZB_Click()Frame2.Caption=" 库存信息"DimZBAsString'DimNAsString'PM=InputBox(" 产品名"," 请输入",0) ZB="select*from 库存表"'where 品名='"&PM&"'"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid0EndSubPrivateSubInitGrid0()WithDataGrid1.Columns(0).Width=1600.Columns(1).Width=2200.Columns(2).Width=2200.Columns(3).Width=1000.Columns(4).Width=1000.Columns(5).Width=4000EndWithEndSubPrivateSubInitGrid1()WithDataGrid1.Columns(0).Width=800.Columns(1).Width=1600.Columns(2).Width=1600.Columns(3).Width=800.Columns(4).Width=800.Columns(5).Width=1000 精心整理精心整理.Columns(6).Width=800.Columns(7).Width=4000EndWithEndSubPrivateSubInitGrid2()WithDataGrid1'.Columns(0).Caption=" 学号"'.Columns(1).Caption=" 课程名"'.Columns(2).Caption=" 学分"'.Columns(3).Caption=" 成绩"' 设置DtgCond的列宽.Columns(0).Width=800.Columns(1).Width=1600.Columns(2).Width=1600.Columns(3).Width=800.Columns(4).Width=800.Columns(5).Width=800.Columns(6).Width=1000.Columns(7).Width=800.Columns(8).Width=4000EndWithEndSub用户重新登录界面代码:PrivateSubCommand1_Click()DimstrSnoAsStringDimstrSelectAsStringstrSno=Trim(Text1.Text) ' 检测用户名是否存在strSelect="select 密码from 用户登录信息表where 用户名='"&strSno&"'"mandType=adCmdTextAdodc1.RecordSource=strSelectAdodc1.RefreshMsgBox" 用户名不存在,请重新输入!",," 登录提示信息:"Text1.Text=""Text2.Text=""Text1.SetFocusExitSubEndIfUnloadMeForm2.Show'MsgBox" 登陆成功!",," 登录提示信息:"ElseMsgBox" 密码不正确,请重新输入!",," 登录提示信息:" 精心整理精心整理Text2.Text=""Text2.SetFocusEndIfEndSubPrivateSubCommand2_Click()UnloadMeForm2.ShowEndSub修改用户密码界面代码:PrivateSubCommand1_Click()IfTrim(Text1.Text)<>Form2.TextUserNameThenMsgBox" 用户名不正确,请确认!",," 信息提示!"Text1.Text=""Text1.SetFocusExitSubElseDimnameAsStringDimnamesAsStringname=Trim(Text1.Text)names="select*from 用户登录信息表where 用户名='"&name&"'" mandType=adCmdTextAdodc1.RecordSource=namesAdodc1.RefreshIfText2.Text=""ThenMsgBox" 请输入旧密码!",," 信息提示!"Text2.SetFocusExitSubEndIfMsgBox" 旧密码不正确,请确认!",," 信息提示!"Text2.Text=""Text2.SetFocusExitSubEndIfIfText3.Text=""ThenMsgBox" 请输入新密码!",," 信息提示!"Text3.SetFocusExitSubEndIfIfText4.Text=""ThenMsgBox" 请再次输入新密码!",," 信息提示!"Text4.SetFocusExitSub精心整理精心整理EndIfIfTrim(Text3.Text)<>Trim(Text4.Text)ThenMsgBox" 两次输入的新密码不一致!",," 信息提示!"Text3.Text=""Text4.Text=""Text3.SetFocusExitSubElseMsgBox(" 密码修改成功!")UnloadMe'Form2.ShowEndIfEndIfEndSubPrivateSubCommand2_Click()UnloadMe'Form2.ShowEndSub入库管理代码:PrivateSubCommand1_Click()IfText1.Text=""AndText2.Text=""ThenMsgBox" “品名”和“型号”不能同时为空,必须输入其中一项 !",," 提示信息!" ExitSubText1.SetFocusElseIfText3.Text=""AndText4.Text=""ThenMsgBox" 请输入产品“数量”或“单位”之一 !",," 提示信息!"Text3.SetFocusExitSubEndIfIfText5.Text=""ThenMsgBox" 请经手人签名!",vbCritical," 提示信息!"Text5.SetFocusExitSubEndIfAdodc1.Refresh EndIf DimpmAsString DimpmsAsString DimnAsString DimmAsStringpm=Trim(Text1.Text) 精心整理精心整理n=Val(Text3.Text)pms="select*from 库存表where 品名='"&pm&"'"WithForm2EndWithElseEndIfEndIfDimXAsIntegerX=MsgBox(" 产品入库登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1," 提示信息!") IfX=vbNoThenUnloadMe'Form2.ShowElseText1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""Text5.Text=""Text6.Text=""Text7.Text=""Text1.SetFocusEndIfDimZBAsStringZB="select*from 入库表"'where 品名='"&PM&"'"EndSubPrivateSubCommand2_Click()Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""Text5.Text=""Text6.Text=""Text7.Text=""Text1.SetFocusEndSubPrivateSubCommand3_Click()UnloadMe'Form2.ShowEndSub出库管理代码:PrivateSubCommand1_Click()IfCombo1.Text=""AndCombo2.Text=""Then'text1.Text=""AndText2.Text=""Then 精心整理精心整理MsgBox" “品名”和“型号”不能同时为空,必须输入其中一项 !",," 提示信息!" ExitSubElseIfText1.Text=""AndCombo3.Text=""Then'Text4.Text=""ThenMsgBox" 请输入产品“数量”或“单位”之一 !",," 提示信息!"Text2.SetFocusExitSubEndIfIfText2.Text=""ThenMsgBox" 请经手人签名!",vbCritical," 提示信息!"Text2.SetFocusExitSubEndIfAdodc1.RefreshEndIfDimpmAsStringDimpmsAsStringDimnAsStringDimmAsStringpm=Trim(Combo1.Text)n=Val(Text1.Text)pms="select*from 库存表where 品名='"&pm&"'"EndIfDimXAsIntegerX=MsgBox(" 产品出库登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1," 提示信息!") IfX=vbNoThenUnloadMe'Form2.ShowEndIfCombo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""DimZBAsStringZB="select*from 出库表"'where 品名='"&PM&"'" EndSubPrivateSubCommand2_Click()Combo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""精心整理精心整理Text4.Text=""EndSubPrivateSubCommand3_Click()UnloadMe'Form2.ShowEndSubPrivateSubForm_Load()Adodc2.RefreshLoopEndSub借出管理代码:PrivateSubCommand1_Click()IfCombo1.Text=""AndCombo2.Text=""Then'text1.Text=""AndText2.Text=""Then MsgBox" “品名”和“型号”不能同时为空,必须输入其中一项 !",," 提示信息!" ExitSubElseIfText1.Text=""AndCombo3.Text=""Then'Text4.Text=""ThenMsgBox" 请输入产品“数量”或“单位”之一 !",," 提示信息!"Text1.SetFocusExitSubEndIfIfText2.Text=""ThenMsgBox" 请经手人签名!",vbCritical," 提示信息!"Text2.SetFocusExitSubEndIfAdodc1.RefreshEndIfDimpmAsStringDimpmsAsStringDimnAsStringDimmAsStringpm=Trim(Combo1.Text)n=Val(Text1.Text)pms="select*from 库存表where 品名='"&pm&"'"EndIfDimXAsIntegerX=MsgBox(" 产品借出登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1," 提示信息!") IfX=vbNoThenUnloadMeForm2.ShowEndIf精心整理精心整理Combo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""DimZBAsStringZB="select*from 借出表"'where 品名='"&PM&"'"EndSubPrivateSubCommand2_Click()Combo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""EndSubPrivateSubCommand3_Click()UnloadMeForm2.ShowEndSubPrivateSubForm_Load()Adodc2.RefreshLoopEndSub归还管理代码:PrivateSubCommand1_Click()IfCombo1.Text=""AndCombo2.Text=""Then'text1.Text=""AndText2.Text=""Then MsgBox" “品名”和“型号”不能同时为空,必须输入其中一项 !",," 提示信息!" ExitSubElseIfText1.Text=""AndCombo3.Text=""Then'Text4.Text=""ThenMsgBox" 请输入产品“数量”或“单位”之一 !",," 提示信息!"Text1.SetFocusExitSubEndIfIfText2.Text=""ThenMsgBox" 请经手人签名!",vbCritical," 提示信息!"Text2.SetFocusExitSub精心整理精心整理EndIfIfText3.Text=""ThenMsgBox" 请输入归还人姓名!",vbCritical," 提示信息!"Text3.SetFocusExitSubEndIfAdodc1.RefreshEndIfDimpmAsStringDimpmsAsStringDimnAsStringDimmAsStringpm=Trim(Combo1.Text)n=Val(Text1.Text)pms="select*from 库存表where 品名='"&pm&"'"EndIfDimXAsIntegerX=MsgBox(" 产品归还登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1," 提示信息!") IfX=vbNoThenUnloadMeForm2.ShowEndIfCombo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""DimZBAsStringZB="select*from 归还表"'where 品名='"&PM&"'"EndSubPrivateSubCommand2_Click()Combo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""EndSub PrivateSubCommand3_Click() UnloadMeForm2.ShowEndSubPrivateSubForm_Load()精心整理精心整理'DimiAsString'i=0'Adodc2.Refresh'i=i+1'LoopCallpmEndSubPrivateSubpm() DimiAsVariant DimjAsVariant DimkAsVariant DimaAsVariant DimbAsVariant DimcAsVariant DimsAsVariant DimDAsVarianti=0j=0Adodc2.Refreshi=i+1LoopD=Split(a,",")Ifj<iThens=D(2)Combo1.AddItems'k=0'Ifk<jAndD(k)<>D(j)Then'IfD(k)<>D(j)Then'C ombo1.AddItemD(j)'k=k+1'Else'k=k+1'EndIf'EndIfj=j+1EndIfText5.Text=s'a+","+D(2)+D(1)'+""+Val(i)+""+Val(j)+""+Val(k) Text6.Text=j'Combo1.AddItemD(1)EndSub精心整理。
VB仓库管理系统源代码
.1.请购作业程序Private Sub ComCX_Click()'查询'在编号文本框中输入编号,连接数据库,查询编号,并将编号?品名?规格?单位?单价的数据分别导入到相应文本框。
Set CN = New ADODB.ConnectionSet Rs = New ADODB.RecordsetCN.Open Provider=Microsoft.Jet.OLEDB.4.0;Data Source= & F:\VB设计专用\仓库数据资料\仓库数据资料.mdb;Persist Security Info=False'打开数据库Rs.CursorType = adOpenStatic '制定一个静态游标Rs.LockType = adLockOptimistic '设置锁定模式为开放式Rs.Open select * from JLBH where FtextBHSJ Like' & % & Trim(textBHSJ.Text)& % & ', CNDoEventsDo Until Rs.EOF = TrueIf Rs.EOF = False ThenlistBHSJ1.AddItem (Rs.Fields(0))listPMSJ1.AddItem (Rs.Fields(1))listGGSJ1.AddItem (Rs.Fields(2))listDWSJ1.AddItem (Rs.Fields(3))listDJSJ1.AddItem (Rs.Fields(4))专业资料Word.Rs.MoveNextEnd IfLoopEnd SubPrivate Sub comFHZY_Click()'返回上页frmQGZY.HidefrmCKGLXT.ShowEnd SubPrivate Sub comQD_Click()'录入数据If textBHSJ.Text = \ Or textPMSJ.Text = \ Or textGGSJ.Text = \ Or textDWSJ.Text = \ Or textDJSJ.Text = \ Or textQGSLSJ.Text = \ Then獍?硯尠请将数据补充完整!textBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \textDWSJ.Text = \textDJSJ.Text = \textQGSLSJ.Text = \Else专业资料Word.Dim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = Select textBHSJ From qgzy where textBHSJ= ' & Trim(textBHSJ.Text) & 'strconn = Provider=Microsoft.Jet.OLEDB.4.0;Data Source='strconn = strconn & F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)str1=InsertIntoqgzy(textBHSJ,textPMSJ,textGGSJ,textDWSJ,textDJSJ,textQGSJ)str1 = str1 + Values(' & Trim(textBHSJ.Text) & ',' & Trim(textPMSJ.Text) & ',' & Trim(textGGSJ.Text) & ',' & Trim(textDWSJ.Text) & ',' & Trim(textDJSJ.Text) & ',' & Trim(textQGSLSJ.Text) & ')cnn.Execute str1listBHSJ1.AddItem (Trim(textBHSJ.Text))listPMSJ1.AddItem (Trim(textPMSJ.Text))listGGSJ1.AddItem (Trim(textGGSJ.Text))listDWSJ1.AddItem (Trim(textDWSJ.Text))listDJSJ1.AddItem (Trim(textDJSJ.Text))专业资料Word.listQGSLSJ1.AddItem (Trim(textQGSLSJ.Text))獍?硯尠数据输入成功!rst.Closecnn.CloseSet Rs = NothingSet CN = NothingtextBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \textDWSJ.Text = \textDJSJ.Text = \textQGSLSJ.Text = \End IfEnd SubPrivate Sub comsc_Click()'删除If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1 If listBHSJ1.Selected(i) Then专业资料Word.textBHSJ.Text = listBHSJ1.List(i)textPMSJ.Text = listPMSJ1.List(i)textGGSJ.Text = listGGSJ1.List(i)textDWSJ.Text = listDWSJ1.List(i)textDJSJ.Text = listDJSJ1.List(i)textQGSLSJ.Text = listQGSLSJ1.List(i) End IfNextEnd IfDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = Select FtextBHSJ From jlbh where FtextBHSJ=' & Trim(textBHSJ.Text) & 'strconn = Provider=Microsoft.Jet.OLEDB.4.0;Data Source='strconn = strconn & F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False Thenstr1 = Delete from qgzy where FtextBHSJ=' & Trim(textBHSJ.Text) & 'cnn.Execute str1专业资料Word.textBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \textDWSJ.Text = \textDJSJ.Text = \If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistBHSJ1.RemoveItem (i)listPMSJ1.RemoveItem (i)listGGSJ1.RemoveItem (i)listDWSJ1.RemoveItem (i)listDJSJ1.RemoveItem (i)listQGSLSJ1.RemoveItem (i)End IfNextEnd If獍?硯尠数据已删除!Else专业资料Word.獍?硯尠无此数据!textBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \textDJSJ.Text = \textQGSLSJ.Text = \End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingEnd Sub‘以下是listbox串连显示Private Sub listBHSJ1_Click()If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1 If listBHSJ1.Selected(i) ThenlistPMSJ1.Selected(i) = TrueEnd If专业资料Word.NextEnd IfPrivate Sub listDJSJ1_Click()If listDJSJ1.SelCount > 0 ThenFor i = listDJSJ1.ListCount - 1 To 0 Step -1If listDJSJ1.Selected(i) ThenlistQGSLSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDWSJ1_Click()If listDWSJ1.SelCount > 0 ThenFor i = listDWSJ1.ListCount - 1 To 0 Step -1 If listDWSJ1.Selected(i) ThenlistDJSJ1.Selected(i) = TrueEnd IfNextEnd If专业资料Word.Private Sub listGGSJ1_Click()If listGGSJ1.SelCount > 0 ThenFor i = listGGSJ1.ListCount - 1 To 0 Step -1 If listGGSJ1.Selected(i) ThenlistDWSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listPMSJ1_Click()If listPMSJ1.SelCount > 0 ThenFor i = listPMSJ1.ListCount - 1 To 0 Step -1 If listPMSJ1.Selected(i) ThenlistGGSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub专业资料Word.Private Sub listQGSLSJ1_Click()If listQGSLSJ1.SelCount > 0 ThenFor i = listQGSLSJ1.ListCount - 1 To 0 Step -1 If listQGSLSJ1.Selected(i) ThenlistBHSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub2.增加料号程序Private Sub comFHZY_Click()'返回上页frmJLBH.HidefrmCKGLXT.ShowEnd SubPrivate Sub comSCBH_Click()'删除If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThentextBHSJ.Text = listBHSJ1.List(i)textPMSJ.Text = listPMSJ1.List(i)专业资料Word.textGGSJ.Text = listGGSJ1.List(i)textDWSJ.Text = listDWSJ1.List(i)textDJSJ.Text = listDJSJ1.List(i)End IfNextEnd IfDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = Select FtextBHSJ From jlbh where FtextBHSJ=' & Trim(textBHSJ.Text) & 'strconn = Provider=Microsoft.Jet.OLEDB.4.0;Data Source='strconn = strconn & F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False Thenstr1 = Delete * from jlbh where FtextBHSJ=' & Trim(textBHSJ.Text) & 'cnn.Execute str1textBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \专业资料Word.textDWSJ.Text = \textDJSJ.Text = \If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistBHSJ1.RemoveItem (i)listPMSJ1.RemoveItem (i)listGGSJ1.RemoveItem (i)listDWSJ1.RemoveItem (i)listDJSJ1.RemoveItem (i)End IfNextEnd If獍?硯尠编号已删除!Else獍?硯尠无此编号!请确认后重新输入textBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \textDWSJ.Text = \textDJSJ.Text = \专业资料Word.End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingEnd SubPrivate Sub comZJBH_Click()'新增料号If textBHSJ.Text = \ Or textPMSJ.Text = \ Or textGGSJ.Text = \ Or textDWSJ.Text = \ Or textDJSJ.Text = \ Then獍?硯尠请将数据补充完整!textBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \textDWSJ.Text = \textDJSJ.Text = \ElseDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = Select FtextBHSJ From jlbh where FtextBHSJ= ' & Trim(textBHSJ.Text) 专业资料Word.& 'strconn = Provider=Microsoft.Jet.OLEDB.4.0;Data Source='strconn = strconn & F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False Then獍?硯尠该编号已存在,不能追加!Elsestr1 = Insert Into jlbh (FtextBHSJ,FtextPMSJ,FtextGGSJ,FtextDWSJ,FtextDJSJ) str1 = str1 + Values(' & Trim(textBHSJ.Text) & ',' & Trim(textPMSJ.Text) & ',' & Trim(textGGSJ.Text) & ',' & Trim(textDWSJ.Text) & ',' & Trim(textDJSJ.Text)cnn.Execute str1listBHSJ1.AddItem (Trim(textBHSJ.Text))listPMSJ1.AddItem (Trim(textPMSJ.Text))listGGSJ1.AddItem (Trim(textGGSJ.Text))listDWSJ1.AddItem (Trim(textDWSJ.Text))listDJSJ1.AddItem (Trim(textDJSJ.Text))獍?硯尠恭喜您,添加成功!专业资料Word.End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingtextBHSJ.Text = \textPMSJ.Text = \textGGSJ.Text = \textDWSJ.Text = \textDJSJ.Text = \End Sub‘以下是listbox循环选中程序Private Sub listBHSJ1_Click()If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1 If listBHSJ1.Selected(i) ThenlistPMSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub专业资料Word.Private Sub listDJSJ1_Click()If listDJSJ1.SelCount > 0 ThenFor i = listDJSJ1.ListCount - 1 To 0 Step -1If listDJSJ1.Selected(i) ThenlistBHSJ1.Selected(i) = TrueEnd IfNextEnd IfPrivate Sub listDWSJ1_Click()If listDWSJ1.SelCount > 0 ThenFor i = listDWSJ1.ListCount - 1 To 0 Step -1 If listDWSJ1.Selected(i) ThenlistDJSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listGGSJ1_Click()If listGGSJ1.SelCount > 0 Then专业资料Word.For i = listGGSJ1.ListCount - 1 To 0 Step -1If listGGSJ1.Selected(i) ThenlistDWSJ1.Selected(i) = TrueEnd IfNextEnd IfPrivate Sub listPMSJ1_Click()If listPMSJ1.SelCount > 0 ThenFor i = listPMSJ1.ListCount - 1 To 0 Step -1 If listPMSJ1.Selected(i) ThenlistGGSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub专业资料Word。
仓库管理系统(VB Access 源代码)
仓库管理系统项目的建立这是本人利用闲暇之余在VB6.0上制作的一个简陋的类库管系统,现图文结合的方式一步一步展现制作过程。
由于本人是个初学者,里面存在很多不足之处望得到高手们的指导。
此文可作供初学者们学习交流。
作者联系方式:E-mail luo.shiye@ QQ:1355044347最终运行效果打开软件出现如下登录界面主界面:1、创建标准EXE2、按“打开”3、添加MDI窗体——打开4、编辑菜单在空白处右击——点击“菜单编辑器”在“标题”里输入“系统”,在“名称”里输入“Sys”(注意此处不能为汉字)点击“下一个”再点击“”“确定”退到MDI界面点击“系统”——“退出”如下,然后编写代码。
代码如下:Private Sub Exit_Click()EndEnd Sub数据库的建立VB6.0中可以创建Access数据库。
如下建立一个“用户表”的数据库,用来存放用户信息及一些出入库管理信息。
如下图单击“外接程序”再单击“可视化数据管理器”出现如图点击“文件”——“新建”——“Microsoft Access”——“Version 2.0 MDB”输入数据库名,“保存”出现如下图在数据窗口中右击——“新建表”,最终如下往数据表里添加数据在这里就不罗嗦了,请查阅相关书籍。
登录界面窗口的建立最终界面如下:1、Adodc1的添加过程为:单击“工程”——“部件”出现下图所示,选择“控件”下的“Microsoft ADO Data Control 6.0 (OLEDB)”单击“确定”在工具栏中会出现“”图标,单击它并拖动到相应位置即可。
其它元件不在一一说明。
2、本窗体代码如下:Private Sub Command1_Click() '“登录”、“确定”按钮 If Command1.Caption = "确定" And Command2.Caption = "取消" Then '如果为“确定”则添加新用户 If Text1.Text = "" Then '提示用户输入用户名MsgBox "请输入用户名!", , "登录信息提示:"Exit SubElse 'Dim usename As String '检测用户名是否已经存在 Dim strS As Stringusename = Trim(Text1.Text)strS = "select * from 用户登录信息表 where 用户名='" & usename & "'"mandType = adCmdTextAdodc1.RecordSource = strSAdodc1.RefreshIf Adodc1.Recordset.EOF = False ThenMsgBox "您输入的用户已存在!", , "登录提示信息:"Text1.Text = ""Text3.Text = ""Text1.SetFocusExit SubEnd IfEnd IfIf Text2.Text = "" Then '提示用户密码不能为空MsgBox "密码不能为空!", , "登录提示信息:"Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请再次输入密码!", , "登录提示信息:"Text3.SetFocusExit SubEnd IfIf Text2.Text <> Text3.Text ThenMsgBox "两次输入的密码不一致,请确认!", , "登录提示信息:"Text2.Text = ""Text3.Text = ""Text2.SetFocusExit SubElseAdodc1.Recordset.AddNew '添加新用户Adodc1.Recordset.Fields("用户名") = Trim(Text1.Text)Adodc1.Recordset.Fields("密码") = Trim(Text2.Text)Adodc1.Recordset.UpdateMsgBox ("添加新用户成功,现在您可以登陆系统了!")Label3.Visible = FalseText3.Visible = FalseCommand1.Caption = "登录"Command2.Caption = "退出"End IfElse '“登录”按钮,用户登录 Dim strSno As StringDim strSelect As StringstrSno = Trim(Text1.Text) '检测用户名是否存在strSelect = "select 密码 from 用户登录信息表 where 用户名 = '" & strSno & "'"mandType = adCmdTextAdodc1.RecordSource = strSelectAdodc1.RefreshIf Adodc1.Recordset.EOF = True ThenMsgBox "用户名不存在,请重新输入!", , "登录提示信息:"Text1.Text = ""Text1.SetFocusExit SubEnd IfIf Adodc1.Recordset.Fields("密码") = Trim(Text2.Text) Then '检测密码是否正确Form1.Hide'Unload MeForm2.Show'MsgBox "登陆成功!", , "登录提示信息:"ElseMsgBox "密码不正确,请重新输入!", , "登录提示信息:"Text2.Text = ""Text2.SetFocusEnd IfEnd IfEnd SubPrivate Sub Command2_Click() '“退出”或“取消”按钮 If Command2.Caption = "取消" ThenLabel3.Visible = FalseText3.Visible = FalseCommand1.Caption = "登录"Command2.Caption = "退出"Text1.Text = ""Text2.Text = ""Text1.SetFocusElseEnd 'Unload MeEnd IfEnd SubPrivate Sub Command3_Click() '“新用户”按钮Label3.Visible = TrueText3.Visible = TrueText1.Text = ""Text2.Text = ""Text3.Text = ""Command1.Caption = "确定"Command2.Caption = "取消"Text1.SetFocusEnd SubPrivate Sub Command3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Label6.Visible = TrueEnd SubPrivate Sub Command3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Label6.Visible = FalseEnd SubPrivate Sub Form_Load()Label3.Visible = FalseText3.Visible = FalseEnd SubPrivate Sub Timer1_Timer() '时间time1控件的time事件代码,用来'显示向左移动的欢迎字幕If Label4.Left + Label4.Width > 0 Then '当标签右边位置大于0时,标签向左移Label4.Move Label4.Left - 80Else '否则标签从头开始Label4.Left = Form1.ScaleWidthEnd IfIf Label5.Left + Label5.Width > 0 ThenLabel5.Move Label5.Left - 80ElseLabel5.Left = Form1.ScaleWidthEnd IfEnd Sub主界面窗体如下:代码:Private Sub AddNew_Click()Frame1.Visible = TrueFrame2.Visible = FalseEnd SubPrivate Sub CHKPMCHX_Click()Frame2.Caption = "出库信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 出库表 where 品名 = '" & pm & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub CHKXHCHX_Click()Frame2.Caption = "出库信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)n = "select * from 出库表 where 型号 = '" & XH & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshEnd SubPrivate Sub CKCZ_Click()'Form2.HideForm6.ShowEnd SubPrivate Sub CKJSHR_Click()Frame2.Caption = "出库信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 出库表 where 经手人 = '" & JSHR & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub CKSHJ_Click()Frame2.Caption = "出库信息"Dim CHKRQ As StringDim n As StringCHKRQ = InputBox("出库日期,格式为:月/日/年如:12/1/2011", "请输入", 0)n = "select * from 出库表 where 出库日期 = '" & CHKRQ & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub CKZCX_Click()Frame2.Caption = "出库信息"Dim ZB As StringZB = "select * from 出库表 "mandType = adCmdTextAdodc2.RecordSource = ZBAdodc2.RefreshCall InitGrid1End SubPrivate Sub Command1_Click()If Text1.Text = "" Then '提示用户输入用户名MsgBox "请输入用户名!", , "登录信息提示:"Exit SubElse 'Dim usename As String '检测用户名是否已经存在 Dim strS As Stringusename = Trim(Text1.Text)strS = "select * from 用户登录信息表 where 用户名='" & usename & "'"mandType = adCmdTextAdodc1.RecordSource = strSAdodc1.RefreshIf Adodc1.Recordset.EOF = False ThenMsgBox "您输入的用户已存在!", , "登录提示信息:"Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusExit SubEnd IfEnd IfIf Text2.Text = "" Then '提示用户密码不能为空 MsgBox "密码不能为空!", , "登录提示信息:"Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请再次输入密码!", , "登录提示信息:"Text3.SetFocusExit SubEnd IfIf Text2.Text <> Text3.Text ThenMsgBox "两次输入的密码不一致,请确认!", , "登录提示信息:"Text2.Text = ""Text3.Text = ""Text2.SetFocusExit SubElseAdodc1.Recordset.AddNew '添加新用户Adodc1.Recordset.Fields("用户名") = Trim(Text1.Text)Adodc1.Recordset.Fields("密码") = Trim(Text2.Text)Adodc1.Recordset.UpdateDim X As IntegerX = MsgBox("成功添加新用户,是否要重新登录!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbYes ThenUnload MeForm3.ShowEnd If'MsgBox ("成功添加新用户!")'Label3.Visible = False'Text3.Visible = False'Command1.Caption = "登录"'Command2.Caption = "退出"End IfFrame1.Visible = FalseFrame2.Visible = TrueText1.Text = ""Text2.Text = "'"Text3.Text = ""'Form3.ShowEnd SubPrivate Sub Command2_Click()Frame1.Visible = FalseFrame2.Visible = TrueEnd SubPrivate Sub CXDL_Click()Form3.Show'Unload MeEnd SubPrivate Sub Exit_Click()EndUnload Form1Unload Form3Unload Form4Unload Form5Unload Form6Unload Form7Unload Form8End SubPrivate Sub Form_Load()TextUserName = Trim(Form1.Text1.Text)Unload Form1Frame1.Visible = FalseCall InitGrid0Me.Height = MDIForm1.Height - 1060Me.Width = MDIForm1.Width - 560Me.Top = MDIForm1.TopMe.Left = MDIForm1.LeftEnd SubPrivate Sub GHCZ_Click()'Form2.HideForm8.ShowEnd SubPrivate Sub GHPMCX_Click()Frame2.Caption = "归还信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 归还表 where 品名 = '" & pm & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub GHRCX_Click()Frame2.Caption = "归还信息"Dim JCR As StringDim n As StringJCR = InputBox("归还人", "请输入", 0)n = "select * from 归还表 where 归还人 = '" & JCR & "'" mandType = adCmdTextAdodc2.RecordSource = nCall InitGrid2End SubPrivate Sub GHSJCX_Click()Frame2.Caption = "归还信息"Dim JCRQ As StringDim n As StringJCRQ = InputBox("归还日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 归还表 where 归还日期 = '" & JCRQ & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub GHXHCX_Click()Frame2.Caption = "归还信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)n = "select * from 归还表 where 型号 = '" & XH & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub GHZCX_Click()Frame2.Caption = "归还信息"Dim ZB As StringZB = "select * from 归还表 "mandType = adCmdTextAdodc2.RecordSource = ZBAdodc2.RefreshCall InitGrid2End SubPrivate Sub JCCZ_Click()'Form2.HideForm7.ShowEnd SubPrivate Sub JCHPMCHX_Click()Frame2.Caption = "借出信息"Dim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 借出表 where 品名 = '" & pm & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub JCHXHCHX_Click()Frame2.Caption = "借出信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)n = "select * from 借出表 where 型号 = '" & XH & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub JCRCX_Click()Frame2.Caption = "借出信息"Dim JCR As StringDim n As StringJCR = InputBox("借出人", "请输入", 0)n = "select * from 借出表 where 借出人 = '" & JCR & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub JCSHJCX_Click()Frame2.Caption = "借出信息"Dim JCRQ As StringDim n As StringJCRQ = InputBox("借出日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 借出表 where 借出日期 = '" & JCRQ & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub JCZCX_Click()Frame2.Caption = "借出信息"ZB = "select * from 借出表 "mandType = adCmdTextAdodc2.RecordSource = ZBAdodc2.RefreshCall InitGrid2End SubPrivate Sub JSHRCHX_Click()Frame2.Caption = "归还信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 归还表 where 经手人 = '" & JSHR & "'" mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub JSHRCX_Click()Frame2.Caption = "借出信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 借出表 where 经手人 = '" & JSHR & "'" mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub PMCX_Click()Frame2.Caption = "库存信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 库存表 where 品名 = '" & pm & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid0End SubPrivate Sub RKCZ_Click()'Form2.HideForm5.ShowEnd SubPrivate Sub RKJSHR_Click()Frame2.Caption = "入库信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 入库表 where 经手人 = '" & JSHR & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub RKPMCHX_Click()Frame2.Caption = "入库信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)If Len(pm) > 0 Thenn = "select * from 入库表 where 品名 = '" & pm & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshEnd IfCall InitGrid1End SubPrivate Sub RKSHJ_Click()Frame2.Caption = "入库信息"Dim RKRQ As StringDim n As StringRKRQ = InputBox("入库日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 入库表 where 入库日期 = '" & RKRQ & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub RKXHCHX_Click()Frame2.Caption = "入库信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)If Len(XH) > 0 Thenn = "select * from 入库表 where 型号 = '" & XH & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshEnd IfCall InitGrid1End SubPrivate Sub RKZCX_Click()Frame2.Caption = "入库信息"Dim ZB As StringZB = "select * from 入库表 "mandType = adCmdTextAdodc2.RecordSource = ZBAdodc2.RefreshCall InitGrid1End SubPrivate Sub Timer1_Timer()If Label4.Left + Label4.Width > 0 Then '当标签右边位置大于0时,标签向左移Label4.Move Label4.Left - 80Else '否则标签从头开始Label4.Left = Form2.ScaleWidthEnd IfIf Label5.Left + Label5.Width > 0 ThenLabel5.Move Label5.Left - 80ElseLabel5.Left = Form2.ScaleWidthEnd IfIf Label6.Left + Label6.Width > 0 ThenLabel6.Move Label6.Left - 80ElseLabel6.Left = Form2.ScaleWidthEnd IfIf Label7.Left + Label7.Width > 0 ThenLabel7.Move Label7.Left - 80ElseLabel7.Left = Form2.ScaleWidthEnd IfEnd SubPrivate Sub XGMM_Click()'Form2.HideForm4.ShowEnd SubPrivate Sub XHCX_Click()Frame2.Caption = "库存信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)If Len(XH) > 0 Then 'And Val(XH) <> 0n = "select * from 库存表 where 型号 = '" & XH & "'" mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshEnd IfCall InitGrid0End SubPrivate Sub ZB_Click()Frame2.Caption = "库存信息"Dim ZB As String'Dim N As String'PM = InputBox("产品名", "请输入", 0)ZB = "select * from 库存表 " 'where 品名 = '" & PM & "'" mandType = adCmdTextAdodc2.RecordSource = ZBAdodc2.RefreshCall InitGrid0End SubPrivate Sub InitGrid0()With DataGrid1.Columns(0).Width = 1600.Columns(1).Width = 2200.Columns(2).Width = 2200.Columns(3).Width = 1000.Columns(4).Width = 1000.Columns(5).Width = 4000End WithEnd SubPrivate Sub InitGrid1()With DataGrid1.Columns(0).Width = 800.Columns(1).Width = 1600.Columns(2).Width = 1600.Columns(3).Width = 800.Columns(4).Width = 800.Columns(5).Width = 1000.Columns(6).Width = 800.Columns(7).Width = 4000End WithEnd SubPrivate Sub InitGrid2()With DataGrid1'.Columns(0).Caption = "学号"' .Columns(1).Caption = "课程名"'.Columns(2).Caption = "学分"' .Columns(3).Caption = "成绩"'设置DtgCond的列宽.Columns(0).Width = 800.Columns(1).Width = 1600.Columns(2).Width = 1600.Columns(3).Width = 800.Columns(4).Width = 800.Columns(5).Width = 800.Columns(6).Width = 1000.Columns(7).Width = 800.Columns(8).Width = 4000End WithEnd Sub用户重新登录界面代码:Private Sub Command1_Click()Dim strSno As StringDim strSelect As StringstrSno = Trim(Text1.Text) '检测用户名是否存在 strSelect = "select 密码 from 用户登录信息表 where 用户名 = '" & strSno & "'"mandType = adCmdTextAdodc1.RecordSource = strSelectAdodc1.RefreshIf Adodc1.Recordset.EOF = True ThenMsgBox "用户名不存在,请重新输入!", , "登录提示信息:"Text1.Text = ""Text2.Text = ""Text1.SetFocusExit SubEnd IfIf Adodc1.Recordset.Fields("密码") = Trim(Text2.Text) Then '检测密码是否正确 Unload MeForm2.Show'MsgBox "登陆成功!", , "登录提示信息:"ElseMsgBox "密码不正确,请重新输入!", , "登录提示信息:"Text2.Text = ""Text2.SetFocusEnd IfEnd SubPrivate Sub Command2_Click()Unload MeForm2.ShowEnd Sub修改用户密码界面代码:Private Sub Command1_Click()If Trim(Text1.Text) <> Form2.TextUserName ThenMsgBox "用户名不正确,请确认!", , "信息提示!"Text1.Text = ""Text1.SetFocusExit SubElseDim name As StringDim names As Stringname = Trim(Text1.Text)names = "select * from 用户登录信息表 where 用户名='" & name & "'" mandType = adCmdTextAdodc1.RecordSource = namesAdodc1.RefreshIf Text2.Text = "" ThenMsgBox "请输入旧密码!", , "信息提示!"Text2.SetFocusExit SubEnd IfIf Adodc1.Recordset.Fields("密码") <> Trim(Text2.Text) ThenMsgBox "旧密码不正确,请确认!", , "信息提示!"Text2.Text = ""Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请输入新密码!", , "信息提示!"Text3.SetFocusExit SubEnd IfIf Text4.Text = "" ThenMsgBox "请再次输入新密码!", , "信息提示!"Text4.SetFocusExit SubEnd IfIf Trim(Text3.Text) <> Trim(Text4.Text) ThenMsgBox "两次输入的新密码不一致!", , "信息提示!"Text3.Text = ""Text4.Text = ""Text3.SetFocusExit SubElseAdodc1.Recordset.Fields("密码") = Trim(Text3.Text)Adodc1.Recordset.UpdateMsgBox ("密码修改成功!")Unload Me'Form2.ShowEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Unload Me'Form2.ShowEnd Sub入库管理代码:Private Sub Command1_Click()If Text1.Text = "" And Text2.Text = "" ThenMsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!"Exit SubText1.SetFocusElseIf Text3.Text = "" And Text4.Text = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Text3.SetFocusExit SubEnd IfIf Text5.Text = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Text5.SetFocusExit SubEnd IfAdodc1.RefreshAdodc1.Recordset.AddNew '添加 Adodc1.Recordset.Fields("品名") = Trim(Text1.Text)Adodc1.Recordset.Fields("型号") = Trim(Text2.Text)Adodc1.Recordset.Fields("数量") = Trim(Text3.Text)Adodc1.Recordset.Fields("单位") = Trim(Text4.Text)Adodc1.Recordset.Fields("经手人") = Trim(Text5.Text)Adodc1.Recordset.Fields("入库日期") = DateAdodc1.Recordset.Fields("说明") = Trim(Text7.Text)Adodc1.Recordset.UpdateEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trim(Text1.Text)n = Val(Text3.Text)pms = "select * from 库存表 where 品名='" & pm & "'"mandType = adCmdTextForm2.Adodc2.RecordSource = pmsForm2.Adodc2.RefreshIf Form2.Adodc2.Recordset.EOF ThenWith Form2.Adodc2.Recordset.AddNew.Adodc2.Recordset.Fields("品名") = Trim(Text1.Text).Adodc2.Recordset.Fields("型号") = Trim(Text2.Text).Adodc2.Recordset.Fields("数量") = Trim(Text3.Text).Adodc2.Recordset.Fields("单位") = Trim(Text4.Text).Adodc2.Recordset.Fields("说明") = Trim(Text7.Text).Adodc2.Recordset.UpdateEnd WithElsem = Form2.Adodc2.Recordset.Fields("数量").ValueIf Form2.Adodc2.Recordset.Fields("型号") = Trim(Text2.Text) ThenForm2.Adodc2.Recordset.Fields("数量") = Val(m) + Val(n)Form2.Adodc2.Recordset.UpdateEnd IfEnd IfDim X As IntegerX = MsgBox("产品入库登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload Me'Form2.ShowElseText1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Text7.Text = ""Text1.SetFocusEnd IfForm2.Frame2.Caption = "入库信息"Dim ZB As StringZB = "select * from 入库表 " 'where 品名 = '" & PM & "'"mandType = adCmdTextForm2.Adodc2.RecordSource = ZBForm2.Adodc2.RefreshEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Text7.Text = ""Text1.SetFocusEnd SubPrivate Sub Command3_Click()Unload Me'Form2.ShowEnd Sub出库管理代码:Private Sub Command1_Click()If Combo1.Text = "" And Combo2.Text = "" Then ' text1.Text = "" And Text2.Text = "" Then MsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!"Exit SubElseIf Text1.Text = "" And Combo3.Text = "" Then ' Text4.Text = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Text2.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Text2.SetFocusExit SubEnd IfAdodc1.RefreshAdodc1.Recordset.AddNew '添加Adodc1.Recordset.Fields("品名") = Trim(Combo1.Text) 'Trim(Text1.Text)Adodc1.Recordset.Fields("型号") = Trim(Combo2.Text) 'Trim(Text2.Text)Adodc1.Recordset.Fields("数量") = Trim(Text1.Text)Adodc1.Recordset.Fields("单位") = Trim(Combo3.Text) 'Trim(Text4.Text)Adodc1.Recordset.Fields("经手人") = Trim(Text2.Text)Adodc1.Recordset.Fields("出库日期") = DateAdodc1.Recordset.Fields("说明") = Trim(Text4.Text)Adodc1.Recordset.UpdateEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trim(Combo1.Text)n = Val(Text1.Text)pms = "select * from 库存表 where 品名='" & pm & "'"mandType = adCmdTextForm2.Adodc2.RecordSource = pmsForm2.Adodc2.Refreshm = Form2.Adodc2.Recordset.Fields("数量").ValueIf Form2.Adodc2.Recordset.Fields("型号") = Trim(Combo2.Text) ThenForm2.Adodc2.Recordset.Fields("数量") = Val(m) - Val(n)Form2.Adodc2.Recordset.UpdateEnd IfDim X As IntegerX = MsgBox("产品出库登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload Me'Form2.ShowEnd IfCombo1.Text = ""Combo2.Text = ""Combo3.Text = ""Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Form2.Frame2.Caption = "出库信息"Dim ZB As StringZB = "select * from 出库表 " 'where 品名 = '" & PM & "'" mandType = adCmdTextForm2.Adodc2.RecordSource = ZBForm2.Adodc2.RefreshEnd SubPrivate Sub Command2_Click()Combo1.Text = ""Combo2.Text = ""Combo3.Text = ""Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""End SubPrivate Sub Command3_Click()Unload Me'Form2.ShowEnd SubPrivate Sub Form_Load()Adodc2.RefreshAdodc2.Recordset.MoveFirstDo Until Adodc2.Recordset.EOFCombo2.AddItem Adodc2.Recordset.Fields("型号")Combo1.AddItem Adodc2.Recordset.Fields("品名")Combo3.AddItem Adodc2.Recordset.Fields("单位")Adodc2.Recordset.MoveNextLoopEnd Sub借出管理代码:Private Sub Command1_Click()If Combo1.Text = "" And Combo2.Text = "" Then ' text1.Text = "" And Text2.Text = "" Then MsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!"Exit SubElseIf Text1.Text = "" And Combo3.Text = "" Then ' Text4.Text = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Text2.SetFocusExit SubEnd IfAdodc1.RefreshAdodc1.Recordset.AddNew '添加Adodc1.Recordset.Fields("品名") = Trim(Combo1.Text) 'Trim(Text1.Text)Adodc1.Recordset.Fields("型号") = Trim(Combo2.Text) 'Trim(Text2.Text)Adodc1.Recordset.Fields("数量") = Trim(Text1.Text)Adodc1.Recordset.Fields("单位") = Trim(Combo3.Text) 'Trim(Text4.Text)Adodc1.Recordset.Fields("经手人") = Trim(Text2.Text)Adodc1.Recordset.Fields("借出人") = Trim(Text3.Text)Adodc1.Recordset.Fields("借出日期") = DateAdodc1.Recordset.Fields("说明") = Trim(Text4.Text)Adodc1.Recordset.UpdateEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trim(Combo1.Text)n = Val(Text1.Text)pms = "select * from 库存表 where 品名='" & pm & "'"mandType = adCmdTextForm2.Adodc2.RecordSource = pmsForm2.Adodc2.Refreshm = Form2.Adodc2.Recordset.Fields("数量").ValueIf Form2.Adodc2.Recordset.Fields("型号") = Trim(Combo2.Text) ThenForm2.Adodc2.Recordset.Fields("数量") = Val(m) - Val(n)Form2.Adodc2.Recordset.UpdateEnd IfDim X As IntegerX = MsgBox("产品借出登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload MeForm2.ShowEnd IfCombo1.Text = ""Combo2.Text = ""Combo3.Text = ""Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Form2.Frame2.Caption = "借出信息"Dim ZB As StringZB = "select * from 借出表 " 'where 品名 = '" & PM & "'"mandType = adCmdTextForm2.Adodc2.RecordSource = ZBForm2.Adodc2.RefreshEnd SubPrivate Sub Command2_Click()Combo1.Text = ""Combo2.Text = ""Combo3.Text = ""Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""End SubPrivate Sub Command3_Click()Unload MeForm2.ShowEnd Sub。
库存管理之用户登录及用户列表——VB代码
1、首页,用户登录界面'连接SQL数据库时必写语句Imports System.Data.SqlClientPublic Class Frm_UserloginPrivate Sub Bt_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_login.ClickIf Txt_UserId.Text = ""ThenMsgBox("用户名不能为空,请输入用户名!", MsgBoxStyle.OkOnly, "温馨提示") Exit SubEnd IfIf Txt_Paw.Text = ""ThenMsgBox("密码不能为空,请输入密码!", MsgBoxStyle.OkOnly, "温馨提示")Exit SubEnd If'连接数据库Dim conn As New SqlConnection'conn.ConnectionString = "user id=sa;password=;database=test;data source=."连接SQL2000数据库的方法'连接SQL Server2005数据库的方法conn.ConnectionString = "server=.;integrated security=sspi;database=NO.4"conn.Open()Dim constr As String'判断输入的数据是否正确Dim UserName, password As StringUserName = Trim(Txt_UserId.Text)password = Trim(Txt_Paw.Text)constr = "select * from t1 where id='" & UserName & " 'and Psd='" & password & "'"Dim da As New SqlDataAdapter(constr, conn)Dim ds As New DataSetda.Fill(ds)If ds.Tables(0).Rows.Count >= 1 ThenMDIParent1.ShowDialog()Me.Hide()ElseMsgBox("用户名或密码错误", MsgBoxStyle.OkOnly, "温馨提示")Txt_UserId.Text = ""Txt_Paw.Text = ""Txt_Paw.Focus()Txt_UserId.Focus()End IfEnd SubPrivate Sub Bt_cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_cancel.ClickTxt_UserId.Text = ""Txt_Paw.Text = ""Txt_Paw.Focus()Txt_UserId.Focus()End SubEnd ClassImports System.Data.SqlClientPublic Class Frm_yhlbDim conn As New SqlConnection()Dim flag As IntegerDim ds As New DataSetPrivate Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load‘添加数据库中的数据到DGW控件中GroupBox1.Enabled = Falsebaocun.Enabled = Falsequxiao.Enabled = Falseconn.ConnectionString = "server=(local);integrated security=sspi;database=NO.4"conn.Open()Dim st As Stringst = "select * from t1"Dim da As New SqlDataAdapter(st, conn)Dim ds As New DataSetda.Fill(ds)DGW1.ColumnCount = ds.Tables(0).Columns.CountDGW1.RowCount = ds.Tables(0).Rows.Count'DGW1.ColumnCount = 4 '列'DGW1.RowCount = 4 '行For i = 0 To ds.Tables(0).Rows.Count - 1For j = 0 To ds.Tables(0).Columns.Count - 1DGW1.Rows(i).Cells(j).Value = ds.Tables(0).Rows(i).ItemArray(j)Next jFor j = 0 To ds.Tables(0).Columns.Count - 1DGW1.Columns(j).HeaderText = ds.Tables(0).Columns(j).ColumnNameNextNext iEnd SubFunction f_diaoyong(ByVal st As String) As Long'Dim st As String'st = "select * from t1"Dim da As New SqlDataAdapter(st, conn)Dim ds As New DataSetda.Fill(ds)DGW1.ColumnCount = ds.Tables(0).Columns.CountDGW1.RowCount = ds.Tables(0).Rows.Count'DGW1.ColumnCount = 4 '列'DGW1.RowCount = 4 '行For i = 0 To ds.Tables(0).Rows.Count - 1For j = 0 To ds.Tables(0).Columns.Count - 1DGW1.Rows(i).Cells(j).Value = ds.Tables(0).Rows(i).ItemArray(j)Next jFor j = 0 To ds.Tables(0).Columns.Count - 1DGW1.Columns(j).HeaderText = ds.Tables(0).Columns(j).ColumnNameNextNext iEnd FunctionPrivate Sub tianjia_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tianjia.Clickflag = -1GroupBox1.Enabled = Truebaocun.Enabled = Truequxiao.Enabled = TrueTextBox1.Enabled = TrueTextBox2.Text = ""TextBox1.Text = ""TextBox1.Focus()TextBox3.Text = ""End SubPrivate Sub baocun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles baocun.ClickIf flag = -1 ThenDim a, b, c As Stringa = Trim(TextBox1.Text)b = Trim(TextBox2.Text)c = Trim(TextBox3.Text)Dim str As StringDim da As New SqlDataAdapter("select * from t1", conn)da.Fill(ds)For i = 0 To ds.Tables(0).Rows.Count - 1str = Trim(ds.Tables(0).Rows(i).ItemArray(0))If Trim(TextBox1.Text) = str ThenMsgBox("对不起,你的ID重复,请重新输入!", MsgBoxStyle.OkOnly, "用户消息提示框")TextBox1.Text = ""TextBox1.Focus()Exit SubEnd IfNextDim stre = "Insert into t1 values('"& Trim(a) & " ',' "& Trim(b) & " ', ' "& Trim(c) & " ' )"Dim com As New SqlCommand(stre, conn)com.ExecuteNonQuery()ElseIf flag = 1 ThenDim name1, mima1, a1 As Stringname1 = TextBox2.Textmima1 = TextBox3.Texta1 = TextBox1.Texta1 = DGW1.SelectedRows(0).Cells(0).ValueDim stre = "update t1 set name= ' " & name1 & " ', psd= ' " & mima1 & " 'where id='" & a1 & " ' "Dim com As New SqlCommand(stre, conn)com.ExecuteNonQuery()End IfTextBox1.Text = ""TextBox1.Focus()TextBox2.Text = ""TextBox3.Text = ""baocun.Enabled = Falsequxiao.Enabled = FalseGroupBox1.Enabled = FalseCall f_diaoyong("select * from t1")End SubPrivate Sub quxiao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quxiao.ClickTextBox1.Text = ""TextBox1.Focus()TextBox2.Text = ""TextBox3.Text = ""DGW1.Enabled = Falsebaocun.Enabled = Falsequxiao.Enabled = FalseGroupBox1.Enabled = FalseEnd SubPrivate Sub xiugai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xiugai.Clickflag = 1TextBox1.Enabled = Falsebaocun.Enabled = Truequxiao.Enabled = TrueGroupBox1.Enabled = TrueTextBox1.Text = DGW1.SelectedRows(0).Cells(0).ValueTextBox2.Text = DGW1.SelectedRows(0).Cells(1).ValueTextBox3.Text = DGW1.SelectedRows(0).Cells(2).ValueEnd SubPrivate Sub tuichu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tuichu.ClickEndEnd SubPrivate Sub shanchu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles shanchu.ClickDim yh As Stringyh = TextBox1.Textyh = DGW1.SelectedRows(0).Cells(0).ValueDim stre = "delete from t1 where id='" & yh & " '"Dim com As New SqlCommand(stre, conn)com.ExecuteNonQuery()MsgBox("确定删除!", MsgBoxStyle.OkOnly, "提示信息")baocun.Enabled = Truequxiao.Enabled = TrueDGW1.Enabled = FalseCall f_diaoyong("select * from t1")End SubEnd Class。
仓库管理系统(VB+Access+源代码)
仓库管理系统项目的建立这是本人利用闲暇之余在上制作的一个简陋的类库管系统,现图文结合的方式一步一步展现制作过程。
由于本人是个初学者,里面存在很多不足之处望得到高手们的指导。
此文可作供初学者们学习交流。
作者联系方式:E-mail最终运行效果打开软件出现如下登录界面输入系统预设用户名及密码( 1 1 )单击“登录”或单击“新用户”添加新用户进入如下主界面:建立工程1、创建标准EXE2、按“打开”3、添加MDI窗体——打开4、编辑菜单在空白处右击——点击“菜单编辑器”在“标题”里输入“系统”,在“名称”里输入“Sys”(注意此处不能为汉字)点击“下一个”再点击“”“确定”退到MDI界面点击“系统”——“退出”如下,然后编写代码。
代码如下:Private Sub Exit_Click()EndEnd Sub数据库的建立中可以创建Access数据库。
如下建立一个“用户表”的数据库,用来存放用户信息及一些出入库管理信息。
如下图单击“外接程序”再单击“可视化数据管理器”出现如图点击“文件”——“新建”——“Microsoft Access”——“Version MDB”输入数据库名,“保存”出现如下图在数据窗口中右击——“新建表”,最终如下往数据表里添加数据在这里就不罗嗦了,请查阅相关书籍。
登录界面窗口的建立最终界面如下:1、Adodc1的添加过程为:单击“工程”——“部件”出现下图所示,选择“控件”下的“Microsoft ADO Data Control (OLEDB)”单击“确定”在工具栏中会出现“”图标,单击它并拖动到相应位置即可。
其它元件不在一一说明。
2、本窗体代码如下:Private Sub Command1_Click() '“登录”、“确定”按钮 If = "确定" And = "取消" Then '如果为“确定”则添加新用户If = "" Then '提示用户输入用户名MsgBox "请输入用户名!", , "登录信息提示:"Exit SubElse 'Dim usename As String '检测用户名是否已经存在Dim strS As Stringusename = TrimstrS = "select * from 用户登录信息表 where 用户名='" & usename & "'"= adCmdText= strSIf = False ThenMsgBox "您输入的用户已存在!", , "登录提示信息:"= ""= ""= ""Exit SubEnd IfEnd IfIf = "" Then '提示用户密码不能为空 MsgBox "密码不能为空!", , "登录提示信息:"Exit SubEnd IfIf = "" ThenMsgBox "请再次输入密码!", , "登录提示信息:"Exit SubEnd IfIf <> ThenMsgBox "两次输入的密码不一致,请确认!", , "登录提示信息:"= ""Exit SubElse'添加新用户"用户名") = Trim"密码") = TrimMsgBox ("添加新用户成功,现在您可以登陆系统了!")= False= False= "登录"= "退出"End IfElse '“登录”按钮,用户登录 Dim strSno As StringDim strSelect As StringstrSno = Trim '检测用户名是否存在strSelect = "select 密码 from 用户登录信息表 where 用户名 = '" & strSno & "'"= adCmdText= strSelectIf = True ThenMsgBox "用户名不存在,请重新输入!", , "登录提示信息:"= ""= ""End IfIf "密码") = Trim Then '检测密码是否正确'Unload Me'MsgBox "登陆成功!", , "登录提示信息:"ElseMsgBox "密码不正确,请重新输入!", , "登录提示信息:"= ""End IfEnd IfEnd SubPrivate Sub Command2_Click() '“退出”或“取消”按钮 If = "取消" Then= False= False= "登录"= "退出"= ""= ""ElseEnd 'Unload MeEnd IfEnd SubPrivate Sub Command3_Click() '“新用户”按钮= True= True= ""= ""= ""= "确定"= "取消"End SubPrivate Sub Command3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)= TrueEnd SubPrivate Sub Command3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)= FalseEnd SubPrivate Sub Form_Load()= False= FalseEnd SubPrivate Sub Timer1_Timer() '时间time1控件的time事件代码,用来'显示向左移动的欢迎字幕If + > 0 Then '当标签右边位置大于0时,标签向左移- 80Else '否则标签从头开始=End IfIf + > 0 Then- 80Else=End IfEnd Sub主界面窗体如下:代码:Private Sub AddNew_Click() = True= FalseEnd SubPrivate Sub CHKPMCHX_Click()= "出库信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 出库表 where 品名 = '" & pm & "'" = adCmdText= nCall InitGrid1End SubPrivate Sub CHKXHCHX_Click()= "出库信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)n = "select * from 出库表 where 型号 = '" & XH & "'" = adCmdText= nEnd SubPrivate Sub CKCZ_Click()'End SubPrivate Sub CKJSHR_Click()= "出库信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 出库表 where 经手人 = '" & JSHR & "'"= adCmdText= nCall InitGrid1End SubPrivate Sub CKSHJ_Click()= "出库信息"Dim CHKRQ As StringDim n As StringCHKRQ = InputBox("出库日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 出库表 where 出库日期 = '" & CHKRQ & "'"= adCmdText= nCall InitGrid1End SubPrivate Sub CKZCX_Click()= "出库信息"Dim ZB As StringZB = "select * from 出库表 "= adCmdText= ZBCall InitGrid1End SubPrivate Sub Command1_Click()If = "" Then '提示用户输入用户名MsgBox "请输入用户名!", , "登录信息提示:"Exit SubElse 'Dim usename As String '检测用户名是否已经存在 Dim strS As Stringusename = TrimstrS = "select * from 用户登录信息表 where 用户名='" & usename & "'"= adCmdText= strSIf = False ThenMsgBox "您输入的用户已存在!", , "登录提示信息:"= ""= ""= ""Exit SubEnd IfEnd IfIf = "" Then '提示用户密码不能为空MsgBox "密码不能为空!", , "登录提示信息:"Exit SubEnd IfIf = "" ThenMsgBox "请再次输入密码!", , "登录提示信息:"Exit SubEnd IfIf <> ThenMsgBox "两次输入的密码不一致,请确认!", , "登录提示信息:"= ""= ""Exit SubElse'添加新用户"用户名") = Trim"密码") = TrimDim X As IntegerX = MsgBox("成功添加新用户,是否要重新登录!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbYes ThenUnload MeEnd If'MsgBox ("成功添加新用户!")' = False' = False' = "登录"' = "退出"End If= False= True= ""= "'"= ""'End SubPrivate Sub Command2_Click() = False= TrueEnd SubPrivate Sub CXDL_Click()'Unload MeEnd SubPrivate Sub Exit_Click()EndUnload Form1Unload Form2Unload Form3Unload Form4Unload Form5Unload Form6Unload Form7Unload Form8End SubPrivate Sub Form_Load()TextUserName = Trim Unload Form1= FalseCall InitGrid0= - 1060= - 560==End SubPrivate Sub GHCZ_Click()'End SubPrivate Sub GHPMCX_Click()= "归还信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 归还表 where 品名 = '" & pm & "'" = adCmdText= nCall InitGrid2End SubPrivate Sub GHRCX_Click()= "归还信息"Dim JCR As StringDim n As StringJCR = InputBox("归还人", "请输入", 0)n = "select * from 归还表 where 归还人 = '" & JCR & "'"= adCmdText= nCall InitGrid2End SubPrivate Sub GHSJCX_Click()= "归还信息"Dim JCRQ As StringDim n As StringJCRQ = InputBox("归还日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 归还表 where 归还日期 = '" & JCRQ & "'"= adCmdText= nCall InitGrid2End SubPrivate Sub GHXHCX_Click()= "归还信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)n = "select * from 归还表 where 型号 = '" & XH & "'" = adCmdText= nCall InitGrid2End SubPrivate Sub GHZCX_Click()= "归还信息"Dim ZB As StringZB = "select * from 归还表 "= adCmdText= ZBCall InitGrid2End SubPrivate Sub JCCZ_Click()'End SubPrivate Sub JCHPMCHX_Click()= "借出信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 借出表 where 品名 = '" & pm & "'"= adCmdText= nCall InitGrid2End SubPrivate Sub JCHXHCHX_Click()= "借出信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)n = "select * from 借出表 where 型号 = '" & XH & "'"= adCmdText= nCall InitGrid2End SubPrivate Sub JCRCX_Click()= "借出信息"Dim JCR As StringDim n As StringJCR = InputBox("借出人", "请输入", 0)n = "select * from 借出表 where 借出人 = '" & JCR & "'" = adCmdText= nCall InitGrid2End SubPrivate Sub JCSHJCX_Click()= "借出信息"Dim JCRQ As StringDim n As StringJCRQ = InputBox("借出日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 借出表 where 借出日期 = '" & JCRQ & "'"= adCmdText= nCall InitGrid2End SubPrivate Sub JCZCX_Click()= "借出信息"Dim ZB As StringZB = "select * from 借出表 "= adCmdText= ZBCall InitGrid2End SubPrivate Sub JSHRCHX_Click()= "归还信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 归还表 where 经手人 = '" & JSHR & "'" = adCmdText= nCall InitGrid2End SubPrivate Sub JSHRCX_Click()= "借出信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 借出表 where 经手人 = '" & JSHR & "'" = adCmdText= nCall InitGrid2End SubPrivate Sub PMCX_Click()= "库存信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 库存表 where 品名 = '" & pm & "'"= adCmdText= nCall InitGrid0End SubPrivate Sub RKCZ_Click()'End SubPrivate Sub RKJSHR_Click()= "入库信息"Dim JSHR As StringDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 入库表 where 经手人 = '" & JSHR & "'" = adCmdText= nCall InitGrid1End SubPrivate Sub RKPMCHX_Click()= "入库信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)If Len(pm) > 0 Thenn = "select * from 入库表 where 品名 = '" & pm & "'" = adCmdText= nEnd IfCall InitGrid1End SubPrivate Sub RKSHJ_Click()= "入库信息"Dim RKRQ As StringDim n As StringRKRQ = InputBox("入库日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 入库表 where 入库日期 = '" & RKRQ & "'"= adCmdText= nCall InitGrid1End SubPrivate Sub RKXHCHX_Click()= "入库信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)If Len(XH) > 0 Thenn = "select * from 入库表 where 型号 = '" & XH & "'"= adCmdText= nEnd IfCall InitGrid1End SubPrivate Sub RKZCX_Click()= "入库信息"Dim ZB As StringZB = "select * from 入库表 "= adCmdText= ZBCall InitGrid1End SubPrivate Sub Timer1_Timer()If + > 0 Then '当标签右边位置大于0时,标签向左移- 80Else '否则标签从头开始 =End IfIf + > 0 Then- 80Else=End IfIf + > 0 Then- 80Else=End IfIf + > 0 Then- 80Else=End IfEnd SubPrivate Sub XGMM_Click()'End SubPrivate Sub XHCX_Click()= "库存信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)If Len(XH) > 0 Then 'And Val(XH) <> 0n = "select * from 库存表 where 型号 = '" & XH & "'" = adCmdText= nEnd IfCall InitGrid0End SubPrivate Sub ZB_Click()= "库存信息"Dim ZB As String'Dim N As String'PM = InputBox("产品名", "请输入", 0)ZB = "select * from 库存表 " 'where 品名 = '" & PM & "'" = adCmdText= ZBCall InitGrid0End SubPrivate Sub InitGrid0()With DataGrid1.Columns(0).Width = 1600.Columns(1).Width = 2200.Columns(2).Width = 2200.Columns(3).Width = 1000.Columns(4).Width = 1000.Columns(5).Width = 4000End WithEnd SubPrivate Sub InitGrid1()With DataGrid1.Columns(0).Width = 800.Columns(1).Width = 1600.Columns(2).Width = 1600.Columns(3).Width = 800.Columns(4).Width = 800.Columns(5).Width = 1000.Columns(6).Width = 800.Columns(7).Width = 4000End WithEnd SubPrivate Sub InitGrid2()With DataGrid1'.Columns(0).Caption = "学号" ' .Columns(1).Caption = "课程名" '.Columns(2).Caption = "学分" ' .Columns(3).Caption = "成绩" '设置DtgCond的列宽.Columns(0).Width = 800.Columns(1).Width = 1600.Columns(2).Width = 1600.Columns(3).Width = 800.Columns(4).Width = 800.Columns(5).Width = 800.Columns(6).Width = 1000.Columns(7).Width = 800.Columns(8).Width = 4000End WithEnd Sub用户重新登录界面代码:Private Sub Command1_Click()Dim strSno As StringDim strSelect As StringstrSno = Trim '检测用户名是否存在 strSelect = "select 密码 from 用户登录信息表 where 用户名 = '" & strSno & "'"= adCmdText= strSelectIf = True ThenMsgBox "用户名不存在,请重新输入!", , "登录提示信息:"= ""= ""Exit SubEnd IfIf "密码") = Trim Then '检测密码是否正确Unload Me'MsgBox "登陆成功!", , "登录提示信息:"ElseMsgBox "密码不正确,请重新输入!", , "登录提示信息:" = ""End IfEnd SubPrivate Sub Command2_Click()Unload MeEnd Sub修改用户密码界面代码:Private Sub Command1_Click()If Trim <> ThenMsgBox "用户名不正确,请确认!", , "信息提示!"= ""Exit SubElseDim name As StringDim names As Stringname = Trimnames = "select * from 用户登录信息表 where 用户名='" & name & "'" = adCmdText= namesIf = "" ThenMsgBox "请输入旧密码!", , "信息提示!"Exit SubEnd IfIf "密码") <> Trim ThenMsgBox "旧密码不正确,请确认!", , "信息提示!"= ""Exit SubEnd IfIf = "" ThenMsgBox "请输入新密码!", , "信息提示!"Exit SubEnd IfIf = "" ThenMsgBox "请再次输入新密码!", , "信息提示!"Exit SubEnd IfIf Trim <> Trim ThenMsgBox "两次输入的新密码不一致!", , "信息提示!" = ""= ""Exit SubElse"密码") = TrimMsgBox ("密码修改成功!")Unload Me'End IfEnd IfEnd SubPrivate Sub Command2_Click()Unload Me'End Sub入库管理代码:Private Sub Command1_Click()If = "" And = "" ThenMsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!" Exit SubElseIf = "" And = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Exit SubEnd IfIf = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Exit SubEnd If'添加 "品名") = Trim"型号") = Trim"数量") = Trim"单位") = Trim"经手人") = Trim"入库日期") = Date"说明") = TrimEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trimn = Valpms = "select * from 库存表 where 品名='" & pm & "'"= adCmdText= pmsIf ThenWith Form2. ."品名") = Trim."型号") = Trim."数量") = Trim."单位") = Trim."说明") = Trim. End WithElsem = "数量").ValueIf "型号") = Trim Then"数量") = Val(m) + Val(n)End IfEnd IfDim X As IntegerX = MsgBox("产品入库登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload Me'Else= ""= ""= ""= ""= ""= ""= ""End If= "入库信息"Dim ZB As StringZB = "select * from 入库表 " 'where 品名 = '" & PM & "'"= adCmdText= ZBSubPrivate Sub Command2_Click()= ""= ""= ""= ""= ""= ""End SubPrivate Sub Command3_Click()Unload Me'End Sub出库管理代码:Private Sub Command1_Click()If = "" And = "" Then ' = "" And = "" ThenMsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!" Exit SubIf = "" And = "" Then ' = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Exit SubEnd IfIf = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Exit SubEnd If'添加"品名") = Trim 'Trim"型号") = Trim 'Trim"数量") = Trim"单位") = Trim 'Trim"经手人") = Trim"出库日期") = Date"说明") = TrimEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trimn = Valpms = "select * from 库存表 where 品名='" & pm & "'"= adCmdText= pmsm = "数量").ValueIf "型号") = Trim Then"数量") = Val(m) - Val(n)End IfDim X As IntegerX = MsgBox("产品出库登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload Me'End If= ""= ""= ""= ""= ""= ""= ""= "出库信息"Dim ZB As StringZB = "select * from 出库表 " 'where 品名 = '" & PM & "'"= adCmdText= ZBSubPrivate Sub Command2_Click()= ""= ""= ""= ""= ""= ""= ""End SubPrivate Sub Command3_Click() Unload Me'End SubPrivate Sub Form_Load()Do Until "型号") "品名")"单位")LoopEnd Sub借出管理代码:Private Sub Command1_Click()If = "" And = "" Then ' = "" And = "" ThenMsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!" Exit SubElseIf = "" And = "" Then ' = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Exit SubEnd IfIf = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Exit SubEnd If'添加"品名") = Trim 'Trim"型号") = Trim 'Trim"数量") = Trim"单位") = Trim 'Trim"经手人") = Trim"借出人") = Trim"借出日期") = Date"说明") = TrimEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trimn = Valpms = "select * from 库存表 where 品名='" & pm & "'"= adCmdText= pmsm = "数量").ValueIf "型号") = Trim Then"数量") = Val(m) - Val(n)End IfDim X As IntegerX = MsgBox("产品借出登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload MeEnd If= ""= ""= ""= ""= ""= ""= ""= "借出信息"Dim ZB As StringZB = "select * from 借出表 " 'where 品名 = '" & PM & "'" = adCmdText= ZBSubPrivate Sub Command2_Click()= ""= ""= ""= ""= ""= ""= ""End SubPrivate Sub Command3_Click()Unload MeEnd SubPrivate Sub Form_Load()Do Until "品名")"型号")"单位")LoopEnd Sub归还管理代码:Private Sub Command1_Click()If = "" And = "" Then ' = "" And = "" ThenMsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!" Exit SubElseIf = "" And = "" Then ' = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Exit SubEnd IfIf = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Exit SubEnd IfIf = "" ThenMsgBox "请输入归还人姓名!", vbCritical, "提示信息!"Exit SubEnd If'添加 "品名") = Trim 'Trim"型号") = Trim 'Trim"数量") = Trim"单位") = Trim 'Trim"经手人") = Trim"归还人") = Trim"归还日期") = Date"说明") = TrimEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trimn = Valpms = "select * from 库存表 where 品名='" & pm & "'"= adCmdText= pmsm = "数量").ValueIf "型号") = Trim Then"数量") = Val(m) + Val(n)End IfDim X As IntegerX = MsgBox("产品归还登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload MeEnd If= ""= ""= ""= ""= ""= ""= ""= "归还信息"Dim ZB As StringZB = "select * from 归还表 " 'where 品名 = '" & PM & "'"= adCmdText= ZBSubPrivate Sub Command2_Click()= ""= ""= ""= ""= ""= ""= ""End SubPrivate Sub Command3_Click() Unload MeEnd SubPrivate Sub Form_Load()' Dim i As String' i = 0'' ' Do Until ' "品名") ' "型号")' "单位")' ' i = i + 1' LoopCall pmEnd SubPrivate Sub pm()Dim i As VariantDim j As VariantDim k As VariantDim a As VariantDim b As VariantDim c As VariantDim s As VariantDim D As Varianti = 0j = 0Do Until a = a + "," + "品名")b = b + "," + "型号")b = b + "," + "单位")i = i + 1LoopD = Split(a, ",")If j < i Thens = D(2)s'k = 0'If k < j And D(k) <> D(j) Then'If D(k) <> D(j) Then' D(j)' k = k + 1' Else' k = k + 1'End If'End Ifj = j + 1End If= s 'a + "," + D(2) + D(1) '+ " " + Val(i) + " " + Val(j) + " " + Val(k) = j' D(1)End Sub。
仓库管理系统VBAccess源代码
仓库管理系统V B A c c e s s源代码 SANY标准化小组 #QS8QHH-HHGX8Q8-GNHHJ8-HHMHGN#仓库管理系统项目的建立这是本人利用闲暇之余在VB6.0上制作的一个简陋的类库管系统,现图文结合的方式一步一步展现制作过程。
由于本人是个初学者,里面存在很多不足之处望得到高手们的指导。
此文可作供初学者们学习交流。
作者联系方式:E-mail 最终运行效果打开软件出现如下登录界面输入系统预设用户名及密码(11)单击“登录”或单击“新用户”添加新用户进入如下主界面:建立工程1、创建标准EXE2、按“打开”3、添加MDI窗体——打开4、编辑菜单在空白处右击——点击“菜单编辑器”在“标题”里输入“系统”,在“名称”里输入“Sys”(注意此处不能为汉字)点击“下一个”再点击“”“确定”退到MDI界面点击“系统”——“退出”如下,然后编写代码。
代码如下:PrivateSubExit_Click()EndEndSub数据库的建立VB6.0中可以创建Access数据库。
如下建立一个“用户表”的数据库,用来存放用户信息及一些出入库管理信息。
如下图单击“外接程序”再单击“可视化数据管理器”出现如图点击“文件”——“新建”——“MicrosoftAccess”——“Version2.0MDB”输入数据库名,“保存”出现如下图在数据窗口中右击——“新建表”,最终如下往数据表里添加数据在这里就不罗嗦了,请查阅相关书籍。
登录界面窗口的建立最终界面如下:1、Adodc1的添加过程为:单击“工程”——“部件”出现下图所示,选择“控件”下的“MicrosoftADODataControl6.0(OLEDB)”单击“确定”在工具栏中会出现“”图标,单击它并拖动到相应位置即可。
其它元件不在一一说明。
2、本窗体代码如下:PrivateSubCommand1_Click()'“登录”、“确定”按钮IfCommand1.Caption="确定"AndCommand2.Caption="取消"Then'如果为“确定”则添加新用户MsgBox"请输入用户名!",,"登录信息提示:"ExitSubElse'DimusenameAsString'检测用户名是否已经存在DimstrSAsStringusename=Trim(Text1.Text)strS="select*from用户登录信息表where用户名='"&usename&"'" mandType=adCmdTextAdodc1.RecordSource=strSAdodc1.RefreshMsgBox"您输入的用户已存在!",,"登录提示信息:"Text1.Text=""Text2.Text=""Text3.Text=""Text1.SetFocusExitSubEndIfEndIfIfText2.Text=""Then'提示用户密码不能为空MsgBox"密码不能为空!",,"登录提示信息:"Text2.SetFocusExitSubEndIfIfText3.Text=""ThenMsgBox"请再次输入密码!",,"登录提示信息:"Text3.SetFocusExitSubEndIfIfText2.Text<>Text3.TextThenMsgBox"两次输入的密码不一致,请确认!",,"登录提示信息:" Text2.Text=""Text3.Text=""Text2.SetFocusExitSubElseMsgBox("添加新用户成功,现在您可以登陆系统了!")Label3.Visible=FalseText3.Visible=FalseCommand1.Caption="登录"Command2.Caption="退出"EndIfElse'“登录”按钮,用户登录DimstrSnoAsStringDimstrSelectAsStringstrSno=Trim(Text1.Text)'检测用户名是否存在strSelect="select密码from用户登录信息表where用户名='"&strSno&"'" mandType=adCmdTextAdodc1.RecordSource=strSelectAdodc1.RefreshMsgBox"用户名不存在,请重新输入!",,"登录提示信息:"Text1.Text=""Text2.Text=""Text1.SetFocusExitSubEndIfForm1.Hide'UnloadMeForm2.Show'MsgBox"登陆成功!",,"登录提示信息:"ElseMsgBox"密码不正确,请重新输入!",,"登录提示信息:"Text2.Text=""Text2.SetFocusEndIfEndIfEndSubPrivateSubCommand2_Click()'“退出”或“取消”按钮IfCommand2.Caption="取消"ThenLabel3.Visible=FalseText3.Visible=FalseCommand1.Caption="登录"Command2.Caption="退出"Text1.Text=""Text2.Text=""Text1.SetFocusElseEnd'UnloadMeEndIfEndSubPrivateSubCommand3_Click()'“新用户”按钮Label3.Visible=TrueText3.Visible=TrueText1.Text=""Text2.Text=""Text3.Text=""Command1.Caption="确定"Command2.Caption="取消"Text1.SetFocusEndSubPrivateSubCommand3_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle) Label6.Visible=TrueEndSubPrivateSubCommand3_MouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle) Label6.Visible=FalseEndSubPrivateSubForm_Load()Label3.Visible=FalseText3.Visible=FalseEndSubPrivateSubTimer1_Timer()'时间time1控件的time事件代码,用来'显示向左移动的欢迎字幕IfLabel4.Left+Label4.Width>0Then'当标签右边位置大于0时,标签向左移Else'否则标签从头开始Label4.Left=Form1.ScaleWidthEndIfIfLabel5.Left+Label5.Width>0ThenElseLabel5.Left=Form1.ScaleWidthEndIfEndSub主界面窗体如下:代码:PrivateSubAddNew_Click()Frame1.Visible=TrueFrame2.Visible=FalseEndSubPrivateSubCHKPMCHX_Click()Frame2.Caption="出库信息"DimpmAsStringDimnAsStringpm=InputBox("产品名","请输入",0)n="select*from出库表where品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubCHKXHCHX_Click()Frame2.Caption="出库信息"DimXHAsStringDimnAsStringXH=InputBox("产品型号","请输入",0)n="select*from出库表where型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndSubPrivateSubCKCZ_Click()'Form2.HideForm6.ShowEndSubPrivateSubCKJSHR_Click()Frame2.Caption="出库信息"DimJSHRAsStringDimnAsStringJSHR=InputBox("经手人","请输入",0)n="select*from出库表where经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubCKSHJ_Click()Frame2.Caption="出库信息"DimCHKRQAsStringDimnAsStringCHKRQ=InputBox("出库日期,格式为:月/日/年如:12/1/2011","请输入",0) n="select*from出库表where出库日期='"&CHKRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubCKZCX_Click()Frame2.Caption="出库信息"DimZBAsStringZB="select*from出库表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid1EndSubPrivateSubCommand1_Click()IfText1.Text=""Then'提示用户输入用户名MsgBox"请输入用户名!",,"登录信息提示:"ExitSubElse'DimusenameAsString'检测用户名是否已经存在DimstrSAsStringusename=Trim(Text1.Text)strS="select*from用户登录信息表where用户名='"&usename&"'"mandType=adCmdTextAdodc1.RecordSource=strSAdodc1.RefreshMsgBox"您输入的用户已存在!",,"登录提示信息:"Text1.Text=""Text2.Text=""Text3.Text=""Text1.SetFocusExitSubEndIfEndIfIfText2.Text=""Then'提示用户密码不能为空MsgBox"密码不能为空!",,"登录提示信息:"Text2.SetFocusExitSubEndIfIfText3.Text=""ThenMsgBox"请再次输入密码!",,"登录提示信息:"Text3.SetFocusExitSubEndIfIfText2.Text<>Text3.TextThenMsgBox"两次输入的密码不一致,请确认!",,"登录提示信息:"Text2.Text=""Text3.Text=""Text2.SetFocusExitSubElseeDimXAsIntegerX=MsgBox("成功添加新用户,是否要重新登录!",vbYesNo+vbQuestion+vbDefaultButton1,"提示信息!") IfX=vbYesThenUnloadMeForm3.ShowEndIf'MsgBox("成功添加新用户!")'Label3.Visible=False'Text3.Visible=False'Command1.Caption="登录"'Command2.Caption="退出"EndIfFrame1.Visible=FalseFrame2.Visible=TrueText1.Text=""Text2.Text="'"Text3.Text=""'Form3.ShowEndSubPrivateSubCommand2_Click() Frame1.Visible=FalseFrame2.Visible=TrueEndSubPrivateSubCXDL_Click()Form3.Show'UnloadMeEndSubPrivateSubExit_Click()EndUnloadForm1UnloadForm2UnloadForm3UnloadForm4UnloadForm5UnloadForm6UnloadForm7UnloadForm8EndSubPrivateSubForm_Load() UnloadForm1Frame1.Visible=False CallInitGrid0Me.Height=MDIForm1.Height-1060 Me.Width=MDIForm1.Width-560 Me.Top=MDIForm1.TopMe.Left=MDIForm1.LeftEndSubPrivateSubGHCZ_Click()'Form2.HideForm8.ShowEndSubFrame2.Caption="归还信息"DimpmAsStringDimnAsStringpm=InputBox("产品名","请输入",0)n="select*from归还表where品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubGHRCX_Click()Frame2.Caption="归还信息"DimJCRAsStringDimnAsStringJCR=InputBox("归还人","请输入",0)n="select*from归还表where归还人='"&JCR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubGHSJCX_Click()Frame2.Caption="归还信息"DimJCRQAsStringDimnAsStringJCRQ=InputBox("归还日期,格式为:月/日/年如:12/1/2011","请输入",0) n="select*from归还表where归还日期='"&JCRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubGHXHCX_Click()Frame2.Caption="归还信息"DimXHAsStringDimnAsStringXH=InputBox("产品型号","请输入",0)n="select*from归还表where型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubFrame2.Caption="归还信息"DimZBAsStringZB="select*from归还表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCCZ_Click()'Form2.HideForm7.ShowEndSubPrivateSubJCHPMCHX_Click()Frame2.Caption="借出信息"DimpmAsStringDimnAsStringpm=InputBox("产品名","请输入",0)n="select*from借出表where品名='"&pm&"'" mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCHXHCHX_Click()Frame2.Caption="借出信息"DimXHAsStringDimnAsStringXH=InputBox("产品型号","请输入",0)n="select*from借出表where型号='"&XH&"'" mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCRCX_Click()Frame2.Caption="借出信息"DimJCRAsStringDimnAsStringJCR=InputBox("借出人","请输入",0)n="select*from借出表where借出人='"&JCR&"'" mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCSHJCX_Click()Frame2.Caption="借出信息"DimJCRQAsStringDimnAsStringJCRQ=InputBox("借出日期,格式为:月/日/年如:12/1/2011","请输入",0) n="select*from借出表where借出日期='"&JCRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJCZCX_Click()Frame2.Caption="借出信息"DimZBAsStringZB="select*from借出表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid2EndSubPrivateSubJSHRCHX_Click()Frame2.Caption="归还信息"DimJSHRAsStringDimnAsStringJSHR=InputBox("经手人","请输入",0)n="select*from归还表where经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubJSHRCX_Click()Frame2.Caption="借出信息"DimJSHRAsStringDimnAsStringJSHR=InputBox("经手人","请输入",0)n="select*from借出表where经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid2EndSubPrivateSubPMCX_Click()Frame2.Caption="库存信息"DimpmAsStringDimnAsStringpm=InputBox("产品名","请输入",0)n="select*from库存表where品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid0EndSubPrivateSubRKCZ_Click()'Form2.HideForm5.ShowEndSubPrivateSubRKJSHR_Click()Frame2.Caption="入库信息"DimJSHRAsStringDimnAsStringJSHR=InputBox("经手人","请输入",0)n="select*from入库表where经手人='"&JSHR&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubRKPMCHX_Click()Frame2.Caption="入库信息"DimpmAsStringDimnAsStringpm=InputBox("产品名","请输入",0)IfLen(pm)>0Thenn="select*from入库表where品名='"&pm&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndIfCallInitGrid1EndSubPrivateSubRKSHJ_Click()Frame2.Caption="入库信息"DimRKRQAsStringDimnAsStringRKRQ=InputBox("入库日期,格式为:月/日/年如:12/1/2011","请输入",0)n="select*from入库表where入库日期='"&RKRQ&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshCallInitGrid1EndSubPrivateSubRKXHCHX_Click()Frame2.Caption="入库信息"DimXHAsStringDimnAsStringXH=InputBox("产品型号","请输入",0)IfLen(XH)>0Thenn="select*from入库表where型号='"&XH&"'"mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndIfCallInitGrid1EndSubPrivateSubRKZCX_Click()Frame2.Caption="入库信息"DimZBAsStringZB="select*from入库表"mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid1EndSubPrivateSubTimer1_Timer()IfLabel4.Left+Label4.Width>0Then'当标签右边位置大于0时,标签向左移Else'否则标签从头开始Label4.Left=Form2.ScaleWidthEndIfIfLabel5.Left+Label5.Width>0ThenElseLabel5.Left=Form2.ScaleWidthEndIfIfLabel6.Left+Label6.Width>0ThenElseLabel6.Left=Form2.ScaleWidthEndIfIfLabel7.Left+Label7.Width>0ThenElseLabel7.Left=Form2.ScaleWidthEndIfEndSubPrivateSubXGMM_Click()'Form2.HideForm4.ShowEndSubPrivateSubXHCX_Click()Frame2.Caption="库存信息"DimXHAsStringDimnAsStringXH=InputBox("产品型号","请输入",0)IfLen(XH)>0Then'AndVal(XH)<>0n="select*from库存表where型号='"&XH&"'" mandType=adCmdTextAdodc2.RecordSource=nAdodc2.RefreshEndIfCallInitGrid0EndSubPrivateSubZB_Click()Frame2.Caption="库存信息"DimZBAsString'DimNAsString'PM=InputBox("产品名","请输入",0)ZB="select*from库存表"'where品名='"&PM&"'" mandType=adCmdTextAdodc2.RecordSource=ZBAdodc2.RefreshCallInitGrid0EndSubPrivateSubInitGrid0()WithDataGrid1.Columns(0).Width=1600.Columns(1).Width=2200.Columns(2).Width=2200.Columns(3).Width=1000.Columns(4).Width=1000.Columns(5).Width=4000EndWithEndSubPrivateSubInitGrid1()WithDataGrid1.Columns(0).Width=800.Columns(1).Width=1600.Columns(2).Width=1600.Columns(3).Width=800.Columns(4).Width=800.Columns(5).Width=1000.Columns(6).Width=800.Columns(7).Width=4000EndWithEndSubPrivateSubInitGrid2()WithDataGrid1'.Columns(0).Caption="学号"'.Columns(1).Caption="课程名"'.Columns(2).Caption="学分"'.Columns(3).Caption="成绩"'设置DtgCond的列宽.Columns(0).Width=800.Columns(1).Width=1600.Columns(2).Width=1600.Columns(3).Width=800.Columns(4).Width=800.Columns(5).Width=800.Columns(6).Width=1000.Columns(7).Width=800.Columns(8).Width=4000EndWithEndSub用户重新登录界面代码:PrivateSubCommand1_Click()DimstrSnoAsStringDimstrSelectAsStringstrSno=Trim(Text1.Text)'检测用户名是否存在strSelect="select密码from用户登录信息表where用户名='"&strSno&"'" mandType=adCmdTextAdodc1.RecordSource=strSelectAdodc1.RefreshMsgBox"用户名不存在,请重新输入!",,"登录提示信息:"Text1.Text=""Text2.Text=""Text1.SetFocusEndIfUnloadMeForm2.Show'MsgBox"登陆成功!",,"登录提示信息:"ElseMsgBox"密码不正确,请重新输入!",,"登录提示信息:"Text2.Text=""Text2.SetFocusEndIfEndSubPrivateSubCommand2_Click()UnloadMeForm2.ShowEndSub修改用户密码界面代码:PrivateSubCommand1_Click()IfTrim(Text1.Text)<>Form2.TextUserNameThenMsgBox"用户名不正确,请确认!",,"信息提示!"Text1.Text=""Text1.SetFocusExitSubElseDimnameAsStringDimnamesAsStringname=Trim(Text1.Text)names="select*from用户登录信息表where用户名='"&name&"'" mandType=adCmdTextAdodc1.RecordSource=namesAdodc1.RefreshIfText2.Text=""ThenMsgBox"请输入旧密码!",,"信息提示!"Text2.SetFocusExitSubEndIfMsgBox"旧密码不正确,请确认!",,"信息提示!"Text2.Text=""Text2.SetFocusExitSubEndIfIfText3.Text=""ThenMsgBox"请输入新密码!",,"信息提示!"Text3.SetFocusEndIfIfText4.Text=""ThenMsgBox"请再次输入新密码!",,"信息提示!"Text4.SetFocusExitSubEndIfIfTrim(Text3.Text)<>Trim(Text4.Text)ThenMsgBox"两次输入的新密码不一致!",,"信息提示!"Text3.Text=""Text4.Text=""Text3.SetFocusExitSubElseMsgBox("密码修改成功!")UnloadMe'Form2.ShowEndIfEndIfEndSubPrivateSubCommand2_Click()UnloadMe'Form2.ShowEndSub入库管理代码:PrivateSubCommand1_Click()IfText1.Text=""AndText2.Text=""ThenMsgBox"“品名”和“型号”不能同时为空,必须输入其中一项!",,"提示信息!" ExitSubText1.SetFocusElseIfText3.Text=""AndText4.Text=""ThenMsgBox"请输入产品“数量”或“单位”之一!",,"提示信息!"Text3.SetFocusExitSubEndIfIfText5.Text=""ThenMsgBox"请经手人签名!",vbCritical,"提示信息!"Text5.SetFocusExitSubEndIfAdodc1.RefreshEndIfDimpmAsStringDimpmsAsStringDimnAsStringDimmAsStringpm=Trim(Text1.Text)n=Val(Text3.Text)pms="select*from库存表where品名='"&pm&"'"WithForm2EndWithElseEndIfEndIfDimXAsIntegerX=MsgBox("产品入库登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1,"提示信息!") IfX=vbNoThenUnloadMe'Form2.ShowElseText1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""Text5.Text=""Text6.Text=""Text7.Text=""Text1.SetFocusEndIfDimZBAsStringZB="select*from入库表"'where品名='"&PM&"'"EndSubPrivateSubCommand2_Click()Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""Text5.Text=""Text6.Text=""Text7.Text=""Text1.SetFocusEndSubPrivateSubCommand3_Click()UnloadMe'Form2.ShowEndSub出库管理代码:PrivateSubCommand1_Click()IfCombo1.Text=""AndCombo2.Text=""Then'text1.Text=""AndText2.Text=""ThenMsgBox"“品名”和“型号”不能同时为空,必须输入其中一项!",,"提示信息!"ExitSubElseIfText1.Text=""AndCombo3.Text=""Then'Text4.Text=""ThenMsgBox"请输入产品“数量”或“单位”之一!",,"提示信息!"Text2.SetFocusExitSubEndIfIfText2.Text=""ThenMsgBox"请经手人签名!",vbCritical,"提示信息!"Text2.SetFocusExitSubEndIfAdodc1.RefreshEndIfDimpmAsStringDimpmsAsStringDimnAsStringDimmAsStringpm=Trim(Combo1.Text)n=Val(Text1.Text)pms="select*from库存表where品名='"&pm&"'"EndIfDimXAsIntegerX=MsgBox("产品出库登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1,"提示信息!") IfX=vbNoThenUnloadMe'Form2.ShowEndIfCombo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""DimZBAsStringZB="select*from出库表"'where品名='"&PM&"'"EndSubPrivateSubCommand2_Click()Combo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""EndSubPrivateSubCommand3_Click()UnloadMe'Form2.ShowEndSubPrivateSubForm_Load()Adodc2.RefreshLoopEndSub借出管理代码:PrivateSubCommand1_Click()IfCombo1.Text=""AndCombo2.Text=""Then'text1.Text=""AndText2.Text=""Then MsgBox"“品名”和“型号”不能同时为空,必须输入其中一项!",,"提示信息!" ExitSubElseIfText1.Text=""AndCombo3.Text=""Then'Text4.Text=""ThenMsgBox"请输入产品“数量”或“单位”之一!",,"提示信息!"Text1.SetFocusExitSubEndIfIfText2.Text=""ThenMsgBox"请经手人签名!",vbCritical,"提示信息!"Text2.SetFocusExitSubEndIfAdodc1.RefreshEndIfDimpmAsStringDimpmsAsStringDimnAsStringDimmAsStringpm=Trim(Combo1.Text)n=Val(Text1.Text)pms="select*from库存表where品名='"&pm&"'"EndIfDimXAsIntegerX=MsgBox("产品借出登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1,"提示信息!") IfX=vbNoThenUnloadMeForm2.ShowEndIfCombo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""DimZBAsStringZB="select*from借出表"'where品名='"&PM&"'"EndSubPrivateSubCommand2_Click()Combo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""EndSubPrivateSubCommand3_Click()UnloadMeForm2.ShowEndSubPrivateSubForm_Load()Adodc2.RefreshLoopEndSub归还管理代码:PrivateSubCommand1_Click()IfCombo1.Text=""AndCombo2.Text=""Then'text1.Text=""AndText2.Text=""ThenMsgBox"“品名”和“型号”不能同时为空,必须输入其中一项!",,"提示信息!"ExitSubElseIfText1.Text=""AndCombo3.Text=""Then'Text4.Text=""ThenMsgBox"请输入产品“数量”或“单位”之一!",,"提示信息!"Text1.SetFocusExitSubEndIfIfText2.Text=""ThenMsgBox"请经手人签名!",vbCritical,"提示信息!"Text2.SetFocusExitSubEndIfIfText3.Text=""ThenMsgBox"请输入归还人姓名!",vbCritical,"提示信息!"Text3.SetFocusExitSubEndIfAdodc1.RefreshEndIfDimpmAsStringDimpmsAsStringDimnAsStringDimmAsStringpm=Trim(Combo1.Text)n=Val(Text1.Text)pms="select*from库存表where品名='"&pm&"'"EndIfDimXAsIntegerX=MsgBox("产品归还登记成功,是否继续添加产品!",vbYesNo+vbQuestion+vbDefaultButton1,"提示信息!") IfX=vbNoThenUnloadMeForm2.ShowEndIfCombo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""DimZBAsStringZB="select*from归还表"'where品名='"&PM&"'"EndSubPrivateSubCommand2_Click()Combo1.Text=""Combo2.Text=""Combo3.Text=""Text1.Text=""Text2.Text=""Text3.Text=""Text4.Text=""EndSubPrivateSubCommand3_Click()UnloadMeForm2.ShowEndSubPrivateSubForm_Load()'DimiAsString'i=0'Adodc2.Refresh'i=i+1'LoopCallpmEndSubPrivateSubpm()DimiAsVariantDimjAsVariantDimkAsVariantDimaAsVariantDimbAsVariantDimcAsVariantDimsAsVariantDimDAsVarianti=0j=0Adodc2.Refreshi=i+1LoopD=Split(a,",")Ifj<iThens=D(2)Combo1.AddItems'k=0'Ifk<jAndD(k)<>D(j)Then'IfD(k)<>D(j)Then'Combo1.AddItemD(j)'k=k+1'Else'k=k+1'EndIf'EndIfj=j+1EndIfText5.Text=s'a+","+D(2)+D(1)'+""+Val(i)+""+Val(j)+""+Val(k) Text6.Text=j'Combo1.AddItemD(1) EndSub。
仓库管理系统(VB+Access+源代码)
精心整理仓库管理系统项目的建立这是本人利用闲暇之余在VB6.0上制作的一个简陋的类库管系统,现图文结合的方式一步一步展现制作过程。
由于本人是个初学者,里面存在很多不足之处望得到高手们的指导。
此文可作供初学者们学习交流。
作者联系方式:E-mail1、2、3、4、EndVB6.0中可以创建Access数据库。
如下建立一个“用户表”的数据库,用来存放用户信息及一些出入库管理信息。
如下图单击“外接程序”再单击“可视化数据管理器”出现如图点击“文件”——“新建”——“Microsoft Access”——“Version 2.0 MDB”输入数据库名,“保存”出现如下图在数据窗口中右击——“新建表”,最终如下往数据表里添加数据在这里就不罗嗦了,请查阅相关书籍。
登录界面窗口的建立最终界面如下:1、Adodc1的添加过程为:单击“工程”——“部件”出现下图所示,选择“控件”下的“Microsoft ADO Data Control 6.0 (OLEDB)”单击“确定”在工具栏中会出现“”图标,单击它并拖动到相应位置即可。
其它元件不在一一说明。
2、本窗体代码如下:Private Sub Command1_Click() '“登录”、“确定”按钮If Command1.Caption = "确定" And Command2.Caption = "取消" Then '如果为“确定”则添加新用户If Text1.Text = "" Then '提示用户输入用户名MsgBox "请输入用户名!", , "登录信息提示:"Exit SubElse 'Dim usename As String '检测用户名是否已经存在Dim strS As Stringusename = Trim(Text1.Text)strS = "select * from 用户登录信息表 where 用户名='" & usename & "'"mandType = adCmdTextAdodc1.RecordSource = strSAdodc1.RefreshMsgBox "您输入的用户已存在!", , "登录提示信息:"Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusExit SubEnd IfEnd IfIf Text2.Text = "" Then '提示用户密码不能为空MsgBox "密码不能为空!", , "登录提示信息:"Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请再次输入密码!", , "登录提示信息:"Text3.SetFocusExit SubEnd IfIf Text2.Text <> Text3.Text ThenMsgBox "两次输入的密码不一致,请确认!", , "登录提示信息:"Text2.Text = ""Text3.Text = ""Exit SubElseMsgBox ("添加新用户成功,现在您可以登陆系统了!")Label3.Visible = FalseText3.Visible = FalseCommand1.Caption = "登录"Command2.Caption = "退出"End IfElse '“登录”按钮,用户登录 Dim strSno As StringDim strSelect As StringText3.Visible = FalseCommand1.Caption = "登录"Command2.Caption = "退出"Text1.Text = ""Text2.Text = ""Text1.SetFocusElseEnd 'Unload MeEnd IfPrivate Sub Command3_Click() '“新用户”按钮 Label3.Visible = TrueText3.Visible = TrueText1.Text = ""Text2.Text = ""Text3.Text = ""Command1.Caption = "确定"Command2.Caption = "取消"Text1.SetFocusEnd SubPrivate Sub Command3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)如下:代码:Private Sub AddNew_Click()Frame1.Visible = TrueFrame2.Visible = FalseEnd SubPrivate Sub CHKPMCHX_Click()Frame2.Caption = "出库信息"pm = InputBox("产品名", "请输入", 0)n = "select * from 出库表 where 品名 = '" & pm & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub CHKXHCHX_Click()Frame2.Caption = "出库信息"Dim XH As StringDim n As StringCHKRQ = InputBox("出库日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 出库表 where 出库日期 = '" & CHKRQ & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub CKZCX_Click()ZB = "select * from 出库表 "mandType = adCmdTextAdodc2.RecordSource = ZBAdodc2.RefreshCall InitGrid1End SubPrivate Sub Command1_Click()If Text1.Text = "" Then '提示用户输入用户名 MsgBox "请输入用户名!", , "登录信息提示:"Exit SubEnd IfIf Text2.Text <> Text3.Text ThenMsgBox "两次输入的密码不一致,请确认!", , "登录提示信息:"Text2.Text = ""Text3.Text = ""Text2.SetFocusExit SubElseeX = MsgBox("成功添加新用户,是否要重新登录!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbYes ThenUnload MeForm3.ShowEnd If'MsgBox ("成功添加新用户!")'Label3.Visible = False'Text3.Visible = False'Command1.Caption = "登录"'Command2.Caption = "退出"End IfEndEnd SubPrivate Sub Form_Load()Unload Form1Frame1.Visible = FalseCall InitGrid0Me.Height = MDIForm1.Height - 1060Me.Width = MDIForm1.Width - 560Me.Top = MDIForm1.TopMe.Left = MDIForm1.LeftPrivate Sub GHCZ_Click()'Form2.HideForm8.ShowEnd SubPrivate Sub GHPMCX_Click()Frame2.Caption = "归还信息"Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 归还表 where 品名 = '" & pm & "'" mandType = adCmdTextEnd SubPrivate Sub GHXHCX_Click()Frame2.Caption = "归还信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)n = "select * from 归还表 where 型号 = '" & XH & "'" mandType = adCmdTextAdodc2.RecordSource = nPrivate Sub GHZCX_Click()Frame2.Caption = "归还信息"Dim ZB As StringZB = "select * from 归还表 "mandType = adCmdTextAdodc2.RecordSource = ZBAdodc2.RefreshCall InitGrid2End SubEnd SubPrivate Sub JCRCX_Click()Frame2.Caption = "借出信息"Dim JCR As StringDim n As StringJCR = InputBox("借出人", "请输入", 0)n = "select * from 借出表 where 借出人 = '" & JCR & "'" mandType = adCmdTextAdodc2.RecordSource = nPrivate Sub JCSHJCX_Click()Frame2.Caption = "借出信息"Dim JCRQ As StringDim n As StringJCRQ = InputBox("借出日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 借出表 where 借出日期 = '" & JCRQ & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshDim n As StringJSHR = InputBox("经手人", "请输入", 0)n = "select * from 借出表 where 经手人 = '" & JSHR & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid2End SubPrivate Sub PMCX_Click()Dim pm As StringDim n As Stringpm = InputBox("产品名", "请输入", 0)n = "select * from 库存表 where 品名 = '" & pm & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid0End SubPrivate Sub RKCZ_Click()'Form2.HideEnd SubPrivate Sub RKSHJ_Click()Frame2.Caption = "入库信息"Dim RKRQ As StringDim n As StringRKRQ = InputBox("入库日期,格式为:月/日/年如:12/1/2011", "请输入", 0) n = "select * from 入库表 where 入库日期 = '" & RKRQ & "'"mandType = adCmdTextAdodc2.RecordSource = nAdodc2.RefreshCall InitGrid1End SubPrivate Sub RKXHCHX_Click()Frame2.Caption = "入库信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)If Len(XH) > 0 Thenn = "select * from 入库表 where 型号 = '" & XH & "'" mandType = adCmdTextAdodc2.RecordSource = nElseLabel6.Move Label6.Left - 80ElseLabel6.Left = Form2.ScaleWidthEnd IfIf Label7.Left + Label7.Width > 0 ThenLabel7.Move Label7.Left - 80ElseLabel7.Left = Form2.ScaleWidthEnd IfEnd SubPrivate Sub XGMM_Click()'Form2.HideForm4.ShowEnd SubPrivate Sub XHCX_Click()Frame2.Caption = "库存信息"Dim XH As StringDim n As StringXH = InputBox("产品型号", "请输入", 0)If Len(XH) > 0 Then 'And Val(XH) <> 0n = "select * from 库存表 where 型号 = '" & XH & "'"End WithEnd SubPrivate Sub InitGrid1()With DataGrid1.Columns(0).Width = 800.Columns(1).Width = 1600.Columns(2).Width = 1600.Columns(3).Width = 800.Columns(4).Width = 800.Columns(5).Width = 1000.Columns(6).Width = 800.Columns(7).Width = 4000End WithEnd SubPrivate Sub InitGrid2()With DataGrid1'.Columns(0).Caption = "学号"' .Columns(1).Caption = "课程名"'.Columns(2).Caption = "学分"' .Columns(3).Caption = "成绩"'设置DtgCond的列宽Text1.Text = ""Text2.Text = ""Text1.SetFocusExit SubEnd IfUnload MeForm2.Show'MsgBox "登陆成功!", , "登录提示信息:"ElseMsgBox "密码不正确,请重新输入!", , "登录提示信息:"Text2.Text = ""Text2.SetFocusEnd IfEnd SubPrivate Sub Command2_Click()Unload MeForm2.ShowEnd Sub修改用户密码界面代码:ElseEnd IfIf Text3.Text = "" ThenMsgBox "请输入新密码!", , "信息提示!"Text3.SetFocusExit SubEnd IfIf Text4.Text = "" ThenMsgBox "请再次输入新密码!", , "信息提示!" Text4.SetFocusExit SubEnd IfIf Trim(Text3.Text) <> Trim(Text4.Text) ThenMsgBox "两次输入的新密码不一致!", , "信息提示!" Text3.Text = ""Text4.Text = ""Text3.SetFocusExit SubElseMsgBox ("密码修改成功!")Unload Me'Form2.ShowEnd SubEnd Sub代码:ElseText5.SetFocusExit SubEnd IfAdodc1.RefreshEnd IfDim pm As StringDim pms As StringDim n As StringDim m As Stringpm = Trim(Text1.Text)n = Val(Text3.Text)pms = "select * from 库存表 where 品名='" & pm & "'"With Form2End WithElseEnd IfEnd IfDim X As IntegerX = MsgBox("产品入库登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload MeElseEnd SubEnd SubUnload Me'Form2.ShowEnd Sub出库管理代码:Private Sub Command1_Click()If Combo1.Text = "" And Combo2.Text = "" Then ' text1.Text = "" And Text2.Text = "" ThenMsgBox "“品名”和“型号”不能同时为空,必须输入其中一项!", , "提示信息!" Exit SubElseIf Text1.Text = "" And Combo3.Text = "" Then ' Text4.Text = "" ThenMsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Text2.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Text2.SetFocusDim ZB As StringZB = "select * from 出库表 " 'where 品名 = '" & PM & "'"End SubPrivate Sub Command2_Click()Combo1.Text = ""Combo2.Text = ""Combo3.Text = ""Text1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub Command3_Click()Unload Me'Form2.ShowEnd SubPrivate Sub Form_Load()Adodc2.RefreshLoopEnd Sub代码:Elsepm = Trim(Combo1.Text)n = Val(Text1.Text)pms = "select * from 库存表 where 品名='" & pm & "'"End IfDim X As IntegerX = MsgBox("产品借出登记成功,是否继续添加产品!", vbYesNo + vbQuestion + vbDefaultButton1, "提示信息!") If X = vbNo ThenUnload MeForm2.ShowEnd IfCombo2.Text = ""Combo3.Text = ""Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Dim ZB As StringZB = "select * from 借出表 " 'where 品名 = '" & PM & "'"End SubPrivate Sub Command2_Click()End SubEnd SubLoopEnd Sub代码:ElseIf Text1.Text = "" And Combo3.Text = "" Then ' Text4.Text = "" Then MsgBox "请输入产品“数量”或“单位”之一!", , "提示信息!"Text1.SetFocusExit SubEnd IfIf Text2.Text = "" ThenMsgBox "请经手人签名!", vbCritical, "提示信息!"Text2.SetFocusExit SubEnd IfIf Text3.Text = "" ThenMsgBox "请输入归还人姓名!", vbCritical, "提示信息!" Text3.SetFocusExit SubEnd IfAdodc1.RefreshEnd IfDim pm As StringDim pms As StringDim n As StringEnd SubText1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""End SubPrivate Sub Command3_Click()Unload MeForm2.ShowEnd SubPrivate Sub Form_Load()' Dim i As String' i = 0' Adodc2.Refresh' i = i + 1' LoopCall pmEnd SubPrivate Sub pm()Dim i As VariantDim j As VariantDim k As Varianti = 0j = 0LoopText5.Text = s 'a + "," + D(2) + D(1) '+ " " + Val(i) + " " + Val(j) + " " + Val(k) Text6.Text = j'Combo1.AddItem D(1)End Sub。
VB物流管理系统设计(源代码及全套资料)
货运物流管理系统摘要现代物流作为一种先进的组织方式和管理技术,被广泛认为是企业在降低物资消耗、提高劳动生产效率以外的重要利润源泉,在国民经济和社会发展中发挥着重要作用。
加快中国现代物流的发展,对于优化资源配置,提高经济运行质量,促进企业改革发展,推进中国经济体制与经济增长方式的两个根本性转变,具有十分重要的意义。
随着经济全球化和信息技术的迅速发展,企业生产资料获取与产品营销范围日趋扩大,社会生产、物资流通、商品交易及其管理方式正在并将继续发生深刻的变革。
我国流通现代化的发展,经营范围广、经营品种多,要求物流组织也必须大型化,物流设施现代化、多样化、一体化,企业竞争优势的途径之一在于成本优势。
而成本优势的建立和保持必须以可靠和高效的物流运作为保证。
国有大中型企业要走出目前的困境,不仅需要生产适销对路的产品、采取正确的营销策略、以及强有力的资金支持,更需要加强“品质经营”,即强调“时效性”,其核心在于服务的及时性、产品的及时性、信息的及时性和决策反馈的及时性。
这些都必须以强有力的物流能力作为保证。
一次完整的电子商务过程包括由生产厂家将产品生产出来,通过运输、仓储、加工、配送到用户、消费者的物流全过程。
其中分为以下几个方面:生产厂家将生产的单个产品进行包装,并将多个产品集中在大的包装箱内;然后,经过运输、批发等环节,在这一环节中通常需要更大的包装;最后,产品通过零售环节流通到消费者手中,产品通常在这一环节中再还原为单个产品。
人们将上述过程的管理称之为供应链物流管理。
贸易过程中的商品从厂家到最终用户的物流过程是客观存在的,长期以来人们从未主动地、系统地、整体地去考虑,因而未能发挥其系统的总体优势。
供应链物流的地域和时间跨度大,为此,我们这次毕业设计特此开发了物流管理系统。
关键词: 货运物流,商品交易,供应链物流管理1Fr e i g ht l og i s t i c s ma na g e me nt s y s t e mAbs t r actMode r n l ogi s t i cs a s a m e ans of t he or gani zat i on and m a nage m e nt of advanced t echnol ogi es a r e wi del y r ecogni zed a s ent er pr i s es i n r educi ng m a t er i a l cons umpt i on, i mpr ove l abor pr oduct i vi t y out s i de i mpor t ant s our ce of pr of i t s i n t he nat i onal economy and s oci a l devel opme nt pl ays an i mpor t ant r ol e . Ac cel er a t i ng t he devel opme nt of mode r n l ogi s t i cs i n Chi na f or opt i m i zi ng t he a l l ocat i on of r es our ces , i mpr ovi ng t he qual i t y of economi c oper a t i on, and pr omot e t he r ef or m and devel opme nt of ent er pr i s es and pr omot i ng Chi na ' s economi c s t r uct ur e and mode of economi c gr owt h t wo f unda me nt a l changes i s of gr eat s i gni f i ca nce. W i t h economi c gl obal i zat i on and t he r api d devel opme n t of i nf or ma t i on t echnol ogy, acces s t o me a ns of pr oduct i on and ma r ket i ng ent er pr i s es a r e i ncr eas i ngl y expandi ng t he s cope of s oci a l pr oduct i on, ma t er i a l f l ows , commodi t y t r adi ng and ma nage me nt me t hods a r e bei ng and wi l l cont i nue t o under go pr of ound changes . M y f l ow of t he devel opme nt of mode r ni zat i on, bus i nes s s cope, mul t i - s peci es m a nage m e nt , l ogi s t i cs r equi r e me nt s of l a r ge or gani zat i ons mus t , l ogi s t i cs f aci l i t i es mode r ni zat i on, di ver s i f i cat i on, i nt egr a t i on, ent er pr i s e compe t i t i ve advant age l i es i n t he wa y of cos t advant ages . And t he cos t advant ages of t he need t o es t abl i s h and m a i nt a i n r e l i abl e and ef f i c i ent l ogi s t i cs oper a t i on t o ens ur e . M e di um- s i zed s t a t e- owne d ent er pr i s es t o come out of t he cur r ent di f f i cul t i es need not onl y t he pr oduct i on of ma r ket abl e pr oduct s , t he adopt i on of a cor r ect m a r ket i ng s t r a t egy, and s t r ong f i nanci a l s uppor t , but a l s o t he need t o s t r engt hen t he " qual i t y m a nage m e nt " , whi ch s t r es s ed t hat " t i me l i nes s " , t he cor e l i es i n t he t i me l i nes s of s er vi ces and pr oduct s t i me l i nes s , t he t i me l i nes s of t he i nf or ma t i on and deci s i on- m a ki ng f eedback t i me l i nes s . The s e mus t be s t r ong l ogi s t i cs capabi l i t i es as a guar ant ee.I s a compl et e e- comme r ce pr oces s i ncl udes pr oduct s pr oduced by m a nuf act ur er s wi l l be t hr ough t r ans por t , s t or age, pr oces s i ng, di s t r i but i on t o us er s , cons ume r s t hr oughout t he l ogi s t i cs pr oces s . Whi ch i s di vi ded i nt o t he f ol l owi ng a r eas : t he i ndi vi dual ma nuf act ur er s wi l l pr oduce pr oduct s packagi ng, and a numbe r of pr oduct s f ocus ed on l a r ge boxes ; The n, a f t er t r ans por t a t i on, whol es a l e and l i nks i n t he chai n, us ual l y r equi r es gr eat er packagi ng; Fi nal l y , t he f l ow of pr oduct s t hr o ught he r et a i l chai n t o cons ume r s , t he pr oduct i s us ua l l y f ur t her back i n t he chai n f or i ndi vi dual pr oduct s . I t wi l l be known a s t he s uppl y chai n ma nage m e nt pr oces s l ogi s t i cs m a nage m e nt .Tr ade pr oces s f r om m a nuf act ur er s t o end- us er s of commodi t i es l ogi s t i cs pr oces s i s an obj ect i ve exi s t ence, i t has never been act i ve, s ys t e m a t i c , i nt egr a t ed m a nner t o cons i der , and t hus unabl e t o pl ay i t s over a l l advant ages of t he s ys t e m. Suppl y chai n l ogi s t i cs geogr aphi ca l and t i m e s pan l a r ge, and f or t hi s r eas on we devel oped t he gr aduat e des i gn her eby l ogi s t i cs m a nage m e nt s ys t e m.Ke y wor d : f r e i ght l ogi s t i cs , commodi t y t r a di ng, s uppl y chai n l ogi s t i cs ma nage m e n t目录摘要 (Ⅰ)Abs t r act (Ⅱ)引言 (1)第一章概述 (1)1. 1 管理信息系统概述 (1)1. 2 可行性分析 (1)1. 2. 1 物流管理系统的分析 (1)1. 2. 2 业务流程分析 (1)1. 3 数据库系统设计 (3)1. 4 测试方法简介 (5)1. 4. 1 白盒法 (5)1. 4. 2 黑盒法 (5)1. 4. 3 测试步骤 (5)1. 5 开发工具的选择 (5)第二章编程环境的选择 (9)2. 1 关系型数据库的实现 (9)2. 2 二者的结合(DBA) (9)第三章 W i n dows 下的 Vi s ua l Ba s i c 编程环境简介 (10)3. 1 面向对象的编程 (10)3. 2 实现菜单选项 (10)3. 3 实现工具栏 (10)3. 4 帮助 (11)3. 5 关于版本 (11)第四章使用 Ac c es s 2003 实现关系型数据库 (12)4. 1 数据库的概念 (12)4. 2 新建一个数据库 (12)4. 3 修改已建的数据库 (12)4. 4 实现数据库之间的联系 (12)4. 5 数据库设计 (12)第五章物流系统分析与各功能模块设计 (15)5. 1 物流管理系统系统分析 (15)5. 2 系统模块分析 (15)5. 3 各功能模块设计 (16)总结 (23)参考文献 (24)致谢 (25)附录代码清单 (26)引言当今社会是一个信息社会也是一个知识经济的时代。
课程设计-基于VB的仓库管理系统设计模板
专业方向组设计仓库管理系统指导教师院(系、部)电子与信息工程学院专业班级计算07-2学号姓名电子与信息工程学院计算机科学系目录1.问题定义 (1)1.1.项目背景 (1)1.2.项目目标及范围 (1)1.2.1.项目计划 (1)1.2.2.专题计划要点 (2)2.可行性研究 (2)2.1.技术可行性 (2)2.2.市场可行性 (2)2.3.经济可行性 (3)2.3.1.成本分析 (3)2.3.2.运行费用分析 (4)2.3.3.效益分析 (4)3.需求分析 (4)3.1.系统功能需求分析 (4)3.2.系统数据需求分析 (5)3.3.系统数据需求分析 (5)3.4.系统数据流图 (6)3.4.1.数据流图符号说明 (6)3.4.2.系统数据流图 (7)3.5.数据字典 (8)4.总体设计 (9)4.1.总体设计任务 (9)4.2.总体设计原理 (9)4.2.1.模块化 (9)4.2.2.模块独立 (9)5.软件结构设计 (10)5.1.1.软件结构层次图 (10)5.1.2.模块设计 (10)5.2.数据库设计 (11)5.2.1.数据库逻辑设计 (11)5.2.2.数据库物理设计 (13)5.3.系统安全设计 (14)5.3.1.出错处理设计 (14)5.3.2.安全设计 (14)5.3.3.维护设计 (14)6.系统详细设计 (14)6.1.界面设计 (14)6.2.实体-关系图设计(E-R图) (15)6.3.系统流程图设计 (16)6.4.程序设计 (16)7.编码 (17)7.1.程序设计语言选择 (17)8.测试 (17)8.1.黑盒测试 (17)8.1.1.登录模块 (17)8.1.2.密码修改模块 (17)8.1.3.入库模块 (18)8.1.4.出库模块 (21)8.1.5.汇总模块 (24)9.用户手册 (25)9.1.软件概述 (25)9.2.软件使用 (26)专业方向组设计1.问题定义本系统设计是在windows环境的支持下运行的,采用窗口式执行文件,操作实用、简易、方便、直观。
数据库VB编写公司产品信息管理系统界面源代码
If (Adodc1.Recordset.RecordCount = 0) Then '无记录才可注册新用户
If KEY1.Text = KEY2.Text Then
Adodc1.Recordset.AddNew
Adodc1.Recordset("用户名") = USERNAME.Text
strName = "'" + FIND_USER.Text + "'"
Adodc1.RecordSource = "select * from 产品清单 where 型号 = " + strName
Adodc1.Refresh
End SLeabharlann b ///////////////////////////////////////////////
制作人:成都信息工程学院 => 缪林
///////////////////////////////////////////////
本数据库操作软件实现的是公司产品信息管理,在VB平台上创建可操作界面,实现功能有:
Adodc1.Refresh
DataGrid1.Col = UserCol
Adodc1.Recordset.Delete '删除
Adodc1.Recordset.Update
Adodc1.RecordSource = "select * from 产品清单"
Adodc1.Recordset("价格") = blank3.Text
Adodc1.Recordset("产地") = blank4.Text
excel.VBA.仓库管理系统
下面是整个仓库管理系统整个设计界面和代码,还是不会的朋友可以私信我。
一、初始界面及代码初始界面代码:Private Sub CommandButton1_Click()入库界面.Show '显示入库界面End SubPrivate Sub CommandButton2_Click()出库界面.Show '显示出库界面End Sub二、出库界面及代码出库界面代码:Private Sub CommandButton1_Click()If TextBox1 = "" Then '检测输入数据是否为空,如果为空弹出'提示窗口,提示用户需要填写MsgBox "名称不能为空", vbOKOnlyExit SubEnd IfIf TextBox2 = "" ThenMsgBox "型号不能为空", vbOKOnlyExit SubEnd IfIf TextBox3 = "" ThenMsgBox "国标号不能为空", vbOKOnlyExit SubEnd IfIf TextBox4 = "" ThenMsgBox "材质不能为空", vbOKOnlyExit SubEnd IfIf TextBox5 = "" ThenMsgBox "数量不能为空", vbOKOnlyExit SubEnd IfIf TextBox6 = "" ThenMsgBox "技术通知号不能为空", vbOKOnlyExit SubEnd IfDim i% '制作后台数据,将现有库存属性'合并为一列存入sheet2,方便下'一步出库时对照i = 2With Sheet1While .Cells(i, 1) <> ""Sheet2.Cells(i, 1) = .Cells(i, 1) & " " & .Cells(i, 2) & " " & .Cells(i,3) & " " & .Cells(i, 4) & " " & .Cells(i, 6)i = i + 1WendEnd WithDim sr As StringDim fd As RangeDim r%Dim idate As Date '记录当前出库时间idate = Format(Now, "yyyy/m/d")sr = TextBox1.Value & " " & TextBox2.Value & " " & TextBox3.Value & " " & TextBox4.Value & " " & TextBox6.ValueSet fd = Sheet2.Range("a:a").Find(what:=sr, lookat:=xlWhole) '用'find函数对要出库标准件在库存中匹配,找到其所在行If fd Is Nothing Then '如果未找到,弹出提示窗体提示用户MsgBox "错误,未在库存中找到您要出库的东西,请重新输入", vbOKOnlyExit SubEnd Ifr = fd.RowWith Sheet1If Abs(TextBox5.Value) > .Cells(r, 5) Then '核对库存是否满足出库数量MsgBox "库存不足,请核对数量是否正确", vbOKOnlyExit SubEnd If.Cells(r, 5) = .Cells(r, 5) - TextBox5.Value '现有库存数量减去出库数量.Cells(r, 10) = .Cells(r, 10) & ";" & idate & "出库" & TextBox5.Value & "件"MsgBox "出库成功,库存数量变为" & .Cells(r, 5), vbOKOnly '出库成功提示End WithCall clear '清空所有文本框内的值End SubSub clear() '清空函数TextBox1 = ""TextBox2 = ""TextBox3 = ""TextBox4 = ""TextBox5 = ""TextBox6 = ""End SubPrivate Sub CommandButton2_Click() Call clearEnd Sub三、入库界面及代码入库界面代码:Private Sub CommandButton1_Click()If TextBox1 = "" Or TextBox2 = "" Or TextBox3 = "" Or TextBox4 = "" Or TextBox5 = "" Or TextBox6 = "" _Or TextBox7 = "" Or TextBox8 = "" ThenCall 漏项检测Exit SubEnd IfCall 后台合并数据Dim sr As StringDim fd As RangeDim r%Dim i%Dim idate As Dateidate = Format(Now, "yyyy/m/d") '读取当前系统时间,并设定格式sr = TextBox1.Value & " " & TextBox2.Value & " " & TextBox3.Value & " " & TextBox4.Value & " " & TextBox6.ValueSet fd = Sheet2.Range("a:a").Find(what:=sr, lookat:=xlWhole) '用find函数对要出库标准件'在库存中找到其所在行If fd Is Nothing Then '如果入库的标准件不在库存中则执行下面的命令i = 2 '查找第一行空行While Cells(i, 1) <> ""i = i + 1Wend '查找第一行空行With Sheet1.Cells(i, 1) = TextBox1.Value '将用户填写的数据录入表格.Cells(i, 2) = TextBox2.Value.Cells(i, 3) = TextBox3.Value.Cells(i, 4) = TextBox4.Value.Cells(i, 5) = TextBox5.Value.Cells(i, 6) = TextBox6.Value.Cells(i, 7) = idate & "入库" & TextBox5.Value & "件".Cells(i, 8) = TextBox7.Value.Cells(i, 9) = TextBox8.ValueEnd WithMsgBox "添加完成", vbOKOnlyCall clearExit Sub'''''''''''''''''''''End Ifr = fd.RowCells(r, 5) = Cells(r, 5) + TextBox5.ValueCells(r, 7) = Cells(r, 7) & ";" & idate & "入库" & TextBox5.Value & "件"MsgBox "添加完成", vbOKOnlyCall clearEnd SubPrivate Sub CommandButton2_Click() '一键清空Call clearEnd SubSub clear() '清空函数TextBox1 = ""TextBox2 = ""TextBox3 = ""TextBox4 = ""TextBox5 = ""TextBox6 = ""TextBox7 = ""TextBox8 = ""End SubSub 漏项检测()If TextBox1 = "" Then '检测输入数据是否为空,如果为空弹出提示窗口,提示用户需要填写MsgBox "名称不能为空", vbOKOnlyExit SubEnd IfIf TextBox2 = "" ThenMsgBox "型号不能为空", vbOKOnlyExit SubEnd IfIf TextBox3 = "" ThenMsgBox "国标号不能为空", vbOKOnlyExit SubEnd IfIf TextBox4 = "" ThenMsgBox "材质不能为空", vbOKOnlyExit SubEnd IfIf TextBox5 = "" ThenMsgBox "数量不能为空", vbOKOnlyExit SubEnd IfIf TextBox6 = "" ThenMsgBox "技术通知号不能为空", vbOKOnlyExit SubEnd IfIf TextBox7 = "" ThenMsgBox "备注不能为空", vbOKOnlyExit SubEnd IfIf TextBox8 = "" ThenMsgBox "摆放位置不能为空", vbOKOnlyExit SubEnd IfEnd SubSub 后台合并数据()Dim j% '制作后台数据,将现有库存属性合并为一列存入sheet2,方便下一步入库时对照j = 2With Sheet1While .Cells(j, 1) <> ""Sheet2.Cells(j, 1) = .Cells(j, 1) & " " & .Cells(j, 2) & " " & .Cells(j, 3) & " " & .Cells(j, 4) & " " & .Cells(j, 6)j = j + 1WendEnd WithEnd Sub。
VB物流管理系统设计(源代码及全套资料)
货运物流管理系统摘要现代物流作为一种先进的组织方式和管理技术,被广泛认为是企业在降低物资消耗、提高劳动生产效率以外的重要利润源泉,在国民经济和社会发展中发挥着重要作用。
加快中国现代物流的发展,对于优化资源配置,提高经济运行质量,促进企业改革发展,推进中国经济体制与经济增长方式的两个根本性转变,具有十分重要的意义。
随着经济全球化和信息技术的迅速发展,企业生产资料获取与产品营销范围日趋扩大,社会生产、物资流通、商品交易及其管理方式正在并将继续发生深刻的变革。
我国流通现代化的发展,经营范围广、经营品种多,要求物流组织也必须大型化,物流设施现代化、多样化、一体化,企业竞争优势的途径之一在于成本优势。
而成本优势的建立和保持必须以可靠和高效的物流运作为保证。
国有大中型企业要走出目前的困境,不仅需要生产适销对路的产品、采取正确的营销策略、以及强有力的资金支持,更需要加强“品质经营”,即强调“时效性”,其核心在于服务的及时性、产品的及时性、信息的及时性和决策反馈的及时性。
这些都必须以强有力的物流能力作为保证。
一次完整的电子商务过程包括由生产厂家将产品生产出来,通过运输、仓储、加工、配送到用户、消费者的物流全过程。
其中分为以下几个方面:生产厂家将生产的单个产品进行包装,并将多个产品集中在大的包装箱内;然后,经过运输、批发等环节,在这一环节中通常需要更大的包装;最后,产品通过零售环节流通到消费者手中,产品通常在这一环节中再还原为单个产品。
人们将上述过程的管理称之为供应链物流管理。
贸易过程中的商品从厂家到最终用户的物流过程是客观存在的,长期以来人们从未主动地、系统地、整体地去考虑,因而未能发挥其系统的总体优势。
供应链物流的地域和时间跨度大,为此,我们这次毕业设计特此开发了物流管理系统。
关键词: 货运物流,商品交易,供应链物流管理1Fr e i g ht l og i s t i c s ma na g e me nt s y s t e mAbs t r actMode r n l ogi s t i cs a s a m e ans of t he or gani zat i on and m a nage m e nt of advanced t echnol ogi es a r e wi del y r ecogni zed a s ent er pr i s es i n r educi ng m a t er i a l cons umpt i on, i mpr ove l abor pr oduct i vi t y out s i de i mpor t ant s our ce of pr of i t s i n t he nat i onal economy and s oci a l devel opme nt pl ays an i mpor t ant r ol e . Ac cel er a t i ng t he devel opme nt of mode r n l ogi s t i cs i n Chi na f or opt i m i zi ng t he a l l ocat i on of r es our ces , i mpr ovi ng t he qual i t y of economi c oper a t i on, and pr omot e t he r ef or m and devel opme nt of ent er pr i s es and pr omot i ng Chi na ' s economi c s t r uct ur e and mode of economi c gr owt h t wo f unda me nt a l changes i s of gr eat s i gni f i ca nce. W i t h economi c gl obal i zat i on and t he r api d devel opme n t of i nf or ma t i on t echnol ogy, acces s t o me a ns of pr oduct i on and ma r ket i ng ent er pr i s es a r e i ncr eas i ngl y expandi ng t he s cope of s oci a l pr oduct i on, ma t er i a l f l ows , commodi t y t r adi ng and ma nage me nt me t hods a r e bei ng and wi l l cont i nue t o under go pr of ound changes . M y f l ow of t he devel opme nt of mode r ni zat i on, bus i nes s s cope, mul t i - s peci es m a nage m e nt , l ogi s t i cs r equi r e me nt s of l a r ge or gani zat i ons mus t , l ogi s t i cs f aci l i t i es mode r ni zat i on, di ver s i f i cat i on, i nt egr a t i on, ent er pr i s e compe t i t i ve advant age l i es i n t he wa y of cos t advant ages . And t he cos t advant ages of t he need t o es t abl i s h and m a i nt a i n r e l i abl e and ef f i c i ent l ogi s t i cs oper a t i on t o ens ur e . M e di um- s i zed s t a t e- owne d ent er pr i s es t o come out of t he cur r ent di f f i cul t i es need not onl y t he pr oduct i on of ma r ket abl e pr oduct s , t he adopt i on of a cor r ect m a r ket i ng s t r a t egy, and s t r ong f i nanci a l s uppor t , but a l s o t he need t o s t r engt hen t he " qual i t y m a nage m e nt " , whi ch s t r es s ed t hat " t i me l i nes s " , t he cor e l i es i n t he t i me l i nes s of s er vi ces and pr oduct s t i me l i nes s , t he t i me l i nes s of t he i nf or ma t i on and deci s i on- m a ki ng f eedback t i me l i nes s . The s e mus t be s t r ong l ogi s t i cs capabi l i t i es as a guar ant ee.I s a compl et e e- comme r ce pr oces s i ncl udes pr oduct s pr oduced by m a nuf act ur er s wi l l be t hr ough t r ans por t , s t or age, pr oces s i ng, di s t r i but i on t o us er s , cons ume r s t hr oughout t he l ogi s t i cs pr oces s . Whi ch i s di vi ded i nt o t he f ol l owi ng a r eas : t he i ndi vi dual ma nuf act ur er s wi l l pr oduce pr oduct s packagi ng, and a numbe r of pr oduct s f ocus ed on l a r ge boxes ; The n, a f t er t r ans por t a t i on, whol es a l e and l i nks i n t he chai n, us ual l y r equi r es gr eat er packagi ng; Fi nal l y , t he f l ow of pr oduct s t hr o ught he r et a i l chai n t o cons ume r s , t he pr oduct i s us ua l l y f ur t her back i n t he chai n f or i ndi vi dual pr oduct s . I t wi l l be known a s t he s uppl y chai n ma nage m e nt pr oces s l ogi s t i cs m a nage m e nt .Tr ade pr oces s f r om m a nuf act ur er s t o end- us er s of commodi t i es l ogi s t i cs pr oces s i s an obj ect i ve exi s t ence, i t has never been act i ve, s ys t e m a t i c , i nt egr a t ed m a nner t o cons i der , and t hus unabl e t o pl ay i t s over a l l advant ages of t he s ys t e m. Suppl y chai n l ogi s t i cs geogr aphi ca l and t i m e s pan l a r ge, and f or t hi s r eas on we devel oped t he gr aduat e des i gn her eby l ogi s t i cs m a nage m e nt s ys t e m.Ke y wor d : f r e i ght l ogi s t i cs , commodi t y t r a di ng, s uppl y chai n l ogi s t i cs ma nage m e n t目录摘要 (Ⅰ)Abs t r act (Ⅱ)引言 (1)第一章概述 (1)1. 1 管理信息系统概述 (1)1. 2 可行性分析 (1)1. 2. 1 物流管理系统的分析 (1)1. 2. 2 业务流程分析 (1)1. 3 数据库系统设计 (3)1. 4 测试方法简介 (5)1. 4. 1 白盒法 (5)1. 4. 2 黑盒法 (5)1. 4. 3 测试步骤 (5)1. 5 开发工具的选择 (5)第二章编程环境的选择 (9)2. 1 关系型数据库的实现 (9)2. 2 二者的结合(DBA) (9)第三章 W i n dows 下的 Vi s ua l Ba s i c 编程环境简介 (10)3. 1 面向对象的编程 (10)3. 2 实现菜单选项 (10)3. 3 实现工具栏 (10)3. 4 帮助 (11)3. 5 关于版本 (11)第四章使用 Ac c es s 2003 实现关系型数据库 (12)4. 1 数据库的概念 (12)4. 2 新建一个数据库 (12)4. 3 修改已建的数据库 (12)4. 4 实现数据库之间的联系 (12)4. 5 数据库设计 (12)第五章物流系统分析与各功能模块设计 (15)5. 1 物流管理系统系统分析 (15)5. 2 系统模块分析 (15)5. 3 各功能模块设计 (16)总结 (23)参考文献 (24)致谢 (25)附录代码清单 (26)引言当今社会是一个信息社会也是一个知识经济的时代。
VB资金管理系统及源代码
VB资金管理系统及源代码Dim addrecord As Variant'Dim usercheck As BooleanDim conn As New ADODB.ConnectionDim rszjsx As New ADODB.RecordsetDim rsyskm As New ADODB.Recordset Dim rsfygsbm As New ADODB.Recordset '设置资金科目资金上限管理中按钮的状态Private Sub setbuttonsyskm(bval As Boolean)For i = 0 To 5cmdyskm(i).Enabled = bvalNext icmdyskm(6).Enabled = Not bvalDacomyskmdm.Enabled = Not bvalDacomyskmmc.Enabled = Not bvalDacombmdm.Enabled = Not bvalDacombmmc.Enabled = Not bvalDacomzjsxje.Enabled = Not bvalDataGrid1.Enabled = bvalIf bval Thencmdyskm(7).Caption = "退出"Elsecmdyskm(7).Caption = "取消"End IfExit SubEnd Sub'资金科目资金上限管理中记录增加或修改后的字段检验Private Function zjsxcheck() As BooleanDim id As IntegerDim str As StringDim note(3) As Stringnote(0) = "资金科目名称和代码不能同时为空!"note(1) = "费用归属部门名称和代码不能为空!"note(2) = "此部门在该资金科目上的资金上限已经设置!"zjsxcheck = FalseIf Dacomyskmdm.Text = "" Or Dacomyskmmc.Text = "" ThenMsgBox note(0)Dacomyskmdm.SetFocusExit FunctionEnd IfIf Dacombmdm.Text = "" Or Dacombmmc.Text = "" ThenMsgBox note(1)Dacombmdm.SetFocusExit FunctionEnd Ifid = rszjsx.Fields("xuhao")If addrecord = True Thenstr = "select * from zjsx where yskmmc='" & Dacomyskmmc.Text & "' and gsbmmc='" &Dacombmmc.Text & "'"Set rs = conn.Execute(str)Elsestr = "select * from zjsx where (yskmmc='" & Dacomyskmmc.Text & "' and gsbmmc='" & Dacombmmc.Text & "') and xuhao <> '" & id & "'"Set rs = conn.Execute(str)End IfIf rs.EOF Thenzjsxcheck = TrueElseMsgBox note(2)'rszjsx.CancelBatch adAffectAllChaptersDacomyskmdm.SetFocusEnd IfExit FunctionEnd FunctionPrivate Sub cmdyskm_Click(Index As Integer)Dim i As IntegerDim result As BooleanDim m_name As StringDim bookmark As VariantOn Error GoTo adderrSelect Case IndexCase 0 '添加按钮addrecord = Truerszjsx.AddNewsetbuttonsyskm FalseDacomyskmdm.SetFocusExit SubCase 1 '修改按钮addrecord = Falsesetbuttonsyskm FalseDacomyskmdm.SetFocusExit SubCase 2 '查询按钮bookmark = rszjsx.bookmarkm_name = InputBox("请输入资金科目代码或资金科目名称或归属部门代码或归属部门名称", "按资金科目代码或资金科目名称或归属部门代码或归属部门名称称搜索")If m_name = "" ThenExit SubEnd Ifrszjsx.MoveFirstrszjsx.Find "yskmdm like '%" & m_name & "%'"If rszjsx.EOF Thenrszjsx.MoveFirstrszjsx.Find "yskmmc like '%" & m_name & "%'"If rszjsx.EOF Thenrszjsx.MoveFirstrszjsx.Find "gsbmdm like '%" & m_name & "%'"If rszjsx.EOF Thenrszjsx.MoveFirstrszjsx.Find "gsbmmc like '%" & m_name & "%'"If rszjsx.EOF ThenMsgBox "没有设置此部门在该资金科目上的资金上限!"rszjsx.bookmark = bookmarkEnd IfEnd IfEnd If'rszjsx.MoveFirstEnd IfExit SubCase 3 '删除按钮If MsgBox("你确认要删除该条记录吗?", vbexclaimation + vbOKCancel, "记录删除") =vbCancel ThenExit SubEnd Ifconn.Execute ("delete from zjsx where xuhao=" & rszjsx.Fields("xuhao"))'With rszjsx'删除该纪录'.Delete' .UpdateBatch adAffectCurrent'If .RecordCount <= 0 Then' Adodc1.Enabled = False' Exit Sub'End If'移到下一条' .MoveNext'如果到文件尾,移到最后一条' If .EOF Then .MoveLast'End WithExit SubCase 4 '下一条rszjsx.MoveNextIf rszjsx.EOF ThenMsgBox "这是最后一个记录!"rszjsx.MovePreviousEnd IfExit SubCase 5 '上一条rszjsx.MovePreviousIf rszjsx.BOF ThenMsgBox "这是第一个记录!"rszjsx.MoveNextEnd IfExit SubCase 6 '保存按钮result = zjsxcheck()If result = True Thenrszjsx.UpdateBatch adAffectCurrentsetbuttonsyskm TrueMsgBox "保存成功!"rszjsx.RequeryEnd IfExit SubCase 7 ' 退出或取消按钮If cmdyskm(Index).Caption = "退出" ThenUnload MeElserszjsx.CancelUpdatesetbuttonsyskm TrueExit SubEnd IfEnd SelectExit Subadderr:MsgBox Err.DescriptionUnload MeEnd SubPrivate Sub Dacombmdm_Change()Dim str1 As Stringstr1 = Trim(Dacombmdm.Text)'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")rsfygsbm.MoveFirstIf str1 <> "" Thenrsfygsbm.Filter = "dm='" & str1 & "'"If Not rsfygsbm.EOF ThenDacombmmc.Text = rsfygsbm.Fields("gsbmmc").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacombmmc_Change()'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")If Trim(Dacombmmc.Text) <> "" Thenrsfygsbm.Filter = "gsbmmc ='" & Trim(Dacombmmc.Text) & "'"If Not rsfygsbm.EOF ThenDacombmdm.Text = rsfygsbm.Fields("dm").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomyskmdm_Click(Area As Integer)'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")If Trim(Dacomyskmdm.Text) <> "" Thenrsyskm.Filter = "dm ='" & Trim(Dacomyskmdm.Text) & "'"If Not rsyskm.EOF ThenDacomyskmmc.Text = rsyskm.Fields("yskmmc").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomyskmmc_Change()'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")If Trim(Dacomyskmmc.Text) <> "" Thenrsyskm.Filter = "yskmmc= '" & Trim(Dacomyskmmc.Text) & "'"If Not rsyskm.EOF ThenDacomyskmdm.Text = rsyskm.Fields("dm").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub DataGrid1_Click()End SubPrivate Sub Form_Load()Dim fieldname(6) As VariantDim wide(6) As VariantDim str As Stringfieldname(0) = "序号"fieldname(1) = "资金科目代码"fieldname(2) = "资金科目名称"fieldname(3) = "费用归属部门代码"fieldname(4) = "费用归属部门名称"fieldname(5) = "资金上限"wide(0) = 400wide(1) = 800wide(2) = 1400wide(3) = 1000wide(4) = 1800wide(5) = 800'str = "Provider=SQLOLEDB.1;Password=090309;Persist Security Info=True;User ID=cw;InitialCatalog=ysgl2004;Data Source=CWSERVER"If conn.State <> 1 Thenconn.CursorLocation = adUseClientconn.Open nowconnectstringEnd Ifstr = "SELECT a.xuhao, b.dm as yskmdm, a.yskmmc, c.dm AS gsbmdm, a.gsbmmc, a.zjsxje FROM zjsx a INNER JOIN yskm b ON a.yskmmc = b.yskmmc INNER JOIN fygsbm c ON a.gsbmmc =c.gsbmmc ORDER BY b.dm, c.dm"rszjsx.Open str, conn, adOpenStatic, adLockBatchOptimisticrsyskm.Open "select * from yskm order by dm", conn, adOpenStatic, adLockBatchOptimistic rsfygsbm.Open "select * from fygsbm order by dm", conn, adOpenStatic, adLockBatchOptimisticSet DataGrid1.DataSource = rszjsxFor i = 0 To 5DataGrid1.Columns(i).Caption = fieldname(i)DataGrid1.Columns(i).Width = wide(i)DataGrid1.Columns(i).DataField = rszjsx.Fields(i).NameNext i'Set Dacomyskmdm.DataSource = rszjsx'Dacomyskmdm.DataField = rszjsx.Fields("yskmdm").NameSet Dacomyskmdm.RowSource = rsyskmDacomyskmdm.ListField = rsyskm.Fields("dm").NameSet Dacomyskmmc.DataSource = rszjsxDacomyskmmc.DataField = rszjsx.Fields("yskmmc").NameSet Dacomyskmmc.RowSource = rsyskmDacomyskmmc.ListField = rsyskm.Fields("yskmmc").Name'Set Dacombmdm.DataSource = rszjsx'Dacombmdm.DataField = rszjsx.Fields("bmdm").NameSet Dacombmdm.RowSource = rsfygsbmDacombmdm.ListField = rsfygsbm.Fields("dm").NameSet Dacombmmc.DataSource = rszjsxDacombmmc.DataField = rszjsx.Fields("gsbmmc").NameSet Dacombmmc.RowSource = rsfygsbmDacombmmc.ListField = rsfygsbm.Fields("gsbmmc").NameSet Dacomzjsxje.DataSource = rszjsxDacomzjsxje.DataField = rszjsx.Fields("zjsxje").NameEnd SubPrivate Sub Form_Unload(Cancel As Integer)'rs.Closeconn.CloseEnd SubDim conn As New ADODB.ConnectionDim rshistory As New ADODB.RecordsetDim rskjyw As New ADODB.RecordsetDim rspzlb As New ADODB.RecordsetDim rsgkglbm As New ADODB.RecordsetDim rsyskmlb As New ADODB.RecordsetDim rsyskm As New ADODB.RecordsetDim rsfygsbm As New ADODB.RecordsetDim rs As New ADODB.RecordsetDim addrecord As BooleanDim m_pzhm As StringDim m_glbmmc As StringDim m_gsbmmc As StringDim m_yskmmc As StringDim m_yslbmc As StringDim m_ywje As StringDim m_bz As StringDim m_fsrq As DatePrivate Sub setbuttons(bval As Boolean)Dim setcontrol As ControlFor Each setcontrol In Me.ControlsIf TypeName(setcontrol) = "DataCombo" Or TypeName(setcontrol) = "TextBox" Or TypeName(setcontrol) = "CheckBox" Thensetcontrol.Enabled = bvalNextcmdkjyw(0).Enabled = Not bvalcmdkjyw(1).Enabled = bvalcmdkjyw(2).Enabled = bvalcmdkjyw(3).Enabled = Not bvalDTfsrq.Enabled = bvalExit SubEnd Sub'存储修改的纪录内容到历史数据表Private Sub storehistory()Dim i As IntegerDim j As IntegerDim str As StringIf m_pzhm <> rskjyw.Fields("pzhm") Thenhistory = history & "票据号码(" & rskjyw.Fields("pzhm") & ")"End IfIf m_pzlbmc <> rspzlb.Fields("pzlbmc") Thenhistory = history & "票据类别名称(" & rspzlb.Fields("pzlbmc") & ")"End IfIf m_yslbmc <> rskjyw.Fields("yslbmc") Thenhistory = history & "资金科目类别名称(" & rskjyw.Fields("yslbmc") & ")"End IfIf m_yskmmc <> rskjyw.Fields("yskmmc") Thenhistory = history & "资金科目名称(" & rskjyw.Fields("yskmmc") & ")"End IfIf m_gsbmmc <> rskjyw.Fields("gsbmmc") Thenhistory = history & "费用归属部门名称(" & rskjyw.Fields("gsbmmc") & ")"End IfIf m_glbmmc <> rskjyw.Fields("glbmmc") Thenhistory = history & "费用管理部门名称(" & rskjyw.Fields("glbmmc") & ")"End IfIf m_fsrq <> rskjyw.Fields("fsrq") Thenhistory = history & "发生日期(" & rskjyw.Fields("fsrq") & ")"End IfIf m_ywje <> rskjyw.Fields("ywje") Thenhistory = history & "业务金额(" & rskjyw.Fields("ywje") & ")"End IfIf m_bz <> rskjyw.Fields("bz") Thenhistory = history & "备注(" & txtbz.Text & ")"End IfIf history <> "" Thenconn.Execute ("insert into ywhistory (pzhm,username,act,content,actdate) values('" & m_pzhm & "','" & username & "','修改','" & history & "','" & Format(Date, "yyyy-MM-dd") & "')")End Sub'保存会计业务纪录Private Function storekjyw() As BooleanDim note(10) As StringDim str As StringDim gsbmzh As SingleDim jtzh As SingleDim gsbmsx As SingleDim jtsx As SingleDim i As Singlegsbmje = 0jtje = 0jtsx = 0gsbmsx = 0note(0) = "票据号码不能为空!"note(1) = "发生日期不能为空!"note(2) = "归口管理部门代码和名称不能同时为空!" note(3) = "资金科目类别代码和名称不能同时为空!" note(4) = "资金科目代码和名称不能同时为空!" note(5) = "费用归属部门代码和名称不能同时为空!"note(6) = "业务金额不能为空!"note(7) = "该票据号码已经存在!"note(8) = "票据类别名称不能为空!"note(9) = "该票据号码的格式不正确!"storekjyw = FalseIf Dacompzhm.Text = "" ThenMsgBox note(0)Dacompzhm.SetFocusExit FunctionEnd IfIf InStr(Dacompzhm.Text, "-") = 0 ThenMsgBox note(9)Dacompzhm.SetFocusExit FunctionEnd IfIf Dacompzlbmc.Text = "" ThenMsgBox note(8)Dacompzlbmc.SetFocusExit FunctionEnd IfIf DTfsrq.Value = "" ThenMsgBox note(1)DTfsrq.SetFocusExit FunctionEnd IfIf Dacomglbmdm.Text = "" And Dacomglbmmc.Text = "" ThenMsgBox note(2)Dacomglbmdm.SetFocusExit FunctionEnd IfIf Dacomyslbdm.Text = "" And Dacomyslbmc.Text = "" ThenMsgBox note(3)Dacomyslbdm.SetFocusExit FunctionEnd IfIf Dacomyskmdm.Text = "" And Dacomyskmmc.Text = "" ThenMsgBox note(4)Dacomyskmdm.SetFocusExit FunctionEnd IfIf Dacomgsbmdm.Text = "" And Dacomgsbmmc.Text = "" ThenMsgBox note(5)Dacomgsbmdm.SetFocusExit FunctionEnd IfIf Dacomywje.Text = "" ThenMsgBox note(6)Dacomywje.SetFocusExit FunctionEnd IfSet rs = conn.Execute("select sum(ywje) as jezh from kjyw where yskmmc='" & Dacomyskmmc.Text & "' and gsbmmc='" & Dacomgsbmmc.Text & "'")If Not rs.EOF Thengsbmze = rs.Fields("jezh")Elsegsbmze = 0End Ifrs.CloseSet rs = conn.Execute("select sum(ywje) as jezh from kjyw")jtze = rs.Fields("jezh")Elsejtze = 0End Ifrs.CloseSet rs = conn.Execute("select * from zjsx where yskmmc='" & Dacomyskmmc.Text & "' andgsbmmc='" & Dacomgsbmmc.Text & "'")If Not rs.EOF Thengsbmsx = rs.Fields("zjsxje")Elsegsbmsx = 0End Ifrs.CloseSet rs = conn.Execute("select * from zjsx where yskmmc='" & Dacomyskmmc.Text & "' andgsbmmc='集团'")If Not rs.EOF Thenjtsx = rs.Fields("zjsxje")Elsejtsx = 0End Ifrs.CloseIf gsbmsx <> 0 Theni = gsbmze / gsbmsxElsei = 0End IfIf i > 0.8 ThenIf i > 0.9 ThenIf MsgBox(Dacomgsbmmc.Text & "在资金科目" & Dacomyskmmc.Text & "上的" & Dacomyslbmc.Text & "已经超过90%,请确定是否继续添加?", vbOKCancel) = vbCancel ThenExit FunctionEnd IfElseIf MsgBox(Dacomgsbmmc.Text & "在资金科目" & Dacomyskmmc.Text & "上的" & Dacomyslbmc.Text & "已经超过80%,请确定是否继续添加?", vbOKCancel) = vbCancel ThenExit FunctionEnd IfEnd IfEnd Ifi = jtze / jtsxElsei = 0End IfIf i > 0.8 ThenIf i > 0.95 ThenIf MsgBox("集团在资金科目" & Dacomyskmmc.Text & "上的支出已经超过90%,请确定是否继续添加?", vbOKCancel) = vbCancel ThenExit FunctionEnd IfElseIf MsgBox("集团在资金科目" & Dacomyskmmc.Text & "上的支出已经超过80%,请确定是否继续添加?", vbOKCancel) = vbCancel ThenExit FunctionEnd IfEnd IfEnd IfIf addrecord = True ThenSet rs = conn.Execute("select * from kjyw where pzhm='" & Dacompzhm.Text & "'")ElseSet rs = conn.Execute("select * from kjyw where pzhm='" & Dacompzhm.Text & "' and xuhao <>" & rskjyw.Fields("xuhao").Value)End IfIf Not rs.EOF ThenMsgBox note(7)Dacompzhm.SetFocusExit FunctionEnd Ifstorekjyw = TrueExit FunctionEnd FunctionPrivate Sub cmdkjyw_Click(Index As Integer)Select Case IndexCase 0 '添加、修改或删除If cmdkjyw(Index).Caption = "添加" Thenaddrecord = TrueDacomglbmdm.Text = ""Dacomyslbdm.Text = ""Dacomyskmdm.Text = ""Dacomgsbmdm.Text = ""setbuttons Truerskjyw.AddNewDTfsrq.Value = Datetxtbz.Text = " "ElseIf cmdkjyw(Index).Caption = "修改" Thenaddrecord = Falsesetbuttons TrueElse '删除conn.Execute ("insert into ywhistory (pzhm,username,act,content,actdate) values('" & pzhm & "','" & username & "','删除','','" & Format(Date, "yyyy-MM-dd") & "')") conn.Execute ("delete from kjyw where xuhao=" & rskjyw.Fields("xuhao"))rskjyw.RequeryExit SubEnd IfEnd IfDacompzhm.SetFocusExit SubCase 1 '保存If storekjyw = True Then'If addrecord = True Thenrskjyw.UpdateBatch adAffectCurrentstorehistorysetbuttons Falsershistory.RequeryMsgBox "保存成功!"'Else'End If'setbuttons False'storehistory'adorefresh'conn.Execute ("insert into hthistory (username,act,content,date) values('" & yhmc& "','增加','','" & Date & "')")End IfExit SubCase 2 '取消rskjyw.CancelUpdatesetbuttons FalseExit SubCase 3 '退出Unload MeEnd SelectEnd SubPrivate Sub Dacomglbmdm_Change()'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")If Trim(Dacomglbmdm.Text) <> "" Thenrsgkglbm.Filter = "dm ='" & Trim(Dacomglbmdm.Text) & "'"If Not rsgkglbm.EOF ThenDacomglbmmc.Text = rsgkglbm.Fields("glbmmc").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomglbmmc_Change()If Trim(Dacomglbmmc.Text) <> "" Thenrsgkglbm.Filter = "glbmmc ='" & Trim(Dacomglbmmc.Text) & "'"If Not rsgkglbm.EOF ThenDacomglbmdm.Text = rsgkglbm.Fields("dm").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomyslbdm_Change()'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")If Trim(Dacomyslbdm.Text) <> "" Thenrsyskmlb.Filter = "dm ='" & Trim(Dacomyslbdm.Text) & "'"If Not rsyskmlb.EOF ThenDacomyslbmc.Text = rsyskmlb.Fields("yslbmc").ValueSet rsyskm = conn.Execute("select * from yskm where left(dm,1)='" &Trim(Dacomyslbdm.Text) & "'")Set Dacomyskmdm.RowSource = rsyskmDacomyskmdm.ListField = rsyskm.Fields("dm").NameSet Dacomyskmmc.RowSource = rsyskmDacomyskmmc.ListField = rsyskm.Fields("yskmmc").NameIf Not rsyskm.EOF ThenDacomyskmdm.Text = rsyskm.Fields("dm")Dacomyskmmc.Text = rsyskm.Fields("yskmmc")ElseDacomyskmdm.Text = ""Dacomyskmmc.Text = ""End IfElseDacomyslbmc.Text = ""'rsyskmlb.Filter = "dm='" & Left(Trim(Dacomyslbdm.Text), 1) & "'"Dacomyskmdm.Text = ""Dacomyskmmc.Text = ""End If' Dacomlbdm.RefreshElseDacomyslbmc.Text = " "End IfEnd SubPrivate Sub Dacomyslbmc_Change()If Trim(Dacomyslbmc.Text) <> "" Thenrsyskmlb.Filter = "yslbmc ='" & Trim(Dacomyslbmc.Text) & "'"If Not rsgkglbm.EOF ThenDacomyslbdm.Text = rsyskmlb.Fields("dm").ValueSet rsyskm = conn.Execute("select * from yskm where left(dm,1)='" &Trim(Dacomyslbdm.Text) & "'")Set Dacomyskmdm.RowSource = rsyskmDacomyskmdm.ListField = rsyskm.Fields("dm").NameSet Dacomyskmmc.RowSource = rsyskmDacomyskmmc.ListField = rsyskm.Fields("yskmmc").NameIf Not rsyskm.EOF ThenDacomyskmdm.Text = rsyskm.Fields("dm")Dacomyskmmc.Text = rsyskm.Fields("yskmmc")ElseDacomyskmdm.Text = ""Dacomyskmmc.Text = ""End IfElseDacomyslbdm.Text = ""'rsyskmlb.Filter = "dm='" & Left(Trim(Dacomyslbdm.Text), 1) & "'"Dacomyskmdm.Text = ""Dacomyskmmc.Text = ""End If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomyskmdm_Change()'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")If Trim(Dacomyskmdm.Text) <> "" ThenSet rsyskm = conn.Execute("select * from yskm where dm ='" & Trim(Dacomyskmdm.Text) &"'")If Not rsyskm.EOF ThenDacomyskmmc.Text = rsyskm.Fields("yskmmc").Value'rsyskmlb.Filter = "dm='" & Left(Trim(Dacomyslbdm.Text), 1) & "'"Dacomyslbdm.Text = Left(rsyskm.Fields("dm").Value, 1)Dacomyslbmc.Text = rsyskm.Fields("yslbmc").ValueElseDacomyskmmc.Text = ""'rsyskmlb.Filter = "dm='" & Left(Trim(Dacomyslbdm.Text), 1) & "'"Dacomyslbdm.Text = ""Dacomyslbmc.Text = ""End If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomyskmmc_Change()If Trim(Dacomyskmmc.Text) <> "" ThenSet rsyskm = conn.Execute("select * from yskm where yskmmc ='" & Trim(Dacomyskmmc.Text)& "'")If Not rsyskm.EOF ThenDacomyskmdm.Text = rsyskm.Fields("dm").Value'rsyskmlb.Filter = "dm='" & Left(Trim(Dacomyskmdm.Text), 1) & "'"Dacomyslbdm.Text = Left(Dacomyskmdm.Text, 1)Dacomyslbmc.Text = rsyskm.Fields("yslbmc").ValueElseDacomyskmdm.Text = ""'rsyskmlb.Filter = "dm='" & Left(Trim(Dacomyslbdm.Text), 1) & "'"Dacomyslbdm.Text = ""Dacomyslbmc.Text = ""End If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomgsbmdm_Change()'Set rs = conn.Execute("select * from yskmlb where dm='" & Left(Dacomdm.Text, 1) & "'")If Trim(Dacomgsbmdm.Text) <> "" Thenrsfygsbm.Filter = "dm ='" & Trim(Dacomgsbmdm.Text) & "'"If Not rsfygsbm.EOF ThenDacomgsbmmc.Text = rsfygsbm.Fields("gsbmmc").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomgsbmmc_Change()If Trim(Dacomgsbmmc.Text) <> "" Thenrsfygsbm.Filter = "gsbmmc ='" & Trim(Dacomgsbmmc.Text) & "'"If Not rsgkglbm.EOF ThenDacomgsbmdm.Text = rsfygsbm.Fields("dm").ValueEnd If' Dacomlbdm.RefreshEnd IfEnd SubPrivate Sub Dacomyslbmc_Click(Area As Integer)Dacomyskmdm.Text = ""Dacomyskmmc.Text = ""End SubPrivate Sub DataGrid1_Click()End SubPrivate Sub Form_Load()Dim fieldname(6) As VariantDim wide(6) As VariantDim str As Stringfieldname(0) = "序号"fieldname(1) = "票据号码"fieldname(2) = "用户名称"fieldname(3) = "操作类型"fieldname(4) = "操作内容"fieldname(5) = "操作日期"wide(0) = 400wide(1) = 800wide(2) = 1000wide(3) = 1000wide(4) = 21000wide(5) = 1000'str = "Provider=SQLOLEDB.1;Password=090309;Persist Security Info=True;User ID=cw;InitialCatalog=ysgl2004;Data Source=CWSERVER"If conn.State <> 1 Thenconn.CursorLocation = adUseClientconn.Open nowconnectstringEnd IfSet rshistory = conn.Execute("select * from ywhistory where pzhm='" & pzhm & "'")str = "SELECT a.xuhao, a.pzhm,a.pzlbmc, a.fsrq , e.dm as glbmdm,a.glbmmc,b.dm AS yskmlbdm, a.yslbmc, c.dm AS yskmdm,a.yskmmc, d.dm AS gsbmdm, a.gsbmmc, a.ywje, a.bz FROM kjyw a INNER JOIN yskmlb b ON a.yslbmc = b.yslbmc INNER JOIN yskm c ON a.yskmmc = c.yskmmc INNER JOIN fygsbm d ON a.gsbmmc = d.gsbmmc INNER JOIN gkglbm e ON a.glbmmc =e.glbmmc where a.pzhm='" & pzhm & "'"rskjyw.Open str, conn, adOpenStatic, adLockBatchOptimisticrspzlb.Open "select * from pzlb ", conn, adOpenStatic, adLockBatchOptimistic rsyskm.Open "select * from yskm order by dm", conn, adOpenStatic, adLockBatchOptimistic rsyskmlb.Open "select * from yskmlb order by dm", conn, adOpenStatic, adLockBatchOptimistic rsfygsbm.Open "select * from fygsbm order by dm", conn, adOpenStatic, adLockBatchOptimistic rsgkglbm.Open "select * from gkglbm order by dm", conn, adOpenStatic, adLockBatchOptimisticSet DataGrid1.DataSource = rshistoryFor i = 0 To 5DataGrid1.Columns(i).Caption = fieldname(i)DataGrid1.Columns(i).Width = wide(i) DataGrid1.Columns(i).DataField = rshistory.Fields(i).NameNext iSet Dacompzhm.DataSource = rskjywDacompzhm.DataField = rskjyw.Fields("pzhm").Name'Set Dacompzhm.RowSource = rskjyw'Dacomyskmdm.ListField = rskjyw.Fields("dm").NameSet DTfsrq.DataSource = rskjywDTfsrq.DataField = rskjyw.Fields("fsrq").NameSet Dacompzlbmc.DataSource = rskjyw Dacompzlbmc.DataField = rskjyw.Fields("pzlbmc").Name Set Dacompzlbmc.RowSource = rspzlb Dacompzlbmc.ListField = rspzlb.Fields("pzlbmc").NameSet Dacomglbmdm.RowSource = rsgkglbm Dacomglbmdm.ListField = rsgkglbm.Fields("dm").NameSet Dacomglbmmc.DataSource = rskjyw Dacomglbmmc.DataField = rskjyw.Fields("glbmmc").Name Set Dacomglbmmc.RowSource = rsgkglbm Dacomglbmmc.ListField = rsgkglbm.Fields("glbmmc").NameSet Dacomyslbdm.RowSource = rsyskmlb Dacomyslbdm.ListField = rsyskmlb.Fields("dm").NameSet Dacomyslbmc.DataSource = rskjyw Dacomyslbmc.DataField = rskjyw.Fields("yslbmc").Name Set Dacomyslbmc.RowSource = rsyskmlb Dacomyslbmc.ListField = rsyskmlb.Fields("yslbmc").NameSet Dacomyskmdm.RowSource = rsyskm Dacomyskmdm.ListField = rsyskm.Fields("dm").NameSet Dacomyskmmc.DataSource = rskjyw Dacomyskmmc.DataField = rskjyw.Fields("yskmmc").Name Set Dacomyskmmc.RowSource = rsyskm Dacomyskmmc.ListField = rsyskm.Fields("yskmmc").NameSet Dacomgsbmdm.RowSource = rsfygsbmDacomgsbmdm.ListField = rsfygsbm.Fields("dm").NameSet Dacomgsbmmc.DataSource = rskjyw Dacomgsbmmc.DataField = rskjyw.Fields("gsbmmc").Name Set Dacomgsbmmc.RowSource = rsfygsbm Dacomgsbmmc.ListField = rsfygsbm.Fields("gsbmmc").NameSet Dacomywje.DataSource = rskjywDacomywje.DataField = rskjyw.Fields("ywje").NameSet txtbz.DataSource = rskjywtxtbz.DataField = rskjyw.Fields("bz").Namem_pzhm = rskjyw.Fields("pzhm")m_pzlbmc = rskjyw.Fields("pzlbmc")m_glbmmc = rskjyw.Fields("glbmmc")m_gsbmmc = rskjyw.Fields("gsbmmc")m_yslbmc = rskjyw.Fields("yslbmc")m_yskmmc = rskjyw.Fields("yskmmc")m_fsrq = rskjyw.Fields("fsrq")m_ywje = rskjyw.Fields("ywje")m_bz = rskjyw.Fields("bz")If operatetype = 1 Thencmdkjyw(0).Caption = "添加"ElseIf operatetype = 2 Thencmdkjyw(0).Caption = "修改"Elsecmdkjyw(0).Caption = "删除"End IfEnd IfEnd SubPrivate Sub Form_Unload(Cancel As Integer)conn.CloseEnd Sub。
仓库管理系统源代码
/********************************************仓库管理系统***********************************************************/
{
printf("\tCan not open the temp file!");
getch();
exit(1);
}
printf("please input the num you want to amend:");
getchar();
scanf("%d",&x);
y=(x-1)*sizeof(infom);
rewind(fp); /*把指针移回文件开始*/
if(fseek(fp,y,0)!=0)/*把指针指向Y*/
{
printf("can not move there!\n");
exit(1);
remove("c:\\123.dat"); /*删除文件123*/
rename("c:\\456.dat","c:\\123.dat"); /*对文件456重命名*/
}
else
printf("Can not find this record!\n");
getch();
仓库管理系统-源代码 -VB编程毕业设计
材料入库模块源代码如下:Private Sub Command1_Click()If Text1.Text <> "" And Text2.Text <> "" And DTPicker1.Value <> "" And Text4.Text <> "" And Text5.Text <> "" And DataCombo1.Text <> "" And Text7.Text <> "" ThenAdodc1.RefreshAdodc2.RecordSource = "select * from 库存材料清单where 材料号='" & Text1.Text & "'" Adodc2.RefreshIf Adodc2.Recordset.BOF Thenmsg$ = "确定要添加该记录吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "添加记录")If ans = vbOK ThenAdodc1.Recordset.AddNewAdodc1.Recordset.Fields(0) = Text1.TextAdodc1.Recordset.Fields(1) = Text2.TextAdodc1.Recordset.Fields(2) = CStr(DTPicker1.V alue)Adodc1.Recordset.Fields(3) = Text4.TextAdodc1.Recordset.Fields(4) = Text5.TextAdodc1.Recordset.Fields(5) = DataCombo1.TextAdodc1.Recordset.Fields(6) = Text7.TextAdodc1.Recordset.Fields(7) = Text8.TextAdodc1.Recordset.UpdateMsgBox ("保存成功!!*_*")End IfElse MsgBox "材料号不能重复,该材料号已存在!!", 48, "警告"End IfElse MsgBox "资料输入不全,请重新输入!!", 64, "提示"End IfText1.SetFocusText1.Text = ""Text2.Text = ""Text4.Text = ""Text5.Text = ""DataCombo1.Text = ""Text7.Text = ""Text8.Text = ""End SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text4.Text = ""Text5.Text = ""DataCombo1.Text = ""Text7.Text = ""Text8.Text = ""End SubPrivate Sub Command3_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc1.RecordSource = "库存材料清单"Adodc1.RefreshAdodc2.ConnectionString = adoAdodc3.ConnectionString = adoAdodc3.RecordSource = "gysxx"Adodc3.RefreshEnd SubPrivate Sub Text2_GotFocus()If Not Adodc1.Recordset.BOF ThenAdodc1.Recordset.MoveFirstWhile Not Adodc1.Recordset.EOFIf Adodc1.Recordset.Fields(0) = Text1.Text ThenMsgBox "该材料号已经存在,请重新输入!!", 48, "提示"Text1.Text = ""End IfAdodc1.Recordset.MoveNextWendEnd IfEnd SubPrivate Sub Text7_GotFocus()If Not Adodc3.Recordset.BOF ThenAdodc3.Recordset.MoveFirstWhile Not Adodc3.Recordset.EOFIf Adodc3.Recordset.Fields(0) = DataCombo1.Text ThenText7.Text = Adodc3.Recordset.Fields(1)End IfAdodc3.Recordset.MoveNextWendEnd IfEnd Sub库存管理模块源代码如下:Dim sql As StringPrivate Sub Command1_Click()If DataCombo1.Text = "" And DataCombo2.Text = "" And DataCombo3.Text = "" Then MsgBox "请在组合框中输入你要查询的内容!!", 64, "提示"ElseIf DataCombo1.Text = "" And DataCombo2.Text = "" And DataCombo3.Text <> "" Thensql = "select * from 库存材料清单where 供应商号= '" & DataCombo3.Text & "'"Adodc1.RecordSource = sqlAdodc1.RefreshElseIf DataCombo1.Text = "" And DataCombo2.Text <> "" And DataCombo3.Text = "" Thensql = "select * from 库存材料清单where 进货日期='" & DataCombo2.Text & "'"Adodc1.RecordSource = sqlAdodc1.RefreshElseIf DataCombo1.Text = "" And DataCombo2.Text <> "" And DataCombo3.Text <> "" Then sql = "select * from 库存材料清单where 进货日期='" & DataCombo2.Text & "' and 供应商号='" & DataCombo3.Text & "'"Adodc1.RecordSource = sqlAdodc1.RefreshElseIf DataCombo1.Text <> "" And DataCombo2.Text = "" And DataCombo3.Text = "" Thensql = "select * from 库存材料清单where 材料号='" & DataCombo1.Text & "'"Adodc1.RecordSource = sqlAdodc1.RefreshElseIf DataCombo1.Text <> "" And DataCombo2.Text = "" And DataCombo3.Text <> "" Then sql = "select * from 库存材料清单where 材料号='" & DataCombo1.Text & "' and 供应商号='" & DataCombo3.Text & "'"Adodc1.RecordSource = sqlAdodc1.RefreshElseIf DataCombo1.Text <> "" And DataCombo2.Text <> "" And DataCombo3.Text = "" Then sql = "select * from 库存材料清单where 材料号='" & DataCombo1.Text & "' and 进货日期='" & DataCombo2.Text & "'"Adodc1.RecordSource = sqlAdodc1.RefreshElseIf DataCombo1.Text <> "" And DataCombo2.Text <> "" And DataCombo3.Text <> "" Then sql = "select * from 库存材料清单where 材料号='" & DataCombo1.Text & "' and 进货日期='" & DataCombo2.Text & "' and 供应商号='" & DataCombo3.Text & "'"Adodc1.RecordSource = sqlAdodc1.RefreshEnd IfIf Adodc1.Recordset.BOF ThenMsgBox "对不起,该库存不存在!!", 64, "提示"End IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click()If DataGrid1.AllowUpdate = False ThenDataGrid1.AllowUpdate = TrueDataGrid1.AllowDelete = TrueCommand3.Caption = "锁定"MsgBox "您巳进入修改状态!"ElseDataGrid1.AllowUpdate = FalseDataGrid1.AllowDelete = TrueCommand3.Caption = "修改"MsgBox "您进入锁定状态!"End IfEnd SubPrivate Sub Command4_Click()msg$ = "确定要删除该库存材料记录吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "删除记录")If ans = vbOK ThenAdodc1.Recordset.DeleteAdodc1.Recordset.MoveNextEnd IfEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc1.RecordSource = "库存材料清单"Adodc1.RefreshAdodc2.ConnectionString = adoAdodc2.RecordSource = "库存材料清单"Adodc2.RefreshIf er_type <> 1 ThenCommand3.Enabled = FalseCommand4.Enabled = FalseEnd IfEnd Sub美容项目定义模块源代码如下:Private Sub Command1_Click()If Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" ThenAdodc2.RecordSource = "select * from 美容项目定义表where 美容项目编号='" & Text1.Text & "'"Adodc2.RefreshIf Adodc2.Recordset.BOF ThenAdodc1.Recordset.AddNewAdodc1.Recordset.Fields(0) = Text1.TextAdodc1.Recordset.Fields(1) = Text2.TextAdodc1.Recordset.Fields(2) = Text3.TextAdodc1.Recordset.UpdateElseMsgBox "该美容项目编号已存在!!", 48, "警告"End IfElseMsgBox "资料输入不全,请重新输入!!", 64, "提示"End IfText1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""End SubPrivate Sub Command3_Click()Unload MeEnd SubPrivate Sub Command4_Click()msg$ = "确定要删除该美容项目吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "删除记录") If ans = vbOK ThenAdodc1.Recordset.DeleteAdodc1.Recordset.MoveNextEnd IfEnd SubPrivate Sub Command5_Click()If DataGrid1.AllowUpdate = False ThenDataGrid1.AllowUpdate = TrueDataGrid1.AllowDelete = TrueCommand5.Caption = "锁定"MsgBox "您巳进入修改状态!"ElseDataGrid1.AllowUpdate = FalseDataGrid1.AllowDelete = TrueCommand5.Caption = "修改"MsgBox "您进入锁定状态!"End IfEnd SubPrivate Sub Text2_GotFocus()If Not Adodc1.Recordset.BOF ThenAdodc1.Recordset.MoveFirstWhile Not Adodc1.Recordset.EOFIf Adodc1.Recordset.Fields(0) = Text1.Text ThenMsgBox "该美容项目编号已经存在,请重新输入!!", 48, "提示"Text1.Text = ""End IfAdodc1.Recordset.MoveNextWendEnd IfEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc1.RecordSource = "美容项目定义表"Adodc1.RefreshAdodc2.ConnectionString = adoEnd Sub美容项目查询模块源代码如下:Private Sub Command1_Click()If DataCombo1.Text = "" ThenMsgBox ("输入不能为空!!")ElseAdodc2.RecordSource = "select * from 美容项目定义表where 美容项目名称='" & DataCombo1.Text & "'"Adodc2.RefreshDataGrid1.Columns(0).Width = 120XXDataGrid1.Columns(1).Width = 120XXDataGrid1.Columns(2).Width = 120XXEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc1.RecordSource = "美容项目定义表"Adodc1.RefreshAdodc2.ConnectionString = adoEnd Sub来车登记模块源代码如下:Dim sql As StringPrivate Sub Command1_Click()If DTPicker1.Value <> "" And Text2.Text <> "" And Text3.Text <> "" And Text4.Text <> "" And DataCombo1.Text <> "" Thenmsg$ = "确定要添加该登记吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "添加登记")If ans = vbOK ThenAdodc1.RefreshAdodc1.Recordset.AddNewAdodc1.Recordset.Fields(0) = CStr(DTPicker1.V alue)Adodc1.Recordset.Fields(1) = Text2.TextAdodc1.Recordset.Fields(2) = Text3.TextAdodc1.Recordset.Fields(3) = Text4.TextAdodc1.Recordset.Fields(4) = DataCombo1.TextAdodc1.Recordset.Fields(5) = Text5.TextAdodc1.Recordset.UpdateMsgBox ("成功登记!!~-~")ElseExit SubEnd IfDim sql As Stringsql = "select * from 车辆基本信息表where 车牌号码='" & Text2.Text & "'"Adodc3.RecordSource = sqlAdodc3.RefreshIf Adodc3.Recordset.BOF ThenAdodc2.RefreshAdodc2.Recordset.AddNewAdodc2.Recordset.Fields(0) = Text2.TextAdodc2.Recordset.Fields(1) = Text3.TextAdodc2.Recordset.Fields(2) = Text4.TextAdodc2.Recordset.Fields(3) = Text5.TextAdodc2.Recordset.UpdateEnd IfElseMsgBox "资料输入不全,请重新输入!!", 64, "提示"End IfDTPicker1.SetFocusText2.Text = ""Text3.Text = ""Text4.Text = ""DataCombo1.Text = ""Text5.Text = ""End SubPrivate Sub Command2_Click()Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""DataCombo1.Text = ""End SubPrivate Sub Command3_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;" ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc1.RecordSource = "来车登记表"Adodc1.RefreshAdodc2.ConnectionString = adoAdodc2.RecordSource = "车辆基本信息表"Adodc2.RefreshAdodc3.ConnectionString = adoAdodc4.ConnectionString = adoAdodc4.RecordSource = "bmxx"Adodc4.RefreshEnd Sub车辆基本信息管理模块源代码如下:Private Sub Command1_Click()查询车辆基本信息.ShowEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click()msg$ = "确定要删除该项信息吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "删除记录")If ans = vbOK ThenAdodc1.Recordset.DeleteAdodc1.Recordset.MoveNextEnd IfEnd SubPrivate Sub Command4_Click()If DataGrid1.AllowUpdate = False ThenDataGrid1.AllowUpdate = TrueDataGrid1.AllowDelete = TrueCommand4.Caption = "锁定"MsgBox "您巳进入修改状态!"ElseDataGrid1.AllowUpdate = FalseDataGrid1.AllowDelete = TrueCommand4.Caption = "修改"MsgBox "您进入锁定状态!"End IfEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc1.RecordSource = "车辆基本信息表"Adodc1.RefreshIf er_type <> 1 ThenCommand3.Enabled = FalseCommand4.Enabled = FalseEnd IfEnd Sub车辆美容信息管理模块源代码如下:Private Sub Command1_Click()Dim sum1, x, z As CurrencyDim y, n1, l, l1 As Longsum1 = 0n1 = 0l1 = 0If CStr(DTPicker1.Value) <> "" And Text2.Text <> "" And Text3.Text <> "" And DataCombo1.Text <> "" And DataCombo5.Text <> "" And DataCombo6.Text <> "" Then'修改库存材料清单Dim q, q1 As Longq1 = 0If Not Adodc5.Recordset.BOF ThenAdodc5.RefreshAdodc5.Recordset.MoveFirstWhile Not Adodc5.Recordset.EOFIf Adodc5.Recordset.Fields(0) = DataCombo5.Text And Adodc5.Recordset.Fields(1) = DataCombo6.Text Thenq1 = 1If Adodc5.Recordset.Fields(4) < CLng(Text3.Text) ThenMsgBox "这种材料的库存数量不够!!", 48, "警告"DataCombo5.Text = ""DataCombo6.Text = ""Text2.Text = ""Text3.Text = ""Exit SubElseq = Adodc5.Recordset.Fields(4)Adodc5.Recordset.Fields(4) = q - CLng(Text3.Text)Adodc5.Recordset.UpdateEnd IfEnd IfAdodc5.Recordset.MoveNextWendIf q1 = 0 ThenMsgBox "库存中没有这种材料!!", 48, "警告"End If'修改库存材料清单完毕End IfIf q1 = 1 ThenAdodc6.RefreshIf Not Adodc6.Recordset.BOF ThenAdodc6.Recordset.MoveFirstWhile Not Adodc6.Recordset.EOF '查找一下车辆用料信息表中是否存在这种材料If Adodc6.Recordset.Fields(0) = CStr(DTPicker1.Value) And Adodc6.Recordset.Fields(1) = DataCombo1.Text And Adodc6.Recordset.Fields(2) = DataCombo5.Text And Adodc6.Recordset.Fields(3) = DataCombo6.Text And Adodc6.Recordset.Fields(4) = Text2.Text Thenl = Adodc6.Recordset.Fields(5)l1 = 1Adodc6.Recordset.Fields(5) = l + CLng(Text3.Text) '如果存在,只修改数量Adodc6.Recordset.UpdateEnd IfAdodc6.Recordset.MoveNextWendEnd IfIf l1 = 0 Then '如果不存在,则在车辆用料信息表中添加新记录Adodc6.Recordset.AddNewAdodc6.Recordset.Fields(0) = CStr(DTPicker1.V alue)Adodc6.Recordset.Fields(1) = DataCombo1.TextAdodc6.Recordset.Fields(2) = DataCombo5.TextAdodc6.Recordset.Fields(3) = DataCombo6.TextAdodc6.Recordset.Fields(4) = Text2.TextAdodc6.Recordset.Fields(5) = Text3.TextAdodc6.Recordset.UpdateAdodc6.RefreshEnd IfIf Not Adodc9.Recordset.BOF ThenAdodc9.Refresh '在车辆消费信息表中添加该车辆的材料费Adodc9.Recordset.MoveFirstWhile Not Adodc9.Recordset.EOFIf Adodc9.Recordset.Fields(0) = CStr(DTPicker1.Value) And Adodc9.Recordset.Fields(1) = DataCombo1.Text Thenn1 = 1 '如果车辆消费信息表中存在当天该车的记录时Adodc6.Refresh '在车辆用料信息表中,计算该车的材料费Adodc6.Recordset.MoveFirstWhile Not Adodc6.Recordset.EOFIf Adodc6.Recordset.Fields(0) = CStr(DTPicker1.Value) And Adodc6.Recordset.Fields(1) = DataCombo1.Text Thenx = Adodc6.Recordset.Fields(4)y = Adodc6.Recordset.Fields(5)z = x * ysum1 = sum1 + zEnd IfAdodc6.Recordset.MoveNextWendAdodc9.Recordset.Fields(0) = CStr(DTPicker1.V alue)Adodc9.Recordset.Fields(1) = DataCombo1.TextAdodc9.Recordset.Fields(3) = sum1Adodc9.Recordset.Fields(4) = sum1 + Adodc9.Recordset.Fields(2)Adodc9.Recordset.UpdateEnd IfAdodc9.Recordset.MoveNextWendEnd IfIf n1 = 0 Then '车辆消费信息表中无该车辆记录时Adodc9.Recordset.AddNew '向车辆消费信息表中添加材料费记录Adodc6.Refresh '车辆用料信息表Adodc6.Recordset.MoveFirstWhile Not Adodc6.Recordset.EOFIf Adodc6.Recordset.Fields(0) = CStr(DTPicker1.Value) And Adodc6.Recordset.Fields(1) = DataCombo1.Text Thenx = Adodc6.Recordset.Fields(4)y = Adodc6.Recordset.Fields(5)z = x * ysum1 = sum1 + zEnd IfAdodc6.Recordset.MoveNextWendAdodc9.Recordset.Fields(0) = CStr(DTPicker1.V alue)Adodc9.Recordset.Fields(1) = DataCombo1.TextAdodc9.Recordset.Fields(3) = sum1Adodc9.Recordset.Fields(4) = sum1Adodc9.Recordset.Update '保存记录End IfEnd IfElseMsgBox "资料输入不全,请重新输入!!", 64, "提示"End IfDataCombo5.Text = ""DataCombo6.Text = ""Text2.Text = ""Text3.Text = ""DataCombo5.SetFocusEnd SubPrivate Sub Command2_Click()DataCombo1.Text = ""DataCombo2.Text = ""DataCombo3.Text = ""DataCombo4.Text = ""Unload MeEnd SubPrivate Sub Command3_Click()修改美容项目.ShowEnd SubPrivate Sub Command4_Click()Dim sum, x, z As CurrencyDim y, n As Longsum = 0 n = 0If DTPicker1.Value <> "" And DataCombo1.Text <> "" And DataCombo2.Text <> "" And DataCombo3.Text <> "" And DataCombo4.Text <> "" ThenAdodc4.Refresh '车辆美容信息登记表Adodc4.Recordset.AddNewAdodc4.Recordset.Fields(0) = CStr(DTPicker1.V alue)Adodc4.Recordset.Fields(1) = DataCombo1.TextAdodc4.Recordset.Fields(2) = DataCombo4.TextAdodc4.Recordset.Fields(3) = DataCombo2.TextAdodc4.Recordset.Fields(4) = DataCombo3.TextAdodc4.Recordset.UpdateAdodc9.RefreshIf Not Adodc9.Recordset.BOF Then '判断一下表是否为空表Adodc9.RefreshAdodc9.Recordset.MoveFirstWhile Not Adodc9.Recordset.EOFIf Adodc9.Recordset.Fields(0) = CStr(DTPicker1.Value) And Adodc9.Recordset.Fields(1) = DataCombo1.Text Thenn = 1Adodc4.RefreshAdodc4.Recordset.MoveFirstWhile Not Adodc4.Recordset.EOFIf Adodc4.Recordset.Fields(0) = CStr(DTPicker1.Value) And Adodc4.Recordset.Fields(1) = DataCombo1.Text Thensum = sum + Adodc4.Recordset.Fields(4)End IfAdodc4.Recordset.MoveNextWendAdodc9.Recordset.Fields(0) = CStr(DTPicker1.V alue)Adodc9.Recordset.Fields(1) = DataCombo1.TextAdodc9.Recordset.Fields(2) = sumAdodc9.Recordset.Fields(4) = sum + Adodc9.Recordset.Fields(3)Adodc9.Recordset.Update '保存End IfAdodc9.Recordset.MoveNextWendEnd IfIf n = 0 ThenAdodc9.Recordset.AddNew '向车辆消费信息表中添加美容项目消费Adodc4.RefreshAdodc4.Recordset.MoveFirstWhile Not Adodc4.Recordset.EOFIf Adodc4.Recordset.Fields(0) = CStr(DTPicker1.Value) And Adodc4.Recordset.Fields(1) = DataCombo1.Text Thensum = sum + Adodc4.Recordset.Fields(4)End IfAdodc4.Recordset.MoveNextWendAdodc9.Recordset.Fields(0) = CStr(DTPicker1.V alue)Adodc9.Recordset.Fields(1) = DataCombo1.TextAdodc9.Recordset.Fields(2) = sumAdodc9.Recordset.Fields(4) = sumAdodc9.Recordset.Update '保存End IfElse MsgBox "资料输入不全,请重新输入!!", 64, "提示"End IfDataCombo2.Text = ""DataCombo3.Text = ""DataGrid1.Columns(0).Width = 1500DataGrid1.Columns(1).Width = 1500DataCombo2.SetFocusEnd SubPrivate Sub Command5_Click()修改用料.ShowEnd SubPrivate Sub Command6_Click()If DataGrid1.AllowUpdate = False ThenDataGrid1.AllowUpdate = TrueDataGrid1.AllowDelete = TrueCommand6.Caption = "锁定"MsgBox "您巳进入修改状态!"ElseDataGrid1.AllowUpdate = FalseDataGrid1.AllowDelete = TrueCommand6.Caption = "修改"MsgBox "您进入锁定状态!"End IfEnd SubPrivate Sub DataCombo2_GotFocus()Adodc7.RecordSource = "select 美容项目,价格from 车辆美容信息登记表where 日期='" & CStr(DTPicker1.Value) & "' and 车牌号码='" & DataCombo1.Text & "'"Adodc7.RefreshEnd SubPrivate Sub DataCombo5_GotFocus()Adodc8.RecordSource = "select 材料号,材料名称,单价,数量from 车辆用料信息表where 日期='" & CStr(DTPicker1.Value) & "' and 车牌号码='" & DataCombo1.Text & "'"Adodc8.RefreshDataGrid2.Columns(0).Width = 1000DataGrid2.Columns(1).Width = 1000DataGrid2.Columns(2).Width = 1000DataGrid2.Columns(3).Width = 1000End SubPrivate Sub DataCombo3_GotFocus()'查询美容项目定义表,美容价格随着美容项目的选择而变If Not Adodc2.Recordset.BOF ThenAdodc2.Recordset.MoveFirstWhile Not Adodc2.Recordset.EOFIf Adodc2.Recordset.Fields(1) = DataCombo2.Text ThenDataCombo3.Text = Adodc2.Recordset.Fields(2)End IfAdodc2.Recordset.MoveNextWendEnd IfEnd SubPrivate Sub DataCombo6_GotFocus()If Not Adodc5.Recordset.BOF Then '根据填入的材料号,材料名称会自动出现Adodc5.Recordset.MoveFirstWhile Not Adodc5.Recordset.EOFIf Adodc5.Recordset.Fields(0) = DataCombo5.Text ThenDataCombo6.Text = Adodc5.Recordset.Fields(1)End IfAdodc5.Recordset.MoveNextWendEnd IfEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc1.RecordSource = "车辆基本信息表"Adodc1.RefreshAdodc2.ConnectionString = adoAdodc2.RecordSource = "美容项目定义表"Adodc2.RefreshAdodc3.ConnectionString = adoAdodc3.RecordSource = "bmxx"Adodc3.RefreshAdodc4.ConnectionString = adoAdodc4.RecordSource = "车辆美容信息登记表"Adodc4.RefreshAdodc5.ConnectionString = adoAdodc5.RecordSource = "库存材料清单"Adodc5.RefreshAdodc6.ConnectionString = adoAdodc6.RecordSource = "车辆用料信息表"Adodc6.RefreshAdodc9.ConnectionString = adoAdodc9.RecordSource = "车辆消费信息表"Adodc9.RefreshIf er_type <> 1 ThenCommand3.Enabled = FalseCommand5.Enabled = FalseEnd IfEnd Sub修改美容项目模块源代码如下:Private Sub Command1_Click()Dim l, x, y As Longl = 0Adodc2.Refresh '在美容项目登记表中删除项目Adodc2.Recordset.MoveFirstWhile Not Adodc2.Recordset.EOFIf Adodc2.Recordset.Fields(0) = Text1.Text And Adodc2.Recordset.Fields(1) = DataCombo1.Text And Adodc2.Recordset.Fields(2) = DataCombo2.Text And Adodc2.Recordset.Fields(3) = DataCombo3.Text And Adodc2.Recordset.Fields(4) = DataCombo4.Text Thenl = 1y = Adodc2.Recordset.Fields(4)msg$ = "确定要删除该美容项目吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "删除记录")If ans = vbOK ThenAdodc2.Recordset.DeleteAdodc2.Recordset.MoveNextAdodc2.Recordset.UpdateAdodc2.RefreshEnd IfDataGrid1.Columns(0).Width = 120XXDataGrid1.Columns(1).Width = 120XXDataGrid1.Columns(2).Width = 120XXDataGrid1.Columns(3).Width = 120XXDataGrid1.Columns(4).Width = 120XXEnd IfAdodc2.Recordset.MoveNextWendIf l = 0 Then '要删除的项目不存在时MsgBox ("数据库中没有您要删除的项目!!")End IfAdodc6.Refresh '修改车辆消费信息表中的人工费合计和总金额Adodc6.Recordset.MoveFirstWhile Not Adodc6.Recordset.EOFIf Adodc6.Recordset.Fields(0) = Text1.Text And Adodc6.Recordset.Fields(1) = DataCombo1.Text Thenx = Adodc6.Recordset.Fields(2)Adodc6.Recordset.Fields(2) = x - yAdodc6.Recordset.Fields(4) = Adodc6.Recordset.Fields(2) + Adodc6.Recordset.Fields(3)Adodc6.Recordset.UpdateEnd IfAdodc6.Recordset.MoveNextWendDataCombo2.Text = ""DataCombo3.Text = ""DataCombo4.Text = ""DataCombo2.SetFocusEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click()If DataGrid1.AllowUpdate = False ThenDataGrid1.AllowUpdate = TrueDataGrid1.AllowDelete = TrueCommand3.Caption = "锁定"MsgBox "您巳进入修改状态!"ElseDataGrid1.AllowUpdate = FalseDataGrid1.AllowDelete = TrueCommand3.Caption = "修改"MsgBox "您进入锁定状态!"End IfEnd SubPrivate Sub DataCombo2_GotFocus()Adodc1.RecordSource = "select * from 车辆美容信息登记表where 日期='" & Text1.Text & "' and 车牌号码='" & DataCombo1.Text & "'"Adodc1.RefreshEnd SubPrivate Sub Form_Load()Dim ado As String, mpath As Stringmpath = App.pathIf Right(mpath, 1) <> "\" Then mpath = mpath + "\"ado = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;"ado = ado + "Data Source=" + mpath + "database.mdb"Adodc1.ConnectionString = adoAdodc2.ConnectionString = adoAdodc2.RecordSource = "车辆美容信息登记表"Adodc2.RefreshAdodc3.ConnectionString = adoAdodc3.RecordSource = "车辆基本信息表"Adodc3.RefreshAdodc5.ConnectionString = adoAdodc5.RecordSource = "美容项目定义表"Adodc5.RefreshAdodc6.ConnectionString = adoAdodc6.RecordSource = "车辆消费信息表"Adodc6.Refresh'Text1.SetFocusEnd Sub修改用料模块源代码如下:Private Sub Command1_Click()Dim l, x, y, z, m, l1 As Longl = 0l1 = 0Adodc3.Refresh '在车辆用料信息表中删除信息If Not Adodc3.Recordset.BOF ThenAdodc3.Recordset.MoveFirstWhile Not Adodc3.Recordset.EOFIf Adodc3.Recordset.Fields(0) = Text1.Text And Adodc3.Recordset.Fields(1) = DataCombo1.Text And Adodc3.Recordset.Fields(2) = DataCombo2.Text And Adodc3.Recordset.Fields(3) = DataCombo3.Text And Adodc3.Recordset.Fields(4) = Text2.Text Thenl = 1z = Adodc3.Recordset.Fields(5)m = z - CLng(Text3.Text)If m > 0 Thenmsg$ = "确定要修改该用料信息吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "修改记录")If ans = vbOK Thenl1 = 1Adodc3.Recordset.Fields(5) = mAdodc3.Recordset.UpdateAdodc3.Refreshy = Adodc3.Recordset.Fields(4) * CLng(Text3.Text)End IfElseIf m = 0 Thenmsg$ = "确定要删除该用料信息吗?"ans = MsgBox(msg$, vbOKCancel + vbDefaultButton2, "删除记录")If ans = vbOK Thenl1 = 1y = Adodc3.Recordset.Fields(4) * CLng(Text3.Text)Adodc3.Recordset.DeleteAdodc3.Recordset.MoveNextAdodc3.RefreshEnd IfElseIf m < 0 ThenMsgBox ("您要删除的数量大于该车实际用量!!")End IfDataGrid1.Columns(0).Width = 120XXDataGrid1.Columns(1).Width = 120XXDataGrid1.Columns(2).Width = 120XXDataGrid1.Columns(3).Width = 120XXDataGrid1.Columns(4).Width = 120XXDataGrid1.Columns(5).Width = 120XXIf l1 = 1 ThenAdodc4.Refresh '修改车辆消费信息表中的材料费合计和总金额If Not Adodc4.Recordset.BOF ThenAdodc4.Recordset.MoveFirstWhile Not Adodc4.Recordset.EOFIf Adodc4.Recordset.Fields(0) = Text1.Text And Adodc4.Recordset.Fields(1) = DataCombo1.Text Thenx = Adodc4.Recordset.Fields(3)Adodc4.Recordset.Fields(3) = x - yAdodc4.Recordset.Fields(4) = Adodc4.Recordset.Fields(2) + Adodc4.Recordset.Fields(3)Adodc4.Recordset.UpdateEnd IfAdodc4.Recordset.MoveNextWendEnd IfAdodc2.Refresh '修改库存材料清单If Not Adodc2.Recordset.BOF ThenAdodc2.Recordset.MoveFirstWhile Not Adodc2.Recordset.EOFIf Adodc2.Recordset.Fields(0) = DataCombo2.Text And Adodc2.Recordset.Fields(1) = DataCombo3.Text ThenAdodc2.Recordset.Fields(4) = Adodc2.Recordset.Fields(4) + CLng(Text3.Text)Adodc2.Recordset.UpdateEnd IfAdodc2.Recordset.MoveNextWendEnd If '修改库存材料清单完毕End IfDataCombo2.Text = ""DataCombo3.Text = ""Text2.Text = ""Text3.Text = ""DataCombo2.SetFocusExit SubEnd IfAdodc3.Recordset.MoveNextWendEnd IfIf l = 0 Then '要删除的项目不存在时。
VB库存管理系统(有源程序)(可编辑)
VB库存管理系统(有源程序)源程序代码等全套设计联系 174320523 各专业都有第一章引言新的世纪、新的千年和新的时代,同时向我们走来。
即将过去的二十世纪是伟大的,正在向我们走来的新世纪将更加伟大。
人类将从传统的物质经济迈向崭新的知识经济时代。
在知识经济时代,以电脑为核心的信息技术,将成为时代的标志,单位是知识的前沿领域,单位的一些管理者应该首先冲入智能化、网络化的行列。
那么库存管理应该用哪些软件、怎样来设计呢?Visual Basic 6.0是由软件界巨头、著名的微软公司可视化编程语言、由于其可视化程度高、代码简洁易读,因此是最容易入门的编程之一。
Visual Basic6.0使用了Microsoft Windows图形用户界面的许多先进特性和设计思想,提供了向导自动生成代码,支持拖放技术、属性提示与检查、语法检查等内置自动化,大大降低了编写代码的工作量,特别是提供了极其丰富的控件,使得Visual Basic 6.0成为最简捷、最有效的开发 Windows应用程序工具。
随着网络技术的不断发展,Visual Basic 6.0的应用范围也从开发单机软件发展到开发网上颁式应用程序。
Visual Basic 6.0不但受到广大初、中级计算机爱好者的欢迎,也越来越受到高级程序员的欢迎。
第二章概述2.1 程序设计的目的和意义库存管理系统是一个企业不可缺少的部分,它的内容对于单位的决策者和管理者来说都至关重要,所以库存管理系统应该能够为用户提供充足的信息和快捷的查询手段。
但一直以来人们使用传统人工的方式管理文件库存,这种管理方式存在着许多缺点,如:效率低、保密性差,另外时间一长,将产生大量的文件和数据,这对于查找、更新和维护都带来了不少的困难。
随着科学技术的不断提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。
作为计算机应用的一部分,使用计算机对库存信息进行管理,具有着手工管理所无法比拟的优点.例如:检索迅速、查找方便、可靠性高、存储量大、保密性好、寿命长、成本低等。
好用的VB--仓库管理系统
摘要仓库管理系统是为了实现企业产品管理的系统化、规范化和自动化,从而提高企业管理效率而设计的。
它完全取代了原来一直用人工管理的工作方式,避免了由于管理人员的工作疏忽以及管理质量问题所造成的各种错误,为及时、准确、高效的完成仓库管理提供了强有力的工具和管理手段。
仓库管理系统是一个中小型数据库管理系统,它界面美观、操作简单、安全性高,基本满足了仓库管理的要求。
整个系统由基本信息、单据中心、查询统计、报表打印、维护设置、帮助等模块组成.本系统是在以ACCESS2000作为后台数据库,以Visual Basic为编程语言来开发的。
仓库管理系统在运行阶段,效果好,数据准确性高,提高了工作效率,同时也实现了仓库管理计算机化。
关键字:仓库,管理系统,数据库AbstractThe administrative system of the warehouse is designed for realizing the systematization ,standardization and automization of enterprise's products management and improving efficiency of enterprises management。
It completely replaces the working way of artificial management originally ,prevents from various kinds of mistakes because of administrative staff neglect and the quality problem of management and offeres powerful tool and management way to complet storehouse management for prompt ,accurate ,high—efficient 。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1.请购作业程序Private Sub ComCX_Click()’查询'在"编号"文本框中输入编号,连接数据库,查询编号,并将"编号","品名","规格","单位","单价"的数据分别导入到相应文本框。
Set CN = New ADODB.ConnectionSet Rs = New ADODB.RecordsetCN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb;Persist Security Info=False"'打开数据库Rs.CursorType = adOpenStatic '制定一个静态游标Rs.LockType = adLockOptimistic '设置锁定模式为开放式Rs.Open "select * from JLBH where FtextBHSJ Like'" & "%" & Trim(textBHSJ.Text) & "%" & "'", CNDoEventsDo Until Rs.EOF = TrueIf Rs.EOF = False ThenlistBHSJ1.AddItem (Rs.Fields(0))listPMSJ1.AddItem (Rs.Fields(1))listGGSJ1.AddItem (Rs.Fields(2))listDWSJ1.AddItem (Rs.Fields(3))listDJSJ1.AddItem (Rs.Fields(4))Rs.MoveNextEnd IfLoopEnd SubPrivate Sub comFHZY_Click()’返回上页frmQGZY.HidefrmCKGLXT.ShowEnd SubPrivate Sub comQD_Click()’录入数据If textBHSJ.Text = "" Or textPMSJ.Text = "" Or textGGSJ.Text = "" Or textDWSJ.Text = "" Or textDJSJ.Text = "" Or textQGSLSJ.Text = "" ThenMsgBox "请将数据补充完整!"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""ElseDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select textBHSJ From qgzy where textBHSJ= '" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)str1 = "Insert Into qgzy (textBHSJ,textPMSJ,textGGSJ,textDWSJ,textDJSJ,textQGSJ)"str1 = str1 + "Values('" & Trim(textBHSJ.Text) & "','" & Trim(textPMSJ.Text) & "','" & Trim(textGGSJ.Text) & "','" & Trim(textDWSJ.Text) & "','" & Trim(textDJSJ.Text) & "','" & Trim(textQGSLSJ.Text) & "')"cnn.Execute str1listBHSJ1.AddItem (Trim(textBHSJ.Text))listPMSJ1.AddItem (Trim(textPMSJ.Text))listGGSJ1.AddItem (Trim(textGGSJ.Text))listDWSJ1.AddItem (Trim(textDWSJ.Text))listDJSJ1.AddItem (Trim(textDJSJ.Text))listQGSLSJ1.AddItem (Trim(textQGSLSJ.Text))MsgBox "数据输入成功!"rst.Closecnn.CloseSet Rs = NothingSet CN = NothingtextBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""End IfEnd SubPrivate Sub comsc_Click()’删除If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThentextBHSJ.Text = listBHSJ1.List(i)textPMSJ.Text = listPMSJ1.List(i)textGGSJ.Text = listGGSJ1.List(i)textDWSJ.Text = listDWSJ1.List(i)textDJSJ.Text = listDJSJ1.List(i)textQGSLSJ.Text = listQGSLSJ1.List(i)End IfNextEnd IfDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select FtextBHSJ From jlbh where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False Thenstr1 = "Delete from qgzy where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"cnn.Execute str1textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistBHSJ1.RemoveItem (i)listPMSJ1.RemoveItem (i)listGGSJ1.RemoveItem (i)listDWSJ1.RemoveItem (i)listDJSJ1.RemoveItem (i)listQGSLSJ1.RemoveItem (i)End IfNextEnd IfMsgBox "数据已删除!"ElseMsgBox "无此数据!"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""textQGSLSJ.Text = ""End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingEnd Sub‘以下是listbox串连显示Private Sub listBHSJ1_Click()If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistPMSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDJSJ1_Click()If listDJSJ1.SelCount > 0 ThenFor i = listDJSJ1.ListCount - 1 To 0 Step -1If listDJSJ1.Selected(i) ThenlistQGSLSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDWSJ1_Click()If listDWSJ1.SelCount > 0 ThenFor i = listDWSJ1.ListCount - 1 To 0 Step -1If listDWSJ1.Selected(i) ThenlistDJSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listGGSJ1_Click()If listGGSJ1.SelCount > 0 ThenFor i = listGGSJ1.ListCount - 1 To 0 Step -1If listGGSJ1.Selected(i) ThenlistDWSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listPMSJ1_Click()If listPMSJ1.SelCount > 0 ThenFor i = listPMSJ1.ListCount - 1 To 0 Step -1If listPMSJ1.Selected(i) ThenlistGGSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listQGSLSJ1_Click()If listQGSLSJ1.SelCount > 0 ThenFor i = listQGSLSJ1.ListCount - 1 To 0 Step -1If listQGSLSJ1.Selected(i) ThenlistBHSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub2.增加料号程序Private Sub comFHZY_Click()’返回上页frmJLBH.HidefrmCKGLXT.ShowEnd SubPrivate Sub comSCBH_Click()’删除If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThentextBHSJ.Text = listBHSJ1.List(i)textPMSJ.Text = listPMSJ1.List(i)textGGSJ.Text = listGGSJ1.List(i)textDWSJ.Text = listDWSJ1.List(i)textDJSJ.Text = listDJSJ1.List(i)End IfNextEnd IfDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select FtextBHSJ From jlbh where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False Thenstr1 = "Delete * from jlbh where FtextBHSJ='" & Trim(textBHSJ.Text) & "'"cnn.Execute str1textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistBHSJ1.RemoveItem (i)listPMSJ1.RemoveItem (i)listGGSJ1.RemoveItem (i)listDWSJ1.RemoveItem (i)listDJSJ1.RemoveItem (i)End IfNextEnd IfMsgBox "编号已删除!"ElseMsgBox "无此编号!请确认后重新输入"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingEnd SubPrivate Sub comZJBH_Click()’新增料号If textBHSJ.Text = "" Or textPMSJ.Text = "" Or textGGSJ.Text = "" Or textDWSJ.Text = "" Or textDJSJ.Text = "" ThenMsgBox "请将数据补充完整!"textBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""ElseDim cnn As New Connection, rst As New Recordset, fid As FieldDim strSql As String, strconn As StringstrSql = "Select FtextBHSJ From jlbh where FtextBHSJ= '" & Trim(textBHSJ.Text) & "'"strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='"strconn = strconn & "F:\VB设计专用\仓库数据资料\仓库数据资料.mdb'"cnn.ConnectionString = strconncnn.OpenSet rst = cnn.Execute(strSql)If rst.EOF = False ThenMsgBox "该编号已存在,不能追加!"Elsestr1 = "Insert Into jlbh (FtextBHSJ,FtextPMSJ,FtextGGSJ,FtextDWSJ,FtextDJSJ)"str1 = str1 + "Values('" & Trim(textBHSJ.Text) & "','" & Trim(textPMSJ.Text) & "','" & Trim(textGGSJ.Text) & "','" & Trim(textDWSJ.Text) & "','" & Trim(textDJSJ.Text) & "')"cnn.Execute str1listBHSJ1.AddItem (Trim(textBHSJ.Text))listPMSJ1.AddItem (Trim(textPMSJ.Text))listGGSJ1.AddItem (Trim(textGGSJ.Text))listDWSJ1.AddItem (Trim(textDWSJ.Text))listDJSJ1.AddItem (Trim(textDJSJ.Text))MsgBox "恭喜您,添加成功!"End Ifrst.Closecnn.CloseSet Rs = NothingSet CN = NothingtextBHSJ.Text = ""textPMSJ.Text = ""textGGSJ.Text = ""textDWSJ.Text = ""textDJSJ.Text = ""End IfEnd Sub‘以下是listbox循环选中程序Private Sub listBHSJ1_Click()If listBHSJ1.SelCount > 0 ThenFor i = listBHSJ1.ListCount - 1 To 0 Step -1If listBHSJ1.Selected(i) ThenlistPMSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDJSJ1_Click()If listDJSJ1.SelCount > 0 ThenFor i = listDJSJ1.ListCount - 1 To 0 Step -1If listDJSJ1.Selected(i) ThenlistBHSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listDWSJ1_Click()If listDWSJ1.SelCount > 0 ThenFor i = listDWSJ1.ListCount - 1 To 0 Step -1If listDWSJ1.Selected(i) ThenlistDJSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listGGSJ1_Click()If listGGSJ1.SelCount > 0 ThenFor i = listGGSJ1.ListCount - 1 To 0 Step -1If listGGSJ1.Selected(i) ThenlistDWSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd SubPrivate Sub listPMSJ1_Click()If listPMSJ1.SelCount > 0 ThenFor i = listPMSJ1.ListCount - 1 To 0 Step -1If listPMSJ1.Selected(i) ThenlistGGSJ1.Selected(i) = TrueEnd IfNextEnd IfEnd Sub。