?? frmmanrecord1.frm
字號:
Caption = "姓 名:"
Height = 255
Index = 1
Left = 240
TabIndex = 29
Top = 720
Width = 975
End
Begin VB.Label Label2
Caption = "性 別:"
Height = 255
Index = 2
Left = 240
TabIndex = 28
Top = 1440
Width = 975
End
Begin VB.Label Label2
Caption = "學 歷:"
Height = 255
Index = 3
Left = 240
TabIndex = 27
Top = 2520
Width = 975
End
Begin VB.Label Label2
Caption = "專 業:"
Height = 255
Index = 4
Left = 240
TabIndex = 26
Top = 2880
Width = 975
End
Begin VB.Label Label2
Caption = "生 日:"
Height = 255
Index = 12
Left = 240
TabIndex = 25
Top = 1800
Width = 975
End
Begin VB.Label Label2
Caption = "籍 貫:"
Height = 255
Index = 13
Left = 240
TabIndex = 24
Top = 2160
Width = 975
End
Begin VB.Label Label2
Caption = "部 門:"
Height = 255
Index = 16
Left = 240
TabIndex = 23
Top = 1080
Width = 975
End
End
Begin VB.CommandButton cmdExit
Caption = "返回 (&X)"
Height = 375
Left = 6600
TabIndex = 21
Top = 6120
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存 (&S)"
Height = 375
Left = 5040
TabIndex = 20
Top = 6120
Width = 1215
End
End
Attribute VB_Name = "frmManRecord1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'是否改動過記錄,ture為改過
Dim mblChange As Boolean
Public txtSQL As String
Dim mrc As ADODB.Recordset
'操作的表名稱
Private Sub cboItem_Change()
'有變化設置gblchange
mblChange = True
End Sub
Private Sub cboItem_KeyDown(KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Sub cmdExit_Click()
If mblChange And cmdSave.Enabled Then
If MsgBox("保存當前記錄的變化嗎?", vbOKCancel + vbExclamation, "警告") = vbOK Then
'保存
Call cmdSave_Click
End If
End If
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim txtSQL As String
Dim MsgText As String
Dim sMeg As String
Dim i As Integer
For intCount = 0 To 2
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "編號"
Case 1
sMeg = "姓名"
Case 3
sMeg = "部門"
End Select
sMeg = sMeg & "不能為空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
If Trim(txtItem(3) & " ") <> "" Then
If Not IsDate(txtItem(3)) Then
MsgBox "生日應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(3).SetFocus
Exit Sub
Else
txtItem(3) = Format(txtItem(3), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(7) & " ") <> "" Then
If Not IsDate(txtItem(7)) Then
MsgBox "參加工作時間應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(7).SetFocus
Exit Sub
Else
txtItem(7) = Format(txtItem(7), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(8) & " ") <> "" Then
If Not IsDate(txtItem(8)) Then
MsgBox "入黨時間應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(8).SetFocus
Exit Sub
Else
txtItem(8) = Format(txtItem(8), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(10) & "") <> "" Then
If Not IsDate(txtItem(10)) Then
MsgBox "職稱時間應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(10).SetFocus
Exit Sub
Else
txtItem(10) = Format(txtItem(10), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(14) & "") <> "" Then
If Not IsDate(txtItem(14)) Then
MsgBox "進入公司時間應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(14).SetFocus
Exit Sub
Else
txtItem(14) = Format(txtItem(14), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(15) & "") <> "" Then
If Not IsDate(txtItem(15)) Then
MsgBox "起薪時間應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(15).SetFocus
Exit Sub
Else
txtItem(15) = Format(txtItem(15), "yyyy-mm-dd")
End If
End If
If Trim(txtItem(16) & "") <> "" Then
If Not IsDate(txtItem(16)) Then
MsgBox "調入時間應輸入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
txtItem(16).SetFocus
Exit Sub
Else
txtItem(16) = Format(txtItem(16), "yyyy-mm-dd")
End If
End If
'添加判斷是否有相同的ID記錄
If gintMode = 1 Then
txtSQL = "select * from manrecord where ygid='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已經存在此員工檔案編號的記錄!", vbOKOnly + vbExclamation, "警告"
txtItem(0).SetFocus
txtItem(0).SelStart = 0
txtItem(0).SelLength = Len(txtItem(0))
Exit Sub
End If
mrc.Close
End If
'先刪除已有記錄
txtSQL = "delete from manrecord where ygid='" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新記錄
txtSQL = "select * from manrecord"
Set mrc = ExecuteSQL(txtSQL, MsgText)
mrc.AddNew
For intCount = 0 To 2
mrc.Fields(intCount) = Trim(txtItem(intCount))
Next intCount
mrc.Fields(3) = Trim(cboItem.Text)
For intCount = 3 To 18
mrc.Fields(intCount + 1) = Trim(txtItem(intCount))
Next intCount
mrc.Update
If gintMode = 1 Then
MsgBox "記錄添加成功!", vbOKOnly + vbExclamation, "警告"
For i = 0 To 18
txtItem(i).Text = ""
mblChange = False
Next i
frmManRecord1.Show
frmManRecord1.ZOrder 0
frmManRecord.ShowTitle
frmManRecord.txtSQL = "select * from manrecord"
frmManRecord.ShowData
frmManRecord.ZOrder 1
Else
MsgBox "記錄修改成功!", vbOKOnly + vbExclamation, "警告"
Unload Me
frmManRecord.ShowTitle
frmManRecord.txtSQL = "select * from manrecord"
frmManRecord.ShowData
frmManRecord.ZOrder 0
End If
gintMode = 0
End Sub
Private Sub Form_Load()
Dim MsgText As String
Dim intCount As Integer
With cboItem
.AddItem "男"
.AddItem "女"
End With
If gintMode = 1 Then
Me.Caption = Me.Caption & "添加"
cboItem.ListIndex = 0
ElseIf gintMode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
For intCount = 0 To 2
txtItem(intCount) = .Fields(intCount)
Next intCount
If Not IsNull(!ygsex) Then
cboItem = !ygsex
End If
For intCount = 3 To 18
If Not IsNull(.Fields(intCount + 1)) Then
txtItem(intCount) = .Fields(intCount + 1)
End If
Next intCount
End With
txtItem(0).Enabled = False
End If
mrc.Close
Me.Caption = Me.Caption & "修改"
End If
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
'MsgBox "realy want to quit?", vbOKOnly + vbExclamation, "quit"
End Sub
Private Sub txtItem_Change(Index As Integer)
'有變化設置gblchange
mblChange = True
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -