📄 main_htgl_ygjb.frm
字号:
AllowUpdate = 0 'False
AllowArrows = 0 'False
BackColor = -2147483624
HeadLines = 1
RowHeight = 15
FormatLocked = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 3
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
BeginProperty Column02
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
ColumnWidth = 1365.165
EndProperty
BeginProperty Column01
ColumnWidth = 2759.811
EndProperty
BeginProperty Column02
ColumnWidth = 3660.095
EndProperty
EndProperty
End
End
Attribute VB_Name = "main_htgl_ygjb"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义整数变量,表示字段编号和数组编号
Dim i As Integer
'定义数据集对象
Dim rs1 As New ADODB.Recordset
Private Sub DataGrid1_Click()
On Error Resume Next
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End Sub
Private Sub Form_Activate()
'查询所有,并按"级别编号"排序
Sql = "select * from 员工级别表 order by 级别编号"
Call FunAdo(Adodc1, Sql)
Adodc1.Refresh
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
Me.Caption = Me.Caption & " " & frm_main.St1.Panels(3).text
ComSave.Enabled = False
End Sub
Private Sub Form_Load()
Sql = "select * from 员工级别表"
Call FunAdo(Adodc1, Sql)
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
Enter KeyCode '回车获得焦点
End Sub
Private Sub ComFirst_Click() '移到第一条记录
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
End Sub
Private Sub ComPrevious_Click() '向上移一条记录
If Adodc1.Recordset.RecordCount <> 0 Then
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
End Sub
Private Sub ComNext_Click() '向下移一条记录
If Adodc1.Recordset.RecordCount <> 0 Then
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
End Sub
Private Sub ComLast_Click() '移到最后一条记录
If Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
End Sub
Private Sub ComAdd_Click()
Dim dm As Integer
Set rs1 = New ADODB.Recordset
'打开连接
rs1.Open "select * from 员工级别表 order by 级别编号", cnn, adOpenKeyset, adLockOptimistic
'创建供应商编号
If rs1.RecordCount > 0 Then
If Not rs1.EOF Then rs1.MoveLast
If rs1.Fields("级别编号") <> "" Then
dm = Right(Trim(rs1.Fields("级别编号")), 3) + 1
Text1(0).text = Format(dm, "000")
End If
Else
Text1(0).text = "001"
End If
rs1.Close
For i = 1 To 2
Text1(i).Enabled = True
Text1(i).text = ""
Next i
Text1(1).SetFocus
ComAdd.Enabled = False
ComDelete.Enabled = False
ComModify.Enabled = False
ComSave.Enabled = True
ComEsc.Enabled = True
End Sub
Private Sub ComModify_Click()
If Adodc1.Recordset.RecordCount <> 0 Then
For i = 1 To 2
Text1(i).Enabled = True
Next i
ComSave.Enabled = True
ComEsc.Enabled = True
ComFirst.Enabled = False
ComPrevious.Enabled = False
ComNext.Enabled = False
ComLast.Enabled = False
ComAdd.Enabled = False
ComModify.Enabled = False
ComDelete.Enabled = False
Else
MsgBox ("没有要修改的数据!")
End If
End Sub
Private Sub ComDelete_Click()
'删除仓库信息
On Error Resume Next
Adodc1.Recordset.Delete
Adodc1.Refresh
If Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveLast
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
End Sub
Private Sub ComSave_Click()
Set rs1 = New ADODB.Recordset
'打开连接
rs1.Open "select * from 员工级别表 where 级别编号='" & Trim(Text1(0).text) & "'or 级别名称='" & Trim(Text1(1).text) & "'order by 级别编号", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
Dim a As String
a = MsgBox("确定要修改吗?", vbYesNo)
If a = vbYes Then
For i = 0 To 2
If Text1(1).text <> "" Then rs1.Fields(i) = Trim(Text1(i).text)
Text1(i).Enabled = False
Next i
rs1.Update
Adodc1.Refresh
End If
Else
If Text1(1).text <> "" Then
'添加仓库信息
rs1.AddNew
For i = 0 To 2
rs1.Fields(i) = Trim(Text1(i).text)
Text1(i).Enabled = False
Next i
'更新数据库
rs1.Update
Adodc1.Refresh
Else
MsgBox "请填写完整的信息"
End If
End If
'关闭数据集对象
rs1.Close
'设置控件状态
ComSave.Enabled = False
ComEsc.Enabled = False
ComFirst.Enabled = True
ComPrevious.Enabled = True
ComNext.Enabled = True
ComLast.Enabled = True
ComAdd.Enabled = True
ComModify.Enabled = True
ComDelete.Enabled = True
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
End Sub
Private Sub ComEsc_Click()
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveFirst
For i = 0 To 2
If Adodc1.Recordset.Fields(i) <> "" Then Text1(i).text = Adodc1.Recordset.Fields(i)
Text1(i).Enabled = False
Next i
End If
ComSave.Enabled = False
ComEsc.Enabled = False
ComFirst.Enabled = True
ComPrevious.Enabled = True
ComNext.Enabled = True
ComLast.Enabled = True
ComAdd.Enabled = True
ComModify.Enabled = True
ComDelete.Enabled = True
End Sub
Private Sub ComExit_Click()
Unload Me
frm_main.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -