Module1.bas
上传用户:darkchong
上传日期:2007-06-21
资源大小:44k
文件大小:2k
- Attribute VB_Name = "Module1"
- Public fMainForm As frmMain
- Public gintSmode As Integer 'for service
- Public gintPmode As Integer 'for plane
- Public gintAmode As Integer 'for airline
- Public gintTmode As Integer 'for customertype
- Public gintCmode As Integer 'for customer
- Public gintKmode As Integer 'for ticket
- Sub Main()
- Dim fLogin As New frmLogin
- fLogin.Show vbModal
- If Not fLogin.OK Then
- 'Login Failed so exit app
- End
- End If
- Unload fLogin
- Set fMainForm = New frmMain
- fMainForm.Show
- End Sub
- Public Function ConnectString() _
- As String
- 'returns a DB ConnectString
- ConnectString = "FileDSN=ticket.dsn;UID=sa;PWD="
- End Function
- Public Function ExecuteSQL(ByVal SQL _
- As String, MsgString As String) _
- As ADODB.Recordset
- 'executes SQL and returns Recordset
- Dim cnn As ADODB.Connection
- Dim rst As ADODB.Recordset
- Dim sTokens() As String
-
- On Error GoTo ExecuteSQL_Error
-
- sTokens = Split(SQL)
- Set cnn = New ADODB.Connection
- cnn.Open ConnectString
- If InStr("INSERT,DELETE,UPDATE", _
- UCase$(sTokens(0))) Then
- cnn.Execute SQL
- MsgString = sTokens(0) & _
- " query successful"
- Else
- Set rst = New ADODB.Recordset
- rst.Open Trim$(SQL), cnn, _
- adOpenKeyset, _
- adLockOptimistic
- 'rst.MoveLast 'get RecordCount
- Set ExecuteSQL = rst
- MsgString = "查询到" & rst.RecordCount & _
- " 条记录 "
- End If
- ExecuteSQL_Exit:
- Set rst = Nothing
- Set cnn = Nothing
- Exit Function
-
-
- ExecuteSQL_Error:
- MsgString = "查询错误: " & _
- Err.Description
- Resume ExecuteSQL_Exit
- End Function
- Public Sub EnterToTab(Keyasc As Integer)
- If Keyasc = 13 Then
- SendKeys "{TAB}"
- End If
- End Sub
- Public Function GetRkno() As String
- GetRkno = Format(Now, "yymmddhhmmss")
- Randomize
- GetRkno = GetRkno & Int((99 - 10 + 1) * Rnd + 10)
- End Function