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

📄 frm_dpgl.frm

📁 采用VB编写的学生订票管理系统 有详细的代码~解压后可以直接使用!~附有使用说明
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_ydcp;Data Source=."
      OLEDBString     =   "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_ydcp;Data Source=."
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "tb_jbxx"
      Caption         =   "Adodc2"
      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 MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   0
      Top             =   5670
      Width           =   1860
      _ExtentX        =   3281
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   2
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_dpgl;Data Source=."
      OLEDBString     =   "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_dpgl;Data Source=."
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "tb_cz"
      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 label14 
      Caption         =   "Label14"
      DataField       =   "硬座价格"
      DataSource      =   "Adodc1"
      Height          =   300
      Left            =   1365
      TabIndex        =   32
      Top             =   5310
      Width           =   1455
   End
   Begin VB.Label Label5 
      Caption         =   "Label5"
      Height          =   240
      Left            =   3210
      TabIndex        =   31
      Top             =   5295
      Width           =   1290
   End
   Begin VB.Label Label12 
      Caption         =   "订票日期"
      Height          =   225
      Left            =   5805
      TabIndex        =   30
      Top             =   315
      Width           =   825
   End
   Begin VB.Label Label15 
      AutoSize        =   -1  'True
      Caption         =   "Label15"
      Height          =   180
      Left            =   6750
      TabIndex        =   29
      Top             =   285
      Width           =   630
   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 Cbx_cc_Click()
    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 & "") = "\" Then
            MsgBox "该次列车没有此种乘坐方式"
            Cbx_czfs.Text = "硬座"
        End If
    End If
    rs.Close
    Call price
    Call isyz
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 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 ADODB.Recordset
    Dim rs2 As ADODB.Recordset
    Set rs1 = New ADODB.Recordset
    Set rs2 = 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_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
    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
    MsgBox "订票成功!", , "学生订票管理系统"
End Sub
Private Sub Command2_Click()
    Unload Me
    Frm_main.Show
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

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
    Txt_num.Enabled = False: Txt_name.Enabled = False
    Txt_num.Text = Frm_main.Text3.Text: Txt_name.Text = Frm_main.Text4.Text
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 Txt_price_Change()
Call Tprice
End Sub

⌨️ 快捷键说明

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