?? main_htgl_ygjb.frm
字號:
Height = 1980
Left = 75
TabIndex = 12
Top = 2190
Width = 8220
_ExtentX = 14499
_ExtentY = 3493
_Version = 393216
AllowUpdate = 0 'False
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
'定義整數(shù)變量,表示字段編號和數(shù)組編號
Dim i As Integer
'定義數(shù)據(jù)集對象
Dim rs1 As New ADODB.Recordset
Private Sub Form_Activate()
'查詢所有,并按"級別編號"排序
Adodc1.RecordSource = "select * from 員工級別表 order by 級別編號"
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_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
'創(chuàng)建供應(yīng)商編號
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 ("沒有要修改的數(shù)據(jù)!")
End If
End Sub
Private Sub ComDelete_Click()
'刪除倉庫信息
On Error Resume Next
Adodc1.Recordset.Delete
Adodc1.Refresh
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
'更新數(shù)據(jù)庫
rs1.Update
Adodc1.Refresh
Else
MsgBox "請?zhí)顚懲暾男畔?quot;
End If
End If
'關(guān)閉數(shù)據(jù)集對象
rs1.Close
'設(shè)置控件狀態(tài)
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 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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -