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

📄 frmfjxx.frm

📁 c++酒店管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmFJXX 
   Caption         =   "房间信息管理"
   ClientHeight    =   7212
   ClientLeft      =   48
   ClientTop       =   336
   ClientWidth     =   8880
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7212
   ScaleWidth      =   8880
   WindowState     =   2  'Maximized
   Begin VB.Frame Frame1 
      Height          =   2412
      Left            =   480
      TabIndex        =   1
      Top             =   120
      Width           =   7812
      Begin VB.ComboBox Combo1 
         Height          =   276
         ItemData        =   "frmFJXX.frx":0000
         Left            =   1320
         List            =   "frmFJXX.frx":0002
         TabIndex        =   17
         Top             =   240
         Width           =   2172
      End
      Begin VB.Frame Frame2 
         Height          =   1032
         Left            =   360
         TabIndex        =   7
         Top             =   600
         Width           =   7095
         Begin VB.TextBox Text3 
            Height          =   300
            Left            =   5400
            TabIndex        =   10
            Top             =   240
            Width           =   1515
         End
         Begin VB.TextBox Text2 
            Height          =   300
            Left            =   3120
            TabIndex        =   9
            Top             =   240
            Width           =   1515
         End
         Begin VB.TextBox Text1 
            BeginProperty DataFormat 
               Type            =   1
               Format          =   """¥""#,##0.00"
               HaveTrueFalseNull=   0
               FirstDayOfWeek  =   0
               FirstWeekOfYear =   0
               LCID            =   2052
               SubFormatType   =   2
            EndProperty
            Height          =   300
            Left            =   840
            TabIndex        =   8
            Top             =   240
            Width           =   1515
         End
         Begin VB.Label Label9 
            AutoSize        =   -1  'True
            Caption         =   "单位:元"
            ForeColor       =   &H00FF0000&
            Height          =   180
            Left            =   6240
            TabIndex        =   16
            Top             =   720
            Width           =   636
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            Caption         =   "门市价"
            Height          =   180
            Left            =   4800
            TabIndex        =   13
            Top             =   240
            Width           =   540
         End
         Begin VB.Label Label5 
            AutoSize        =   -1  'True
            Caption         =   "会员价"
            Height          =   180
            Left            =   240
            TabIndex        =   12
            Top             =   240
            Width           =   540
         End
         Begin VB.Label Label6 
            AutoSize        =   -1  'True
            Caption         =   "内部价"
            Height          =   180
            Left            =   2520
            TabIndex        =   11
            Top             =   240
            Width           =   540
         End
      End
      Begin VB.ComboBox Combo2 
         Height          =   276
         Left            =   4800
         TabIndex        =   6
         Top             =   240
         Width           =   2592
      End
      Begin VB.CommandButton Command4 
         Caption         =   "保存"
         Height          =   345
         Left            =   2355
         TabIndex        =   5
         Top             =   1800
         Width           =   1230
      End
      Begin VB.CommandButton Command3 
         Caption         =   "删除"
         Height          =   345
         Left            =   5070
         TabIndex        =   4
         Top             =   1800
         Width           =   1230
      End
      Begin VB.CommandButton Command2 
         Caption         =   "修改"
         Height          =   345
         Left            =   3705
         TabIndex        =   3
         Top             =   1800
         Width           =   1230
      End
      Begin VB.CommandButton Command1 
         Caption         =   "添加"
         Height          =   345
         Left            =   960
         TabIndex        =   2
         Top             =   1800
         Width           =   1230
      End
      Begin VB.Label Label1 
         Caption         =   "酒店名称"
         Height          =   252
         Left            =   480
         TabIndex        =   15
         Top             =   240
         Width           =   1092
      End
      Begin VB.Label Label8 
         AutoSize        =   -1  'True
         Caption         =   "房间类型"
         Height          =   180
         Left            =   3960
         TabIndex        =   14
         Top             =   240
         Width           =   720
      End
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Align           =   2  'Align Bottom
      Height          =   4188
      Left            =   0
      TabIndex        =   0
      Top             =   2688
      Width           =   8880
      _ExtentX        =   15663
      _ExtentY        =   7387
      _Version        =   393216
      AllowUpdate     =   -1  'True
      ForeColor       =   0
      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
         AllowRowSizing  =   0   'False
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Align           =   2  'Align Bottom
      Height          =   336
      Left            =   0
      Top             =   6876
      Visible         =   0   'False
      Width           =   8880
      _ExtentX        =   15663
      _ExtentY        =   593
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      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
End
Attribute VB_Name = "frmFJXX"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim editing As Boolean


Private Sub Combo1_Click()
Call FreshData
End Sub

Private Sub Combo2_Click()
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "房间类型 = '" & Combo2.Text & "'"

If Not Adodc1.Recordset.EOF Then
Call DataGrid1_Click
End If

End Sub


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

Combo2.Text = ""
Combo2.SetFocus
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""

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 Combo2.Text = "" Then
MsgBox "请输入房间类型!"
Combo2.SetFocus
Exit Sub
End If

If Text1.Text = "" Then
MsgBox "请输入门市价!"
Text1.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

If Adodc1.Recordset.RecordCount <> 0 Then
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "房间类型 = '" & Combo2.Text & "'"
If Not Adodc1.Recordset.EOF Then
MsgBox "该房间类型的记录已经存在!将取消添加。"
editing = False
Call DataGrid1_Click
Exit Sub
End If
End If

Adodc1.Recordset.AddNew
Adodc1.Recordset(1) = Combo1.Text
Adodc1.Recordset(2) = Combo2.Text
Adodc1.Recordset(3) = Text1.Text
Adodc1.Recordset(4) = Text2.Text
Adodc1.Recordset(5) = Text3.Text
Adodc1.Recordset.UpdateBatch adAffectAllChapters
Else
Adodc1.Recordset(1) = Combo1.Text
Adodc1.Recordset(2) = Combo2.Text
Adodc1.Recordset(3) = Text1.Text
Adodc1.Recordset(4) = Text2.Text
Adodc1.Recordset(5) = Text3.Text
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(3)
Text2.Text = Adodc1.Recordset(4)
Text3.Text = Adodc1.Recordset(5)
Combo2.Text = Adodc1.Recordset(2)
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
    
    Combo1.Clear
    Adodc1.Recordset.MoveFirst
    While Not Adodc1.Recordset.EOF
    Combo1.AddItem Adodc1.Recordset(1)
    Adodc1.Recordset.MoveNext
    Wend
    
    Combo1.ListIndex = 0
    
    editing = False

    Call FreshData
        
End Sub

Private Sub Form_Resize()
If Me.WindowState = 1 Then
Exit Sub
End If
With Frame1
    .Left = (Me.Width - Frame1.Width) / 2
    .Top = 120
End With

DataGrid1.Height = Me.Height - Frame1.Height - Adodc1.Height - 200

End Sub

Public Sub FreshData()
Dim str As String

    Adodc1.ConnectionString = constr
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = "select * from 房间类型表 where 酒店名称 = '" & Combo1.Text & "'"
    Adodc1.Refresh
    
    Combo2.Clear
    If Adodc1.Recordset.RecordCount <> 0 Then
    Adodc1.Recordset.MoveFirst
    While Not Adodc1.Recordset.EOF
    Combo2.AddItem Adodc1.Recordset(2)
    Adodc1.Recordset.MoveNext
    Wend
    End If
    
    Set DataGrid1.DataSource = Adodc1
    Adodc1.Refresh
    DataGrid1.ReBind
    
    Call DataGrid1_Click
    
End Sub

⌨️ 快捷键说明

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