⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 publicmodule.bas

📁 汽车维修管理软件。其中包含三个编辑控件。
💻 BAS
字号:
Attribute VB_Name = "PublicModule"
Enum PopupMode
     PM_ADD = 1
     PM_EDIT = 2
     PM_VIWE = 3
End Enum
Enum ReturnCode
     RC_ERROR = -1
     RC_NOTHING = 0
     RC_OK = 1
     RC_CANCET = 2
End Enum
Enum FieldType
     FT_NUMBER = 1
     FT_CHAR = 2
End Enum
Enum WorkMode
     WM_NOTHING = 0
     WM_ADD = 1
     WM_EDIT = 2
     WM_DELETE = 3
End Enum
Public Enum FindType
       Find_From_AutoId = 0
       Find_From_Code = 1
       Find_From_Name = 2
End Enum
Public g_Provider As String
Public g_DataSource As String
Public g_Conn As ADODB.Connection

'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\汽车修理管理\Data.mdb;Persist Security Info=False
Public Sub main()
Dim t_logonDlg As LogonDlg
Set t_logonDlg = New LogonDlg
If t_logonDlg.DoModal() = ReturnCode.RC_OK Then
   g_Provider = "Microsoft.Jet.OLEDB.4.0"

   g_DataSource = App.Path & "\" & t_logonDlg.DataName
   Set g_Conn = New ADODB.Connection
   With g_Conn
        .Provider = g_Provider
        .CommandTimeout = 7
        .ConnectionTimeout = 10
        .Open g_DataSource
   End With
   Set t_logonDlg = Nothing
   Load MainWin
   MainWin.Show
End If
Set t_logonDlg = Nothing
End Sub
Public Function SQLFind(pCode As String, pTableName As String, pFieldName As String, pFieldType As FieldType) As ADODB.Recordset
Dim re As ADODB.Recordset
Dim com As String
com = "SELECT * FROM " & pTableName & " WHERE " & pFieldName & "="
If pFieldType = FT_CHAR Then
   com = com & "'" & pCode & "'"
Else
   com = com & pCode
End If
If g_Conn Is Nothing Then
Set g_Conn = New ADODB.Connection
With g_Conn
    .Provider = g_Provider
    .CommandTimeout = 7
    .ConnectionTimeout = 10
    .Open g_DataSource
End With
End If
If g_Conn.State = adStateClosed Then
   g_Conn.Open g_DataSource
End If
Set re = g_Conn.Execute(com)
Set SQLFind = re
Set re = Nothing

End Function
Public Function SQLFindIsNull(pCode As String, pTableName As String, pFieldName As String, pFieldType As FieldType) As Boolean
Dim re As ADODB.Recordset
Set re = SQLFind(pCode, pTableName, pFieldName, pFieldType)
If re.BOF And re.EOF Then
   SQLFindIsNull = True
Else
   SQLFindIsNull = False
End If
Set re = Nothing
End Function
Public Function FindListIndex(pText As String, ByRef pListBox As ComboBox) As Long
Dim i As Long
For i = 0 To pListBox.ListCount - 1
   If pText = pListBox.List(i) Then
      FindListIndex = i
      Exit Function
   End If
Next i
FindListIndex = -1
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -