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

📄 frmtestcustomer.vb

📁 vb.net MCP课程的英文讲义,70-310课程,值得一读
💻 VB
字号:
Imports CustomerComponent

Public Class frmTestCustomer
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Public Overloads Overrides Sub Dispose()
        MyBase.Dispose()
        If Not (components Is Nothing) Then
            components.Dispose()
        End If
    End Sub

    Friend WithEvents lblAddress As System.Windows.Forms.Label
    Friend WithEvents txtEmail As System.Windows.Forms.TextBox
    Friend WithEvents label2 As System.Windows.Forms.Label
    Friend WithEvents lblPassword As System.Windows.Forms.Label
    Friend WithEvents txtFName As System.Windows.Forms.TextBox
    Friend WithEvents txtPassword As System.Windows.Forms.TextBox
    Friend WithEvents txtAddress As System.Windows.Forms.TextBox
    Friend WithEvents lblFirstName As System.Windows.Forms.Label
    Friend WithEvents txtLName As System.Windows.Forms.TextBox
    Friend WithEvents lblCompany As System.Windows.Forms.Label
    Friend WithEvents lblStatefulCustomerID As System.Windows.Forms.Label
    Friend WithEvents txtCompany As System.Windows.Forms.TextBox
    Friend WithEvents btnClose As System.Windows.Forms.Button
    Friend WithEvents txtID As System.Windows.Forms.TextBox
    Friend WithEvents lblLastName As System.Windows.Forms.Label
    Friend WithEvents btnLogon As System.Windows.Forms.Button

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.lblStatefulCustomerID = New System.Windows.Forms.Label()
        Me.lblLastName = New System.Windows.Forms.Label()
        Me.txtCompany = New System.Windows.Forms.TextBox()
        Me.lblPassword = New System.Windows.Forms.Label()
        Me.txtFName = New System.Windows.Forms.TextBox()
        Me.label2 = New System.Windows.Forms.Label()
        Me.txtAddress = New System.Windows.Forms.TextBox()
        Me.lblAddress = New System.Windows.Forms.Label()
        Me.lblFirstName = New System.Windows.Forms.Label()
        Me.btnClose = New System.Windows.Forms.Button()
        Me.lblCompany = New System.Windows.Forms.Label()
        Me.txtPassword = New System.Windows.Forms.TextBox()
        Me.txtID = New System.Windows.Forms.TextBox()
        Me.btnLogon = New System.Windows.Forms.Button()
        Me.txtLName = New System.Windows.Forms.TextBox()
        Me.txtEmail = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        '
        'lblStatefulCustomerID
        '
        Me.lblStatefulCustomerID.AutoSize = True
        Me.lblStatefulCustomerID.Location = New System.Drawing.Point(23, 92)
        Me.lblStatefulCustomerID.Name = "lblStatefulCustomerID"
        Me.lblStatefulCustomerID.Size = New System.Drawing.Size(68, 13)
        Me.lblStatefulCustomerID.TabIndex = 1
        Me.lblStatefulCustomerID.Text = "CustomerID:"
        '
        'lblLastName
        '
        Me.lblLastName.AutoSize = True
        Me.lblLastName.Location = New System.Drawing.Point(29, 151)
        Me.lblLastName.Name = "lblLastName"
        Me.lblLastName.Size = New System.Drawing.Size(62, 13)
        Me.lblLastName.TabIndex = 9
        Me.lblLastName.Text = "Last Name:"
        '
        'txtCompany
        '
        Me.txtCompany.Location = New System.Drawing.Point(96, 179)
        Me.txtCompany.Name = "txtCompany"
        Me.txtCompany.Size = New System.Drawing.Size(160, 20)
        Me.txtCompany.TabIndex = 5
        Me.txtCompany.Text = ""
        '
        'lblPassword
        '
        Me.lblPassword.AutoSize = True
        Me.lblPassword.Location = New System.Drawing.Point(34, 48)
        Me.lblPassword.Name = "lblPassword"
        Me.lblPassword.Size = New System.Drawing.Size(57, 13)
        Me.lblPassword.TabIndex = 17
        Me.lblPassword.Text = "Password:"
        '
        'txtFName
        '
        Me.txtFName.Location = New System.Drawing.Point(96, 121)
        Me.txtFName.Name = "txtFName"
        Me.txtFName.Size = New System.Drawing.Size(160, 20)
        Me.txtFName.TabIndex = 3
        Me.txtFName.Text = ""
        '
        'label2
        '
        Me.label2.AutoSize = True
        Me.label2.Location = New System.Drawing.Point(51, 27)
        Me.label2.Name = "label2"
        Me.label2.Size = New System.Drawing.Size(40, 13)
        Me.label2.TabIndex = 3
        Me.label2.Text = "E-mail:"
        '
        'txtAddress
        '
        Me.txtAddress.AcceptsReturn = True
        Me.txtAddress.Location = New System.Drawing.Point(96, 208)
        Me.txtAddress.Multiline = True
        Me.txtAddress.Name = "txtAddress"
        Me.txtAddress.Size = New System.Drawing.Size(160, 64)
        Me.txtAddress.TabIndex = 6
        Me.txtAddress.Text = ""
        '
        'lblAddress
        '
        Me.lblAddress.AutoSize = True
        Me.lblAddress.Location = New System.Drawing.Point(42, 208)
        Me.lblAddress.Name = "lblAddress"
        Me.lblAddress.Size = New System.Drawing.Size(49, 13)
        Me.lblAddress.TabIndex = 11
        Me.lblAddress.Text = "Address:"
        '
        'lblFirstName
        '
        Me.lblFirstName.AutoSize = True
        Me.lblFirstName.Location = New System.Drawing.Point(28, 120)
        Me.lblFirstName.Name = "lblFirstName"
        Me.lblFirstName.Size = New System.Drawing.Size(63, 13)
        Me.lblFirstName.TabIndex = 7
        Me.lblFirstName.Text = "First Name:"
        '
        'btnClose
        '
        Me.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnClose.Location = New System.Drawing.Point(272, 64)
        Me.btnClose.Name = "btnClose"
        Me.btnClose.Size = New System.Drawing.Size(75, 24)
        Me.btnClose.TabIndex = 8
        Me.btnClose.Text = "Close"
        '
        'lblCompany
        '
        Me.lblCompany.AutoSize = True
        Me.lblCompany.Location = New System.Drawing.Point(35, 180)
        Me.lblCompany.Name = "lblCompany"
        Me.lblCompany.Size = New System.Drawing.Size(56, 13)
        Me.lblCompany.TabIndex = 13
        Me.lblCompany.Text = "Company:"
        '
        'txtPassword
        '
        Me.txtPassword.Location = New System.Drawing.Point(96, 48)
        Me.txtPassword.Name = "txtPassword"
        Me.txtPassword.PasswordChar = ChrW(42)
        Me.txtPassword.Size = New System.Drawing.Size(160, 20)
        Me.txtPassword.TabIndex = 1
        Me.txtPassword.Text = ""
        '
        'txtID
        '
        Me.txtID.Location = New System.Drawing.Point(96, 92)
        Me.txtID.Name = "txtID"
        Me.txtID.Size = New System.Drawing.Size(160, 20)
        Me.txtID.TabIndex = 2
        Me.txtID.Text = ""
        '
        'btnLogon
        '
        Me.btnLogon.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnLogon.Location = New System.Drawing.Point(272, 24)
        Me.btnLogon.Name = "btnLogon"
        Me.btnLogon.Size = New System.Drawing.Size(75, 24)
        Me.btnLogon.TabIndex = 7
        Me.btnLogon.Text = "Logon"
        '
        'txtLName
        '
        Me.txtLName.Location = New System.Drawing.Point(96, 150)
        Me.txtLName.Name = "txtLName"
        Me.txtLName.Size = New System.Drawing.Size(160, 20)
        Me.txtLName.TabIndex = 4
        Me.txtLName.Text = ""
        '
        'txtEmail
        '
        Me.txtEmail.Location = New System.Drawing.Point(96, 24)
        Me.txtEmail.Name = "txtEmail"
        Me.txtEmail.Size = New System.Drawing.Size(160, 20)
        Me.txtEmail.TabIndex = 0
        Me.txtEmail.Text = ""
        '
        'frmTestCustomer
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(355, 277)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.txtEmail, Me.txtFName, Me.txtPassword, Me.txtAddress, Me.txtLName, Me.txtCompany, Me.txtID, Me.btnClose, Me.btnLogon, Me.lblAddress, Me.label2, Me.lblPassword, Me.lblFirstName, Me.lblCompany, Me.lblStatefulCustomerID, Me.lblLastName})
        Me.Name = "frmTestCustomer"
        Me.Text = "Test Customer"
        Me.ResumeLayout(False)

    End Sub


#End Region

    Private Sub btnLogon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogon.Click
        Try
            Dim ds As DataSet, dr As DataRow

            Dim cust As ICustomer = New Customer()
            ds = cust.Logon(txtEmail.Text, txtPassword.Text)

            'check for "no record found"
            If ds.Tables(0).Rows.Count = 0 Then
                MessageBox.Show("No customer found with matching details", "No Match", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                dr = ds.Tables(0).Rows(0)
                txtAddress.Text = dr("Address")
                txtCompany.Text = dr("CompanyName")
                txtFName.Text = dr("FirstName")
                txtLName.Text = dr("LastName")
                txtID.Text = dr("CustomerId")
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

End Class

⌨️ 快捷键说明

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