NelloRizzo

[ASPX] Pagina di codice behind per form inserimento person

Feb 15th, 2017
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.23 KB | None | 0 0
  1. Imports CodiceFiscale.Model
  2.  
  3. Public Class FiscalCode
  4.     Inherits System.Web.UI.Page
  5.  
  6. #Region "Proprietà per l'accesso ai controlli"
  7.     ' il form dovrà gestire le info di una persona
  8.     ' nome
  9.     Property FirstName As String
  10.         Get
  11.             Return txtFirstName.Text.Trim
  12.         End Get
  13.         Set(value As String)
  14.             txtFirstName.Text = value
  15.         End Set
  16.     End Property
  17.     ' cognome
  18.     Property LastName As String
  19.         Get
  20.             Return txtLastName.Text.Trim
  21.         End Get
  22.         Set(value As String)
  23.             txtLastName.Text = value
  24.         End Set
  25.     End Property
  26.     ' sesso
  27.     Property Sex As SexType
  28.         Get
  29.             If rbSex.SelectedValue = "F" Then
  30.                 Return SexType.Female
  31.             End If
  32.             Return SexType.Male
  33.         End Get
  34.         Set(value As SexType)
  35.             If value = SexType.Male Then
  36.                 rbSex.SelectedValue = "M"
  37.             Else
  38.                 rbSex.SelectedValue = "F"
  39.             End If
  40.         End Set
  41.     End Property
  42.     ' data di nascita
  43.     Property Birthday As DateTime
  44.         Get
  45.             Return txtDate.Text
  46.         End Get
  47.         Set(value As DateTime)
  48.             txtDate.Text = value.Date
  49.         End Set
  50.     End Property
  51.     ' città di nascita
  52.     Property CityOfBirth As String
  53.         Get
  54.             Return txtCity.Text.Trim
  55.         End Get
  56.         Set(value As String)
  57.             txtCity.Text = value
  58.         End Set
  59.     End Property
  60. #End Region
  61.  
  62.     Private Function ValidationRule() As Boolean
  63.         Return Not String.IsNullOrEmpty(FirstName) AndAlso
  64.             Not String.IsNullOrEmpty(LastName) AndAlso
  65.             Not String.IsNullOrEmpty(CityOfBirth)
  66.     End Function
  67.  
  68.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  69.  
  70.     End Sub
  71.  
  72.     Protected Sub CalcFC(sender As Object, e As EventArgs) Handles btnCalc.Click
  73.         Dim p As New Person() With {
  74.             .FirstName = FirstName,
  75.             .LastName = LastName,
  76.             .Birthday = Birthday,
  77.             .CityOfBirth = CityOfBirth,
  78.             .Sex = Sex
  79.             }
  80.         lblFiscalCode.Text = p.GetFiscalCode()
  81.     End Sub
  82. End Class
Add Comment
Please, Sign In to add comment