📄 form15.frm
字号:
BackColor = &H00C0FFC0&
Height = 315
Index = 0
Left = 1080
TabIndex = 11
Top = 195
Width = 1410
End
Begin VB.Label Label8
Caption = "归还日期"
Height = 285
Left = 105
TabIndex = 10
Top = 2190
Width = 825
End
Begin VB.Label Label7
Caption = "备注"
Height = 285
Left = 105
TabIndex = 9
Top = 2985
Width = 825
End
Begin VB.Label Label6
Caption = "审核人编号"
ForeColor = &H000000FF&
Height = 270
Left = 105
TabIndex = 8
Top = 2580
Width = 975
End
Begin VB.Label Label5
Caption = "归还部门"
ForeColor = &H000000FF&
Height = 285
Left = 105
TabIndex = 7
Top = 1794
Width = 825
End
Begin VB.Label Label4
Caption = "归还数量"
Height = 285
Left = 105
TabIndex = 6
Top = 1398
Width = 825
End
Begin VB.Label Label3
Caption = "类别编号"
ForeColor = &H000000FF&
Height = 285
Left = 105
TabIndex = 5
Top = 1002
Width = 825
End
Begin VB.Label Label2
Caption = "设备名称"
ForeColor = &H00000000&
Height = 285
Left = 105
TabIndex = 4
Top = 606
Width = 825
End
Begin VB.Label Label1
Caption = "业务编号"
Height = 285
Left = 105
TabIndex = 3
Top = 210
Width = 825
End
End
Begin VB.Label Label14
Caption = "为了避免数据不一致,您只能删除本次添加的记录"
ForeColor = &H000000FF&
Height = 255
Left = 3240
TabIndex = 25
Top = 5280
Width = 4095
End
Begin VB.Label Label9
BackColor = &H00FFC0FF&
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 180
TabIndex = 22
Top = 5220
Width = 3075
End
End
Attribute VB_Name = "Form15"
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 num As Integer '定义计算该部门借的该设备的总数量的变量
Dim num1 As Integer
Dim xx As Integer
Dim count1 As Integer '控制全局变量count2只能获得最旧值
Private Sub Cmd_Add_Click()
num = 0: num1 = 0
On Error Resume Next
j1 = 1: j2 = 1: j3 = 1
For j = 0 To 6
Text1(j).Text = ""
Next j
Adodc1.RecordSource = "select * from guihuan 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
count15 = StrNum
count1 = count1 + 1
End If
''''''''''''''***'''''''''''''
Else
count1 = 1
count15 = 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 < count15 Then
MsgBox "您只能删除本次所添加的记录,不能删除以前记录!", 48, "提示"
Exit Sub
End If
''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''
If Adodc1.Recordset.EOF = False Then
c = MsgBox("您确认要删除该记录吗?", 17, "删除提示信息")
If c = vbOK Then
xx = Val(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(xx)
'修改该货品的库存数量
adoRs.Update
Set adoRs = adoCon.Execute("UPDATE jiben_kc SET 数量='" + Str(SNum) + "' where 名称='" + Text1(1).Text + "'and 类别='" + Text1(2).Text + "'")
End If
adoCon.Close
For i = 0 To 6
Text1(i).Text = ""
Next i
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(4).Text = "" Or Text1(2).Text = "" Or Text1(3).Text = "" Or Text1(5).Text = "" Then
MsgBox "信息不完全!", 48, "保存信息提示"
Else
If Not IsNumeric(Text1(3).Text) Then '强制转换输入的信息为数值型数据
MsgBox "输入的货品数量必须为数值型数据", 48, "保存信息提示"
Else
Call main '调用公共模块连接数据库函数
'以下计算该部门借的该设备的总数量 num
Adodc2.RecordSource = "select * from jiechu where 设备名称='" & Text1(1).Text & "' and 类别名称='" & Text1(2).Text & "' and 借货单位='" & Text1(4).Text & "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
With Adodc2.Recordset
.MoveFirst
again: num = num + Val(.Fields("借出数量"))
.MoveNext
If .EOF = False Then GoTo again
End With
End If
'该部门借的该设备的总数为 num
'以下计算该部门已归还的该设备的总数量num1
Adodc2.RecordSource = "select * from guihuan where 设备名称='" & Text1(1).Text & "' and 类别编号='" & Text1(2).Text & "' and 归还单位='" & Text1(4).Text & "'"
Adodc2.Refresh
num1 = 0
If Adodc2.Recordset.RecordCount > 0 Then
With Adodc2.Recordset
.MoveFirst
again1: num1 = num1 + Val(.Fields("归还数量"))
.MoveNext
If .EOF = False Then GoTo again1
End With
End If
'该部门归还的该设备的总数为 num1
num2 = num - num1 - Val(Text1(3).Text)
If num2 < 0 Then
Strs = "该部门对该货品的借出数量为:"
strs1 = "该部门对该货品的已归还数量为:"
ss = "您本次欲归还的货品数量为:"
strs2 = "货品归还数量不应大于其借出的数量"
MsgBox Strs & Str(num) & Chr(13) + Chr(10) & strs1 & Str(num1) & Chr(13) + Chr(10) & ss & Str(Text1(3).Text) & Chr(13) + Chr(10) & strs2, 48, "输入错误提示信息"
cmd_save.Enabled = False
adoCon.Close '*******一定要注意‘退出时的连接处理’
Exit Sub
Else ''**以下表示用户输入正确,修改相应数据**
adoRs.Open "select * from jiben_kc where 名称='" + Text1(1).Text + "'and 类别='" + Text1(2).Text + "'", adoCon, adOpenKeyset, adLockOptimistic
If adoRs.RecordCount > 0 Then
SNum = Val(adoRs.Fields("数量")) + Val(Text1(3).Text) '计算归还货品的库存数量
'保存货品归还信息
adoRs.Update
Set adoRs = adoCon.Execute("insert into guihuan 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 & "')")
'修改归还货品的库存数量信息
Set adoRs = adoCon.Execute("UPDATE jiben_kc SET 数量='" + Str(SNum) + "' where 名称='" + Text1(1).Text + "'and 类别='" + Text1(2).Text + "'")
'修改归还货品的借出数据表中的数量信息
num3 = num - num1 - Val(Text1(3).Text)
MsgBox "信息保存成功,该部门对该货品的未还数量为" & num3, 64, "保存信息提示"
cmd_save.Enabled = False
adoCon.Close '关闭数据连接 ''''*******必须在这*************
End If
End If
End If
End If
End If
Call TRefresh '调用数据刷新过程
End Sub
Private Sub Command1_Click()
tb = "guihuan"
riqi = "归还日期"
Form17.Show 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 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
num = 0
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)
count15 = count15 + 1
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 Form7
With Form7
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form7.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 Form7
With Form7
.Frame2.Visible = False
.Frame3.Visible = True
End With
Form7.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 JionBack()
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(7)
End If
End Sub
'*** 自定义数据刷新过程 ***
Private Sub TRefresh()
Adodc1.RecordSource = "select * from guihuan order by 业务编号"
Adodc1.Refresh
End Sub
Private Sub Timer1_Timer() '通过时钟控件随时检测数据库中记录的条数
If Adodc1.Recordset.RecordCount > 0 Then
Label9.Caption = "目前数据库中共有 " & Adodc1.Recordset.RecordCount & " 条归还货品数据"
Else
Label9.Caption = "目前数据库中尚没有归还记录"
End If
End Sub
Private Sub Form_Activate()
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 Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -