以下是引用片段:
其代码实现如下: Private Sub btn添加_Click() '判断信息的正确性 '更新商品类别表中的信息记录 '1 If Trim(Me.Text3.Text) = "" Then MsgBox "类别名称不能为空!" Exit Sub End If If ExecSql("select * from splb where lbid <>'" & Trim(Me.Text2.Text) & "' and lbmc='" & Trim(Me.Text3.Text) & "'").RecordCount > 0 Then MsgBox "类别名称不能重复!" Exit Sub End If '2 Dim strresult As String strresult = Exec_SqL("update splb set lbmc= '" & Trim(Me.Text3.Text) & "' where lbid='" & Me.Text2.Text & "'") If strresult <> "OK" Then MsgBox strresult End If frmSpxx.UserControl12_Click Unload Me End Sub
Private Sub Form_Activate() '得到商品类表表中最大的类别编号 If Me.Text2.Tag = "" Then Me.Text2.Text = Format(GetMaxNum("select max(lbid) from splb"), "000000") End If End Sub
Private Sub Form_Resize() '动态改变窗体的样式和标题 Call FormFace(Me, TopPicture, KKShape) Call TopCaption(Me.TopPicture, Label2.Caption) End Sub
Private Sub TopPicture_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '准备窗体移动标志 intOldX = X intOldy = Y boolMouseFlag = True End Sub
Private Sub TopPicture_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '存储窗提议动前的left,top Dim intLeft, intTop As Integer intLeft = Me.Left intTop = Me.Top If Me.WindowState = 2 Then Exit Sub If boolMouseFlag = True Then Me.Left = intLeft + (X - intOldX) Me.Top = intTop + (Y - intOldy) End If End Sub
Private Sub TopPicture_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) '还原当前的窗体移动标志 boolMouseFlag = False End Sub
Private Sub UserControl11_Click() '关闭窗体 Unload Me End Sub
Private Sub UserControl12_Click() '删除商品类别(如果商品类别下有商品信息,则不允许删除) Dim strresult As String
If ExecSql("select * from spxx where lbid='" & Me.Text2.Text & "'").RecordCount > 0 Then MsgBox "此部门下有商品信息,不能删除!" Exit Sub End If strresult = Exec_SqL("delete from splb where lbid='" & Me.Text2.Text & "'") If strresult <> "OK" Then MsgBox strresult End If frmSpxx.UserControl12_Click Unload Me End Sub
Private Sub UserControl13_Click() '判断信息的正确性 '添加一条商品类别纪录 '1 If Trim(Me.Text3.Text) = "" Then MsgBox "类别名称不能为空!" Exit Sub End If
If ExecSql("select * from splb where lbid='" & Trim(Me.Text2.Text) & "'").RecordCount > 0 Then MsgBox "类别代码不能重复!" Exit Sub End If
If ExecSql("select * from splb where lbmc='" & Trim(Me.Text3.Text) & "'").RecordCount > 0 Then MsgBox "类别名称不能重复!" Exit Sub End If '2 Dim strresult As String strresult = Exec_SqL("insert into splb (lbid,lbmc) values ('" & Trim(Me.Text2.Text) & "','" & Trim(Me.Text3.Text) & "')") If strresult <> "OK" Then MsgBox strresult End If frmSpxx.UserControl12_Click Unload Me End Sub
|