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

📄 form2.frm

📁 酒店管理系统(VB),很强大
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         TabIndex        =   39
         Top             =   240
         Width           =   1215
         _ExtentX        =   2143
         _ExtentY        =   661
         _Version        =   393216
         Format          =   23789569
         CurrentDate     =   37609
      End
      Begin VB.TextBox Text6 
         Height          =   375
         Left            =   3960
         TabIndex        =   27
         Top             =   1560
         Width           =   1215
      End
      Begin VB.ComboBox Combo5 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         Left            =   3960
         TabIndex        =   17
         Top             =   360
         Width           =   1215
      End
      Begin VB.ComboBox Combo3 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         Left            =   3960
         TabIndex        =   9
         Top             =   960
         Width           =   1215
      End
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   1320
         TabIndex        =   7
         Top             =   1560
         Width           =   1215
      End
      Begin VB.Label Label14 
         Caption         =   "床位"
         Height          =   255
         Left            =   3360
         TabIndex        =   28
         Top             =   1560
         Width           =   375
      End
      Begin VB.Label Label5 
         Caption         =   "证件号码"
         Height          =   255
         Left            =   480
         TabIndex        =   5
         Top             =   1560
         Width           =   855
      End
      Begin VB.Label Label7 
         Caption         =   "房间号码"
         Height          =   255
         Left            =   3120
         TabIndex        =   4
         Top             =   960
         Width           =   735
      End
      Begin VB.Label Label22 
         Caption         =   "房间类型"
         Height          =   255
         Left            =   3120
         TabIndex        =   3
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "住店时间"
         Height          =   255
         Left            =   480
         TabIndex        =   2
         Top             =   360
         Width           =   855
      End
      Begin VB.Label Label6 
         Caption         =   "证件名称"
         Height          =   255
         Left            =   480
         TabIndex        =   1
         Top             =   960
         Width           =   735
      End
   End
End
Attribute VB_Name = "form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public rs As ADODB.Recordset
Public db As ADODB.Connection
Public Sub lianjie()
rs.Open "select * from 酒店登记", db, adOpenStatic, adLockReadOnly
Set DataGrid1.DataSource = rs
End Sub

Private Sub Combo5_Click()
Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset

 db.ConnectionString = "driver={SQL Server};server=ZHANWEN\ZHANWEN;database=酒店管理;User ID=sa;pwd="
db.Open
rs.Open "select DISTINCT 房间类型 from 增删房间", db, adOpenStatic, adLockReadOnly
rs.Close
Combo3.Clear
rs.Open "select DISTINCT 房间号码 from 增删房间 WHERE 房间类型 ='" & Trim(Combo5.Text) & "' and 性别 ='" & Trim(Combo1.Text) & "'", db, adOpenStatic, adLockReadOnly
Dim t As Integer
 Dim i As String
  For t = 0 To Val(rs.RecordCount) - 1
  i = Trim(rs.Fields("房间号码").Value)
   rs.MoveNext
 Combo3.AddItem i
  Next t
rs.Close
rs.Open "select 总床位数 from 增删房间 WHERE 房间类型 ='" & Trim(Combo5.Text) & "'"

Text3.Text = rs.Fields("总床位数").Value
rs.Close
rs.Open "select 收费标准 from 增删房间 WHERE 房间类型 ='" & Trim(Combo5.Text) & "'"
Text7.Text = rs.Fields("收费标准").Value
Text9.Text = Combo5.Text
rs.Close
 End Sub
Private Sub Command1_Click()
On Error Resume Next

Dim i As String
Dim m As String
Dim sql1 As String
Dim sql2 As String
Dim n As Integer
Dim x As Integer
Dim j As Integer
Dim h As Integer
   
   Dim fjs As Integer
Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset

 db.ConnectionString = "driver={SQL Server};server=ZHANWEN\ZHANWEN;database=酒店管理;User ID=sa"
db.Open
rs.Open "select DISTINCT 房间类型 from 增删房间", db, adOpenStatic, adLockReadOnly
rs.Close

rs.Open "SELECT COUNT(房间号码) AS Expr1 FROM 酒店登记 WHERE 房间号码 ='" & Trim(Combo3.Text) & "'"
 n = rs.Fields("expr1").Value
 x = Text3.Text
 j = Text6.Text
 h = Text5.Text
If Text1.Text <> "" Then
 rs.Close
 rs.Open "select 床位 from 酒店登记 where 房间号码='" & Trim(Combo3.Text) & "' and 床位='" & Trim(Text6.Text) & "'", db, adOpenDynamic, adLockReadOnly
 
 If rs.EOF = False Then
 
m = MsgBox("此床位已住人,请重填!", 48)
Text6.Text = ""
Text6.SetFocus
 Else
 If Text6.Text <> "" Then
 
 If n < x Then
 
If j <= x And h <= x Then

If Text2.Text <> "" Then

 If Len(Trim(Combo3.Text)) = 4 And Val(Trim(Combo3.Text)) < 9999 And Val(Trim(Combo3.Text)) > 0 Then
    If Len(Trim(Text2.Text)) <= 18 And Len(Trim(Text2.Text)) >= 0 And Val(Trim(Text2.Text)) <= 1E+17 And Val(Trim(Text2.Text)) >= 0 Then
       If Combo2.Text <> "" Then
    
    
    
rs.Close
rs.Open "SELECT count(房间号码) AS fjs From 酒店登记 WHERE 房间号码 ='" & Trim(Combo3.Text) & "'"

 i = MsgBox("你确定添加吗", vbOKCancel)
If i = 1 Then
rs.Close
rs.Open " insert into 酒店登记(住店时间,姓名,性别,住宿人数,籍贯,证件名称,证件号码,房间类型,总床位数,房间号码,床位,出生日期,地址) values ( '" & Trim(DTPicker1.Value) & "','" & Trim(Text1.Text) & "','" & Trim(Combo1.Text) & "','" & Trim(Text5.Text) & "','" & Trim(Combo4.Text) & "','" & Trim(Combo2.Text) & "','" & Trim(Text2.Text) & "','" & Trim(Combo5.Text) & "','" & Trim(Text3.Text) & "','" & Trim(Combo3.Text) & "','" & Trim(Val(Text6.Text)) & "','" & Trim(DTPicker2.Value) & "','" & Trim(Text8.Text) & "')", db, adOpenStatic, adLockReadOnly

Set DataGrid1.DataSource = rs
  lianjie
  Text1.Text = ""
  Text2.Text = ""
  Combo3.Text = ""
  
  Text3.Text = ""
  Combo4.Text = ""
  Text6.Text = ""
  Text7.Text = ""
  Text8.Text = ""
  Text9.Text = ""
  Combo1.Text = ""
  Combo2.Text = ""
  Combo5.Text = ""
 
Else
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
'Text5.Text = ""
Text6.Text = ""
Text9.Text = ""
Combo3.Text = ""

Combo4.Text = ""
Text7.Text = ""
Text8.Text = ""
Combo5.Text = ""
Combo1.Text = ""
Combo2.Text = ""
End If

rs.Close
Else
m = MsgBox(" 证件名称必须填写,请重填!", 48)
Combo2.Text = ""
End If



Else
m = MsgBox("证件号码填写出错,请重填!", 48)
Text2.Text = ""
End If

Else
m = MsgBox("房间号填写出错,请重填!", 48)
Combo3.Text = ""
End If

Else
m = MsgBox("证件号码必须填写,请重填!", 48)
Text1.Text = ""
End If

Else
m = MsgBox("人数和床位不对,请重填!", 48)
'Text5.Text = ""
Text6.Text = ""
Text6.SetFocus
End If

Else
m = MsgBox("此房间住满,请重选房间!", 48)
Combo3.Text = ""
End If
Else
m = MsgBox("床位没填!", 48)
Text6.SetFocus
End If

End If

Else
m = MsgBox("姓名必须填写,请重填!", 48)
Text1.Text = ""
End If

 End Sub
Private Sub Command3_Click()
form2.Hide
form1.Show
End Sub

Private Sub Command4_Click()
Dim strname As String * 40, strs1 As String * 40
Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset

db.ConnectionString = "driver={SQL Server};server=ZHANWEN\ZHANWEN;database=酒店管理;User ID=sa;pwd="
db.Open
rs.Open "select * from 酒店登记", db, adOpenStatic, adLockReadOnly
strs1 = "请输入姓名或电话号码" + Chr(13) + Chr(10) + "然后单击确定"
 strname = InputBox$(strs1, "输入框", , 100, 100)
rs.Close
rs.Open " select 姓名,电话号码,性别,预定时间,房间类型,预定人数,预定天数 from 预定房间 where 姓名='" & strname & "' or  电话号码='" & strname & "'"
 Set DataGrid1.DataSource = rs
If rs.EOF Then
MsgBox "无此人!", , "提示"
 End If
End Sub

Private Sub DTPicker3_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)

End Sub

Private Sub Form_Load()
 Text7.Enabled = False
Dim t As Integer
 Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset
 
 db.ConnectionString = "driver={SQL Server};server=ZHANWEN\ZHANWEN;database=酒店管理;User ID=sa;pwd="

db.Open
rs.Open "select DISTINCT 房间类型 from 增删房间", db, adOpenStatic, adLockReadOnly

 Dim i As String
  For t = 0 To Val(rs.RecordCount) - 1
  i = Trim(rs.Fields("房间类型").Value)
   rs.MoveNext
   
  Combo5.AddItem i
 Next t
rs.Close
Text5.Text = 1
End Sub

Private Sub Label10_Click()

End Sub

Private Sub 旅客查询_Click()
Dim n As String
Dim strname As String * 40, strs1 As String * 40

Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset
 
 db.ConnectionString = "driver={SQL Server};server=ZHANWEN\ZHANWEN;database=酒店管理;User ID=sa;pwd="
db.Open
rs.Open "select * from 酒店登记", db, adOpenStatic, adLockReadOnly
strs1 = "请输入姓名或房间号码或籍贯" + Chr(13) + Chr(10) + "然后单击确定"
 strname = InputBox$(strs1, "输入框")
rs.Close

rs.Open " select 姓名,性别,房间号码,住店时间,住宿天数,籍贯,房间类型,房间号码,证件名称,证件号码,地址,出生日期,床位 from 酒店登记 where 姓名='" & Trim(strname) & "' or 房间号码='" & Val(Trim(strname)) & "' or 籍贯='" & Val(Trim(strname)) & "'"
 Set DataGrid1.DataSource = rs
If rs.EOF Then

n = MsgBox("无此人!", vbInformation)
End If

End Sub

Private Sub 退房_Click()
Dim i As String
Dim n As String
Dim strname As String * 40, strs1 As String * 40
Dim x As String
strs1 = "请输入姓名或证件号码!" + Chr(13) + Chr(10) + "然后单击确定"
 strname = InputBox$(strs1, "输入框")
 Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset
 db.ConnectionString = "driver={SQL Server};server=ZHANWEN\ZHANWEN;database=酒店管理;User ID=sa;pwd="
db.Open
rs.Open "select 姓名 from 酒店登记", db, adOpenStatic, adLockReadOnly

rs.Close
rs.Open " update 酒店登记 Set 房间号码 = Null where 姓名 ='" & Trim(strname) & "' or 证件号码='" & Trim(strname) & "'", db, adOpenStatic, adLockReadOnly
'rs.Open " delete '房间号码' from 酒店登记 where 姓名='" & Trim(strname) & "'", db, adOpenStatic, adLockReadOnly
'rs.Close
rs.Open "select * from 酒店登记 where 姓名='" & Trim(strname) & "' or 证件号码='" & Trim(strname) & "'", db, adOpenStatic, adLockReadOnly
Set DataGrid1.DataSource = rs
If rs.EOF Then
 n = MsgBox("无此人?", vbInformation)
 Else
 i = MsgBox("确实删除此人吗?", vbOKCancel)
  If i = 1 Then
 rs.Close
 rs.Open "delete from 酒店登记 where 姓名='" & Trim(strname) & "' or 证件号码='" & Trim(strname) & "'"
 Set DataGrid1.DataSource = rs
  End If
  End If
End Sub


⌨️ 快捷键说明

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