📄 frmaddressitem.vb
字号:
Public Class frmAddressItem
Inherits System.Windows.Forms.Form
Friend WithEvents lblName As System.Windows.Forms.Label
Friend WithEvents TxtName As System.Windows.Forms.TextBox
#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 TxtAddress As System.Windows.Forms.TextBox
Friend WithEvents LblAddress As System.Windows.Forms.Label
Friend WithEvents TxtTelephone As System.Windows.Forms.TextBox
Friend WithEvents LblTelephone As System.Windows.Forms.Label
Friend WithEvents BtnUpdate As System.Windows.Forms.Button
Friend WithEvents BtnClose As System.Windows.Forms.Button
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents BtnDelete As System.Windows.Forms.Button
Friend WithEvents ChkIsPrivateFlag As System.Windows.Forms.CheckBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmAddressItem))
Me.lblName = New System.Windows.Forms.Label
Me.TxtName = New System.Windows.Forms.TextBox
Me.TxtAddress = New System.Windows.Forms.TextBox
Me.LblAddress = New System.Windows.Forms.Label
Me.TxtTelephone = New System.Windows.Forms.TextBox
Me.LblTelephone = New System.Windows.Forms.Label
Me.BtnUpdate = New System.Windows.Forms.Button
Me.BtnClose = New System.Windows.Forms.Button
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.BtnDelete = New System.Windows.Forms.Button
Me.ChkIsPrivateFlag = New System.Windows.Forms.CheckBox
'
'lblName
'
Me.lblName.Location = New System.Drawing.Point(8, 8)
Me.lblName.Size = New System.Drawing.Size(56, 16)
Me.lblName.Text = "Name"
'
'TxtName
'
Me.TxtName.Location = New System.Drawing.Point(80, 8)
Me.TxtName.Size = New System.Drawing.Size(152, 20)
Me.TxtName.Text = ""
'
'TxtAddress
'
Me.TxtAddress.Location = New System.Drawing.Point(80, 32)
Me.TxtAddress.Multiline = True
Me.TxtAddress.Size = New System.Drawing.Size(152, 88)
Me.TxtAddress.Text = ""
'
'LblAddress
'
Me.LblAddress.Location = New System.Drawing.Point(8, 32)
Me.LblAddress.Size = New System.Drawing.Size(56, 16)
Me.LblAddress.Text = "Address"
'
'TxtTelephone
'
Me.TxtTelephone.Location = New System.Drawing.Point(80, 128)
Me.TxtTelephone.Multiline = True
Me.TxtTelephone.Size = New System.Drawing.Size(152, 40)
Me.TxtTelephone.Text = ""
'
'LblTelephone
'
Me.LblTelephone.Location = New System.Drawing.Point(8, 128)
Me.LblTelephone.Size = New System.Drawing.Size(64, 16)
Me.LblTelephone.Text = "Telephone"
'
'BtnUpdate
'
Me.BtnUpdate.Location = New System.Drawing.Point(16, 240)
Me.BtnUpdate.Size = New System.Drawing.Size(96, 24)
Me.BtnUpdate.Text = "Update"
'
'BtnClose
'
Me.BtnClose.Location = New System.Drawing.Point(128, 240)
Me.BtnClose.Size = New System.Drawing.Size(96, 24)
Me.BtnClose.Text = "Close"
'
'BtnDelete
'
Me.BtnDelete.Location = New System.Drawing.Point(16, 216)
Me.BtnDelete.Size = New System.Drawing.Size(96, 24)
Me.BtnDelete.Text = "Delete"
'
'ChkIsPrivateFlag
'
Me.ChkIsPrivateFlag.Location = New System.Drawing.Point(80, 176)
Me.ChkIsPrivateFlag.Text = "Private"
'
'frmAddressItem
'
Me.Controls.Add(Me.ChkIsPrivateFlag)
Me.Controls.Add(Me.BtnDelete)
Me.Controls.Add(Me.BtnClose)
Me.Controls.Add(Me.BtnUpdate)
Me.Controls.Add(Me.TxtTelephone)
Me.Controls.Add(Me.LblTelephone)
Me.Controls.Add(Me.TxtAddress)
Me.Controls.Add(Me.LblAddress)
Me.Controls.Add(Me.TxtName)
Me.Controls.Add(Me.lblName)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Menu = Me.MainMenu1
Me.Text = "frmAddressItem"
End Sub
#End Region
Private AddressBook As New AddressBookApplication
Public SelectedAddressID As Integer = -1
Private ClassName As String
Private Sub frmAddressItem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ClassName = Me.GetType.Name
Dim ErrLoc As String = ClassName + ".frmAddressItem_Load"
Try
Dim AddressRow As Adr_Address.Address_Type
If SelectedAddressID = -1 Then
Me.BtnDelete.Visible = False
Me.BtnUpdate.Text = "Insert"
Else
AddressRow.Address_ID = CInt(SelectedAddressID)
If AddressBook.AddressGet(AddressRow) Then
TxtName.Text = AddressRow.Name
TxtAddress.Text = AddressRow.Address
TxtTelephone.Text = AddressRow.Telephone
ChkIsPrivateFlag.Checked = AddressRow.IsPrivate_Flag
End If
End If
Catch ex As Exception
UnHandledError(ex.ToString(), ErrLoc)
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
Private Sub BtnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUpdate.Click
Dim ErrLoc As String = ClassName + ".BtnUpdate_Click"
Try
Dim AddressRow As Adr_Address.Address_Type
AddressRow.Address_ID = SelectedAddressID
AddressRow.Name = TxtName.Text
AddressRow.Address = TxtAddress.Text
AddressRow.Telephone = TxtTelephone.Text
AddressRow.IsPrivate_Flag = ChkIsPrivateFlag.Checked
If SelectedAddressID = -1 Then
If Not AddressBook.AddressInsert(AddressRow) Then
MessageBox.Show("Unable to update address")
End If
Else
If Not AddressBook.AddressModify(AddressRow) Then
MessageBox.Show("Unable to update address")
End If
End If
Me.Close()
Catch ex As Exception
UnHandledError(ex.ToString(), ErrLoc)
End Try
End Sub
Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click
Dim ErrLoc As String = ClassName + ".BtnDelete_Click"
Try
If Not AddressBook.AddressDelete(SelectedAddressID) Then
MessageBox.Show("Unable to delete address")
End If
Me.Close()
Catch ex As Exception
UnHandledError(ex.ToString(), ErrLoc)
End Try
End Sub
Public Function UnHandledError(ByVal Exception As String, ByVal Location As String) As String
MsgBox("[-->" + Location + "<--]" + Exception)
End Function
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -