Public Class CStore Dim m_SQL As New CSQLInterface Private cst_TABLE_NAME As String = "仓库表" Public Shared m_COLS_NAME() As String = { "仓库序号", "仓库名称", "仓库地点", "仓库库位表" } Public Enum COLS 仓库序号 仓库名称 仓库地点 仓库库位表 max End Enum '权限 Public Shared AccessRight As Integer = RIGHTS.NONE Public Function AddItem(ByVal 仓库名称 As String, ByVal 仓库地点 As String ) As ERROR_CODE If CBool(AccessRight And RIGHTS.WRITE) = False Then Return ERROR_CODE.NORIGHT End If '"INSERT INTO [dbo].[TABLE1] ([11],[22],[33],[44],[55]) VALUES ('11','2','3','4','5')" Dim strSql As String = "INSERT INTO `" & cst_TABLE_NAME & "` (" '加入列名 Dim isFirst As Boolean = True For i As Integer = COLS.仓库名称 To COLS.max - 1 If isFirst = True Then isFirst = False Else strSql &= "," End If strSql &= "`" & m_COLS_NAME(i) & "`" Next strSql &= ") VALUES (" strSql &= "'" & 仓库名称 & "'," strSql &= "'" & 仓库地点 & "'" strSql &= ")" If SQL_ExeCommand(COL_RIGHTS.仓库管理, strSql) = True Then Return ERROR_CODE.SUCCESS End If Return ERROR_CODE.ACCESS End Function Public Function QueryAll(ByRef rTable As Data.DataTable) As ERROR_CODE If CBool(AccessRight And RIGHTS.READ) = False Then Return ERROR_CODE.NORIGHT End If Dim strSQL As String = "SELECT * FROM " & cst_TABLE_NAME If SQL_Query(COL_RIGHTS.仓库管理, strSQL, rTable) = True Then Return ERROR_CODE.SUCCESS End If Return ERROR_CODE.ACCESS End Function End Class