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

📄 frmcaculate.frm

📁 数据库课程设计
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmCaculate 
   Caption         =   "结帐"
   ClientHeight    =   5955
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6600
   LinkTopic       =   "Form1"
   ScaleHeight     =   5955
   ScaleWidth      =   6600
   StartUpPosition =   3  'Windows Default
   Begin VB.Frame Frame3 
      Caption         =   "结帐信息"
      Height          =   855
      Left            =   120
      TabIndex        =   23
      Top             =   4320
      Width           =   6375
      Begin VB.TextBox txtTotal 
         Height          =   405
         Left            =   2640
         TabIndex        =   27
         Top             =   240
         Width           =   1095
      End
      Begin VB.Label Label7 
         Caption         =   "元"
         Height          =   255
         Left            =   3840
         TabIndex        =   28
         Top             =   360
         Width           =   495
      End
      Begin VB.Label Label6 
         Caption         =   "天,共计"
         Height          =   255
         Left            =   1800
         TabIndex        =   26
         Top             =   360
         Width           =   855
      End
      Begin VB.Label lblDays 
         Caption         =   "0"
         ForeColor       =   &H000000C0&
         Height          =   255
         Left            =   1560
         TabIndex        =   25
         Top             =   360
         Width           =   135
      End
      Begin VB.Label Label4 
         Caption         =   "共住"
         Height          =   255
         Left            =   1080
         TabIndex        =   24
         Top             =   360
         Width           =   495
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取消(&X)"
      Height          =   435
      Left            =   3360
      TabIndex        =   22
      Top             =   5400
      Width           =   1455
   End
   Begin VB.CommandButton Command1 
      Caption         =   "结帐(&C)"
      Height          =   435
      Left            =   1560
      TabIndex        =   21
      Top             =   5400
      Width           =   1455
   End
   Begin VB.Frame Frame2 
      Caption         =   "顾客信息"
      Height          =   2295
      Index           =   1
      Left            =   120
      TabIndex        =   5
      Top             =   2040
      Width           =   6375
      Begin VB.TextBox txtBookNo 
         Height          =   285
         Left            =   1320
         TabIndex        =   31
         Top             =   330
         Width           =   2175
      End
      Begin VB.TextBox txtCusMemo 
         Height          =   1440
         Left            =   3720
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   10
         Top             =   600
         Width           =   2535
      End
      Begin VB.TextBox txtName 
         Height          =   270
         Left            =   1320
         MaxLength       =   5
         TabIndex        =   9
         Top             =   720
         Width           =   2175
      End
      Begin VB.TextBox txtID 
         Height          =   270
         Left            =   1320
         MaxLength       =   18
         TabIndex        =   8
         Top             =   1080
         Width           =   2175
      End
      Begin VB.TextBox txtDateIn 
         Height          =   270
         Left            =   1320
         MaxLength       =   10
         TabIndex        =   7
         Top             =   1440
         Width           =   2172
      End
      Begin VB.TextBox txtDiscount 
         Height          =   270
         Left            =   1320
         MaxLength       =   3
         TabIndex        =   6
         Top             =   1800
         Width           =   1572
      End
      Begin VB.Label Label9 
         Caption         =   "%"
         Height          =   255
         Left            =   3000
         TabIndex        =   32
         Top             =   1800
         Width           =   495
      End
      Begin VB.Label Label8 
         Caption         =   "登    记    号:"
         Height          =   255
         Left            =   240
         TabIndex        =   30
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "%"
         Height          =   255
         Index           =   8
         Left            =   3000
         TabIndex        =   16
         Top             =   1440
         Width           =   495
      End
      Begin VB.Label Label2 
         Caption         =   "备 注 信 息:"
         Height          =   255
         Index           =   7
         Left            =   3720
         TabIndex        =   15
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "入 住 时 间:"
         Height          =   255
         Index           =   11
         Left            =   240
         TabIndex        =   14
         Top             =   1440
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "折            扣:"
         Height          =   255
         Index           =   6
         Left            =   240
         TabIndex        =   13
         Top             =   1800
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "身份证号码:"
         Height          =   255
         Index           =   5
         Left            =   240
         TabIndex        =   12
         Top             =   1080
         Width           =   1095
      End
      Begin VB.Label Label2 
         Caption         =   "顾 客  姓 名:"
         Height          =   255
         Index           =   4
         Left            =   240
         TabIndex        =   11
         Top             =   720
         Width           =   1095
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "房间信息"
      Height          =   855
      Index           =   0
      Left            =   120
      TabIndex        =   4
      Top             =   1080
      Width           =   6375
      Begin VB.TextBox txtRoomNo 
         Height          =   405
         Left            =   1080
         TabIndex        =   29
         Text            =   "Text1"
         Top             =   240
         Width           =   1815
      End
      Begin VB.TextBox txtPrice 
         Height          =   405
         Left            =   4440
         TabIndex        =   17
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label3 
         Caption         =   "元/天"
         Height          =   255
         Left            =   5760
         TabIndex        =   20
         Top             =   360
         Width           =   495
      End
      Begin VB.Label Label2 
         Caption         =   "房间单价:"
         Height          =   255
         Index           =   3
         Left            =   3360
         TabIndex        =   19
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label2 
         Caption         =   "房间编号:"
         Height          =   255
         Index           =   0
         Left            =   120
         TabIndex        =   18
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "房间结帐"
      Height          =   855
      Index           =   0
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6375
      Begin VB.CommandButton cmdQuery 
         Caption         =   "确定(&Y)"
         Height          =   375
         Left            =   4200
         TabIndex        =   3
         Top             =   240
         Width           =   1095
      End
      Begin VB.TextBox txtRoom 
         Height          =   375
         Left            =   1800
         TabIndex        =   2
         Top             =   240
         Width           =   1935
      End
      Begin VB.Label Label1 
         Caption         =   "请输入房间号:"
         Height          =   255
         Left            =   360
         TabIndex        =   1
         Top             =   360
         Width           =   1335
      End
   End
End
Attribute VB_Name = "frmCaculate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public sqlStr As String
Public msgText As String

Private Sub cmdQuery_Click()
    Dim rstRoom As ADODB.Recordset
    Dim rstCheckIn As ADODB.Recordset
    Dim dateIn As Date
    Dim dateOut As Date
    Dim days As Integer
    Dim totalfee As Double
    
        
    '首先查找房间相关信息并显示到屏幕上
 
    sqlStr = "select * from roomInfo where roomNO='" & Trim(txtRoom.Text) & "'"
    Set rstRoom = ExecuteSQL(sqlStr, msgText)
    
    If Not rstRoom.EOF Then
        txtPrice = rstRoom!roomPrice
        txtRoomNo.Text = rstRoom!roomNo
    Else
        MsgBox "没有找到相关数据!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    rstRoom.Close
    
    '查找该房间的登记信息
    sqlStr = "select * from checkIn where roomno='" & Trim(txtRoom.Text) & "' AND hasPaid='否'"
    
    Set rstCheckIn = ExecuteSQL(sqlStr, msgText)
    
    If Not rstCheckIn.EOF Then
        txtBookNo = rstCheckIn!bookno
        txtName = rstCheckIn!customerName
        txtID = rstCheckIn!customerID
        txtDateIn = rstCheckIn!date_in
        txtCusMemo = rstCheckIn!Memo
        txtDiscount = rstCheckIn!discount
    Else
        MsgBox "没有找到相关数据!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    rstCheckIn.Close
    
    '计算费用
       dateIn = CDate(txtDateIn.Text)
       dateOut = Date
       days = DateDiff("d", dateIn, dateOut)
       If days = 0 Then days = days + 1
       
       lblDays.Caption = days
       
       totalfee = days * Val(txtPrice) * Val(txtDiscount.Text) / 100
       txtTotal.Text = totalfee

End Sub

Private Sub Command1_Click()
    Dim rstRoom As ADODB.Recordset
    Dim rstCheckIn As ADODB.Recordset
    Dim dateOut As String
    
        
    '首先查找房间相关信息并修改结帐相关字段
 
    sqlStr = "select * from roomInfo where roomNO='" & Trim(txtRoom.Text) & "'"
    Set rstRoom = ExecuteSQL(sqlStr, msgText)
    
    If Not rstRoom.EOF Then
        rstRoom.Fields("hasBooked") = "否"
        rstRoom.Update
    Else
        MsgBox "没有找到相关数据!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    rstRoom.Close
    
    '查找该房间的登记信息,并修改相关结帐信息
    sqlStr = "select * from checkIn where bookno=" & Trim(txtBookNo.Text)
    
    Set rstCheckIn = ExecuteSQL(sqlStr, msgText)
    
    dateOut = Format(Date, "yyyy-mm-dd")

    If Not rstCheckIn.EOF Then
       rstCheckIn.Fields("date_out") = dateOut
       rstCheckIn.Fields("hasPaid") = "是"
       rstCheckIn.Fields("totalPaid") = txtTotal.Text
       rstCheckIn.Update
    Else
        MsgBox "没有找到相关数据!", vbOKOnly + vbExclamation, "警告"
        Exit Sub
    End If
    rstCheckIn.Close
        MsgBox "结帐完毕!", vbOKOnly, "提示"
    
    Unload Me
    
End Sub

Private Sub Command2_Click()
Unload Me

End Sub

Private Sub Form_Load()

'窗体居中显示
Me.Top = (Screen.Height - Me.Height) \ 2
Me.Left = (Screen.Width - Me.Width) \ 2


End Sub

⌨️ 快捷键说明

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