📄 import.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form import
BorderStyle = 1 'Fixed Single
Caption = "考勤数据导入"
ClientHeight = 3540
ClientLeft = 45
ClientTop = 435
ClientWidth = 5760
Icon = "import.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3540
ScaleWidth = 5760
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command4
Caption = "退出"
Height = 615
Left = 5040
TabIndex = 11
Top = 2760
Width = 615
End
Begin VB.CommandButton Command3
Caption = "导入数据"
Height = 615
Left = 3960
TabIndex = 5
Top = 2760
Width = 975
End
Begin VB.Frame Frame1
Caption = "日期范围"
Height = 1575
Left = 120
TabIndex = 4
Top = 1080
Width = 5535
Begin MSComCtl2.DTPicker DTPicker2
Height = 375
Left = 3600
TabIndex = 7
Top = 480
Width = 1575
_ExtentX = 2778
_ExtentY = 661
_Version = 393216
Format = 25296897
CurrentDate = 39850
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 375
Left = 1200
TabIndex = 6
Top = 480
Width = 1455
_ExtentX = 2566
_ExtentY = 661
_Version = 393216
Format = 25296897
CurrentDate = 39850
End
Begin VB.Label Label3
Caption = "至"
Height = 255
Left = 3120
TabIndex = 9
Top = 480
Width = 375
End
Begin VB.Label Label2
Caption = "从"
Height = 255
Left = 720
TabIndex = 8
Top = 480
Width = 615
End
End
Begin VB.CommandButton Command2
Caption = "保存设置"
Height = 375
Left = 4680
TabIndex = 3
Top = 600
Width = 975
End
Begin VB.CommandButton Command1
Caption = "浏览"
Height = 375
Left = 3960
TabIndex = 2
Top = 600
Width = 615
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 2640
Top = 2880
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.TextBox Text1
Height = 375
Left = 1440
TabIndex = 0
Top = 120
Width = 4215
End
Begin VB.Label Label4
Caption = "欢迎使用!"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 120
TabIndex = 10
Top = 2880
Width = 3735
End
Begin VB.Label Label1
Caption = "浩顺晶密数据库路径"
Height = 495
Left = 120
TabIndex = 1
Top = 120
Width = 1095
End
End
Attribute VB_Name = "import"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sqlcon As New ADODB.Connection
Dim acon As New ADODB.Connection
Private Sub Command1_Click()
CommonDialog1.Filter = "*.mdb|*.mdb"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
Text1 = CommonDialog1.FileName
End If
End Sub
Private Sub Command2_Click()
SaveSetting "nherp", "Settings", "ctnid", Text1.Text
End Sub
Private Sub Command3_Click()
Dim sfile As String
Dim rstmp As New ADODB.Recordset
Dim sql As String
Dim sclock_id As String
Dim scard_id As String
Dim sdate As String
Dim stime As String
On Error GoTo errline:
If Dir(Text1.Text) = "" Then
MsgBox "找不到浩顺考勤数据库,请重新设置数据库路径!", vbExclamation, "系统提示"
Exit Sub
Else
sfile = Trim(Text1.Text)
End If
If acon.State = 1 Then acon.Close
Me.MousePointer = 11
Dim sCn As String
sCn = "Provider=Microsoft.Jet.OLEDB.4.0;"
sCn = sCn & "Data Source=" & sfile & ";password='';"
acon.CursorLocation = adUseClient
acon.Open sCn
sql = "select clock_id,card_id,sign_time from tmptrecords where year(sign_time)>=" & Year(Me.DTPicker1.Value) & " and month(sign_time)>=" & Month(Me.DTPicker1.Value) & " and day(sign_time)>=" & Day(Me.DTPicker1.Value) & " and year(sign_time)<=" & Year(Me.DTPicker2.Value) & " and month(sign_time)<=" & Month(Me.DTPicker2.Value) & " and day(sign_time)<=" & Day(Me.DTPicker2.Value)
rstmp.Open sql, acon, adOpenKeyset, adLockReadOnly
Do While Not rstmp.EOF
sclock_id = ""
scard_id = ""
sdate = ""
stime = ""
sclock_id = rstmp(0)
scard_id = rstmp(1)
sdate = Format(rstmp(2).Value, "yyyy/mm/dd")
stime = Format(rstmp(2).Value, "hhmm")
sql = "if not exists(select * from attmachine where id_card='" & scard_id & "' and id_date='" & sdate & "' and id_time='" & stime & "')" & Chr(10) _
& " insert into attmachine(id,id_card,id_date,id_time) values ('" & sclock_id & "','" & scard_id & "','" & sdate & "','" & stime & "')"
sqlcon.Execute sql
rstmp.MoveNext
Loop
Me.Label4.Caption = "数据导入完毕,谢谢!"
Me.MousePointer = 0
Exit Sub
errline:
Me.Label4.Caption = "数据导入错误,请稍后重试!"
Me.MousePointer = 0
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.DTPicker1.Value = DateAdd("D", -1, Date)
Me.DTPicker2.Value = Date
Text1.Text = GetSetting("nherp", "Settings", "ctnid")
Dim constr As String
constr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=cy_hr;Data Source=fred"
sqlcon.ConnectionString = constr
sqlcon.ConnectionTimeout = 60
sqlcon.CursorLocation = adUseClient
sqlcon.Open
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -