本文介紹以 ASP.NET + VB.NET 三層架構開發的校園一卡通機房刷卡子系統——自訂日誌管理模組,涵蓋自訂格式資料庫設計、業務邏輯封裝與前端查詢/統計/列印功能。
系統不使用標準 SQL 資料表,而是定義 VB 結構體直接對應二進位檔案:
Structure FixUse ' 使用者表
Public ID As Integer
<VBFixedArray(15)> Public NoCard() As Byte ' 卡號
<VBFixedArray(15)> Public NoUser() As Byte ' 學號
<VBFixedArray(15)> Public Name() As Byte ' 姓名
<VBFixedArray(15)> Public PSW() As Byte ' 密碼
Public Dept As Integer ' 部門 ID
Public Attr As Integer ' 機房總管權限
Public AttreEx As Integer ' 擴展權限
Public Money As Integer ' 帳戶餘額
Public Power As Integer ' 使用者權限
Public PowerEx As Integer ' 擴展權限
Public MoneyEx As Integer ' 擴展餘額
<VBFixedArray(31)> Public Rev() As Byte ' 保留
End Structure
Structure FixLog ' 上下機/繳費日誌表
Dim ID As Integer ' 流水號
Dim Type As Integer ' 事件類型
<VBFixedArray(5)> Dim DateTime() As Byte ' 上機開始時間
<VBFixedArray(5)> Dim MAC() As Byte ' 指定 IP
Dim ManagerID As Integer ' 收費管理員 ID
Dim UserID As Integer ' 使用者 ID
Dim Money As Integer ' 金額
Dim ID_EquipMent As Integer ' 設備號
<VBFixedArray(5)> Dim DateTimeEnd() As Byte ' 下機時間
Public Location As Int64 ' 系統保留
<VBFixedArray(13)> Dim revex() As Byte ' 保留
End Structure

ReadFixUse、WriteFixLog 等底層方法。Application 或 Cache,減少磁碟 I/O。App_Data 目錄,備份只需複製檔案。Compact 整理碎片,維持存取速度。