📄 mantable.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form manTable
Caption = "餐桌管理"
ClientHeight = 4155
ClientLeft = 60
ClientTop = 345
ClientWidth = 3960
LinkTopic = "Form1"
ScaleHeight = 4155
ScaleWidth = 3960
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton Command1
Caption = "增 加"
Height = 255
Left = 2880
TabIndex = 5
Top = 240
Width = 855
End
Begin VB.TextBox Text2
Height = 270
Left = 1200
TabIndex = 4
Top = 720
Width = 1335
End
Begin VB.TextBox Text1
Height = 270
Left = 1200
TabIndex = 3
Top = 240
Width = 1335
End
Begin MSFlexGridLib.MSFlexGrid TableGrid
Height = 2775
Left = 0
TabIndex = 0
Top = 1320
Width = 3975
_ExtentX = 7011
_ExtentY = 4895
_Version = 393216
AllowUserResizing= 1
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "餐桌名称:"
Height = 180
Left = 120
TabIndex = 2
Top = 840
Width = 900
End
Begin VB.Label label1
AutoSize = -1 'True
Caption = "餐桌号:"
Height = 180
Left = 120
TabIndex = 1
Top = 360
Width = 720
End
End
Attribute VB_Name = "manTable"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Tables As Long '员工总数
Private Sub Command1_Click()
Dim NewTableID As Integer
Dim NewTableName As String
On Error GoTo Err1
NewTableID = Format(Text1.Text) '得到桌号号
NewTableName = Trim(Text2.Text) '得到桌名
If (NewTableID < 1) Or (NewTableID > 255) Then GoTo Err1 '桌号号判断
If (NewTableName = "") Then GoTo Err1 '桌名判断
'New Data
Set tblTable = Nothing
Set tblTable = DBF.OpenRecordset("SELECT * " & _
" FROM " & tblTableStr & _
" WHERE TableID = " & NewTableID)
With tblTable
If Not .EOF Then GoTo Err1
.AddNew
!TableId = NewTableID
!TableName = NewTableName
!Date = Date
.Update
End With
GoTo NoErr1
Err1:
MsgBox "错误的桌名或桌名,请重新输入!"
NoErr1:
On Error GoTo 0
InitGrid
End Sub
Private Sub InitGrid()
'初始化数据表格
'打开人员表
Set tblTable = DBF.OpenRecordset("SELECT * " & _
" FROM " & tblTableStr & _
" ORDER BY TableID")
TableGrid.Clear
TableGrid.FormatString = "|^ 餐桌名称 |^ 餐桌号 |^ 建档日期 "
With tblTable
.MoveLast
Tables = .RecordCount
TableGrid.Rows = Tables + 1
.MoveFirst
For i = 1 To Tables
TableGrid.Row = i
TableGrid.Col = 1
TableGrid = !TableName
TableGrid.Col = 2
TableGrid = !TableId
TableGrid.Col = 3
TableGrid = !Date
.MoveNext
Next i
End With
End Sub
Private Sub Form_Load()
'初始化
InitGrid
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.InitComtable
End Sub
Private Sub TableGrid_DblClick()
Dim NewTableName As String
Dim NewTableID As Byte
On Error GoTo Err1
Select Case TableGrid.Col
Case 1
NewTableName = InputBox("请输入新的桌名!", "修改桌名")
TableGrid.Col = 2
NewTableID = Format(TableGrid)
TableGrid.Col = 1
Case 2
NewTableID = InputBox("请输入新的桌号!", "修改桌号")
TableGrid.Col = 1
NewTableName = TableGrid
TableGrid.Col = 2
End Select
If (NewTableID < 1) Or (NewTableID > 255) Then GoTo Err1 '桌号判断
If (NewTableName = "") Then GoTo Err1 '桌名判断
Dim tempstr As String
Set tblTable = DBF.OpenRecordset("SELECT * " & _
" FROM " & tblTableStr & _
" WHERE TableID = " & NewTableID)
With tblTable
If (TableGrid.Col = 2) And Not .EOF Then GoTo Err1
TableGrid.Col = 2
tempstr = "是否将编号为:" & TableGrid & " 的桌:"
TableGrid.Col = 1
tempstr = tempstr & TableGrid & "修改为:" & vbCrLf
tempstr = tempstr & NewTableName & ";桌号:" & NewTableID
If MsgBox(tempstr, vbYesNo) = vbYes Then
'del Data
TableGrid.Col = 2
DelTable TableGrid
'New Data
.AddNew
!TableId = NewTableID
!TableName = NewTableName
!Date = Date
.Update
End If
End With
GoTo NoErr1
Err1:
MsgBox "错误的桌号号或桌名,请重新输入!"
NoErr1:
On Error GoTo 0
InitGrid
End Sub
Private Sub TableGrid_KeyUp(KeyCode As Integer, Shift As Integer)
If (KeyCode = 46) And (Shift = 0) Then 'DEL键删除
TableGrid.Col = 0
If MsgBox("是否删除:" & TableGrid, vbYesNo) = vbYes Then
TableGrid.Col = 2
DelTable TableGrid
End If
End If
End Sub
Private Sub DelTable(ByVal DelTableID As Long)
Set tblTable = DBF.OpenRecordset("SELECT * " & _
" FROM " & tblTableStr & _
" WHERE tableID = " & DelTableID)
With tblTable
If .RecordCount >= 1 Then
.Delete
End If
InitGrid
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -