Example #1
0
        protected void AddressAddBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string addressLine1, addressLine2, addressLine3, addressLine4, city, zipOrPostcode,
                       countyStateProvince, country, otherAddressDetails;
                bool insertAddress = true; //boolean to check all fields are entered correctly

                #region addressCheck

                addressLine1 = addressLine1Txt.Text;
                addressLine2 = addressLine2Txt.Text;
                addressLine3 = addressLine3Txt.Text;
                addressLine4 = addressLine4Txt.Text;

                if (cityTxt.Text != "")
                {
                    city = cityTxt.Text;
                }
                else
                {
                    city               = "";
                    insertAddress      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a city.";
                }

                if (Variables.CheckAlphaNumericCharacters(zipOrPostcodeTxt.Text) == true)
                {
                    zipOrPostcode = zipOrPostcodeTxt.Text;
                }
                else
                {
                    zipOrPostcode      = "";
                    insertAddress      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Invalid zip or postcode.";
                }

                countyStateProvince = countyStateProvinceTxt.Text;

                if (countryTxt.Text != "")
                {
                    country = countryTxt.Text;
                }
                else
                {
                    country            = "";
                    insertAddress      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a country.";
                }

                otherAddressDetails = otherAddressDetailsTxt.Text;

                #endregion

                if (insertAddress == true)
                {
                    if (Convert.ToBoolean(Request.QueryString["Company"]) == true)
                    {
                        long companyID;
                        companyID = Convert.ToInt32(companyDdl.SelectedItem.Text.Split(',')[0]);

                        //AddressManager.AddNewCompanyAddress(companyID, addressLine1, addressLine2,
                        //addressLine3, addressLine4, city, zipOrPostcode, countyStateProvince, country, otherAddressDetails);
                        addressSavedLbl.Text = "Save successful";
                    }
                    else if (Convert.ToBoolean(Request.QueryString["Customer"]) == true)
                    {
                        long customerID;
                        customerID = Convert.ToInt32(customerDdl.SelectedItem.Text.Split(',')[0]);

                        //AddressManager.addNewCompanyAddress(companyID, addressLine1, addressLine2,
                        //addressLine3, addressLine4, city, zipOrPostcode, countyStateProvince, country, otherAddressDetails);
                        //addressSavedLbl.Text = "Save successful";
                    }
                }
            }
            catch (Exception ex)
            {
                generalErrorLbl.Text = "An error has occured saying: " + ex.Message + " Please contact your system administrator.";
            }
        }
Example #2
0
        /// <summary>
        /// Checks the location is valid then adds it to the database.
        /// </summary>
        protected void LocationAddBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string locationName, ownerName, addressLine1, addressLine2, city, zipOrPostcode,
                       countyStateProvince, countryCode, countryName, phoneNo, emailAddress;
                int    capacity = 0, tryParseNumber, userID = 0;
                double longitude = 0, latitude = 0;
                bool   insertLocation = true; //boolean to check all fields are entered correctly
                long   locationID;

                #region locationCheck

                if (locationNameTxt.Text != "")
                {
                    locationName = locationNameTxt.Text;
                }
                else
                {
                    locationName       = "";
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a location.";
                }

                if (ownerNameTxt.Text != "")
                {
                    ownerName = ownerNameTxt.Text;
                }
                else
                {
                    ownerName          = "";
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter an owner.";
                }

                if (Int32.TryParse(capacityTxt.Text, out tryParseNumber) == true)
                {
                    capacity = Convert.ToInt32(capacityTxt.Text);
                }
                else
                {
                    capacity = 0;
                }

                addressLine1 = addressLine1Txt.Text;
                addressLine2 = addressLine2Txt.Text;

                if (Variables.CheckAlphaNumericCharacters(cityTxt.Text) && cityTxt.Text != "")
                {
                    city = cityTxt.Text;
                }
                else
                {
                    city               = "";
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a valid city.";
                }

                if (Variables.CheckAlphaNumericCharacters(zipOrPostcodeTxt.Text) == true && zipOrPostcodeTxt.Text != "")
                {
                    zipOrPostcode = zipOrPostcodeTxt.Text;
                }
                else
                {
                    zipOrPostcode      = "";
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Invalid zip or postcode.";
                }

                countyStateProvince = countyStateProvinceTxt.Text;

                //Get from this box as getting from dropdown when it is disabled returns null value
                countryCode = Request["countryTxtVal"];
                if (countryCode == "")
                {
                    //Otherwise if value is still enabled get value directly from dropdown
                    countryCode = Request["countryTxt"];
                }

                //If nothing on the dropdown is selected
                if (countryCode == "")
                {
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a country.";
                }

                phoneNo = Request["phoneNoTxt"];
                if (phoneNo == "")
                {
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a phone no.";
                }

                if (emailAddressTxt.Text != "")
                {
                    emailAddress = emailAddressTxt.Text;
                }
                else
                {
                    emailAddress       = "";
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a email address.";
                }

                if (LocationManager.CheckLongitudeOrLatitudeValid(longitudeTxt.Text))
                {
                    longitude = Convert.ToDouble(longitudeTxt.Text);
                }
                else
                {
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Invalid longitude.";
                }
                if (LocationManager.CheckLongitudeOrLatitudeValid(latitudeTxt.Text))
                {
                    latitude = Convert.ToDouble(latitudeTxt.Text);
                }
                else
                {
                    insertLocation     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Invalid latitude.";
                }

                userID = Variables.GetUser(Session["UserID"].ToString());
                if (userID == 0)
                {
                    insertLocation     = false;
                    inputErrorLbl.Text = "Not logged in. Please login to continue";
                }

                #endregion

                if (insertLocation == true)
                {
                    countryName = Variables.GetCountryByCode(countryCode);
                    LocationManager.AddNewLocation(locationName, ownerName, capacity, addressLine1, addressLine2,
                                                   city, zipOrPostcode, countyStateProvince, countryName, phoneNo, emailAddress, longitude, latitude,
                                                   userID, (int)UserAccess.UserType.company);
                    locationSavedLbl.Text = "Save successful";

                    locationID = LocationManager.GetLastAddedLocation();
                    OpeningTime.InsertDefaultOpeningTimes(locationID);

                    //Proceed on to opening times page
                    Response.Redirect("AddOpeningTime.aspx?LocationID=" + locationID, false);
                }
            }
            catch (Exception ex)
            {
                generalErrorLbl.Text = "An error has occured saying: " + ex.Message + " Please contact your system administrator.";
            }
        }
        /// <summary>
        ///  Adds a new address to be used for this order but does not save it to the database until the order is completed
        ///  to prevent unused records from being added.
        /// </summary>
        protected void AddOrderBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string          addressLine1, addressLine2, city, zipOrPostcode, countyStateProvince, country;
                bool            addOrder = true;
                long            vehicleAvailableID, locationID, addressID;
                DateTime        hireStart, hireEnd;
                CustomerManager customer = null;
                AddressManager  address;

                addressLine1 = addressLine1Txt.Text;
                addressLine2 = addressLine2Txt.Text;

                if (Variables.CheckAlphaNumericCharacters(cityTxt.Text) && cityTxt.Text != "")
                {
                    city = cityTxt.Text;
                }
                else
                {
                    city               = "";
                    addOrder           = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a valid city.";
                }

                if (Variables.CheckAlphaNumericCharacters(zipOrPostcodeTxt.Text) == true && zipOrPostcodeTxt.Text != "")
                {
                    zipOrPostcode = zipOrPostcodeTxt.Text;
                }
                else
                {
                    zipOrPostcode      = "";
                    addOrder           = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Invalid zip or postcode.";
                }

                countyStateProvince = countyStateProvinceTxt.Text;

                country = Variables.GetCountryByCode(Request["countryDdl"]);
                if (country == "")
                {
                    addOrder           = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a country.";
                }

                AddressValid addressSuccess = GetAddress(false);

                if (addressSuccess.addOrder == true && addOrder == true)
                {
                    vehicleAvailableID = Convert.ToInt32(Request.QueryString["VehicleAvailableID"]);
                    locationID         = Convert.ToInt32(Request.QueryString["LocationID"]);
                    hireStart          = Convert.ToDateTime(Request.QueryString["StartDateTime"]);
                    hireEnd            = Convert.ToDateTime(Request.QueryString["EndDateTime"]);

                    //AddressManager.AddNewAddress(1, addressSuccess.addressLine1, addressSuccess.addressLine2, addressSuccess.city
                    //    , addressSuccess.zipOrPostcode, addressSuccess.countyStateProvince, addressSuccess.country);

                    if (customersInCompanyDdl.SelectedValue != "")
                    {
                        if (Session["LoggedInType"].ToString() == "Customer")
                        {
                            customer = CustomerManager.GetCustomers().Where(x => x.UserName.Equals(Session["UserName"].ToString(), StringComparison.OrdinalIgnoreCase)).SingleOrDefault();
                        }
                        else if (Session["LoggedInType"].ToString() == "Company")
                        {
                            CompanyManager company;
                            company = CompanyManager.GetCompanies().Where(x => x.UserName.Equals(Session["UserName"].ToString(), StringComparison.OrdinalIgnoreCase)).SingleOrDefault();

                            customer = CustomerManager.GetCustomers().Where(x => x.CustomerID.ToString() == customersInCompanyDdl.SelectedValue.Split(',')[0]).SingleOrDefault();
                        }

                        if (addressSuccess.existingAddress == null)
                        {
                            addressID = AddressManager.GetLastAddedAddress();

                            address = new AddressManager(addressID + 1, 1, addressSuccess.addressLine1, addressSuccess.addressLine2, addressSuccess.city
                                                         , addressSuccess.zipOrPostcode, addressSuccess.countyStateProvince, addressSuccess.country);
                        }
                        else
                        {
                            address = addressSuccess.existingAddress;
                        }

                        StoreSessionVariables(address, vehicleAvailableID, locationID, hireStart, hireEnd, customer.CustomerID, false);
                        Response.Redirect("~/ReviewOrder", false);

                        orderCreatedLbl.Text = "Order Created";
                    }
                    else
                    {
                        inputErrorLbl.Text = "Please select a customer to book for";
                    }
                }
            }
            catch (Exception ex)
            {
                generalErrorLbl.Text = "An error has occured saying: " + ex.Message + " Please contact your system administrator.";
            }
        }
        /// <summary>
        ///  Registers a new company assuming all the fields are entered correctly.
        /// </summary>
        protected void CreateUser_Click(object sender, EventArgs e)
        {
            try
            {
                string   userName, surname, forename, title, licenseNo, companyName, phoneNo, mobileNo, emailAddress;
                bool     insertCustomer = true; //boolean to check all fields are entered correctly
                long     companyID;
                DateTime issueDate, expirationDate, dateOfBirth;

                #region customerCheck

                if (companyDdl.SelectedValue != "")
                {
                    companyID   = Convert.ToInt32(companyDdl.SelectedValue.Split(',')[0]);
                    companyName = companyDdl.SelectedValue.Split(',')[1];
                }
                else
                {
                    companyID   = 0;
                    companyName = "";
                }

                if (userNameTxt.Text != "")
                {
                    userName = userNameTxt.Text;
                }
                else
                {
                    userName           = "";
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a user name.";
                }

                if (Variables.CheckAlphabetCharacters(surnameTxt.Text) && surnameTxt.Text != "")
                {
                    surname = surnameTxt.Text;
                }
                else
                {
                    surname            = "";
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a surname with only letters.";
                }

                if (Variables.CheckAlphabetCharacters(forenameTxt.Text) && forenameTxt.Text != "")
                {
                    forename = forenameTxt.Text;
                }
                else
                {
                    forename           = "";
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a forename with only letters.";
                }

                if (titleDdl.SelectedValue != "Title")
                {
                    title = titleDdl.SelectedValue;
                }
                else
                {
                    title              = "";
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a title.";
                }

                if (Variables.CheckAlphaNumericCharacters(licenseNoTxt.Text) && licenseNoTxt.Text != "")
                {
                    licenseNo = licenseNoTxt.Text;
                }
                else
                {
                    licenseNo          = "";
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a valid driving license number.";
                }

                if (issueDaysDdl.SelectedValue != "" && issueMonthsDdl.SelectedValue != "" && issueYearsDdl.SelectedValue != "")
                {
                    issueDate = Convert.ToDateTime(issueDaysDdl.SelectedValue + "/" + issueMonthsDdl.SelectedValue + "/" + issueYearsDdl.SelectedValue);
                }
                else
                {
                    issueDate          = DateTime.Now;
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter an issue date for your license.";
                }

                if (expirationDaysDdl.SelectedValue != "" && expirationMonthsDdl.SelectedValue != "" && expirationYearsDdl.SelectedValue != "")
                {
                    expirationDate = Convert.ToDateTime(expirationDaysDdl.SelectedValue + "/" + expirationMonthsDdl.SelectedValue + "/" + expirationYearsDdl.SelectedValue);
                }
                else
                {
                    expirationDate     = DateTime.Now;
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter an expiration date for your license.";
                }

                if (dateOfBirthDaysDdl.SelectedValue != "" && dateOfBirthMonthsDdl.SelectedValue != "" && dateOfBirthYearsDdl.SelectedValue != "")
                {
                    dateOfBirth = Convert.ToDateTime(dateOfBirthDaysDdl.SelectedValue + "/" + dateOfBirthMonthsDdl.SelectedValue + "/" + dateOfBirthYearsDdl.SelectedValue);
                }
                else
                {
                    dateOfBirth        = DateTime.Now;
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter an date of birth";
                }

                phoneNo = Request["phoneNoTxt"];
                if (phoneNo == "")
                {
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a phone no.";
                }

                mobileNo = Request["mobileNoTxt"];

                if (emailAddressTxt.Text != "")
                {
                    emailAddress = emailAddressTxt.Text;
                }
                else
                {
                    emailAddress       = "";
                    insertCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a email address.";
                }

                if (Variables.CheckPasswordValid(passwordTxt.Text) != true)
                {
                    insertCustomer    = false;
                    ErrorMessage.Text = "Passwords must contain at least 1 upper case letter, 1 lower case letter" +
                                        ", 1 number or special character and be at least 6 characters in length";
                }

                #endregion

                if (insertCustomer == true)
                {
                    string passwordEncrypt;
                    List <CustomerManager> customers = CustomerManager.GetCustomers();
                    passwordEncrypt = PasswordHash.CreateHash(passwordTxt.Text);

                    if (customers.Where(x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)).ToList().Count <= 0)
                    {
                        CustomerManager.AddNewCustomer(companyID, userName, surname, forename, title, licenseNo, issueDate, expirationDate,
                                                       dateOfBirth, phoneNo, mobileNo, emailAddress, passwordEncrypt);
                        customerSavedLbl.Text = "Save successful";

                        CustomerManager customer = CustomerManager.GetCustomers().Where(x => x.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase)).SingleOrDefault();

                        Session["LoggedInType"] = "Customer";
                        Session["UserName"]     = userName;
                        Session["UserID"]       = customer.CustomerID;

                        //Return to the home page
                        Response.Redirect("~/", false);
                    }
                    else
                    {
                        inputErrorLbl.Text = "An account with that username already exists. Please enter a different one.";
                    }
                }
            }
            catch (Exception ex)
            {
                generalErrorLbl.Text = "An error has occured saying: " + ex.Message + " Please contact your system administrator.";
            }
        }
Example #5
0
        protected void CompanyAddBtn_Click(object sender, EventArgs e)
        {
            try
            {
                string userName, companyName, companyDescription, phoneNo, emailAddress;
                string addressLine1, addressLine2, addressLine3, addressLine4, city, zipOrPostcode,
                       countyStateProvince, country, otherAddressDetails;
                bool insertCompany = true; //boolean to check all fields are entered correctly
                long companyID;

                #region companyCheck

                if (userNameTxt.Text != "")
                {
                    userName = userNameTxt.Text;
                }
                else
                {
                    userName           = "";
                    insertCompany      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a user name.";
                }

                if (companyNameTxt.Text != "")
                {
                    companyName = companyNameTxt.Text;
                }
                else
                {
                    companyName        = "";
                    insertCompany      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a company name.";
                }

                if (phoneNoTxt.Text != "")
                {
                    phoneNo = phoneNoTxt.Text;
                }
                else
                {
                    phoneNo            = "";
                    insertCompany      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a phone no.";
                }

                if (emailAddressTxt.Text != "")
                {
                    emailAddress = emailAddressTxt.Text;
                }
                else
                {
                    emailAddress       = "";
                    insertCompany      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a email address.";
                }

                companyDescription = companyDescriptionTxt.Text;
                addressLine1       = addressLine1Txt.Text;
                addressLine2       = addressLine2Txt.Text;
                addressLine3       = addressLine3Txt.Text;
                addressLine4       = addressLine4Txt.Text;

                if (cityTxt.Text != "")
                {
                    city = cityTxt.Text;
                }
                else
                {
                    city               = "";
                    insertCompany      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a city.";
                }

                if (Variables.CheckAlphaNumericCharacters(zipOrPostcodeTxt.Text) == true)
                {
                    zipOrPostcode = zipOrPostcodeTxt.Text;
                }
                else
                {
                    zipOrPostcode      = "";
                    insertCompany      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Invalid zip or postcode.";
                }

                countyStateProvince = countyStateProvinceTxt.Text;

                if (countryTxt.Text != "")
                {
                    country = countryTxt.Text;
                }
                else
                {
                    country            = "";
                    insertCompany      = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a country.";
                }

                otherAddressDetails = otherAddressDetailsTxt.Text;

                #endregion

                if (insertCompany == true)
                {
                    //CompanyManager.AddNewCompany(userName, companyName, companyDescription, phoneNo, emailAddress, addressLine1, addressLine2,
                    //addressLine3, addressLine4, city, zipOrPostcode, countyStateProvince, country, otherAddressDetails);
                    companySavedLbl.Text = "Save successful";

                    //locationID = LocationManager.getLastAddedLocation();
                    //OpeningTime.insertDefaultOpeningTimes(locationID);

                    //Proceed on to adding addresses page
                    Response.Redirect("AdditionalAddresses.aspx?Company=true", false);
                }
            }
            catch (Exception ex)
            {
                generalErrorLbl.Text = "An error has occured saying: " + ex.Message + " Please contact your system administrator.";
            }
        }
        /// <summary>
        ///  Update the customer in the database assuming all fields entered are correct.
        /// </summary>
        protected void UpdateUser_Click(object sender, EventArgs e)
        {
            try
            {
                string   surname, forename, title, licenseNo, companyName, phoneNo, mobileNo, emailAddress;
                bool     updateCustomer = true; //boolean to check all fields are entered correctly
                long     companyID;
                DateTime issueDate, expirationDate, dateOfBirth;

                #region customerCheck

                if (companyDdl.SelectedValue != "")
                {
                    companyID   = Convert.ToInt32(companyDdl.SelectedValue.Split(',')[0]);
                    companyName = companyDdl.SelectedValue.Split(',')[1];
                }
                else
                {
                    companyID   = 0;
                    companyName = "";
                }

                if (Variables.CheckAlphabetCharacters(surnameTxt.Text) && surnameTxt.Text != "")
                {
                    surname = surnameTxt.Text;
                }
                else
                {
                    surname            = "";
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a surname with only letters.";
                }

                if (Variables.CheckAlphabetCharacters(forenameTxt.Text) && forenameTxt.Text != "")
                {
                    forename = forenameTxt.Text;
                }
                else
                {
                    forename           = "";
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a forename with only letters.";
                }

                if (titleDdl.SelectedValue != "Title")
                {
                    title = titleDdl.SelectedValue;
                }
                else
                {
                    title              = "";
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a title.";
                }

                if (Variables.CheckAlphaNumericCharacters(licenseNoTxt.Text) && licenseNoTxt.Text != "")
                {
                    licenseNo = licenseNoTxt.Text;
                }
                else
                {
                    licenseNo          = "";
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a valid driving license number.";
                }

                if (issueDaysDdl.SelectedValue != "" && issueMonthsDdl.SelectedValue != "" && issueYearsDdl.SelectedValue != "")
                {
                    issueDate = Convert.ToDateTime(issueDaysDdl.SelectedValue + "/" + issueMonthsDdl.SelectedValue + "/" + issueYearsDdl.SelectedValue);
                }
                else
                {
                    issueDate          = DateTime.Now;
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter an issue date for your license.";
                }

                if (expirationDaysDdl.SelectedValue != "" && expirationMonthsDdl.SelectedValue != "" && expirationYearsDdl.SelectedValue != "")
                {
                    expirationDate = Convert.ToDateTime(expirationDaysDdl.SelectedValue + "/" + expirationMonthsDdl.SelectedValue + "/" + expirationYearsDdl.SelectedValue);
                }
                else
                {
                    expirationDate     = DateTime.Now;
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter an expiration date for your license.";
                }

                if (dateOfBirthDaysDdl.SelectedValue != "" && dateOfBirthMonthsDdl.SelectedValue != "" && dateOfBirthYearsDdl.SelectedValue != "")
                {
                    dateOfBirth = Convert.ToDateTime(dateOfBirthDaysDdl.SelectedValue + "/" + dateOfBirthMonthsDdl.SelectedValue + "/" + dateOfBirthYearsDdl.SelectedValue);
                }
                else
                {
                    dateOfBirth        = DateTime.Now;
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter an date of birth";
                }

                phoneNo = Request["phoneNoTxt"];
                if (phoneNo == "")
                {
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a phone no.";
                }

                mobileNo = Request["mobileNoTxt"];

                if (emailAddressTxt.Text != "")
                {
                    emailAddress = emailAddressTxt.Text;
                }
                else
                {
                    emailAddress       = "";
                    updateCustomer     = false;
                    inputErrorLbl.Text = inputErrorLbl.Text + "<br />" + "Please enter a email address.";
                }

                #endregion

                if (updateCustomer == true)
                {
                    CustomerManager.UpdateCustomer(Variables.GetUser(Session["UserID"].ToString()), companyID, surname, forename, title, licenseNo, issueDate, expirationDate,
                                                   dateOfBirth, phoneNo, mobileNo, emailAddress);
                    customerSavedLbl.Text = "Save successful";
                }

                //Reload because 3rd party phone controller clears itself on postback
                LoadCustomerInfo();
            }
            catch (Exception ex)
            {
                generalErrorLbl.Text = "An error has occured saying: " + ex.Message + " Please contact your system administrator.";
            }
        }