Option Compare Databasesql
Private sqladdress As String數據庫
Private PrintSavebool As Booleanide
'程序初始化
Private Sub Init()
sqladdress = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=U:\2.Personal\Ye\log.mdb;Persist Security Info=False"it
PrintSavebool = Falseio
End Subselect
'判斷是是否存在在數據庫中
'2014.09.02程序
'用於查看im
Private Sub CheckOrder(ordernumber As String)error
PrintSavebool = False數據
On Error GoTo ErrHandle
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Set rs = Nothing
SQL = "select [DT] from [PrintLog] where [ORDERID]=" + "'" + ordernumber + "'"
conn.Open sqladdress
rs.Open SQL, conn
If Not rs.EOF Then
' If MsgBox("order number:" + ordernumber + "Print had Done,Time:" + CStr(rs!DT) + " continue?", vbYesNo) = vbYes Then
'Else
'Cancle = True
'End If
MsgBox "order number:" + ordernumber + "Print had Done,Time:" + CStr(rs!DT) + " continue?"
PrintSavebool = False
Else
PrintSavebool = True
End If
rs.Close
Set rs = Nothing
Exit Sub
'錯誤處理
ErrHandle:
MsgBox "check log database error"
Exit Sub
End Sub
'把打印記錄放到數據庫中
'2014.09.02
Public Sub SaveOrder(ordernumber As String)
If PrintSavebool = False Then
Exit Sub
End If
On Error GoTo ErrHandle
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Set rs = Nothing
SQL = "insert into [PrintLog]([ORDERID],[DT]) values (" + "'" + ordernumber + "'" + "," + "'" + CStr(Now) + "'" + ")"
conn.Open sqladdress
rs.Open SQL, conn
Set rs = Nothing
Exit Sub
'錯誤處理
ErrHandle:
MsgBox "record log error"
Exit Sub
End Sub
'Private Sub Report_Page()
''Call Log(Label0.Caption)
'End Sub
'在打印
Public Sub Log(ordernumber As String)
Call Init
Call CheckOrder(ordernumber)
Call SaveOrder(ordernumber)
End Sub