📄 form14.frm
字号:
BeginProperty Column05
DataField = "借出日期"
Caption = "借出日期"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column06
DataField = "审核人编号"
Caption = "审核人编号"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column07
DataField = "备注"
Caption = "备注"
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
Locked = -1 'True
ColumnWidth = 1005.165
EndProperty
BeginProperty Column01
ColumnWidth = 1005.165
EndProperty
BeginProperty Column02
ColumnWidth = 1005.165
EndProperty
BeginProperty Column03
ColumnWidth = 1005.165
EndProperty
BeginProperty Column04
ColumnWidth = 1005.165
EndProperty
BeginProperty Column05
ColumnWidth = 1005.165
EndProperty
BeginProperty Column06
ColumnWidth = 1005.165
EndProperty
BeginProperty Column07
Locked = -1 'True
ColumnWidth = 1005.165
EndProperty
EndProperty
End
Begin VB.Label Label14
Caption = "为了避免数据不一致,您只能删除本次添加的记录"
ForeColor = &H000000FF&
Height = 255
Left = 3840
TabIndex = 25
Top = 6615
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
ForeColor = &H000000FF&
Height = 240
Left = 180
TabIndex = 23
Top = 6615
Width = 3630
End
End
Attribute VB_Name = "Form14"
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 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 jiechu 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
count14 = StrNum
count1 = count1 + 1
End If
''''''''''''''***'''''''''''''
Else
count1 = 1
count14 = 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 < count14 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)
'修改该货品的库存数量
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(2).Text = "" Or Text1(4).Text = "" Or Text1(5).Text = "" Then
MsgBox "信息输入不完全!", 48, "保存信息提示"
Else
'IsNumeric函数用于判断输入的信息是否为数值型数据
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("insert into jiechu 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 + "'")
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
Else
End If
Call TRefresh
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 = "jiechu"
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 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)
count14 = count14 + 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()
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(7)
End If
End Sub
'*** 自定义数据刷新过程 ***
Private Sub TRefresh()
Adodc1.RecordSource = "select * from jiechu 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()
'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 Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -