📄 车票.frm
字号:
Text = "Text2"
Top = 1440
Width = 2535
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "楷体_GB2312"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1560
TabIndex = 8
Text = "Text1"
Top = 720
Width = 2535
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "价格(元)"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 120
TabIndex = 7
Top = 4560
Width = 1455
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "保险"
BeginProperty Font
Name = "楷体_GB2312"
Size = 18
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 360
TabIndex = 6
Top = 3840
Width = 1215
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "发车时间"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 5
Top = 3120
Width = 1455
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "线路编号"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 4
Top = 2280
Width = 1455
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "班次名称"
BeginProperty Font
Name = "楷体_GB2312"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 3
Top = 1440
Width = 1455
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "车票号"
BeginProperty Font
Name = "楷体_GB2312"
Size = 18
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 2
Top = 720
Width = 1215
End
End
Begin VB.Line Line1
X1 = 0
X2 = 12360
Y1 = 1200
Y2 = 1200
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "车票信息维护"
BeginProperty Font
Name = "宋体"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 4080
TabIndex = 0
Top = 240
Width = 4455
End
End
Attribute VB_Name = "车票"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private cnn As ADODB.Connection
Private WithEvents rstPub As ADODB.Recordset
Attribute rstPub.VB_VarHelpID = -1
Private addFlag As Boolean
Private editFlag As Boolean
Private Sub controlLocked()
Dim b As Boolean
b = Not (addFlag Or editFlag)
Text1.Locked = b
Text2.Locked = b
Text3.Locked = b
Text4.Locked = b
Text5.Locked = b
Text6.Locked = b
End Sub
Private Sub controlEnabled()
Dim blnflag As Boolean
blnflag = Not (addFlag Or editFlag)
cmdadd.Enabled = blnflag
cmdedit.Enabled = blnflag
cmddelete.Enabled = blnflag
cmdsave.Enabled = Not blnflag
cmdcancel.Enabled = Not blnflag
cmdLocation.Enabled = blnflag
cmdexit.Enabled = blnflag
cmdfirst.Enabled = blnflag
cmdlast.Enabled = blnflag
cmdnext.Enabled = blnflag
cmdprevious.Enabled = blnflag
List1.Enabled = blnflag
End Sub
Private Sub cmdadd_Click()
MsgBox "请在上面输入车票信息后" + vbCrLf + " 按保存按钮" + vbCrLf + " 或按撤销按钮", 0, Me.Caption
addFlag = True
controlLocked
controlEnabled
rstPub.AddNew
End Sub
Private Sub cmdcancel_Click()
If addFlag = True Or editFlag = True Then
rstPub.CancelUpdate
MsgBox "已撤消新增或修改", 0, Me.Caption
If rstPub.BOF = False And editFlag = True Then
rstPub.MovePrevious
rstPub.MoveNext
End If
Else
MsgBox "未执行新增或修改,无须撤消", 0, Me.Caption
End If
addFlag = False
editFlag = False
controlEnabled
End Sub
Private Sub cmddelete_Click()
Dim n As Integer
n = MsgBox("真的要删除吗?", 4, Me.Caption)
If n = 6 Then
rstPub.Delete
rstPub.MoveFirst
MsgBox "资料已经删除!", 0, Me.Caption
Else
MsgBox "资料未被删除!", 0, Me.Caption
End If
End Sub
Private Sub cmdedit_Click()
editFlag = True
controlLocked
controlEnabled
MsgBox "请在上面修改车票信息后" + vbCrLf + " 按保存按钮" + vbCrLf + " 或按撤销按钮", 0, Me.Caption
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdfirst_Click()
rstPub.MoveFirst
End Sub
Private Sub cmdlast_Click()
rstPub.MoveLast
End Sub
Private Sub cmdLocation_Click()
Dim s As String
s = InputBox("请输入车票号", Me.Caption)
rstPub.MoveFirst
rstPub.Find ("车票号='" & s & "'")
Dim n As Boolean
n = Not rstPub.EOF And Err.Number = 0
If n = False Then
MsgBox "找不到此车票号", 0, Me.Caption
Exit Sub
End If
End Sub
Private Sub cmdLocation_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
cmdLocation.ToolTipText = "根据车票号快速找到对应的信息"
End Sub
Private Sub cmdnext_Click()
rstPub.MoveNext
If rstPub.EOF = True Then
rstPub.MoveLast
End If
End Sub
Private Sub cmdprevious_Click()
rstPub.MovePrevious
If rstPub.BOF = True Then
rstPub.MoveFirst
End If
End Sub
Private Sub cmdsave_Click()
On Error GoTo ErrMsg
rstPub.Update
If addFlag = True Then
MsgBox "新增车票信息成功!", 0, Me.Caption
addFlag = False
End If
If editFlag = True Then
MsgBox "修改车票信息成功!", 0, Me.Caption
editFlag = False
End If
controlEnabled
controlLocked
If Err.Number = 0 Then Exit Sub
ErrMsg:
MsgBox Err.Description, 16, Me.Caption
End Sub
Private Sub Form_Load()
Set cnn = New ADODB.Connection
Set rstPub = New ADODB.Recordset
cnn.CursorLocation = adUseClient
cnn.Open myApp.cnnstr
rstPub.Open "select * from 车票 order by 车票号 ", cnn, adOpenStatic, adLockOptimistic
Call bindPub
addFlag = False
editFlag = False
controlLocked
controlEnabled
txtstatus.Locked = True
End Sub
Private Sub bindPub()
Set Text1.DataSource = rstPub
Text1.DataField = "车票号"
Set Text2.DataSource = rstPub
Text2.DataField = "班次名称"
Set Text3.DataSource = rstPub
Text3.DataField = "线路编号"
Set Text4.DataSource = rstPub
Text4.DataField = "发车时间"
Set Text5.DataSource = rstPub
Text5.DataField = "保险"
Set Text6.DataSource = rstPub
Text6.DataField = "价格"
Set List1.RowSource = rstPub
List1.ListField = "车票号"
End Sub
Private Sub Form_Unload(Cancel As Integer)
rstPub.Close
cnn.Close
End Sub
Private Sub List1_Click()
rstPub.MoveFirst
rstPub.Find ("车票号='" & List1.Text & "'")
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub rstPub_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
If rstPub.EOF = True And rstPub.BOF = True Then
MsgBox "当前记录集为空,你无法执行此次操作!", vbExclamation, Me.Caption
Exit Sub
End If
If rstPub.EOF = False And rstPub.BOF = False Then
txtstatus.Text = " " & rstPub.AbsolutePosition & " of " & rstPub.RecordCount
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -