frmsettings.vb

来自「对现代企业来说」· VB 代码 · 共 154 行

VB
154
字号
Public Class frmSettings
    Inherits System.Windows.Forms.Form
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents LblPCIP As System.Windows.Forms.Label
    Friend WithEvents TxtPCIP As System.Windows.Forms.TextBox
    Friend WithEvents BtnUpdate As System.Windows.Forms.Button
    Friend WithEvents BtnClose As System.Windows.Forms.Button

#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

    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        MyBase.Dispose(disposing)
    End Sub

    '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.
    Friend WithEvents TxtDefaultPassword As System.Windows.Forms.TextBox
    Friend WithEvents LblDefaultPassword As System.Windows.Forms.Label
    Friend WithEvents TxtWebServiceURL As System.Windows.Forms.TextBox
    Friend WithEvents LblWebSericeURL As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmSettings))
        Me.MainMenu1 = New System.Windows.Forms.MainMenu
        Me.LblPCIP = New System.Windows.Forms.Label
        Me.TxtPCIP = New System.Windows.Forms.TextBox
        Me.BtnUpdate = New System.Windows.Forms.Button
        Me.BtnClose = New System.Windows.Forms.Button
        Me.TxtDefaultPassword = New System.Windows.Forms.TextBox
        Me.LblDefaultPassword = New System.Windows.Forms.Label
        Me.TxtWebServiceURL = New System.Windows.Forms.TextBox
        Me.LblWebSericeURL = New System.Windows.Forms.Label
        '
        'LblPCIP
        '
        Me.LblPCIP.Location = New System.Drawing.Point(16, 16)
        Me.LblPCIP.Size = New System.Drawing.Size(48, 20)
        Me.LblPCIP.Text = "PC IP"
        '
        'TxtPCIP
        '
        Me.TxtPCIP.Location = New System.Drawing.Point(16, 32)
        Me.TxtPCIP.Size = New System.Drawing.Size(208, 20)
        Me.TxtPCIP.Text = ""
        '
        'BtnUpdate
        '
        Me.BtnUpdate.Location = New System.Drawing.Point(152, 176)
        Me.BtnUpdate.Text = "Update"
        '
        'BtnClose
        '
        Me.BtnClose.Location = New System.Drawing.Point(72, 176)
        Me.BtnClose.Text = "Close"
        '
        'TxtDefaultPassword
        '
        Me.TxtDefaultPassword.Location = New System.Drawing.Point(16, 128)
        Me.TxtDefaultPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.TxtDefaultPassword.Size = New System.Drawing.Size(208, 20)
        Me.TxtDefaultPassword.Text = ""
        '
        'LblDefaultPassword
        '
        Me.LblDefaultPassword.Location = New System.Drawing.Point(16, 112)
        Me.LblDefaultPassword.Size = New System.Drawing.Size(96, 20)
        Me.LblDefaultPassword.Text = "Default Password"
        '
        'TxtWebServiceURL
        '
        Me.TxtWebServiceURL.Location = New System.Drawing.Point(16, 80)
        Me.TxtWebServiceURL.Size = New System.Drawing.Size(208, 20)
        Me.TxtWebServiceURL.Text = ""
        '
        'LblWebSericeURL
        '
        Me.LblWebSericeURL.Location = New System.Drawing.Point(16, 64)
        Me.LblWebSericeURL.Size = New System.Drawing.Size(104, 20)
        Me.LblWebSericeURL.Text = "WebService URL"
        '
        'frmSettings
        '
        Me.Controls.Add(Me.TxtWebServiceURL)
        Me.Controls.Add(Me.LblWebSericeURL)
        Me.Controls.Add(Me.TxtDefaultPassword)
        Me.Controls.Add(Me.LblDefaultPassword)
        Me.Controls.Add(Me.BtnClose)
        Me.Controls.Add(Me.BtnUpdate)
        Me.Controls.Add(Me.TxtPCIP)
        Me.Controls.Add(Me.LblPCIP)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Menu = Me.MainMenu1
        Me.Text = "frmSettings"

    End Sub

#End Region

    Private AddressBook As New AddressBookApplication

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

    Private Sub frmSettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Try
            Dim SettingsRow As Adr_Settings.Settings_Type
            If Not AddressBook.SettingsGet(SettingsRow) Then
                SettingsRow.PCIP = ""
                SettingsRow.WebService_URL = ""
                SettingsRow.Default_Password = ""
            End If

            TxtPCIP.Text = SettingsRow.PCIP
            TxtDefaultPassword.Text = SettingsRow.Default_Password
            TxtWebServiceURL.Text = SettingsRow.WebService_URL

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try


    End Sub

    Private Sub BtnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUpdate.Click
        Try
            Dim SettingsRow As Adr_Settings.Settings_Type
            SettingsRow.PCIP = TxtPCIP.Text
            SettingsRow.Default_Password = TxtDefaultPassword.Text
            SettingsRow.WebService_URL = TxtWebServiceURL.Text

            If Not AddressBook.SettingsSet(SettingsRow) Then
                MessageBox.Show("Unable to update Settings")
            End If
            Me.Close()
       
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

    End Sub
End Class

⌨️ 快捷键说明

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