예제 #1
0
        protected void btnValidateAddress_Click(object sender, EventArgs e)
        {
            try
            {
                // Create an address that we need to validate
                Address addressToValidate = new Address();
                // Populate properties from ui
                addressToValidate.Line1    = GetControl <TextBox>("txtShipmentAddress1", PageFormView).Text;
                addressToValidate.Line2    = GetControl <TextBox>("txtShipmentAddress2", PageFormView).Text;
                addressToValidate.Line3    = GetControl <TextBox>("txtShipmentAddress3", PageFormView).Text;
                addressToValidate.Line4    = GetControl <TextBox>("txtShipmentAddress4", PageFormView).Text;
                addressToValidate.Line5    = GetControl <TextBox>("txtShipmentAddress5", PageFormView).Text;
                addressToValidate.PostCode = GetControl <TextBox>("txtShipmentAddressPostCode", PageFormView).Text;

                // Validate the address via address lookup provider, etc
                PAFAddress validatedAddress = AddressController.CheckAddress(addressToValidate, GetControl <TextBox>("txtShipmentAddressName", PageFormView).Text);

                // Update the ui with the validated address
                GetControl <TextBox>("txtPAFAddress1", PageFormView).Text        = validatedAddress.Line1;
                GetControl <TextBox>("txtPAFAddress2", PageFormView).Text        = validatedAddress.Line2;
                GetControl <TextBox>("txtPAFAddress3", PageFormView).Text        = validatedAddress.Line3;
                GetControl <TextBox>("txtPAFAddress4", PageFormView).Text        = validatedAddress.Line4;
                GetControl <TextBox>("txtPAFAddress5", PageFormView).Text        = validatedAddress.Line5;
                GetControl <TextBox>("txtPAFAddressPostCode", PageFormView).Text = validatedAddress.PostCode;

                // Update the ui with the easting, northing, etc
                GetControl <TextBox>("txtPAFEasting", PageFormView).Text  = validatedAddress.Easting.ToString();
                GetControl <TextBox>("txtPAFNorthing", PageFormView).Text = validatedAddress.Northing.ToString();
                GetControl <TextBox>("txtPAFDPS", PageFormView).Text      = validatedAddress.DPS;
                GetControl <TextBox>("txtPAFStatus", PageFormView).Text   = validatedAddress.Status.ToString();
                //set the value of a hidden control to save match
            }
            catch (Exception ex)
            {
                // Display message
                DisplayMessage(ex);
            }
        }