日期:2008-12-19  浏览次数:20382 次

 

四、WinForm 层

WinForm 层主要完成与用户互动操作,以及传递参数等。代码相对简单,因为工作都在下面的基层实现了。

以处理用户登录的代码login.vb为例,给大家一个概要的印象。

login.vb代码如下:


Public Class login
    Inherits System.Windows.Forms.Form

    Protected user As business.login.UserLimits
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents T_NAME As System.Windows.Forms.TextBox
    Friend WithEvents T_PASSWORD As System.Windows.Forms.TextBox
    Friend WithEvents B_LOGIN As System.Windows.Forms.Button
    Friend WithEvents L_NAME As System.Windows.Forms.Label
    Friend WithEvents L_PASSWORD As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.B_LOGIN = New System.Windows.Forms.Button
        Me.T_NAME = New System.Windows.Forms.TextBox
        Me.T_PASSWORD = New System.Windows.Forms.TextBox
        Me.L_NAME = New System.Windows.Forms.Label
        Me.L_PASSWORD = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'B_LOGIN
        '
        Me.B_LOGIN.Location = New System.Drawing.Point(112, 176)
        Me.B_LOGIN.Name = "B_LOGIN"
        Me.B_LOGIN.Size = New System.Drawing.Size(56, 32)
        Me.B_LOGIN.TabIndex = 0
        Me.B_LOGIN.Text = "登陆"
        '
        'T_NAME
        '
        Me.T_NAME.Location = New System.Drawing.Point(96, 64)
        Me.T_NAME.Name = "T_NAME"
        Me.T_NAME.Size = New System.Drawing.Size(88, 21)
        Me.T_NAME.TabIndex = 1
        Me.T_NAME.Text = ""
        '
        'T_PASSWORD
        '
 &nb