📄 frmpzlb.frm
字号:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmpzlb
BackColor = &H00FF8080&
Caption = "票据类别名称管理"
ClientHeight = 5670
ClientLeft = 60
ClientTop = 345
ClientWidth = 6825
LinkTopic = "Form1"
ScaleHeight = 5670
ScaleWidth = 6825
StartUpPosition = 1 'CenterOwner
Begin VB.CommandButton cmdkmlb
Caption = "添加类别"
Height = 375
Index = 0
Left = 480
TabIndex = 8
Top = 960
Width = 1100
End
Begin VB.CommandButton cmdkmlb
Caption = "修改类别"
Height = 375
Index = 1
Left = 1920
TabIndex = 7
Top = 960
Width = 1100
End
Begin VB.CommandButton cmdkmlb
Caption = "查询类别"
Height = 375
Index = 2
Left = 3360
TabIndex = 6
Top = 960
Width = 1100
End
Begin VB.CommandButton cmdkmlb
Caption = "删除类别"
Height = 375
Index = 3
Left = 5040
TabIndex = 5
Top = 960
Width = 1100
End
Begin VB.CommandButton cmdkmlb
Caption = "下一个"
Height = 375
Index = 4
Left = 480
TabIndex = 4
Top = 1440
Width = 1100
End
Begin VB.CommandButton cmdkmlb
Caption = "上一个"
Height = 375
Index = 5
Left = 1920
TabIndex = 3
Top = 1440
Width = 1100
End
Begin VB.CommandButton cmdkmlb
Caption = "保存"
Enabled = 0 'False
Height = 375
Index = 6
Left = 3360
TabIndex = 2
Top = 1440
Width = 1100
End
Begin VB.CommandButton cmdkmlb
Caption = "退出"
Height = 375
Index = 7
Left = 5040
TabIndex = 1
Top = 1440
Width = 1100
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 3015
Left = 480
TabIndex = 0
Top = 2040
Width = 5775
_ExtentX = 10186
_ExtentY = 5318
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
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 Column01
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
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin MSDataListLib.DataCombo Dacompzlbmc
CausesValidation= 0 'False
Height = 315
Left = 3240
TabIndex = 9
Top = 360
Width = 1575
_ExtentX = 2778
_ExtentY = 556
_Version = 393216
Text = ""
End
Begin VB.Label Lablxr
BackStyle = 0 'Transparent
Caption = "票据类别名称"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1560
TabIndex = 10
Top = 360
Width = 1455
End
End
Attribute VB_Name = "frmpzlb"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim addrecord As Variant
'Dim usercheck As Boolean
Dim conn As New ADODB.Connection
Dim rspzlb As New ADODB.Recordset
'设置资金科目类别管理中按钮的状态
Private Sub setbuttonskh(bval As Boolean)
For i = 0 To 5
cmdkmlb(i).Enabled = bval
Next i
cmdkmlb(6).Enabled = Not bval
Dacompzlbmc.Enabled = Not bval
DataGrid1.Enabled = bval
If bval Then
cmdkmlb(7).Caption = "退出"
Else
cmdkmlb(7).Caption = "取消"
End If
Exit Sub
End Sub
'资金科目类别管理中记录增加或修改后的字段检验
Private Function pzlbcheck() As Boolean
Dim id As Integer
Dim str As String
Dim note(2) As String
note(0) = "票据类别名称不能为空!"
note(1) = "此票据类别名称已经存在!"
pzlbcheck = False
If Dacompzlbmc.Text = "" Then
MsgBox note(0)
Dacompzlbmc.SetFocus
Exit Function
End If
id = rspzlb.Fields("xuhao")
If addrecord = True Then
str = "select * from pzlb where pzlbmc='" & Dacompzlbmc.Text & "'"
Set rs = conn.Execute(str)
Else
str = "select * from pzlb where pzlbmc='" & Dacompzlbmc.Text & "' and xuhao <> '" & id & "'"
Set rs = conn.Execute(str)
End If
If rs.EOF Then
pzlbcheck = True
Else
MsgBox note(1)
'rspzlb.CancelBatch adAffectAllChapters
Dacompzlbmc.SetFocus
End If
Exit Function
End Function
Private Sub cmdkmlb_Click(Index As Integer)
Dim i As Integer
Dim result As Boolean
Dim m_name As String
Dim bookmark As Variant
On Error GoTo adderr
Select Case Index
Case 0 '添加按钮
addrecord = True
rspzlb.AddNew
setbuttonskh False
Dacompzlbmc.SetFocus
Exit Sub
Case 1 '修改按钮
addrecord = False
setbuttonskh False
Dacompzlbmc.SetFocus
Exit Sub
Case 2 '查询按钮
bookmark = rspzlb.bookmark
m_name = InputBox("请输入票据类别名称", "按票据类别名称搜索")
If m_name = "" Then
Exit Sub
End If
rspzlb.MoveFirst
rspzlb.Find "pzlbmc like '%" & m_name & "%'"
If rspzlb.EOF Then
rspzlb.MoveFirst
rspzlb.Find "pzlbmc like '%" & m_name & "%'"
If rspzlb.EOF Then
MsgBox "没有该票据类别名称!"
rspzlb.bookmark = bookmark
End If
'rspzlb.MoveFirst
End If
Exit Sub
Case 3 '删除按钮
If MsgBox("你确认要删除该条记录吗?", vbexclaimation + vbOKCancel, "记录删除") = vbCancel Then
Exit Sub
End If
With rspzlb
'删除该纪录
.Delete
.UpdateBatch adAffectCurrent
'If .RecordCount <= 0 Then
' Adodc1.Enabled = False
' Exit Sub
'End If
'移到下一条
.MoveNext
'如果到文件尾,移到最后一条
If .EOF Then .MoveLast
End With
Exit Sub
Case 4 '下一条
rspzlb.MoveNext
If rspzlb.EOF Then
MsgBox "这是最后一个记录!"
rspzlb.MovePrevious
End If
Exit Sub
Case 5 '上一条
rspzlb.MovePrevious
If rspzlb.BOF Then
MsgBox "这是第一个记录!"
rspzlb.MoveNext
End If
Exit Sub
Case 6 '保存按钮
result = pzlbcheck()
If result = True Then
rspzlb.UpdateBatch adAffectCurrent
setbuttonskh True
MsgBox "保存成功!"
'Adodc4.Refresh
End If
Exit Sub
Case 7 ' 退出或取消按钮
If cmdkmlb(Index).Caption = "退出" Then
Unload Me
Else
rspzlb.CancelUpdate
setbuttonskh True
Exit Sub
End If
End Select
Exit Sub
adderr:
MsgBox Err.Description
Unload Me
End Sub
Private Sub Form_Load()
Dim fieldname(2) As Variant
Dim wide(2) As Variant
Dim str As String
fieldname(0) = "序号"
fieldname(1) = "票据类别名称"
wide(0) = 400
wide(1) = 1400
'connstring = "Provider=SQLOLEDB.1;Password=db0822;Persist Security Info=True;User ID=sa;Initial Catalog=promotetest;Server=192.168.1.123"
'str = "Provider=SQLOLEDB.1;Password=090309;Persist Security Info=True;User ID=cw;Initial Catalog=ysgl2004;Data Source=CWSERVER"
If conn.State <> 1 Then
conn.CursorLocation = adUseClient
conn.Open nowconnectstring
End If
rspzlb.Open "select * from pzlb ", conn, adOpenDynamic, adLockBatchOptimistic
Set DataGrid1.DataSource = rspzlb
For i = 0 To 1
DataGrid1.Columns(i).Caption = fieldname(i)
DataGrid1.Columns(i).Width = wide(i)
DataGrid1.Columns(i).DataField = rspzlb.Fields(i).Name
Next i
Set Dacompzlbmc.DataSource = rspzlb
Dacompzlbmc.DataField = rspzlb.Fields("pzlbmc").Name
End Sub
Private Sub Form_Unload(Cancel As Integer)
'rs.Close
conn.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -