⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 菜单修改.frm

📁 一个很有意思的点菜系统前后台连接齐全~做课程设计的同学可以参考
💻 FRM
📖 第 1 页 / 共 2 页
字号:
If Combo1.Text = "" Or Combo1.Text = "类别" Then
    Exit Sub
End If

Command3.Enabled = True '*******************6.5
Command4.Enabled = True '*******************6.5
serial = CLng(Text1.Text)
'MsgBox "serial=" & serial
cptable.MoveFirst
Do While Not cptable.EOF
  If Text1.Text = cptable.Fields(0) Then
    Exit Do
  End If
  cptable.MoveNext
Loop
  If Combo1.Text = "所有" Then
      cptable.MovePrevious
      'If cptable.BOF Then
               ' Exit Sub
     ' End If
      number = cptable.Fields(0)
      Text1.Text = number
      Text2.Text = cptable.Fields(1)
      Text3.Text = cptable.Fields(2)
      Text4.Text = cptable.Fields(4)
      If cptable.Fields(8) <> "" Then
          Text5.Text = cptable.Fields(8)
      Else
          Text5.Text = ""
      End If
      cptable.MovePrevious  '*****************6.4
      If cptable.BOF Then
        Command2.Enabled = False
        Command1.Enabled = False
        Exit Sub
      End If
      cptable.MoveNext  '*****************6.4
  Else
    serial = serial - 1
    enable_num = serial - 1
    'MsgBox "serial=" & serial
    cptable.MoveLast
    Do While Not cptable.BOF
      If cptable.Fields(0) = serial Then
        number = cptable.Fields(0)
        Text1.Text = number
        Text2.Text = cptable.Fields(1)
        Text3.Text = cptable.Fields(2)
        Text4.Text = cptable.Fields(4)
        If cptable.Fields(8) <> "" Then
          Text5.Text = cptable.Fields(8)
        Else
          Text5.Text = ""
        End If
        
        cptable.MovePrevious '*****************6.4
        If Not cptable.BOF Then
          If cptable.Fields(0) <> enable_num Then
            Command2.Enabled = False
            Command1.Enabled = False
          End If
        Else
          Command2.Enabled = False
          Command1.Enabled = False
        End If '*****************6.4
        cptable.MoveNext  '********************6.5
        Exit Sub
      End If
      cptable.MovePrevious
     Loop
  End If

End Sub

Private Sub Command3_Click()
Dim number As Long, serial As Long, enable_num As Long

If Combo1.Text = "" Or Combo1.Text = "类别" Then
  Exit Sub
End If

Command2.Enabled = True '*******************6.5
Command1.Enabled = True '*******************6.5
serial = CLng(Text1.Text)
cptable.MoveFirst
Do While Not cptable.EOF
  If cptable.Fields(0) = serial Then
    Exit Do
  End If
  cptable.MoveNext
Loop

  If Combo1.Text = "所有" Then
      cptable.MoveNext
      
      number = cptable.Fields(0)
      Text1.Text = number
      Text2.Text = cptable.Fields(1)
      Text3.Text = cptable.Fields(2)
      Text4.Text = cptable.Fields(4)
      If cptable.Fields(8) <> "" Then
          Text5.Text = cptable.Fields(8)
      Else
          Text5.Text = ""
      End If
      
      cptable.MoveNext '*****************6.4
      If cptable.EOF Then
        Command3.Enabled = False
        Command4.Enabled = False
        Exit Sub
      End If
      cptable.MovePrevious '*****************6.4
  Else
    serial = serial + 1
    enable_num = serial + 1
    Do While Not cptable.EOF
      If cptable.Fields(0) = serial Then
        
          number = cptable.Fields(0)
          Text1.Text = number
          Text2.Text = cptable.Fields(1)
          Text3.Text = cptable.Fields(2)
          Text4.Text = cptable.Fields(4)
          If cptable.Fields(8) <> "" Then
            Text5.Text = cptable.Fields(8)
          Else
            Text5.Text = ""
          End If
          
          cptable.MoveNext '*****************6.4
          If Not cptable.EOF Then
            If cptable.Fields(0) <> enable_num Then
              Command3.Enabled = False
              Command4.Enabled = False
            End If
          Else
            Command3.Enabled = False
            Command4.Enabled = False
          End If '*****************6.4
          cptable.MovePrevious '**********************6.5
          Exit Sub
        
      End If
      cptable.MoveNext
    Loop
    
    'Command3.Enabled = False '************
  End If

