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

📄 reservationform.frm

📁 实现了
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmnewcustomer 
   Caption         =   "Form1"
   ClientHeight    =   8040
   ClientLeft      =   165
   ClientTop       =   270
   ClientWidth     =   10545
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   8040
   ScaleWidth      =   10545
   Begin VB.PictureBox Picture1 
      Align           =   1  'Align Top
      Height          =   7575
      Left            =   0
      ScaleHeight     =   7515
      ScaleWidth      =   10485
      TabIndex        =   0
      Top             =   0
      Width           =   10545
      Begin VB.TextBox txtid 
         Height          =   495
         Left            =   3240
         TabIndex        =   11
         Top             =   840
         Width           =   4335
      End
      Begin VB.TextBox txtcpwd 
         Height          =   495
         Left            =   3240
         TabIndex        =   10
         Top             =   1440
         Width           =   4455
      End
      Begin VB.TextBox txtcname 
         Height          =   495
         Left            =   3240
         TabIndex        =   9
         Top             =   2040
         Width           =   4455
      End
      Begin VB.TextBox txtaddress 
         Height          =   1575
         Left            =   3240
         TabIndex        =   8
         Top             =   2760
         Width           =   4455
      End
      Begin VB.Frame frmlgender 
         Caption         =   "Gender"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   975
         Left            =   720
         TabIndex        =   5
         Top             =   4440
         Width           =   5895
         Begin VB.OptionButton optmale 
            Caption         =   "Male"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   14.25
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   2640
            TabIndex        =   7
            Top             =   360
            Width           =   1215
         End
         Begin VB.OptionButton optfemale 
            Caption         =   "Female"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   14.25
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   4080
            TabIndex        =   6
            Top             =   360
            Width           =   1575
         End
      End
      Begin VB.ComboBox cmbcountry 
         Height          =   300
         Left            =   2520
         TabIndex        =   4
         Top             =   5640
         Width           =   3495
      End
      Begin VB.TextBox txtphone 
         Height          =   495
         Left            =   2520
         TabIndex        =   3
         Top             =   6120
         Width           =   3495
      End
      Begin VB.CommandButton cmdsave 
         Caption         =   "Save"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1800
         TabIndex        =   2
         Top             =   6840
         Width           =   1335
      End
      Begin VB.CommandButton cmdclose 
         Caption         =   "Close"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   3840
         TabIndex        =   1
         Top             =   6840
         Width           =   1335
      End
      Begin VB.Label lblnewcef 
         Caption         =   "New Customer Entry form"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15.75
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   1080
         TabIndex        =   18
         Top             =   120
         Width           =   6855
      End
      Begin VB.Label lblcid 
         Caption         =   "Customer ID:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   360
         TabIndex        =   17
         Top             =   960
         Width           =   1935
      End
      Begin VB.Label lblcpwd 
         Caption         =   "Customer Password:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   360
         TabIndex        =   16
         Top             =   1560
         Width           =   3375
      End
      Begin VB.Label lblcname 
         Caption         =   "Customer Name:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   360
         TabIndex        =   15
         Top             =   2040
         Width           =   2415
      End
      Begin VB.Label lbladdress 
         Caption         =   "Address:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Left            =   360
         TabIndex        =   14
         Top             =   2760
         Width           =   2055
      End
      Begin VB.Label lblcountry 
         Caption         =   "Country:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   600
         TabIndex        =   13
         Top             =   5520
         Width           =   1455
      End
      Begin VB.Label lblphone 
         Caption         =   "Phone:"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   600
         TabIndex        =   12
         Top             =   6240
         Width           =   1815
      End
   End
End
Attribute VB_Name = "frmnewcustomer"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'General Declarations
'Declaring the ADODB objects
Dim rsCustid As ADODB.Recordset
Dim cmdCustid As ADODB.Command
Dim cmdNewCust As ADODB.Command
Dim prmCustid As ADODB.Parameter

Private Sub cmbcountry_Change()

End Sub

Private Sub CmdClose_Click()
 Unload Me
End Sub

Private Sub CmdSave_Click()
On Error Resume Next
Dim strgen As String
Dim str As String
 If (Not (Me.txtid = "")) And (Not (Me.txtcname = "")) And (Not (Me.txtaddress = "")) And (Not (Me.txtcpwd = "")) And (Not (Me.txtphone = "")) And (Not ((Me.optfemale = False) And (Me.optmale = False))) And (Not (Me.cmbcountry = "")) Then
    If optmale.Value = True Then
        strgen = "M"
         ElseIf optfemale.Value = True Then
          strgen = "F"
          End If
     Getconnected
'adding new customer's details to the Customer table
    Set cmdNewCust = New ADODB.Command
    '向数据库之中插入数据
      str = "insert into customers(cust_id,cust_password,cust_name,address,gender,country,phone) values ('" & txtid.Text & "','" & txtcpwd.Text & "','" & txtcname.Text & "' ,'" & txtaddress.Text & "','" & strgen & "','" & cmbcountry.Text & "', '" & txtphone.Text & "') "
    Set cmdNewCust.ActiveConnection = cn
        cmdNewCust.CommandText = str
       cmdNewCust.CommandType = adCmdText
          cmdNewCust.Execute
          '插入成功
    MsgBox "Record saved"
    '将各个文本框设置为空
     txtid.Text = ""
      txtcpwd.Text = ""
        txtcname.Text = ""
       txtaddress.Text = ""
      cmbcountry.Text = ""
     txtphone.Text = "'"
      optmale.Value = False
     optfemale.Value = False
    Else
      MsgBox ("Please enter values in all fields")
   End If
   disconnect
   End Sub
   

   Private Sub Form_Initialize()
   On Error Resume Next
      cmdsave.Enabled = False
   End Sub

Private Sub Form_Load()
On Error Resume Next
cmbcountry.AddItem "China"
cmbcountry.AddItem "English"
cmbcountry.AddItem "American"
cmbcountry.AddItem "India"
cmbcountry.AddItem "France"

End Sub

Private Sub txtid_LostFocus()
On Error Resume Next
Dim cnt As Integer
 cnt = 0
  Set rsCustid = New ADODB.Recordset
   Set cmdCustid = New ADODB.Command
   Getconnected
'using a stored  procedure to check if the customer id exists in the customer table or not
   cmdCustid.ActiveConnection = cn
    cmdCustid.CommandType = adCmdStoredProc
     cmdCustid.CommandText = "CheckCustId"
   Set prmCustid = cmdCustid.CreateParameter("cust_id", adVarChar, adParamInput, 8)
 cmdCustid.Parameters.Append prmCustid
prmCustid.Value = txtid.Text
 Set rsCustid = cmdCustid.Execute
   If rsCustid.EOF = True And rsCustid.BOF = True Then
     txtcpwd.SetFocus
  Else
   MsgBox "Record already exists"
    txtid.SetFocus
   End If
   disconnect
End Sub

Private Sub txtphone_LostFocus()

On Error Resume Next
 cmdsave.Enabled = True

End Sub


⌨️ 快捷键说明

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