Public Class CProductsManage

    Dim m_SQL As New CSQLInterface
    Private cst_TABLE_NAME As String = "成品库存表"

    Public Shared m_COLS_NAME() As String = {
        "序号",
        "入库出库",
        "料号PN",
        "订单号",
        "日期",
        "时间",
         "数量",
        "操作员ID",
        "仓库",
        "库位",
        "用途"}

    Public Enum COLS
        序号
        入库出库
        料号PN
        订单号
        日期
        时间
        数量
        操作员ID
        仓库
        库位
        用途
        max
    End Enum

    '入库或者出库标志
    Private IsOutStore As Boolean = False
    Public Property OutStore() As Boolean
        Get
            Return IsOutStore
        End Get
        Set(ByVal value As Boolean)
            IsOutStore = value
        End Set
    End Property

    '权限
    Public Shared AccessRight As Integer = RIGHTS.NONE


    Public Sub New()
        IsOutStore = False
    End Sub

    Public Function AddItem(ByVal 入库出库 As Boolean,
                            ByVal 料号PN As String,
                            ByVal 订单号 As String,
                            ByVal 日期 As String,
                            ByVal 时间 As String,
                            ByVal 数量 As Integer,
                            ByVal 操作员ID As String,
                            ByVal 仓库 As String,
                            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 m_COLS_NAME.Length - 1
            If isFirst = True Then
                isFirst = False
            Else
                strSql &= ","
            End If
            strSql &= "`" & m_COLS_NAME(i) & "`"
        Next
        strSql &= ") VALUES ("
        strSql &= "'" & IIf(入库出库, 1, 0) & "',"
        strSql &= "'" & 料号PN & "',"
        strSql &= "'" & 订单号 & "',"
        strSql &= "'" & 日期 & "',"
        strSql &= "'" & 时间 & "',"
        strSql &= "'" & 数量 & "',"
        strSql &= "'" & 操作员ID & "',"
        strSql &= "'" & 仓库 & "',"
        strSql &= "'" & 库位 & "',"
        strSql &= "'" & 用途 & "'"
        strSql &= ")"

        If SQL_ExeCommand(COL_RIGHTS.成品库存管理, strSql) = True Then
            Return ERROR_CODE.SUCCESS
        End If

        Return ERROR_CODE.ACCESS
    End Function

End Class
