📄 fixgz.frm
字号:
VERSION 5.00
Begin VB.Form fixgz
Caption = "修改固定资产记录"
ClientHeight = 1710
ClientLeft = 60
ClientTop = 450
ClientWidth = 3525
LinkTopic = "Form1"
ScaleHeight = 1710
ScaleWidth = 3525
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 2520
TabIndex = 2
Top = 1080
Width = 735
End
Begin VB.CommandButton Command1
Caption = "查询"
Default = -1 'True
Height = 375
Left = 240
TabIndex = 1
Top = 1080
Width = 735
End
Begin VB.TextBox FID
Appearance = 0 'Flat
Height = 270
Left = 1800
TabIndex = 0
Top = 360
Width = 1455
End
Begin VB.Label Label1
Caption = "固定资产ID编号"
Height = 255
Left = 240
TabIndex = 3
Top = 360
Width = 1455
End
End
Attribute VB_Name = "fixgz"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim sql As String
Dim rs As New ADODB.Recordset
Dim i As Integer
If FID.Text = "" Then '固定资产编号不可为空
MsgBox "请输入固定资产编号!", vbExclamation
FID.SetFocus
Exit Sub
End If
imjl.Left = (Screen.Width - imjl.ScaleWidth) / 2 '修改固定资产窗体居中化
imjl.Top = (Screen.Height - imjl.ScaleHeight) / 2
If DbHandle.DbConnection Then
sql = "TBL_PART" '提取部门表的所有静态记录
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Filter = ""
rs.Open sql, DbFinance
Do While rs.EOF = False '将结果集加入修改固定资产窗体的下拉列表中
imjl.PartCombo.AddItem (rs("PART_NAME"))
imjl.PartCombo.ItemData(imjl.PartCombo.NewIndex) = rs("PART_ID")
rs.MoveNext
Loop
rs.Close '释放数据库
Set rs = Nothing
DbHandle.DbClose
Else '数据库连接无法打开,显示出错窗体,退出
MsgBox "数据库错误!", vbExclamation
DbHandle.DbClose
End
End If
If DbHandle.DbConnection Then
sql = "TBL_FIXED" '打开固定资产表,搜索定位修改的固定资产是否存在
rs.CursorType = adOpenDynamic
rs.LockType = adLockOptimistic
rs.Filter = "FIXED_ID='" & FID.Text & "'"
rs.Open sql, DbFinance
If DbHandle.resultcount(rs) <> 1 Then '不存在,出错退出
MsgBox "错误,不存在的固定资产记录!", vbExclamation
FID.SetFocus
rs.Close
Set rs = Nothing
DbHandle.DbClose
Exit Sub
End If
'存在记录,设置修改固定资产窗体的各个元素默认值为记录的各个字段属性
imjl.Text1.Text = rs("FIXED_ID") '固定资产编号
imjl.Text2.Text = rs("FIXED_NAME") '固定资产名称
imjl.Text3.Text = Trim(Str(rs("FIXED_NUM"))) '固定资产个数
imjl.Text4.Text = Trim(Str(rs("FIXED_MONEY"))) '固定资产单价
imjl.Text5.Text = rs("FIXED_PHONE") '联系人电话
imjl.Text6.Text = rs("FIXED_REMARK") '固定资产说明
imjl.Text7.Text = rs("FIXED_USER") '经手人ID
imjl.DTPicker1.Value = rs("FIXED_DATE") '固定资产购买日期
imjl.Text7.MaxLength = 100
imjl.PartCombo.Text = ""
For i = 0 To imjl.PartCombo.ListCount - 1 '循环设置固定资产购买部门
If imjl.PartCombo.ItemData(i) = rs("FIXED_PART") Then
imjl.PartCombo.ListIndex = i
Exit For
End If
Next i
rs.Close '设置完成,释放结果集
Set rs = Nothing
DbHandle.DbClose
imjl.Show 1 '修改固定资产窗体显示
Unload Me '完成固定资产修改,退出
Else
MsgBox "数据库错误!", vbExclamation
DbHandle.DbClose
End
End If
End Sub
Private Sub Command2_Click()
Me.Hide '返回主窗体
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.ScaleWidth) / 2 '窗体居中显示
Me.Top = (Screen.Height - Me.ScaleHeight) / 2
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next '窗体关闭时关闭数据库连接
DbHandle.DbClose
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -