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]