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

📄 main_gys.frm

📁 餐饮企业的管理系统主要包括前台管理、后台管理、财务管理、报表打印等功能
💻 FRM
📖 第 1 页 / 共 3 页
字号:
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   270
            Left            =   5580
            TabIndex        =   29
            Top             =   3825
            Width           =   1020
         End
         Begin VB.Label Label1 
            Caption         =   "供应商编号:             供应商全称:           供应商简称:            供应商地址:            "
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   10.5
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   2400
            Left            =   180
            TabIndex        =   28
            Top             =   375
            Width           =   1200
         End
      End
   End
   Begin VB.Frame Frame6 
      Caption         =   "Frame6"
      Height          =   690
      Left            =   3525
      TabIndex        =   11
      Top             =   1665
      Visible         =   0   'False
      Width           =   2820
      Begin MSAdodcLib.Adodc Adodc1 
         Height          =   330
         Left            =   360
         Top             =   300
         Width           =   2025
         _ExtentX        =   3572
         _ExtentY        =   582
         ConnectMode     =   0
         CursorLocation  =   3
         IsolationLevel  =   -1
         ConnectionTimeout=   15
         CommandTimeout  =   30
         CursorType      =   3
         LockType        =   3
         CommandType     =   8
         CursorOptions   =   0
         CacheSize       =   50
         MaxRecords      =   0
         BOFAction       =   0
         EOFAction       =   0
         ConnectStringType=   1
         Appearance      =   1
         BackColor       =   -2147483643
         ForeColor       =   -2147483640
         Orientation     =   0
         Enabled         =   -1
         Connect         =   ""
         OLEDBString     =   ""
         OLEDBFile       =   ""
         DataSourceName  =   ""
         OtherAttributes =   ""
         UserName        =   ""
         Password        =   ""
         RecordSource    =   ""
         Caption         =   "Adodc1"
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         _Version        =   393216
      End
   End
End
Attribute VB_Name = "main_gys"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer     '定义整型变量
'定义数据集对象
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim rs3 As New ADODB.Recordset
Dim rs4 As New ADODB.Recordset
Public Sub View_data()     '定义显示数据的函数
    Adodc1.Recordset.MoveFirst
    Adodc1.Recordset.Move Bkm - 1
  For i = 0 To 13
      If Adodc1.Recordset.RecordCount <> 0 Then gys(i).text = Adodc1.Recordset.Fields(i)
  Next i
End Sub

Private Sub DataGrid1_Click()
    Bkm = Adodc1.Recordset.Bookmark
End Sub

Private Sub Form_Activate()
  '向combo1中添加查询项目列表
  Combo1.AddItem ("供应商编号")
  Combo1.AddItem ("供应商全称")
  Combo1.text = "供应商编号"
  Set rs1 = New ADODB.Recordset
  '打开"供应商信息表"
  rs1.Open "select * from 供应商信息表 order by 供应商编号", cnn, adOpenKeyset, adLockOptimistic
  If rs1.RecordCount > 0 Then
     For i = 0 To 13
         If rs1.Fields(i) <> "" Then gys(i).text = rs1.Fields(i)
     Next i
  End If
  rs1.Close
  '查询所有供应商信息,并按"供应商编号"排序
  Sql = "select * from 供应商信息表 order by 供应商编号"
  Call FunAdo(Adodc1, Sql)
  Adodc1.Refresh
  Me.Caption = Me.Caption & "    " & frm_main.St1.Panels(3).text
End Sub

Private Sub Form_Load()
    Sql = "select * from 供应商信息表"
    Call FunAdo(Adodc1, Sql)
End Sub

Private Sub Form_Unload(Cancel As Integer)
  frm_main.Enabled = True
End Sub

Private Sub gys_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
 'VbKeyReturn常数为键盘上的"回车键"
 If KeyCode = vbKeyReturn And Index < 13 Then gys(Index + 1).SetFocus '回车获得焦点
 If KeyCode = vbKeyReturn And Index = 13 Then ComSave.SetFocus

End Sub

Private Sub gys_KeyPress(Index As Integer, KeyAscii As Integer)
    If Index = 11 Or Index = 5 Then
        KeyAscii = AcceptNumber(KeyAscii)
    End If
End Sub

Private Sub SSTab1_Click(PreviousTab As Integer)
  If Adodc1.Recordset.RecordCount <> 0 Then
     If SSTab1.Tab = 1 And ComAdd.Enabled = False Then
        MsgBox ("您正在处理数据,请取消数据处理,再执行本操作!")
        SSTab1.Tab = 0
     End If
      Adodc1.Recordset.MoveFirst
      Adodc1.Recordset.Move Bkm - 1
      Call View_data
  End If
End Sub
Private Sub Comfind_Click()
  Sql = "select * from 供应商信息表 where (供应商信息表." & Combo1.text & " like +'%" + Trim(Text1.text) + "%')"
  Call FunAdo(Adodc1, Sql)
  Adodc1.Refresh
  Call View_data
  SSTab1.Tab = 1
End Sub
Private Sub CmdMD_Click(Index As Integer)
 Select Case Index
        Case Is = 0     '移到第一条记录
             If Not Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
        Case Is = 1     '移到上一条记录
             If Adodc1.Recordset.RecordCount <> 0 Then
             If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
             If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
         End If
        Case Is = 2     '移到下一条记录
             If Adodc1.Recordset.RecordCount <> 0 Then
             If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
             If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
         End If
        Case Is = 3     '移到最后一条记录
             If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveLast
 End Select
 Bkm = Adodc1.Recordset.Bookmark
 Call View_data

End Sub
Private Sub ComAdd_Click()     '添加
 '创建供应商编号
 Dim bh As Integer
  SSTab1.Tab = 0
      If Not rs1 Is Nothing Then                       '如果记录集rs不为空
        If rs1.State = adStateOpen Then              '如果记录集处于打开状态
            rs1.Close                                '关闭记录集
        End If
        Set rs1 = Nothing                            'rs设置为空
    End If
 rs1.Open "select * from 供应商信息表 order by 供应商编号", cnn, adOpenKeyset, adLockOptimistic
 If rs1.RecordCount > 0 Then
    If Not rs1.EOF Then rs1.MoveLast
       If rs1.Fields("供应商编号") <> "" Then
          bh = Right(Trim(rs1.Fields("供应商编号")), 4) + 1
              '使用Format函数将数据格式为“0000”格式
          gys(0).text = "gys" & Format(bh, "0000")
       End If
  Else
    gys(0).text = "gys0001"
  End If
  rs1.Close
  For i = 1 To 13
      gys(i).Enabled = True
      gys(i).text = ""
  Next i
  '设置控件不可用
  ComSave.Enabled = True: ComEsc.Enabled = True: ComAdd.Enabled = False
  ComModify.Enabled = False: ComDelete.Enabled = False
  For i = 0 To 3
      CmdMD(i).Enabled = False
  Next i
 
  gys(1).SetFocus
  
End Sub
Private Sub ComModify_Click()     '允许修改记录
  If Adodc1.Recordset.RecordCount <> 0 Then
     For i = 0 To 13
         gys(i).Enabled = True
     Next i
     ComSave.Enabled = True: ComEsc.Enabled = True: ComAdd.Enabled = False
     ComModify.Enabled = False: ComDelete.Enabled = False
     For i = 0 To 3
         CmdMD(i).Enabled = False
     Next i
     SSTab1.Tab = 0
  Else
     MsgBox ("没有要修改的数据!")
  End If
End Sub
Private Sub ComDelete_Click()     '删除记录
 If Adodc1.Recordset.RecordCount > 0 Then
    a = MsgBox("您确实要删除这条数据吗?", vbYesNo)
    If a = vbYes Then
       Adodc1.Recordset.Delete
       Bkm = Bkm - 1
       Me.Refresh
       Call View_data     '调用函数
    End If
     ComSave.Enabled = False: ComEsc.Enabled = False: ComAdd.Enabled = True
     ComModify.Enabled = True: ComDelete.Enabled = True
     For i = 0 To 3
         CmdMD(i).Enabled = True
     Next i
  Else
    MsgBox ("没有要删除的数据!")
 End If
End Sub
Private Sub ComSave_Click()     '保存供应商信息
   rs1.Open "select * from 供应商信息表 where 供应商编号='" & Trim(gys(0).text) & "'order by 供应商编号", cnn, adOpenKeyset, adLockOptimistic
   If rs1.RecordCount > 0 Then
      Dim a As String
      a = MsgBox("您确实要修改这条数据吗?", vbYesNo)
      If a = vbYes Then
         For i = 1 To 13
             If gys(1).text <> "" Then rs1.Fields(i) = Trim(gys(i).text)
             gys(i).Enabled = False
         Next i
         rs1.Update
         Adodc1.Refresh
       End If
    Else
       If gys(1).text <> "" And gys(2).text <> "" Then
          '添加供应商信息
          rs1.AddNew
          For i = 0 To 13
              rs1.Fields(i) = Trim(gys(i).text)
              gys(i).Enabled = False
          Next i
           rs1.Update     '更新数据库
           Adodc1.Refresh
        Else
           MsgBox "请填写完整的信息"
           rs1.Close     '关闭数据集对象
           Exit Sub
       End If
   End If
'   rs1.Close     '关闭数据集对象
   '设置控件不可用
   ComSave.Enabled = False: ComEsc.Enabled = False: ComAdd.Enabled = True
   ComModify.Enabled = True: ComDelete.Enabled = True
   For i = 0 To 3
       CmdMD(i).Enabled = True
   Next i
   Adodc1.Recordset.MoveLast
    Call View_data
'     Adodc1.Recordset.Close
End Sub
Private Sub ComEsc_Click()    '取消操作
      If Not rs1 Is Nothing Then                       '如果记录集rs不为空
        If rs1.State = adStateOpen Then              '如果记录集处于打开状态
            rs1.Close                                '关闭记录集
        End If
        Set rs1 = Nothing                            'rs设置为空
    End If
 rs1.Open "select * from 供应商信息表 order by 供应商编号", cnn, adOpenKeyset, adLockOptimistic
 If rs1.RecordCount > 0 Then
  For i = 0 To 13
   If rs1.Fields(i) <> "" Then gys(i).text = rs1.Fields(i)
   gys(i).Enabled = False
  Next i
 End If
 rs1.Close
 ComSave.Enabled = False: ComEsc.Enabled = False: ComAdd.Enabled = True
 ComModify.Enabled = True: ComDelete.Enabled = True
 For i = 0 To 3
  CmdMD(i).Enabled = True
 Next i
  Call View_data
End Sub
Private Sub ComExit_Click()
 frm_main.Enabled = True
 Unload Me
End Sub



⌨️ 快捷键说明

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