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

📄 frmddxx.frm

📁 本程序是一个酒店预定系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      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 MSDataGridLib.DataGrid DataGrid1 
      Align           =   2  'Align Bottom
      Height          =   3888
      Left            =   0
      TabIndex        =   10
      Top             =   2760
      Width           =   11388
      _ExtentX        =   20082
      _ExtentY        =   6853
      _Version        =   393216
      AllowUpdate     =   -1  'True
      HeadLines       =   2
      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
      Caption         =   "订单一览表"
      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 
         MarqueeStyle    =   3
         AllowFocus      =   0   'False
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "frmDDXX"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CurrentHotel As String
Dim editing As Boolean

Private Sub Combo1_Click()
CurrentHotel = Combo1.Text
Call FreshData
End Sub

Private Sub Combo3_Click()
CurrentHotel = Combo3.Text
Call FreshData
End Sub

Private Sub Command1_Click()
If editing = False Then
editing = True

Text1.Text = ""
Text1.SetFocus
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Combo2.Text = ""
DTPicker1.Value = Date

Command1.Caption = "放弃"
Command1.Enabled = True
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True

Else
If MsgBox("确定取消添加新记录?", vbQuestion + vbYesNo, "取消?") = vbYes Then
    editing = False
    Call DataGrid1_Click
End If
End If

End Sub

Private Sub Command2_Click()
If editing = False Then
editing = True

Command2.Caption = "放弃"
Command1.Enabled = False
Command2.Enabled = True
Command3.Enabled = False
Command4.Enabled = True

Else
If MsgBox("确定取消修改当前记录?", vbQuestion + vbYesNo, "取消?") = vbYes Then
    editing = False
    Adodc1.Recordset.CancelBatch adAffectAllChapters
    Call DataGrid1_Click
End If
End If

End Sub

Private Sub Command3_Click()
If MsgBox("确定删除当前记录?", vbQuestion + vbYesNo, "删除?") = vbYes Then
    Adodc1.Recordset.Delete
    Adodc1.Recordset.MoveNext
    If Adodc1.Recordset.EOF Then
        If Adodc1.Recordset.RecordCount <> 0 Then
            Adodc1.Recordset.MoveLast
        End If
    End If
    Call DataGrid1_Click
End If
End Sub

Private Sub Command4_Click()
If Text1.Text = "" Then
MsgBox "请输入客户名称!"
Text1.SetFocus
Exit Sub
End If

If Combo1.Text = "" Then
MsgBox "请输入酒店名称!"
Combo1.SetFocus
Exit Sub
End If

If Combo2.Text = "" Then
MsgBox "请输入房间类型!"
Combo2.SetFocus
Exit Sub
End If

If Text2.Text = "" Then
MsgBox "请输入预定天数!"
Text2.SetFocus
Exit Sub
End If

If Text3.Text = "" Then
MsgBox "请输入预定间数!"
Text3.SetFocus
Exit Sub
End If

If Command1.Enabled = True Then
Adodc1.Recordset.AddNew
Adodc1.Recordset(1) = Text1.Text
Adodc1.Recordset(2) = Combo1.Text
Adodc1.Recordset(3) = UserName
Adodc1.Recordset(4) = Combo2.Text
Adodc1.Recordset(5) = Text2.Text
Adodc1.Recordset(6) = Text3.Text
Adodc1.Recordset(7) = DTPicker1.Value
Adodc1.Recordset.UpdateBatch adAffectAllChapters
Else
Adodc1.Recordset(1) = Text1.Text
Adodc1.Recordset(2) = Combo1.Text
Adodc1.Recordset(3) = UserName
Adodc1.Recordset(4) = Combo2.Text
Adodc1.Recordset(5) = Text2.Text
Adodc1.Recordset(6) = Text3.Text
Adodc1.Recordset(7) = DTPicker1.Value
Adodc1.Recordset.UpdateBatch adAffectAllChapters
End If

editing = False

Call DataGrid1_Click

End Sub

Private Sub DataGrid1_Click()
If editing = False Then
Command1.Caption = "添加"
Command1.Enabled = True

If Adodc1.Recordset.RecordCount <> 0 Then
Command2.Caption = "修改"
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = False
Text1.Text = Adodc1.Recordset(1)
Combo1.Text = Adodc1.Recordset(2)
Combo2.Text = Adodc1.Recordset(4)
Text2.Text = Adodc1.Recordset(5)
Text3.Text = Adodc1.Recordset(6)
DTPicker1.Value = Adodc1.Recordset(7)
Else
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
End If
End If


End Sub

Private Sub Form_Load()
    Adodc1.ConnectionString = constr
    Adodc1.CommandType = adCmdTable
    Adodc1.RecordSource = "订单表"
    Adodc1.Refresh
    Set DataGrid1.DataSource = Adodc1
    Adodc1.Refresh
    DataGrid1.ReBind

    Adodc2.ConnectionString = constr
    Adodc2.CommandType = adCmdTable
    Adodc2.RecordSource = "酒店信息"
    Adodc2.Refresh
    Combo1.Clear
    Combo3.Clear
    Adodc2.Recordset.MoveFirst
    While Not Adodc2.Recordset.EOF
    Combo1.AddItem Adodc2.Recordset(1)
    Combo3.AddItem Adodc2.Recordset(1)
    Adodc2.Recordset.MoveNext
    Wend
    
    editing = False
    
End Sub

Private Sub Form_Resize()
If Me.WindowState = 1 Then
Exit Sub
End If
DataGrid1.Height = Me.Height - Frame1.Height - Adodc1.Height - 200

End Sub

Public Sub FreshData()
    Combo1.Text = CurrentHotel
    Combo3.Text = CurrentHotel

    Adodc2.ConnectionString = constr
    Adodc2.CommandType = adCmdText
    Adodc2.RecordSource = "select * from 房间类型表 where 酒店名称 = '" & CurrentHotel & "'"
    Adodc2.Refresh
    Set DataGrid2.DataSource = Adodc2
    Adodc2.Refresh
    DataGrid2.ReBind
    
    If Adodc2.Recordset.RecordCount <> 0 Then
    Adodc2.Recordset.MoveFirst
    Combo2.Clear
    For i = 0 To Adodc2.Recordset.RecordCount - 1
    Combo2.AddItem Adodc2.Recordset(2)
    Adodc2.Recordset.MoveNext
    Next i
    End If
    
    
End Sub

⌨️ 快捷键说明

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