📄 frmmodifyclass.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmModifyClass
BorderStyle = 1 'Fixed Single
Caption = "设置"
ClientHeight = 3435
ClientLeft = 45
ClientTop = 615
ClientWidth = 5445
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3435
ScaleWidth = 5445
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton cmdAdd
Caption = "增加"
Height = 375
Left = 2880
TabIndex = 6
Top = 2400
Width = 975
End
Begin VB.CommandButton cmdEdit
Caption = "修改"
Height = 375
Left = 4200
TabIndex = 5
Top = 2400
Width = 975
End
Begin VB.CommandButton cmdDel
Caption = "删除"
Height = 375
Left = 2880
TabIndex = 4
Top = 2880
Width = 975
End
Begin VB.CommandButton cmdCancle
Caption = "关闭"
Height = 375
Left = 4200
TabIndex = 3
Top = 2880
Width = 975
End
Begin MSDataGridLib.DataGrid DataGridArg
Height = 3135
Left = 120
TabIndex = 2
Top = 120
Width = 1575
_ExtentX = 2778
_ExtentY = 5530
_Version = 393216
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.TextBox txtArg
Height = 375
Left = 3840
TabIndex = 0
Top = 420
Width = 1455
End
Begin MSAdodcLib.Adodc adodcarg
Height = 375
Left = 120
Top = 2880
Visible = 0 'False
Width = 1575
_ExtentX = 2778
_ExtentY = 661
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
Begin VB.Label lblArg
Caption = "班次"
Height = 255
Left = 2760
TabIndex = 1
Top = 480
Width = 855
End
Begin VB.Menu mmuContent
Caption = "设置内容(&C)"
Begin VB.Menu Class
Caption = "班次(&B)"
End
Begin VB.Menu Postion
Caption = "存放位置(&P)"
End
End
End
Attribute VB_Name = "frmModifyClass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private editmode As Boolean
Private GuiGeValue As String
Private Sub Class_Click()
lblArg.caption = "班次"
adodcarg.ConnectionString = connectString
adodcarg.RecordSource = "select 班次 from 班次表 order by 班次 ASC"
Set DataGridArg.DataSource = adodcarg
adodcarg.Refresh
End Sub
Private Function IsFuHeYaoQiu() As Boolean
IsFuHeYaoQiu = True
If txtArg.Text = "" Then
IsFuHeYaoQiu = False
End If
'判断是否重复,如果有重复的,说明不符合要求。
'添加状态和修改状态时都要判断
cn.Open
Set rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
If lblArg.caption = "班次" Then
rs.Open "select 班次 from 班次表 where 班次 = '" & txtArg.Text & "'"
Else
rs.Open "select 存放位置 from 存放位置表 where 存放位置 = '" & txtArg.Text & "'"
End If
If rs.EOF = False Then
IsFuHeYaoQiu = False
End If
rs.Close
cn.Close
End Function
Private Sub cmdAdd_Click()
If IsFuHeYaoQiu = False Then
MsgBox "输入的内容不符合要求,请重新输入!", , "提示信息"
Exit Sub
End If
cn.Open
Set rs.ActiveConnection = cn
rs.LockType = adLockOptimistic
rs.CursorType = adOpenKeyset
If editmode Then
If lblArg.caption = "班次" Then
rs.Open "select * from 班次表 where 班次 = '" & GuiGeValue & "'"
Else
rs.Open "select * from 存放位置表 where 存放位置 = '" & GuiGeValue & "'"
End If
Else
If lblArg.caption = "班次" Then
rs.Open "select * from 班次表"
Else
rs.Open "select * from 存放位置表"
End If
rs.AddNew
End If
If lblArg.caption = "班次" Then
rs!班次 = txtArg.Text
Else
rs!存放位置 = txtArg.Text
End If
rs.Update
rs.Close
cn.Close
DataGridArg.AllowUpdate = True
If lblArg.caption = "班次" Then
Class_Click
Else
Postion_Click
End If
If editmode = True Then
cmdAdd.caption = "增加"
cmdEdit.Enabled = True
cmdDel.caption = "删除"
editmode = False
End If
txtArg.Text = ""
End Sub
Private Sub AdodcArg_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
If adodcarg.Recordset.BOF Or adodcarg.Recordset.EOF Then
adodcarg.caption = "记录:0"
Else
adodcarg.caption = "记录:" & (adodcarg.Recordset.AbsolutePosition)
End If
End Sub
Private Sub cmdCancle_Click()
Unload Me
End Sub
Private Sub cmdDel_Click()
If cmdDel.caption = "删除" Then
If adodcarg.Recordset.EOF Or adodcarg.Recordset.BOF Then
MsgBox "当前记录为空,不允许删除!", , "提示信息"
Exit Sub
End If
DataGridArg.AllowDelete = True
If MsgBox("确实要删除当前记录吗?", vbYesNo, "提示信息") = vbYes Then
adodcarg.Recordset.Delete
If adodcarg.Recordset.EOF = False Then
adodcarg.Recordset.MoveNext
End If
DataGridArg.AllowDelete = False
End If
Else '当取消来用
cmdAdd.caption = "增加"
cmdDel.caption = "删除"
DataGridArg.AllowDelete = False
cmdAdd.Enabled = True
cmdEdit.Enabled = True
txtArg.Text = ""
End If
End Sub
Private Sub cmdEdit_Click()
If adodcarg.Recordset.EOF Or adodcarg.Recordset.BOF Then
MsgBox "当前记录为空,不能修改!", , "提示"
Exit Sub
Else
txtArg.Text = adodcarg.Recordset.Fields(lblArg.caption)
GuiGeValue = txtArg.Text
End If
cmdDel.caption = "取消"
cmdEdit.Enabled = False
cmdAdd.caption = "保存"
cmdDel.caption = "取消"
editmode = True
End Sub
Private Sub Postion_Click()
lblArg.caption = "存放位置"
adodcarg.ConnectionString = connectString
adodcarg.RecordSource = "select 存放位置 from 存放位置表 order by 存放位置 ASC"
Set DataGridArg.DataSource = adodcarg
adodcarg.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -