📄 frm编码维护.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frm编码维护
BorderStyle = 4 'Fixed ToolWindow
Caption = "编码维护"
ClientHeight = 6960
ClientLeft = 45
ClientTop = 270
ClientWidth = 5535
KeyPreview = -1 'True
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6960
ScaleWidth = 5535
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Height = 6840
Left = 120
TabIndex = 7
Top = 0
Width = 5295
Begin MSComctlLib.ListView lvwCode
Height = 5370
Left = 120
TabIndex = 12
Top = 210
Width = 3375
_ExtentX = 5953
_ExtentY = 9472
View = 3
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
NumItems = 2
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Text = "编码"
Object.Width = 1411
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Text = "名称"
Object.Width = 3951
EndProperty
End
Begin VB.Frame Frame2
Height = 1170
Left = 120
TabIndex = 8
Top = 5565
Width = 3375
Begin VB.TextBox txtFields
BackColor = &H80000018&
Height = 330
Index = 0
Left = 1320
TabIndex = 0
Top = 315
Width = 1935
End
Begin VB.TextBox txtFields
Height = 330
Index = 1
Left = 1320
TabIndex = 1
Top = 735
Width = 1935
End
Begin VB.Label Label1
Caption = "Label1"
Height = 225
Index = 1
Left = 120
TabIndex = 9
Top = 840
Width = 1095
End
Begin VB.Label Label1
Caption = "Label1"
Height = 330
Index = 0
Left = 120
TabIndex = 6
Top = 420
Width = 1095
End
End
Begin VB.Frame Frame3
Caption = "注意"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 3795
Left = 3600
TabIndex = 10
Top = 1785
Width = 1575
Begin VB.Label Label2
Caption = " 在视图中选择要修改的记录,在文本框输入正确的信息,点击“保存”按钮保存!"
ForeColor = &H00FF0000&
Height = 1065
Index = 1
Left = 120
TabIndex = 13
Top = 1785
Width = 1335
End
Begin VB.Label Label2
Caption = " 新增编码时先点击“新增”按钮,在文本框中输入相应信息,点击“保存”按钮保存!"
ForeColor = &H00FF0000&
Height = 1065
Index = 0
Left = 120
TabIndex = 11
Top = 630
Width = 1335
End
Begin VB.Label Label2
Caption = " 编码长度为2位!"
ForeColor = &H00FF0000&
Height = 435
Index = 3
Left = 120
TabIndex = 15
Top = 210
Width = 1335
End
Begin VB.Label Label2
Caption = " 在视图中选择要删除的记录,然后点击“删除”按钮"
ForeColor = &H00FF0000&
Height = 750
Index = 2
Left = 120
TabIndex = 14
Top = 2940
Width = 1335
End
End
Begin VB.CommandButton cmdExit
Height = 435
Left = 3840
Picture = "frm编码维护.frx":0000
Style = 1 'Graphical
TabIndex = 5
Top = 5985
Width = 1095
End
Begin VB.CommandButton cmdSave
Height = 435
Left = 3840
Picture = "frm编码维护.frx":14E4
Style = 1 'Graphical
TabIndex = 3
Top = 735
Width = 1095
End
Begin VB.CommandButton cmdDelete
Height = 435
Left = 3840
Picture = "frm编码维护.frx":29C8
Style = 1 'Graphical
TabIndex = 4
Top = 1260
Width = 1095
End
Begin VB.CommandButton cmdAddnew
Height = 435
Left = 3840
Picture = "frm编码维护.frx":3EAC
Style = 1 'Graphical
TabIndex = 2
Top = 210
Width = 1095
End
End
End
Attribute VB_Name = "frm编码维护"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public strTableName As String
Dim strColName As String
Dim adoQueryRs As New ADODB.Recordset
Dim blnAddOrEdit As Boolean
Private Sub cmdAddNew_Click()
Dim sqlstring As String
Dim rstmp As New ADODB.Recordset
Dim strFormatCode As String
Dim intNumber As Integer
On Error GoTo AddErr
blnAddOrEdit = True
' sqlstring = "select " & strColName & " from " & strTableName
' rstmp.Open sqlstring, cN, adOpenKeyset, adLockBatchOptimistic
'
' If rstmp.Recordcount <> 0 Then
' intNumber = IIf(IsNull(rstmp.Fields(0).Value), 1, rstmp.Fields(0).Value)
' Else
' intNumber = 1
' End If
'
'
' Select Case strTableName
' Case "ProduceType"
' strFormatCode = Format(intNumber, "0#")
' Case "BookType"
' strFormatCode = Format(intNumber, "000#")
' Case "PublishingCompanyData"
' strFormatCode = Format(intNumber, "000#")
' Case "ClientData"
' strFormatCode = Format(intNumber, "000#")
' Case Else
' End Select
txtFields(0).Text = ""
txtFields(0).BackColor = gColor_LockedText
txtFields(1).Text = ""
txtFields(0).SetFocus
Exit Sub
AddErr:
MsgBox "新增记录出错:" & Err.Description, vbInformation
End Sub
Private Sub CmdDelete_Click()
Dim intIndex As Integer '所选行的索引值
Dim itemX As ListItem
Dim sqlstring As String
On Error Resume Next
intIndex = lvwCode.SelectedItem.Index
Set itemX = lvwCode.ListItems(intIndex)
sqlstring = "delete from " & strTableName & " where " & strColName & "='" & txtFields(0).Text & "'"
cN.Execute (sqlstring)
lvwCode.ListItems.Remove (intIndex)
txtFields(0).Text = ""
txtFields(1).Text = ""
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub CmdSave_Click()
Dim rstmp As New ADODB.Recordset
Dim sqlstring As String
On Error GoTo SaveErr
'从记录表中查找是否存在该记录
sqlstring = "select * from " & strTableName & " where " & strColName & "='" & txtFields(0).Text & "'"
rstmp.Open sqlstring, cN, adOpenKeyset, adLockBatchOptimistic
If blnAddOrEdit Then '新增编码记录
rstmp.AddNew
End If
Select Case strTableName
Case "PublishingCompanyData"
rstmp.Fields("chrBenelux").Value = txtFields(1).Text
Case Else
End Select
rstmp.Fields(0).Value = txtFields(0).Text
rstmp.Fields(1).Value = txtFields(1).Text
rstmp.UpdateBatch adAffectCurrent
txtFields(0).Text = ""
txtFields(1).Text = ""
txtFields(0).BackColor = gColor_NormalText
Call Form_Load
Exit Sub
SaveErr:
MsgBox "保存记录时出错:" & Err.Description, vbInformation
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Call autoreturn(KeyCode)
End Sub
Private Sub Form_Load()
Dim sqlstring As String
Dim rstmp As New ADODB.Recordset
Dim itemX As ListItem
Dim j As Integer
On Error GoTo LoadErr
Me.Move 2800, 800
blnAddOrEdit = False
'设置相关表格与列名信息
Select Case strTableName
Case "ProduceType"
Me.Caption = "制品类型编码维护"
Label1(0).Caption = "制品类型编码:"
Label1(1).Caption = "制品类型名称:"
strColName = "ChrProduceNo"
Label2(3).Caption = " 编码长度为2位!"
sqlstring = "select * from " & strTableName & " order by ChrProduceNo"
Case "BookType"
Me.Caption = "图书分类编码维护"
Label1(0).Caption = "图书分类编码:"
Label1(1).Caption = "图书分类名称:"
strColName = "chrBookTypeNo"
Label2(3).Caption = " 编码长度为4位!"
sqlstring = "select * from " & strTableName & " order by chrBookTypeNo"
Case "PublishingCompanyData"
Me.Caption = "出版社编码维护"
Label1(0).Caption = "出版社编码:"
Label1(1).Caption = "出版社名称:"
strColName = "ChrCompanyNo"
Label2(3).Caption = " 编码长度为4位!"
sqlstring = "select * from " & strTableName & " order by ChrCompanyNo"
Case "ClientData"
Me.Caption = "客户编码维护"
Label1(0).Caption = "客户编码:"
Label1(1).Caption = "客户名称:"
strColName = "ChrClientNo"
Label2(3).Caption = " 编码长度为4位!"
sqlstring = "select * from " & strTableName & " order by ChrClientNo"
Case Else
End Select
Set adoQueryRs = New Recordset
adoQueryRs.Open sqlstring, cN, adOpenKeyset, adLockReadOnly
'清空编码记录视图
lvwCode.ListItems.Clear
'添加编码记录视图
Do While Not adoQueryRs.EOF
Set itemX = lvwCode.ListItems.Add(, , Trim(adoQueryRs.Fields(0)))
itemX.SubItems(1) = IIf(IsNull(adoQueryRs.Fields(1)), "", adoQueryRs.Fields(1))
adoQueryRs.MoveNext
Loop
Exit Sub
LoadErr:
MsgBox "启动时出错:" & Err.Description, vbInformation
End Sub
Private Sub lvwCode_Click()
Dim intIndex As Integer '所选行的索引值
Dim j As Integer
Dim itemX As ListItem
On Error Resume Next
intIndex = lvwCode.SelectedItem.Index
Set itemX = lvwCode.ListItems(intIndex)
txtFields(0).Text = itemX.Text
txtFields(1).Text = itemX.SubItems(1)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -