物流运输管理系统 第9页

物流运输管理系统 第9页
   Dim i As Integer
        Dim isfind As Boolean
        isfind = False
        For i = 0 To UBound(arrProduct)
            If txtProduct.Text = arrProduct(i) Then
               isfind = True
            End If
        Next
        If isfind = False Then
            MyVar = MsgBox("确认修改?", vbOKCancel, "信息提示")
            If MyVar = vbOK Then
                '更新数据
                strsql = "UPDATE Product SET NAME= " & sys.StrToInsert(txtProduct) & " WHERE ID =" & sys.TextTolong(txtId)
                sys.DB.ExecuteSQL (strsql)
                MsgBox "操作成功!"
                Unload Me
            End If
        Else
            MsgBox "已经存在该品名!"
        End If
    Else
        MsgBox "品名不能为空!"
    End If

End Sub
Private Sub Command3_Click()
    '检查是否为空
    If Trim(txtProduct.Text) <> "" Then
        '检查数据库是否使用该记录
        strsql = "SELECT COUNT(PRODUCTNAME) AS SProduct FROM TRAFFIC WHERE PRODUCTNAME =" & sys.TextTolong(txtId)
        Set rs = sys.DB.OpenRecordSet(strsql)
        If sys.TextTolong(rs("SProduct")) > 0 Then
            MsgBox "对不起,系统中有运单使用该品名,该品不能删除!"
        Else
            MyVar = MsgBox("确认删除?", vbOKCancel, "信息提示")
            If MyVar = vbOK Then
                '删除数据
                strsql = "DELETE FROM Product WHERE ID =" & sys.TextTolong(txtId)
                sys.DB.ExecuteSQL (strsql)
                MsgBox "操作成功!"
                Unload Me
            End If
        End If
    Else
        MsgBox "品名不能为空!"
    End If
End Sub
Private Sub Form_Load()
    Me.Top = 0
    Me.Left = 0
    Me.Width = MainForm.Width * 0.4
    Me.Height = MainForm.Height * 0.6
    '初始化品
    Dim inum As Integer
    Dim strsql As String
    Dim DB As New clsDataBase
    Dim rs As New ADODB.Recordset
    ReDim arrProduct(0) As String
    strsql = "SELECT * FROM Product"
    Set rs = sys.DB.OpenRecordSet(strsql)
    If Not (rs.BOF) Or (rs.EOF) Then
        inum = 0
        Do While Not rs.EOF
            ReDim Preserve arrProduct(inum)
            arrProduct(inum) = rs("NAME")
            LisProduct.AddItem (rs("NAME"))
            LisProduct.ItemData(inum) = rs("ID")
            rs.MoveNext
            inum = inum + 1
        Loop
    End If
End Sub
Private Sub LisProduct_Click()
    If LisProduct.ListIndex <> -1 Then
        txtId.Text = LisProduct.ItemData(LisProduct.ListIndex)
        txtProduct.Text = LisProduct.Text
    End If
End Sub

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] 

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有