End Sub

Private Sub Command4_Click()
Dim number As Long

If Combo1.Text = "" Or Combo1.Text = "类别" Then
    Exit Sub
End If
Command2.Enabled = True '*******************6.5
Command3.Enabled = False '*******************6.5
Command1.Enabled = True '*******************6.5
Command4.Enabled = False '*******************6.5

  If Combo1.Text = "所有" Then
      cptable.MoveLast
      number = cptable.Fields(0)
      Text1.Text = number
      Text2.Text = cptable.Fields(1)
      Text3.Text = cptable.Fields(2)
      Text4.Text = cptable.Fields(4)
      If cptable.Fields(8) <> "" Then
        Text5.Text = cptable.Fields(8)
      Else
        Text5.Text = ""
      End If
  Else
    cptable.MoveLast
    While Not cptable.BOF
      If cptable.Fields(3) = Combo1.Text Then
        number = cptable.Fields(0)
        Text1.Text = number
        Text2.Text = cptable.Fields(1)
        Text3.Text = cptable.Fields(2)
        Text4.Text = cptable.Fields(4)
        If cptable.Fields(8) <> "" Then
          Text5.Text = cptable.Fields(8)
        Else
          Text5.Text = ""
        End If
        Exit Sub
      End If
      cptable.MovePrevious
    Wend
  End If
  
End Sub

Private Sub Command5_Click()
Dim number As Long, serial As Long
Dim kind As String
If Combo1.Text = "" Or Combo1.Text = "类别" Then
    Exit Sub
End If
serial = CLng(Text1.Text)
cptable.MoveFirst
While Not cptable.EOF
  If cptable.Fields(0) = serial Then
    response = MsgBox("确定要删除吗?", vbYesNo)
        If response = vbNo Then
          Exit Sub
        End If
    cptable.Delete
  End If
  cptable.MoveNext
Wend
'Text1.Text = serial - 1
cptable.MoveFirst
While Not cptable.EOF
  If cptable.Fields(0) = serial + 1 Then
    cptable.Edit
    cptable.Fields(0) = serial
    cptable.Update
    serial = serial + 1
  End If
  cptable.MoveNext
Wend
Call Command2_Click
End Sub

Private Sub Command6_Click()
Dim serial As Long
If Text1.Text = "" Then
  Exit Sub
End If
serial = CLng(Text1.Text)
cptable.MoveFirst
Do While Not cptable.EOF
  If cptable.Fields(0) = serial Then
    Text2.Text = cptable.Fields(1)
    Text3.Text = cptable.Fields(2)
    Text4.Text = cptable.Fields(4)
    If cptable.Fields(8) <> "" Then
      Text5.Text = cptable.Fields(8)
    Else
      Text5.Text = ""
    End If
    Exit Do
  End If
  cptable.MoveNext
Loop
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Command8.Enabled = True
Command6.Enabled = False
Command7.Enabled = False
End Sub

Private Sub Command7_Click()
Dim serial As Long
If Text1.Text = "" Then
  Exit Sub
End If

serial = CLng(Text1.Text)
cptable.MoveFirst
Do While Not cptable.EOF
  If cptable.Fields(0) = serial Then
    cptable.Edit
    cptable.Fields(1) = Text2.Text
    cptable.Fields(2) = Text3.Text
    cptable.Fields(4) = Text4.Text
    cptable.Fields(8) = Text5.Text
    cptable.Update
    MsgBox "记录修改成功!"
    Text2.Enabled = False
    Text3.Enabled = False
    Text4.Enabled = False
    Text5.Enabled = False
    Command8.Enabled = True
    Command6.Enabled = False
    Command7.Enabled = False
    Exit Sub
  End If
  cptable.MoveNext
Loop

End Sub

Private Sub Command8_Click()
'Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = False
End Sub

Private Sub Form_Load()
Form1.Enabled = False
dcpath = "c:\点菜系统.mdb"
Set dcdb = OpenDatabase(dcpath)
Set cptable = dcdb.OpenRecordset("菜谱表", dbOpenTable)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Form1.Enabled = True
dcdb.Close
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -