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

📄 bookticket.frm

📁 此系统实现了火车票订票系统的部分功能
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form bookticket 
   BackColor       =   &H8000000D&
   Caption         =   "订票及查询窗体"
   ClientHeight    =   4230
   ClientLeft      =   60
   ClientTop       =   405
   ClientWidth     =   8820
   LinkTopic       =   "Form4"
   ScaleHeight     =   4230
   ScaleWidth      =   8820
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command4 
      Caption         =   "退出"
      Height          =   495
      Left            =   6360
      TabIndex        =   13
      Top             =   3480
      Width           =   1215
   End
   Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
      Height          =   2775
      Left            =   4800
      TabIndex        =   12
      Top             =   480
      Width           =   3975
      _ExtentX        =   7011
      _ExtentY        =   4895
      _Version        =   393216
      Cols            =   4
      BackColor       =   -2147483634
   End
   Begin VB.CommandButton Command3 
      Caption         =   "查看订票信息"
      Height          =   2055
      Left            =   4320
      TabIndex        =   11
      Top             =   840
      Width           =   375
   End
   Begin VB.CommandButton Command2 
      BackColor       =   &H8000000D&
      Caption         =   "修改订票信息"
      Height          =   495
      Left            =   2280
      TabIndex        =   10
      Top             =   3480
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H80000001&
      Caption         =   "订票"
      Height          =   495
      Left            =   480
      TabIndex        =   9
      Top             =   3480
      Width           =   1215
   End
   Begin VB.TextBox Text4 
      Height          =   495
      Left            =   1440
      TabIndex        =   8
      Top             =   2760
      Width           =   975
   End
   Begin VB.TextBox Text3 
      Height          =   495
      Left            =   1440
      TabIndex        =   6
      Top             =   1920
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      Height          =   495
      Left            =   1440
      TabIndex        =   5
      Top             =   1080
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   1440
      TabIndex        =   4
      Top             =   360
      Width           =   1815
   End
   Begin VB.Label Label5 
      BackColor       =   &H8000000D&
      Caption         =   "(YYYY-MM-DD)"
      Height          =   375
      Left            =   2760
      TabIndex        =   7
      Top             =   2040
      Width           =   1455
   End
   Begin VB.Label Label4 
      BackColor       =   &H8000000D&
      Caption         =   "所定票数:"
      Height          =   495
      Left            =   480
      TabIndex        =   3
      Top             =   2760
      Width           =   975
   End
   Begin VB.Label Label3 
      BackColor       =   &H8000000D&
      Caption         =   "乘车日期:"
      Height          =   495
      Left            =   480
      TabIndex        =   2
      Top             =   1960
      Width           =   975
   End
   Begin VB.Label Label2 
      BackColor       =   &H8000000D&
      Caption         =   "车次:"
      Height          =   495
      Left            =   480
      TabIndex        =   1
      Top             =   1160
      Width           =   975
   End
   Begin VB.Label Label1 
      BackColor       =   &H8000000D&
      Caption         =   "身份证:"
      Height          =   495
      Left            =   480
      TabIndex        =   0
      Top             =   360
      Width           =   975
   End
End
Attribute VB_Name = "bookticket"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Dim cn1 As String
Dim cn2 As String
Dim cn3 As String
Dim CN As String
Private Sub Command1_Click()
  Dim RST1 As ADODB.Recordset
  Dim RST2 As New ADODB.Recordset
  Form_Load
  CN = Text1.Text
  If Text1.Text = "" Then
     MsgBox "身份证不能为空!", vbOKOnly + vbExclamation, "警告"
     Text1.SetFocus
     Exit Sub
   Else
     If Text2.Text = "" Then
        MsgBox "车次不能为空!", vbOKOnly + vbExclamation, "警告"
        Text2.SetFocus
        Exit Sub
      Else
        If Text3.Text = "" Then
           MsgBox "乘车时间不能为空!", vbOKOnly + vbExclamation, "警告"
           Text3.SetFocus
           Exit Sub
        Else
           If Text4.Text = "" Then
              MsgBox "票数不能为空!", vbOKOnly + vbExclamation, "警告"
              Text4.SetFocus
              Exit Sub
           Else
              Dim textSQL1 As String
              Dim textSQL2 As String
              textSQL1 = "select * from bookticket where 身份证=" _
                       & "'" & Text1.Text & "' and 车次=" _
                       & "'" & Text2.Text & "' and 乘车日期=" _
                       & "'" & Text3.Text & "'"
              textSQL2 = "select * from trainticket where 车次='" & Text2.Text & "'"
              Set rst = New ADODB.Recordset
              rst.Open Trim$(textSQL2), conn
              If rst.EOF = True Then
                 MsgBox "您要定的票不存在!请先查询后再订", vbOKOnly + vbExclamation, "提示"
                 Exit Sub
               Else
                 Set RST1 = New ADODB.Recordset
                 RST1.Open Trim$(textSQL1), conn
                 If RST1.EOF = True Then
                    'Set rst2 = New ADODB.Recordset
                    Set RST2 = conn.Execute("exec book" _
                                        & "'" & Text1.Text & "'," _
                                        & "'" & Text2.Text & "'," _
                                        & "'" & Text3.Text & "'," _
                                        & "'" & Text4.Text & "'")
                     MsgBox "订票成功!", vbOKOnly + vbExclamation, "提示"
                     conn.Close
                     Command3.Enabled = True
                  Else
                     MsgBox "此票已定,您可以选择修改订票信息!", vbOKOnly + vbExclamation, "温馨提示"
                     Command2.Enabled = True
                     cn1 = Text1.Text
                     cn2 = Text2.Text
                     cn3 = Text3.Text
                     MsgBox "请输入修改后的数据!", vbOKOnly + vbExclamation, "提示"
                     Text1.Text = ""
                     Text2.Text = ""
                     Text3.Text = ""
                     Text4.Text = ""
                     conn.Close
                     Exit Sub
                  End If
                End If
             End If
          End If
       End If
    End If
End Sub

Private Sub Command2_Click()
  Form_Load
  If Text1.Text = "" Then
     MsgBox "身份证不能为空!", vbOKOnly + vbExclamation, "警告"
     Text1.SetFocus
     Exit Sub
   Else
     If Text2.Text = "" Then
        MsgBox "车次不能为空!", vbOKOnly + vbExclamation, "警告"
        Text2.SetFocus
        Exit Sub
      Else
        If Text3.Text = "" Then
           MsgBox "乘车时间不能为空!", vbOKOnly + vbExclamation, "警告"
           Text3.SetFocus
           Exit Sub
        Else
           If Text4.Text = "" Then
              MsgBox "票数不能为空!", vbOKOnly + vbExclamation, "警告"
              Text4.SetFocus
              Exit Sub
           Else
              Dim textSQL As String
              textSQL = "select * from trainticket where 车次='" & Text2.Text & "'"
              Set rst = New ADODB.Recordset
              rst.Open Trim$(textSQL), conn
              If rst.EOF = True Then
                 MsgBox "您要定的票不存在!请重新输入车次", vbOKOnly + vbExclamation, "提示"
                 Exit Sub
              Else
                 Dim textSQL1 As String
                 textSQL1 = "select * from bookticket where 身份证=" _
                             & "'" & Text1.Text & "' and 车次=" _
                             & "'" & Text2.Text & "' and 乘车日期=" _
                             & "'" & Text3.Text & "'"
                 Dim RS1 As ADODB.Recordset
                 Set RS1 = New ADODB.Recordset
                 RS1.Open Trim$(textSQL1), conn
                 If RS1.EOF = True Then
                    Dim rs As New ADODB.Recordset
                    Set rs = conn.Execute("exec updatebook" _
                                         & "'" & Text1.Text & "'," _
                                         & "'" & Text2.Text & "'," _
                                         & "'" & Text3.Text & "'," _
                                         & "'" & Text4.Text & "'," _
                                         & "'" & cn1 & "'," _
                                         & "'" & cn2 & "'," _
                                         & "'" & cn3 & "'")
                    MsgBox "修改成功!", vbOKOnly + vbExclamation, "提示"
                    Command2.Enabled = False
                    conn.Close
                  Else
                     MsgBox "此票已定,您可以选择修改订票信息!", vbOKOnly + vbExclamation, "温馨提示"
                     cn1 = Text1.Text
                     cn2 = Text2.Text
                     cn3 = Text3.Text
                     MsgBox "请输入修改后的数据!", vbOKOnly + vbExclamation, "提示"
                     Text1.Text = ""
                     Text2.Text = ""
                     Text3.Text = ""
                     Text4.Text = ""
                     conn.Close
                     Exit Sub
                  End If
                End If
              End If
            End If
          End If
        End If
End Sub

Private Sub Command3_Click()
 Form_Load
 Dim textSQL As String
 Dim rst As ADODB.Recordset
 textSQL = "select * from bookticket where 身份证='" & CN & "'"
 Set rst = New ADODB.Recordset
 rst.Open Trim$(textSQL), conn
 With MSFlexGrid1
      .Rows = 2
      .Cols = 4
      .TextMatrix(1, 0) = "身份证"
      .TextMatrix(1, 1) = "车次"
      .TextMatrix(1, 2) = "乘车日期"
      .TextMatrix(1, 3) = "票数"
    While rst.EOF = False
      .Rows = .Rows + 1
      .TextMatrix(.Rows - 1, 0) = rst.Fields(0)
      .TextMatrix(.Rows - 1, 1) = rst.Fields(1)
      .TextMatrix(.Rows - 1, 2) = rst.Fields(2)
      .TextMatrix(.Rows - 1, 3) = rst.Fields(3)
      rst.MoveNext
    Wend
    rst.Close
  End With
  conn.Close
End Sub

Private Sub Command4_Click()
 Unload Me
End Sub

Private Sub Form_Load()
 Command2.Enabled = False
 Command3.Enabled = False
 Dim ConnectString As String
   Set conn = New ADODB.Connection
   ConnectString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
   & "Persist Security Info=False;Initial Catalog=陈念;" _
   & "Data Source=3302A68391D44A0"
   conn.CursorLocation = adUseClient
   conn.Open ConnectString
End Sub

⌨️ 快捷键说明

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