📄 frm_dpgl.frm
字号:
Begin VB.Label Label1
Caption = "到达站"
Height = 255
Left = 2565
TabIndex = 2
Top = 975
Width = 780
End
Begin VB.Label Label2
Caption = "出发站"
Height = 300
Left = 90
TabIndex = 1
Top = 975
Width = 720
End
End
Begin VB.Label Label15
AutoSize = -1 'True
Caption = "Label15"
Height = 180
Left = 6600
TabIndex = 32
Top = 315
Width = 630
End
Begin VB.Label Label12
Caption = "订票日期"
Height = 225
Left = 5655
TabIndex = 31
Top = 345
Width = 825
End
Begin VB.Label Label5
Caption = "Label5"
Height = 240
Left = 3180
TabIndex = 30
Top = 5700
Width = 1290
End
Begin VB.Label label14
Caption = "Label14"
DataField = "硬座价格"
DataSource = "Adodc1"
Height = 300
Left = 1335
TabIndex = 26
Top = 5715
Width = 1455
End
End
Attribute VB_Name = "Frm_dpgl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim i As Integer
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim s, m
s = "select distinct 车次 from tb_ccxx"
m = "车次"
Call add(Cbx_cc, s, m)
Cbx_gpfs.Text = Cbx_gpfs.List(0)
rs.Open "select * from tb_ccxx ", cnn, adOpenKeyset, adLockOptimistic
Set MS1.DataSource = rs
rs.Close
Cbx_czfs.Text = "请选择"
DTP1.Value = Date
Label15.Caption = Date
End Sub
Private Sub Tprice()
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Dim s As Variant
rs1.Open "select * from tb_cz where 车次='" & Cbx_cc.Text & "'and 路过站='" & Cbx_end.Text & "'", cnn, adOpenKeyset, adLockOptimistic
rs2.Open "select * from tb_cz where 车次='" & Cbx_cc.Text & "'and 路过站='" & Cbx_start.Text & "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 And rs2.RecordCount > 0 Then
s = Val(rs1.Fields("硬座价格")) - Val(rs2.Fields("硬座价格"))
If Cbx_gpfs.Text = "全价票" Then Txt_Tprice.Text = Txt_price.Text
If Cbx_gpfs.Text = "学生票" Then
If Cbx_czfs.Text = "硬座" Or Cbx_czfs.Text = "软座" Then Txt_Tprice.Text = Val(Txt_price.Text) / 2
If Cbx_czfs.Text = "硬卧上" Or Cbx_czfs.Text = "硬卧中" Or Cbx_czfs.Text = "硬卧下" Or Cbx_czfs.Text = "软卧上" Or Cbx_czfs.Text = "软卧下" Then Txt_Tprice.Text = Val(Txt_price.Text) - Val(s / 2)
End If
End If
rs1.Close
rs2.Close
End Sub
Private Sub price()
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
rs1.Open "select * from tb_cz where 车次='" & Cbx_cc.Text & "'and 路过站='" & Cbx_end.Text & "'", cnn, adOpenKeyset, adLockOptimistic
rs2.Open "select * from tb_cz where 车次='" & Cbx_cc.Text & "'and 路过站='" & Cbx_start.Text & "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 And rs2.RecordCount > 0 Then
Label14.Caption = Val(rs1.Fields("硬座价格")) - Val(rs2.Fields("硬座价格"))
If Cbx_czfs.Text = "硬座" Then Txt_price = Label14.Caption
If Cbx_czfs.Text = "软座" Then Txt_price = Val(Label14.Caption) * 2
If Cbx_czfs.Text = "硬卧下" Then Txt_price = Val(Label14.Caption) * 130 / 100
If Cbx_czfs.Text = "硬卧中" Then Txt_price = Val(Label14.Caption) * 120 / 100
If Cbx_czfs.Text = "硬卧上" Then Txt_price = Val(Label14.Caption) * 110 / 100
If Cbx_czfs.Text = "软卧上" Then Txt_price = Val(Label14.Caption) * 175 / 100
If Cbx_czfs.Text = "软卧下" Then Txt_price = Val(Label14.Caption) * 195 / 100
End If
rs2.Close
rs1.Close
End Sub
Private Sub Cbx_cc_Click()
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Cbx_start.Clear: Cbx_end.Clear
Txt_price.Text = "": Txt_Tprice = ""
rs1.Open "select * from tb_cz where 车次='" & Cbx_cc.Text & "'", cnn, adOpenStatic, adLockOptimistic
Set MS1.DataSource = rs1
If rs1.RecordCount > 0 Then
For i = 1 To rs1.RecordCount
Cbx_start.AddItem rs1.Fields("路过站").Value
rs1.MoveNext
Next i
rs2.Open "select * from tb_ccxx where 车次='" & Cbx_cc.Text & "'", cnn, adOpenDynamic, adLockOptimistic
Lbl_lb.Caption = rs2.Fields("类型")
rs2.Close
End If
rs1.Close
End Sub
Private Sub Cbx_czfs_Click()
Dim rs As New ADODB.Recordset
If Cbx_czfs.Text = "硬座" Then Label5.Caption = "硬座数量"
If Cbx_czfs.Text = "软座" Then Label5.Caption = "软座数量"
If Cbx_czfs.Text = "硬卧下" Or Cbx_czfs.Text = "硬卧中" Or Cbx_czfs.Text = "硬卧上" Then Label5.Caption = "硬卧数量"
If Cbx_czfs.Text = "软卧上" Or Cbx_czfs.Text = "软卧下" Then Label5.Caption = "软卧数量"
rs.Open "select * from tb_ccxx where 车次='" & Cbx_cc.Text & "'", cnn, adOpenStatic
If rs.RecordCount > 0 Then
If rs.Fields("" & Label5.Caption & "") = "\" Or rs.Fields("" & Label5.Caption & "") = "0" Then
MsgBox "该次列车没有此种乘坐方式"
Cbx_czfs.Text = "硬座"
Exit Sub
End If
End If
rs.Close
Call price
Call isyz
If Cbx_czfs.Text = "请选择" Then Txt_price.Text = ""
End Sub
Private Sub isyz()
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs1.Open "select * from tb_ccxx where 车次='" & Cbx_cc.Text & "'", cnn, adOpenKeyset, adLockBatchOptimistic
rs2.Open "select * from tb_cpyd where 车次='" & Cbx_cc.Text & "'and 乘坐方式='" & Cbx_czfs.Text & "'and 乘坐日期='" & DTP1.Value & "'and 备注='订票'", cnn, adOpenKeyset, adLockBatchOptimistic
If rs1.RecordCount > 0 Then
If Label5.Caption = "硬座数量" Or Label5.Caption = "软座数量" Then
If rs1.Fields("" & Label5.Caption & "") - rs2.RecordCount <= 0 Then
Lbl_zw.Caption = "无座"
Else
Lbl_zw.Caption = "有座"
End If
End If
If Label5.Caption = "硬卧数量" Then
If rs1.Fields("" & Label5.Caption & "") / 3 - rs2.RecordCount <= 0 Then
Lbl_zw.Caption = "无座"
Else
Lbl_zw.Caption = "有座"
End If
End If
If Label5.Caption = "软卧数量" Then
If rs1.Fields("" & Label5.Caption & "") / 2 - rs2.RecordCount <= 0 Then
Lbl_zw.Caption = "无座"
Else
Lbl_zw.Caption = "有座"
End If
End If
End If
rs1.Close
rs2.Close
End Sub
Private Sub Cbx_end_click()
Call price
End Sub
Private Sub Cbx_gpfs_Click()
Call Tprice
End Sub
Private Sub Txt_num_Change()
Dim rs As New ADODB.Recordset
rs.Open "select * from tb_stu where 学号='" & Txt_num.Text & "'", cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Txt_name.Text = rs.Fields("学生姓名")
rs.Close
End If
End Sub
Private Sub Txt_price_Change()
Call Tprice
End Sub
Private Sub Cbx_start_Click()
Dim s, m
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
Cbx_end.Clear
rs1.Open "select * from tb_cz where 车次='" & Cbx_cc.Text & "'and 路过站='" & Cbx_start.Text & "'", cnn, adOpenKeyset
s = "select * from tb_cz where 车次='" & Cbx_cc.Text & "'and cast (车站代码 as int) > '" & Val(rs1.Fields("车站代码")) & "'"
m = "路过站"
Call add(Cbx_end, s, m)
rs1.Close
Call price
End Sub
Private Sub Command1_Click()
Dim rs As New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
rs2.Open "select * from tb_stu where 学号='" & Txt_num.Text & "'", cnn, adOpenKeyset, adLockOptimistic
If rs2.RecordCount <= 0 Then
MsgBox "该生没被添加到数据表中!", , "学生订票管理系统"
Exit Sub
End If
rs2.Close
If Txt_num.Text = "" Or Cbx_end.Text = "" Or Txt_Tprice.Text = "" Then
MsgBox "请输入完整信息!", , "学生订票管理系统"
Exit Sub
End If
rs.Open "select * from tb_cpyd where 学号='" & Txt_num.Text & "'", cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
rs.MoveLast
If rs.Fields("备注") = "订票" Then
MsgBox "该学生已经订票", , "学生订票管理系统"
Exit Sub
End If
End If
rs.Close
rs1.Open "select * from tb_cpyd ", cnn, adOpenKeyset, adLockOptimistic
rs1.AddNew
rs1.Fields("学号") = Txt_num.Text
rs1.Fields("学生姓名") = Txt_name.Text
rs1.Fields("车次") = Cbx_cc.Text
rs1.Fields("类别") = Lbl_lb
rs1.Fields("乘坐日期") = DTP1.Value
rs1.Fields("起点站") = Cbx_start.Text
rs1.Fields("到达站") = Cbx_end.Text
rs1.Fields("乘坐方式") = Cbx_czfs.Text
rs1.Fields("票价") = Format(Txt_price.Text, "0.00")
rs1.Fields("购票方式") = Cbx_gpfs.Text
rs1.Fields("实际票价") = Format(Txt_Tprice.Text, "0.00")
rs1.Fields("是否有座") = Lbl_zw.Caption
rs1.Fields("订票日期") = Label15.Caption
rs1.Fields("备注") = "订票"
rs1.Update
rs1.Close
If MsgBox("订票成功,是否继续订票", 4, "学生订票管理系统") = vbYes Then
Cbx_start.Clear: Cbx_end.Clear
Txt_price.Text = "": Txt_Tprice.Text = "": Lbl_zw.Caption = "": Lbl_lb.Caption = "类别"
Txt_num.Text = "": Txt_name.Text = "": Txt_num.SetFocus
Else
Unload Me
Frm_main.Show
Load Frm_main
End If
End Sub
Private Sub DTP1_change()
If DTP1.Value - Date > 15 Then
MsgBox "只能预定提前15天的票!", , "学生订票管理系统"
Exit Sub
End If
If DTP1.Value < Date Then
MsgBox "日期不能小于当前日期!", , "学生订票管理系统"
End If
Call isyz
End Sub
Public Sub add(ByVal t As ComboBox, ByVal j As String, ByVal m As String)
Set rs1 = New ADODB.Recordset
rs1.Open j, cnn, adOpenStatic
If rs1.RecordCount > 0 Then
For i = 1 To rs1.RecordCount
t.AddItem rs1.Fields(m).Value
rs1.MoveNext
Next i
End If
End Sub
Private Sub Command2_Click()
Unload Me
Frm_main.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -