rj=1To11
mf1.TextMatrix(i,j)=""
Nextj
Nexti
gys.SetFocus
mf1.Row=1:mf1.Col=1'到达mf1表格的第1行,第1列
EndSub
PrivateSubCombc_Click()
Setmydb=Workspaces(0).OpenDatabase(App.Path&"\仓库.mdb")'自动识别数据库路径
Setrs1=mydb.OpenRecordset("rkd",dbOpenTable)
Setrs2=mydb.OpenRecordset("kc",dbOpenTable)
'查询库存商品信息
Data1.RecordSource="SELECT*FROMKC"
Data1.Refresh
Fori=1To100
Ifmf1.TextMatrix(i,1)<>""Andmf1.TextMatrix(i,8)<>""Then
'添加入库商品信息到"rkd"表中
rs1.AddNew
Ifmf1.TextMatrix(i,1)<>""Thenrs1.Fields("商品名称")=mf1.TextMatrix(i,1)
Ifmf1.TextMatrix(i,2)<>""Thenrs1.Fields("简称")=mf1.TextMatrix(i,2)
Ifmf1.TextMatrix(i,3)<>""Thenrs1.Fields("批号")=mf1.TextMatrix(i,3)
Ifmf1.TextMatrix(i,4)<>""Thenrs1.Fields("产地")=mf1.TextMatrix(i,4)
Ifmf1.TextMatrix(i,5)<>""Thenrs1.Fields("规格")=mf1.TextMatrix(i,5)
Ifmf1.TextMatrix(i,6)<>""Thenrs1.Fields("包装")=mf1.TextMatrix(i,6)
Ifmf1.TextMatrix(i,7)<>""Thenrs1.Fields("单位")=mf1.TextMatrix(i,7)
Ifmf1.TextMatrix(i,8)<>""Thenrs1.Fields("数量")=mf1.TextMatrix(i,8)
Ifmf1.TextMatrix(i,9)<>""Thenrs1.Fields("进价")=mf1.TextMatrix(i,9)
Ifmf1.TextMatrix(i,10)<>""Thenrs1.Fields("金额")=mf1.TextMatrix(i,10)
Ifmf1.TextMatrix(i,11)<>""Thenrs1.Fields("备注")=mf1.TextMatrix(i,11)
Ifgys.Text<>""Thenrs1.Fields("供应商")=gys.Text
Ifjsr.Text<>""Thenrs1.Fields("经手人")=jsr.Text
Ifrkrq.Text<>""Thenrs1.Fields("日期")=rkrq.Text
IfPH.Text<>""Thenrs1.Fields("票号")=PH.Text
rs1.Update'更新表
'查找库存商品信息
Data1.Recordset.FindFirst"商品名称like"+Chr(34)+mf1.TextMatrix(i,1)+Chr(34)+"and批号like"+Chr(34)+mf1.TextMatrix(i,3)+Chr(34)+"and产地like"+Chr(34)+mf1.TextMatrix(i,4)+Chr(34)+"and规格like"+Chr(34)+mf1.TextMatrix(i,5)+Chr(34)+""
IfData1.Recordset.NoMatchThen
'添加入库商品到"kc"表中
rs2.AddNew
Ifmf1.TextMatrix(i,1)<>""Thenrs2.Fields("商品名称")=mf1.TextMatrix(i,1)
Ifmf1.TextMatrix(i,2)<>""Thenrs2.Fields("简称")=mf1.TextMatrix(i,2)
Ifmf1.TextMatrix(i,3)<>""Thenrs2.Fields("批号")=mf1.TextMatrix(i,3)
Ifmf1.TextMatrix(i,4)<>""Thenrs2.Fields("产地")=mf1.TextMatrix(i,4)
Ifmf1.TextMatrix(i,5)<>""Thenrs2.Fields("规格")=mf1.TextMatrix(i,5)
Ifmf1.TextMatrix(i,6)<>""Thenrs2.Fields("包装")=mf1.TextMatrix(i,6)
Ifmf1.TextMatrix(i,7)<>""Thenrs2.Fields("单位")=mf1.TextMatrix(i,7)
Ifmf1.TextMatrix(i,8)<>""Thenrs2.Fields("库存")=mf1.TextMatrix(i,8)
Ifmf1.TextMatrix(i,9)<>""Thenrs2.Fields("进价")=mf1.TextMatrix(i,9)
Ifmf1.TextMatrix(i,10)<>""Thenrs2.Fields("库存金额")=mf1.TextMatrix(i,10)
rs2.Update'更新表
Else
'更新"kc"表中的"库存"及"库存金额"
Data1.Recordset.Edit
Data1.Recordset.Fields("库存")=Val(mf1.TextMatrix(i,8))+Val(Data1.Recordset.Fields("库存"))
Data1.Recordset.Fields("库存金额")=Val(Data1.Recordset.Fields("库存"))*Val(Data1.Recordset.Fields("进价"))
Data1.UpdateRecord
EndIf
EndIf
Nexti
rs1.Close:mydb.Close
'清空数据
Fori=1To100
Forj=1To11
mf1.TextMatrix(i,j)=""
Nextj
Nexti
gys.Text="":jsr.Text="":js.Text="":hjsl.Text="":hj.Text=""
Text1.Visible=False:DBList1.Visible=False'设置控件不可见
mf1.Enabled=False:Combc.Enabled=False:Comdj.Enabled=True:Comqx.Enabled=False
EndSub
PrivateSubComqx_Click()'取消操作
gys.Text="":jsr.Text="":js.Text="":hjsl.Text="":hj.Text=""
Fori=1To100
Forj=1To11
mf1.TextMatrix(i,j)=""
Nextj
Nexti
gys.Enabled=False:jsr.Enabled=False:js.Enabled=False:hjsl.Enabled=False:hj.Enabled=False
DBList1.Visible=False:Text1.Enabled=False:mf1.Enabled=False:Combc.Enabled=False:
Comqx.Enabled=False:Comdj.Enabled=True:Comdj.SetFocus
EndSub
PrivateSubComend_Click()
frm_main.Enabled=True
UnloadMe
EndSub
查询模块程序代码:
DimlsqlAsString
Dimtmpsql1AsString
Dimtpsql1AsString
PrivateSubCombo1_LostFocus()
Combo1.AddItem"商品名称"
Combo1.AddItem"批号"
Combo1.AddItem"产地"
Combo1.AddItem"数量"
Combo1.AddItem"供应商"
Combo1.AddItem"日期"
Combo1.AddItem"票号"
EndSub
PrivateSubCombo2_LostFocus()
Combo2.AddItem">"
Combo2.AddItem"<"
Combo2.AddItem">="
Combo2.AddItem"<="
Combo2.AddItem"="
EndSub
PrivateSubCommand1_Click()
Text3.Text=str(Data1.Recordset.RecordCount)
EndSub
PrivateSubCommand2_Click()
UnloadMe
EndSub
PrivateSubCommand3_Click()
Combo1.Text=""
Combo2.Text=""
Combo3.Text=""
slql="select*from.kc"
Data1.RecordSource=slql
Data1.Refresh
Text3.Text=str(Data1.Recordset.RecordCount)
EndSub
PrivateSubCommand4_Click()
i=MsgBox("确实要重新设置吗?",33,"")
Ifi=1Then
Combo1.Text=""
Combo2.Text=""
Combo3.Text=""
EndIf
EndSub
PrivateSubCommand5_Click()
i=MsgBox("真的要打印吗?",33,"")
Ifi=1Then
DataReport1.Show
Else
CommonDialog1.CancelError=True
GoToerrhandler
CommonDialog1.ShowPrinter
errhandler:
ExitSub
EndIf
EndSub
PrivateSubCommand9_Click()
ResumeNext
IfCombo3.Text=""Then
MsgBox"请输入查询内容!",49,"提示信息"
EndIf
tmpsql1=Combo1.Text&Combo2.Text&"'"&Trim(Combo3.Text&"'")
lsql="select*fromrkdwhere"&tmpsql1
Data1.RecordSource=lsql
Data1.Refresh
MSFlexGrid1.Visible=True
EndSub
PrivateSubForm_Load()
Data1.DatabaseName=App.Path&"\仓库.mdb"
Me.Left=(Screen.Width-Me.Width)/2
Me.Top=(Screen.Height-Me.Height)/2
Me.Width=8000
Me.Height=5220
EndSub
入库信息管理程序代码:
PrivateSubCommand1_Click()
Data1.Recordset.MoveFirst
Command2.Enabled=False
Command3.Enabled=True
EndSub
PrivateSubCommand2_Click()
Data1.Recordset.MovePrevious
Command3.Enabled=True
IfData1.Recordset.BOFThen
Data1.Recordset.MoveFirst
Command2.Enabled=False
EndIf
EndSub
PrivateSubCommand3_Click()
Data1.Recordset.MoveNext
Command2.Enabled=True
IfData1.Recordset.EOFThen
Data1.Recordset.MoveLast
Command3.Enabled=False
EndIf
EndSub
PrivateSubCommand4_Click()
Data1.Recordset.MoveLast
Command3.Enabled=False
Command2.Enabled=True
EndSub
PrivateSubCommand5_Click()
IfCommand5.Caption="修改"Then
Text1.Enabled=True
Text2.Enabled=True
Text3.Enabled=True
Text4.Enabled=True
Text5.Enabled=True
Text6.Enabled=True
Text7.Enabled=True
Text8.Enabled=True
Text9.Enabled=True
Text10.Enabled=True
Text11.Enabled=True
Text12.Enabled=True
Text13.Enabled=True
Text14.Enabled=True
Text15.Enabled=True
Command1.Enabled=False
Command2.Enabled=False
Command3.Enabled=False
Command4.Enabled=False
Command7.Enabled=False
Command8.Enabled=False
Command6.Enabled=True
Command5.Caption="确认"
Data1.Recordset.Edit
Text1.SetFocus
Else
Command5.Caption="修改"
Text1.Enabled=False
Text2.Enabled=False
Text3.Enabled=False
Text4.Enabled=False
Text5.Enabled=False
Text6.Enabled=False
Text7.Enabled=False
Text8.Enabled=False
Text9.Enabled=False
Text10.Enabled=False
Text11.Enabled=False
Text12.Enabled=False
Text13.Enabled=False
Text14.Enabled=False
Text15.Enabled=False
Command1.Enabled=True
Command2.Enabled=True
Command3.Enabled=True
Command4.Enabled=True
Command7.Enabled=True
Command8.Enabled=True
Command6.Enabled=False
Data1.Recordset.Update
EndIf
EndSub
PrivateSubCommand7_Click()
r=MsgBox("你是否要真的删除,注意不能恢复!",vbOKCancel,"删除警告")
Ifr=1Then
Data1.Recordset.Delete
Data1.Recordset.MoveNext
IfData1.Recordset.EOFThenData1.Recordset.MoveLast
EndIf
EndSub
PrivateSubCommand6_Click()
Command5.Caption="修改"
Text1.Enabled=False
Text2.Enabled=False
Text3.Enabled=False
Text4.Enabled=False
Text5.Enabled=False
Text6.Enabled=False
Text7.Enabled=False
Text8.Enabled=False
Text9.Enabled=False
Text10.Enabled=False
Text11.Enabled=False
Text12.Enabled=False
Text13.Enabled=False
Text14.Enabled=False
Text15.Enabled=False
Command1.Enabled=True
Command2.Enabled=True
Command3.Enabled=True
Command4.Enabled=True
Command7.Enabled=True
Command8.Enabled=True
Command6.Enabled=False
Data1.UpdateControls
EndSub
PrivateSubCommand8_Click()
UnloadMe
frm_main.Enabled=True
EndSub
PrivateSubForm_Load()
Command6.Enabled=False
Data1.DatabaseName=App.Path&"\仓库.mdb"'自动识别数据库路径
EndSub
供应商管理程序代码:
DimX,i'定义变量
PublicSubviewdata()'定义显示数据的函数
Fori=0To16
IfData1.Recordset.Fields(i)<>""Thengys(i).Text=Data1.Recordset.Fields(i)Elsegys(i).Text=""
Nexti
EndSub
PrivateSubForm_Activate()
'向combo1添加查询项目列表
X=Array("供应商编号","供应商全称","简称","地址","所属地区","邮政编码","电话","传真")
Fori=0To7
Combo1.AddItem(X(i))
Nexti
Combo1.Text="供应商全称"
'初始化给gys(i)赋值
IfData1.Recordset.RecordCount>0Then
Callviewdata'调用函数
EndIf
EndSub
PrivateSubForm_Load()
Data1.DatabaseName=App.Path&"\仓库.mdb"'自动识别数据库路径
EndSub
PrivateSubForm_Unload(CancelAsInteger)
frm_main.Enabled=True
UnloadMe
EndSub
PrivateSubComFind_Click()
'查询供应商信息
Data1.RecordSource="select*fromgyswhere(gys."&Combo1.Text&""&"like"+Chr(34)+Text1.Text+"*"+Chr(34)+")"
Data1.Refresh
Callviewdata'调用函数
EndSub
PrivateSubFrame2_DragDrop(SourceAsControl,XAsSingle,YAsSingle)
EndSub
PrivateSubgys_KeyDown(IndexAsInteger,KeyCodeAsInteger,ShiftAsInteger)'回车获得焦点
IfKeyCode=vbKeyReturnAndIndex<16Thengys(Index+1).SetFocus
IfKeyCode=vbKeyReturnAndIndex=9ThenSSTab1.Tab=1
IfKeyCode=vbKeyReturnAndIndex=16ThenComSaveM.SetFocus
EndSub
PrivateSubSSTab1_Click(PreviousTabAsInteger)
IfData1.Recordset.RecordCount>0Then
IfSSTab1.Tab=2AndComAdd.Enabled=FalseThen
MsgBox("您正在处理数据,请取消数据处理,在执行本操作!")
SSTab1.Tab=0
Else
EndIf
EndIf
EndSub
PrivateSubCmdMD_Click(IndexAsInteger)
SelectCaseIndex
CaseIs=0'移到第一条记录
IfNotData1.Recordset.BOFThenData1.Recordset.MoveFirst
CaseIs=1'移到上一条记录
IfData1.Recordset.RecordCount<>0Then
IfData1.Recordset.BOF=FalseThenData1.Recordset.MovePrevious
IfData1.Recordset.BOF=TrueThenData1.Recordset.MoveFirst
EndIf
CaseIs=2'移到下一条记录
IfData1.Recordset.RecordCount<>0Then
IfData1.Recordset.EOF=FalseThenData1.Recordset.MoveNext
IfData1.Recordset.EOF=TrueThenData1.Recordset.MoveLast
EndIf
CaseIs=3'移到最后一条记录
IfData1.Recordset.RecordCount<>0Then
IfData1.Recordset.EOF=FalseThenData1.Recordset.MoveNext
IfData1.Recordset.EOF=TrueThenData1.Recordset.MoveLast
EndIf
EndSelect
Callviewdata'调用函数
EndSub
PrivateSubComAdd_Click()'允许用户添加新记录
Fori=0To16
gys(i).Text=""
gys(i).Enabled=True
Nexti
ComSaveM.Visible=True:ComSaveA.Visible=False:ComSaveM.Enabled=True:ComE
上一篇:
VB电脑租赁系统(论文和程序)
下一篇:
餐饮管理系统