📄 form13.frm
字号:
End
Begin VB.Label Label8
Caption = "出库日期"
Height = 240
Left = 1995
TabIndex = 7
Top = 1530
Width = 885
End
Begin VB.Label Label7
Caption = "提货单位编号"
ForeColor = &H000000FF&
Height = 255
Left = 285
TabIndex = 6
Top = 1530
Width = 1200
End
Begin VB.Label Label5
Caption = "数量"
Height = 180
Left = 5055
TabIndex = 5
Top = 270
Width = 465
End
Begin VB.Label Label4
Caption = "类别编号"
ForeColor = &H000000FF&
Height = 210
Left = 3480
TabIndex = 4
Top = 270
Width = 915
End
Begin VB.Label Label3
Caption = "设备名称"
Height = 210
Left = 1935
TabIndex = 3
Top = 270
Width = 885
End
Begin VB.Label Label2
Caption = "业务编号"
Height = 240
Left = 330
TabIndex = 2
Top = 270
Width = 945
End
End
Begin VB.Label Label14
Caption = "为了避免数据不一致,您只能删除本次添加的记录"
ForeColor = &H000000FF&
Height = 255
Left = 4800
TabIndex = 27
Top = 6000
Width = 4095
End
Begin VB.Label Label6
BackColor = &H00C0FFC0&
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 270
Left = 255
TabIndex = 25
Top = 5940
Width = 4140
End
Begin VB.Label Label11
BackColor = &H008080FF&
Caption = "在您输入类别名称,提货单位编号,审核人编号时,只能参照弹出框表中的数据"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 270
Left = 285
TabIndex = 18
Top = 135
Width = 7575
End
Begin VB.Label Label1
BackColor = &H00C0FFFF&
Caption = "以下为已存在的出库信息"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 270
Left = 300
TabIndex = 1
Top = 3630
Width = 3195
End
End
Attribute VB_Name = "Form13"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim j1, j2, j3 As Integer
Dim i As Integer '运用在FOR循环中的变量
Dim StrTemp '用于显示编号信息的变量
Dim StrNum As Long '用于显示编号信息的变量
Dim count1 As Integer '控制全局变量count2只能获得最旧值
Private Sub Cmd_Add_Click()
On Error Resume Next
j1 = 1: j2 = 1: j3 = 1
For j = 0 To 6
Text1(j).Text = ""
Next j
Adodc1.RecordSource = "select * from chuku order by 业务编号"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveLast
StrNum = Val(Adodc1.Recordset.Fields("业务编号")) + 1
Text1(0).Text = Trim(Str(StrNum))
'''''''''''''***'''''''''''''
If count1 = 0 Then
count13 = StrNum
count1 = count1 + 1
End If
''''''''''''''***'''''''''''''
Else
count1 = 1
count13 = 1
Text1(0).Text = "1" '如果数据库中没有记录,则给编号赋一个初值
End If
Text1(1).SetFocus
cmd_save.Enabled = True
cmd_del.Enabled = False
End Sub
Private Sub Cmd_del_Click()
If Text1(2).Text = "" Then
MsgBox "请选择您要删除的记录!", 48, "提示"
Exit Sub
End If
If count1 = 0 Then '排除刚启动窗体时的删除'''''''''''''
MsgBox "您只能删除本次所添加的记录,不能删除以前记录!", 48, "提示"
Exit Sub
End If
If Text1(0).Text < count13 Then
MsgBox "您只能删除本次所添加的记录,不能删除以前记录!", 48, "提示"
Exit Sub
End If
''''''''''''''''''''''''''''''''''''''''
If Adodc1.Recordset.EOF = False Then
c = MsgBox("您确认要删除该记录吗?", 17, "删除提示信息")
If c = vbOK Then
d1 = Text1(3).Text
Adodc1.Recordset.Delete '删除货品出库信息记录
Adodc1.Refresh
Call main
adoRs.Open "select * from jiben_kc where 名称='" + Text1(1).Text + "'and 类别='" + Text1(2).Text + "'", adoCon, adOpenKeyset, adLockOptimistic
If adoRs.RecordCount > 0 Then
Dim SNum As Integer
'重新计算库存货品的数量
SNum = Val(adoRs.Fields("数量")) + Val(d1)
'修改该货品的库存数量
Set adoRs = adoCon.Execute("UPDATE jiben_kc SET 数量='" + Str(SNum) + "' where 名称='" + Text1(1).Text + "'and 类别='" + Text1(2).Text + "'")
End If
adoCon.Close
cmd_del.Enabled = False
End If
Else
MsgBox "当前数据库中已经没有可删除的记录", 64, "提示信息"
End If
Call TRefresh
End Sub
Private Sub Cmd_exit_Click()
Unload Me
End Sub
Private Sub Cmd_save_Click()
c = MsgBox("您确认要保存该信息吗?", 33, "保存信息提示")
If c = vbOK Then
If Text1(1).Text = "" Or Text1(3).Text = "" Or Text1(4).Text = "" Then
MsgBox "输入信息不完全!", 48, "保存信息提示"
Else
If Not IsNumeric(Text1(3).Text) Then
MsgBox "输入的货品数量必须为数值型数据", 48, "保存信息提示"
Else
Call main '调用公共模块中的连接数据库函数
adoRs.Open "select * from jiben_kc where 名称='" + Text1(1).Text + "'and 类别='" + Text1(2).Text + "'", adoCon, adOpenKeyset, adLockOptimistic
If adoRs.RecordCount > 0 Then
Dim SNum As Integer
SNum = Val(adoRs.Fields("数量")) - Val(Text1(3).Text) '计算库存中相应货品的数量
If SNum >= 0 Then
'修改库存中货品的数量
Set adoRs = adoCon.Execute("UPDATE jiben_kc SET 数量='" + Str(SNum) + "' where 名称='" + Text1(1).Text + "'and 类别='" + Text1(2).Text + "'")
'保存货品出库信息
Set adoRs = adoCon.Execute("insert into chuku values('" & Text1(0).Text & "','" & Text1(1).Text & "','" & Text1(2).Text & "','" & Text1(3).Text & "','" & Text1(4).Text & "','" & Str(DTPicker1.Value) & "','" & Text1(5).Text & "','" & Text1(6).Text & "')")
MsgBox "信息保存成功", 64, "保存信息提示"
cmd_save.Enabled = False
Else
Dim Strs As String
Strs = "该货品的库存数量为 " & adoRs.Fields("数量") & " ,货品出库数量不应大于其库存数量"
MsgBox Strs, 48, "提示信息"
End If
Else
MsgBox "对不起,库中没有你要的货品!", 48, "提示信息"
End If
adoCon.Close '关闭数据连接
End If
End If
End If
Call TRefresh '调用数据刷新过程
Call main '将库存中数量为0的货品清除掉
adoRs.Open "select * from jiben_kc ", adoCon, adOpenKeyset, adLockOptimistic
If adoRs.RecordCount > 0 Then
Set adoRs = adoCon.Execute("delete from jiben_kc where 数量='" + Str(0) + "'")
End If
adoCon.Close
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '如果按下的是回车键,则光标落到文本框当中
Text1(3).SetFocus
End If
End Sub
Private Sub Command1_Click()
tb = "chuku"
riqi = "出库日期"
Form17.Show 1
i = 1 ''''''''''''''''''''''''''''''''''判断查询,防止通用查询窗口带来‘’‘
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
Call JionBack '调用数据反绑定过程 '调用数据反绑定过程
cmd_del.Enabled = True
cmd_save.Enabled = False
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '如果按下的是回车键,则光标落到文本框当中
Text1(5).SetFocus
End If
End Sub
Private Sub Form_Load()
'利用代码连接数据库
Me.Left = (Screen.Width - Me.Width) / 2 '使窗体居中
Me.Top = (Screen.Height - Me.Height) / 2
DTPicker1.Value = Date
j1 = 1: j2 = 1: j3 = 1
Text1(2).Text = ""
Text1(4).Text = ""
Text1(5).Text = ""
count1 = 0
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sql = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
count13 = count13 + 1
i = 0
End Sub
Private Sub Text1_click(Index As Integer)
If Index = 2 Then
With Form9
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form9.Show 1
End If
If Index = 4 Then
Load Form8
With Form8
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form8.Show 1
End If
If Index = 5 Then
Load Form11
With Form11
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form11.Show 1
End If
End Sub
Private Sub Text1_GotFocus(Index As Integer)
If j1 = 1 And Index = 2 Then
j1 = 2
With Form9
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form9.Show 1
End If
If j2 = 1 And Index = 4 Then
j2 = 2
Load Form8
With Form8
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form8.Show 1
End If
If j3 = 1 And Index = 5 Then
j3 = 2
Load Form11
With Form11
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form11.Show 1
End If
End Sub
Private Sub Timer1_Timer() '通过时钟控件随时检测数据库中记录的条数
If Adodc1.Recordset.RecordCount > 0 Then
Label6.Caption = "目前数据库中共有 " & Adodc1.Recordset.RecordCount & " 条出库数据"
Else
Label6.Caption = "目前数据库中尚没有出库记录"
End If
End Sub
'*** 自定义的数据反绑定过程 ***
Private Sub JionBack()
Dim SLen As Integer
If Adodc1.Recordset.RecordCount > 0 Then
On Error Resume Next '执行错误处理
Text1(0).Text = Adodc1.Recordset(0)
Text1(1).Text = Adodc1.Recordset(1)
Text1(2).Text = Adodc1.Recordset(2)
Text1(3).Text = Adodc1.Recordset(3)
Text1(4).Text = Adodc1.Recordset(4)
DTPicker1.Value = Adodc1.Recordset(5)
Text1(5).Text = Adodc1.Recordset(6)
Text1(6).Text = Adodc1.Recordset(6)
End If
End Sub
'*** 自定义的数据刷新过程 ***
Private Sub TRefresh()
Adodc1.RecordSource = "select * from chuku order by 业务编号"
Adodc1.Refresh
End Sub
Private Sub Form_Activate()
If i = 1 Then
'sql1 = "select * from " & sql
If sql <> "" Then
Adodc1.RecordSource = sql1
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Call JionBack
Adodc1.Recordset.Update
Else
MsgBox "没有找到符合条件的记录!", 64, "提示窗口"
End If
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -