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

📄 form4.frm

📁 该程序采VB6作为前端开发工具,以SQL Server 2000作为后台数据库开发平台.
💻 FRM
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form form4 
   Caption         =   "预定房间"
   ClientHeight    =   6135
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6405
   Icon            =   "Form4.frx":0000
   LinkTopic       =   "Form4"
   ScaleHeight     =   6135
   ScaleWidth      =   6405
   StartUpPosition =   3  '窗口缺省
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   2655
      Left            =   120
      TabIndex        =   19
      Top             =   3360
      Width           =   6135
      _ExtentX        =   10821
      _ExtentY        =   4683
      _Version        =   393216
      HeadLines       =   1
      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
      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 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Frame Frame1 
      Height          =   855
      Left            =   120
      TabIndex        =   15
      Top             =   2400
      Width           =   6135
      Begin VB.CommandButton Command3 
         Caption         =   "添加"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   480
         TabIndex        =   18
         Top             =   240
         Width           =   1215
      End
      Begin VB.CommandButton Command1 
         Caption         =   "返回"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   4440
         TabIndex        =   17
         Top             =   240
         Width           =   1095
      End
      Begin VB.CommandButton Command2 
         Caption         =   "删除超时房间"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   2520
         TabIndex        =   16
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "预定房间"
      Height          =   2295
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6135
      Begin MSComCtl2.DTPicker DTPicker1 
         Height          =   375
         Left            =   4440
         TabIndex        =   14
         Top             =   1200
         Width           =   1455
         _ExtentX        =   2566
         _ExtentY        =   661
         _Version        =   393216
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Format          =   24576001
         CurrentDate     =   37264
      End
      Begin VB.ComboBox Combo2 
         Height          =   300
         ItemData        =   "Form4.frx":030A
         Left            =   1080
         List            =   "Form4.frx":030C
         TabIndex        =   13
         Top             =   1200
         Width           =   1335
      End
      Begin VB.ComboBox Combo1 
         Height          =   300
         ItemData        =   "Form4.frx":030E
         Left            =   2640
         List            =   "Form4.frx":0318
         TabIndex        =   12
         Top             =   480
         Width           =   1095
      End
      Begin VB.TextBox Text4 
         Height          =   375
         Left            =   4440
         TabIndex        =   11
         Top             =   1680
         Width           =   1455
      End
      Begin VB.TextBox Text3 
         Height          =   375
         Left            =   1080
         TabIndex        =   10
         Top             =   1680
         Width           =   1335
      End
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   4680
         TabIndex        =   9
         Top             =   480
         Width           =   1215
      End
      Begin VB.TextBox Text1 
         Height          =   375
         Left            =   720
         TabIndex        =   8
         Top             =   480
         Width           =   1215
      End
      Begin VB.Label Label22 
         Caption         =   "房间类型"
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   1200
         Width           =   855
      End
      Begin VB.Label Label15 
         Caption         =   "预定天数"
         Height          =   255
         Left            =   3600
         TabIndex        =   6
         Top             =   1800
         Width           =   735
      End
      Begin VB.Label Label14 
         Caption         =   "预定时间"
         Height          =   255
         Left            =   3600
         TabIndex        =   5
         Top             =   1200
         Width           =   735
      End
      Begin VB.Label Label13 
         Caption         =   "电话号码"
         Height          =   255
         Left            =   3840
         TabIndex        =   4
         Top             =   480
         Width           =   735
      End
      Begin VB.Label Label16 
         Caption         =   "预定人数"
         Height          =   255
         Left            =   240
         TabIndex        =   3
         Top             =   1800
         Width           =   735
      End
      Begin VB.Label Label17 
         Caption         =   "性别"
         Height          =   255
         Left            =   2160
         TabIndex        =   2
         Top             =   480
         Width           =   495
      End
      Begin VB.Label Label18 
         Caption         =   "姓名"
         Height          =   255
         Left            =   240
         TabIndex        =   1
         Top             =   480
         Width           =   495
      End
   End
End
Attribute VB_Name = "form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public rs As ADODB.Recordset
Public db As ADODB.Connection

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Command2_Click()
Dim i As String
i = MsgBox("你确定删除吗?", vbOKCancel)

If i = 1 Then
rs.Close
  rs.Open "select  min(预定时间) as Expr1 from 预定房间"
  
  w = rs.Fields("expr1").Value
  'MsgBox w
  rs.Close
 rs.Open "select * from 预定房间 where 预定时间='" & Trim(w) & "'"
rs.Close
rs.Open "delete from 预定房间 where 预定时间='" & Trim(w) & "'"
Set DataGrid1.DataSource = rs
Command2.Enabled = False
'rs.Close

End If
End Sub

Private Sub Command3_Click()
Dim n As Date
 Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset
 db.ConnectionString = "driver={SQL Server};server=04;database=酒店管理;Persist Security Info=False;User ID=sa"

db.Open
Dim i As String
If Text1.Text <> "" Then
If Val(Trim(Text3.Text)) <= 9999 And Val(Trim(Text3.Text)) >= 0 Then
If Len(Trim(Text2.Text)) <= 12 And Len(Trim(Text2.Text)) >= 0 And Val(Trim(Text2.Text)) <= 999999999999# And Val(Trim(Text2.Text)) >= 0 Then
i = MsgBox("你确定预定吗?", vbOKCancel)

If i = 1 Then
'rs.Close
  rs.Open " insert into 预定房间(姓名,电话号码,性别,预定时间,预定天数,预定人数,房间类型) values ( '" & Trim(Text1.Text) & "','" & Trim(Text2.Text) & "','" & Trim(Combo1.Text) & "','" & Trim(DTPicker1.Value) & "','" & Trim(Text4.Text) & "','" & Trim(Text3.Text) & "','" & Trim(Combo2.Text) & "')", db, adOpenStatic, adLockReadOnly
 Set DataGrid1.DataSource = rs
 lianjie
  
 Else
 Text1.Text = ""
 Text2.Text = ""
 Text3.Text = ""
 Text4.Text = ""
 Combo1.Text = ""
 Combo2.Text = ""
 End If
  Else
n = MsgBox("电话有错误,请重试!", vbExclamation)
 End If
 Else
n = MsgBox("人数错误,请重试!", vbExclamation)
 End If
 
Else
n = MsgBox("请输入姓名,请重试!", vbExclamation)
 End If
End Sub

Private Sub Form_Load()
On Error Resume Next
Dim n As Date
Dim t As Integer
 Set db = New ADODB.Connection
 Set rs = New ADODB.Recordset
 db.ConnectionString = "driver={SQL Server};server=04;database=酒店管理;Persist Security Info=False;User ID=sa"

db.Open
rs.Open "select * from 预定房间", db, adOpenStatic, adLockReadOnly
 Set DataGrid1.DataSource = rs
  rs.Close
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
   
  Combo2.AddItem i
 Next t
 
 Command2.Enabled = False
 rs.Close
rs.Open "select min(预定时间) as x from 预定房间 "
m = rs.Fields("x").Value
n = Date$
If DateDiff("d", n, m) >= 0 Then

rs.Close
rs.Open "select * from 预定房间"
Set DataGrid1.DataSource = rs
 Else
MsgBox "预定房间里有过期的时间!"
     Command2.Enabled = True
rs.Close
  rs.Open "select  min(预定时间) as Expr1 from 预定房间"
  w = rs.Fields("expr1").Value
  rs.Close
 rs.Open "select * from 预定房间 where 预定时间='" & Trim(w) & "'"
 Set DataGrid1.DataSource = rs
End If
 
End Sub
Public Sub lianjie()
rs.Open "select * from 预定房间", db, adOpenStatic, adLockReadOnly
Set DataGrid1.DataSource = rs
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
 
 
'if not key in ['0'..'9','.',#8]) then Key := #0;
End Sub

⌨️ 快捷键说明

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