Ejemplo n.º 1
0
    private void RebuildGeographyOptions()
    {
        Cities citylist = Cities.FromPostalCode(TextPostalCode.Text, DropCountries.SelectedValue);
        string selectedGeographyName = DropGeographies.SelectedValue;

        LabelGeographies.Text = "Kommun";
        DropGeographies.Items.Clear();
        foreach (City city in citylist)
        {
            Geographies subGeo = city.Geography.GetTree();
            if (!city.Geography.Name.ToLower().Contains("kommun"))
            {
                LabelGeographies.Text = "Stadsdel";
            }
            TextCity.Text = city.Name;
            foreach (Geography geo in subGeo)
            {
                // ignore  if it is not a leaf
                if (geo.ChildrenCount == 0)
                {
                    if (DropGeographies.Items.FindByValue(geo.GeographyId.ToString()) == null)
                    {
                        ListItem newItem = new ListItem(geo.Name, geo.GeographyId.ToString());
                        DropGeographies.Items.Add(newItem);
                        if (selectedGeographyName == geo.GeographyId.ToString())
                        {
                            newItem.Selected = true;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void GeographyFromPostalCode()
    {
        Cities cities = Cities.FromPostalCode(this.TextPostalCode.Text.Replace(" ", ""), this.DropCountries.SelectedValue);

        if (cities.Count == 0)
        {
            LabelPostalMessage.Text = "Unknown Code";
        }
        else
        {
            LabelPostalMessage.Text = "";
            int personGeography = person.GeographyId;
            this.TextCity.Text = cities[0].Name;
            DropDownMunicipalities.Items.Clear();

            foreach (City city in cities)
            {
                Geographies subGeo = city.Geography.GetTree();
                foreach (Geography geo in subGeo)
                {
                    // ignore  if it is not a leaf
                    if (geo.ChildrenCount == 0)
                    {
                        DropDownMunicipalities.Items.Add(new ListItem(geo.Name, geo.GeographyId.ToString()));

                        if (geo.GeographyId == person.GeographyId)
                        {
                            DropDownMunicipalities.SelectedValue = Person.GeographyId.ToString();
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 3
0
    private void RebuildFromPostalCode()
    {
        Cities citylist = Cities.FromPostalCode(TextPostal.Text, DropCountries.SelectedValue);

        LabelPostalErrorUnknown.Visible = false;
        string selectedKommun = DropDownKommun.SelectedValue;

        LabelKommun.Text = "Kommun";
        DropDownKommun.Items.Clear();
        foreach (City city in citylist)
        {
            Geographies subGeo = city.Geography.GetTree();
            if (subGeo.Count > 1 || !city.Geography.Name.ToLower().Contains("kommun"))
            {
                LabelKommun.Text = "Kommun <br>/ Stadsdel";
            }
            TextCity.Text = city.Name;
            foreach (Geography geo in subGeo)
            {
                // ignore  if it is not a leaf
                if (geo.ChildrenCount == 0)
                {
                    if (DropDownKommun.Items.FindByValue(geo.GeographyId.ToString()) == null)
                    {
                        ListItem newItem = new ListItem(geo.Name, geo.GeographyId.ToString());
                        DropDownKommun.Items.Add(newItem);
                        if (selectedKommun == geo.GeographyId.ToString())
                        {
                            newItem.Selected = true;
                        }
                    }
                }
            }
        }

        if (true || citylist.Count > 1)
        {
            LabelKommun.Visible      = true;
            DropDownKommun.Visible   = true;
            LabelKommunError.Visible = true;
        }
        else
        {
            LabelKommun.Visible      = false;
            DropDownKommun.Visible   = false;
            LabelKommunError.Visible = false;
        }

        if (citylist.Count == 0)
        {
            LabelPostalErrorUnknown.Visible = true;
        }
        else
        {
            if (DropDownKommun.SelectedIndex < 0)
            {
                DropDownKommun.SelectedIndex = 0;
            }
        }
    }
Ejemplo n.º 4
0
    protected void TextPostalCode_TextChanged(object sender, EventArgs e)
    {
        if (this.TextPostalCode.Text.Trim().Length == 0)
        {
            return;
        }

        Cities cities = Cities.FromPostalCode(this.TextPostalCode.Text.Replace(" ", ""),
                                              this.DropCountries.SelectedValue);

        // Trigger one of three different mechanisms: Freeform (no match), One choice preset (one match)
        // or dropdown from presets (several matches)

        if (cities.Count == 1)
        {
            this.TextCity.Visible = true;
            this.TextCity.Enabled = false;
            this.TextCity.Text    = cities[0].Name;
        }
        else if (cities.Count == 0)
        {
            this.TextCity.Visible = true;
            this.TextCity.Enabled = true;
            this.TextCity.Focus();
        }
    }
Ejemplo n.º 5
0
    private void PopulateCandidates()
    {
        Ballot ballot        = Ballot.FromIdentity((int)ViewState[this.ClientID + "SelectedBallot"]);
        string candidateText = string.Empty;

        People candidates   = ballot.Candidates;
        int    listPosition = 1;

        foreach (Person candidate in candidates)
        {
            string cityName = string.Empty;

            // Get city name

            Cities cities = Cities.FromPostalCode(candidate.PostalCode, candidate.CountryId);

            if (cities.Count == 0)
            {
                try
                {
                    cityName = City.FromName(candidate.CityName, candidate.CountryId).Name;
                }
                catch (ArgumentException)
                {
                    // ignore
                }
            }
            else
            {
                cityName = cities[0].Name; // This may be adjusted manually, but will work in 99.9% of cases
            }

            if (cityName.Length < 2)
            {
                cityName = candidate.CityName;
            }

            if (cityName.Contains("("))
            {
                cityName = cityName.Split('(')[0].Trim();
            }

            int age = 2010 - candidate.Birthdate.Year;
            if (new DateTime(2010, 9, 19) < new DateTime(2010, candidate.Birthdate.Month, candidate.Birthdate.Day))
            {
                age--;
            }


            candidateText += string.Format("{0,2}. {1}, {2}, {3} \xE5r\r\n", listPosition++, candidate.Canonical,
                                           cityName, age);
        }

        this.TextCandidates.Text = candidateText;
    }
Ejemplo n.º 6
0
        protected int ResolveGeography()
        {
            if (base.CountryId == 0)
            {
                base.GeographyId = 1;
                SwarmDb.GetDatabaseForWriting().SetPersonGeography(Identity, 1);
                return(1); // root geography, if no country set
            }

            Cities cities = Cities.FromPostalCode(PostalCode, base.CountryId);
            City   city   = null;

            if (cities.Count == 0 && PostalCode.Length > 3)
            {
                // try shortening the postal code - like NL dataset - and see if we find anything

                for (int shortening = 1; shortening <= 3; shortening++)
                {
                    cities = Cities.FromPostalCode(PostalCode.Substring(0, PostalCode.Length - shortening),
                                                   base.CountryId);
                    if (cities.Count > 0)
                    {
                        break;
                    }
                }
            }

            if (cities.Count == 0) // still no hit? Move on to getting city by name
            {
                try
                {
                    city = City.FromName(CityName, CountryId);
                }
                catch (ArgumentException)
                {
                    // ignore
                }
            }
            else
            {
                city = cities[0]; // This may be adjusted manually, but will work in 99.9% of cases
            }

            if (city == null)
            {
                base.GeographyId = Country.FromIdentity(base.CountryId).GeographyId;
                return(base.GeographyId);
            }

            base.GeographyId = city.GeographyId;
            SwarmDb.GetDatabaseForWriting().SetPersonGeography(Identity, base.GeographyId);
            return(city.GeographyId);
        }
Ejemplo n.º 7
0
    private void RebuildFromPostalCode()
    {
        Cities citiylist = Cities.FromPostalCode(TextPostal.Text, DropCountries.SelectedValue);

        LabelPostalErrorUnknown.Visible = false;
        string selectedKommun = DropDownKommun.SelectedValue;

        DropDownKommun.Items.Clear();
        foreach (City city in citiylist)
        {
            TextCity.Text = city.Name;
            ListItem newItem = new ListItem(city.Geography.Name, city.Geography.GeographyId.ToString());
            DropDownKommun.Items.Add(newItem);
            if (selectedKommun == city.Geography.GeographyId.ToString())
            {
                newItem.Selected = true;
            }
        }
        if (citiylist.Count > 1)
        {
            LabelKommun.Visible      = true;
            DropDownKommun.Visible   = true;
            LabelKommunError.Visible = true;
        }
        else
        {
            LabelKommun.Visible      = false;
            DropDownKommun.Visible   = false;
            LabelKommunError.Visible = false;
        }

        if (citiylist.Count == 0)
        {
            LabelPostalErrorUnknown.Visible = true;
        }
        else
        {
            if (DropDownKommun.SelectedIndex < 0)
            {
                DropDownKommun.SelectedIndex = 0;
            }
        }
    }
Ejemplo n.º 8
0
        protected int ResolveGeography()
        {
            if (base.CountryId == 0)
            {
                base.GeographyId = 1;
                SwarmDb.GetDatabaseForWriting().SetPersonGeography(this.Identity, 1);
                return(1); // root geography, if no country set
            }

            Structure.Cities cities = Cities.FromPostalCode(this.PostalCode, base.CountryId);
            City             city   = null;

            if (cities.Count == 0)
            {
                try
                {
                    city = Structure.City.FromName(this.CityName, this.CountryId);
                }
                catch (ArgumentException)
                {
                    // ignore
                }
            }
            else
            {
                city = cities[0]; // This may be adjusted manually, but will work in 99.9% of cases
            }

            if (city == null)
            {
                base.GeographyId = Country.FromIdentity(base.CountryId).GeographyId;
                return(base.GeographyId);
            }

            base.GeographyId = city.GeographyId;
            SwarmDb.GetDatabaseForWriting().SetPersonGeography(this.Identity, base.GeographyId);
            return(city.GeographyId);
        }
Ejemplo n.º 9
0
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        // TODO: Validate arguments a bit more, later
        //TODO: Hardcoded Sweden
        Geography geo = null;

        if (this.DropCities.Visible)
        {
            geo = Geography.FromIdentity(Int32.Parse(this.DropCities.SelectedValue));
        }
        else
        {
            /* Fix for #106 - Fel vid aktivistregistrering */
            string postalCode = this.TextPostalCode.Text.Trim().Replace(" ", "");

            geo = Cities.FromPostalCode(postalCode, "SE")[0].Geography;
        }

        Person newActivist = Person.Create(this.TextName.Text, this.TextEmail.Text, Activizr.Logic.Security.Authentication.CreateRandomPassword(16), this.TextPhone.Text,
                                           string.Empty, this.TextPostalCode.Text, string.Empty, "SE", new DateTime(1900, 1, 1), PersonGender.Unknown);

        newActivist.Geography = geo;

        Activizr.Logic.Support.ActivistEvents.CreateActivistWithLogging(geo, newActivist, "The self-signup came from IP " + Request.UserHostAddress, EventSource.SignupPage, false, false, Organization.PPSEid);

        this.LabelGeographyResult.Text = geo.Name;

        this.PanelFinished.Visible          = true;
        this.DropCities.Enabled             = false;
        this.TextEmail.Enabled              = false;
        this.TextPostalCode.Enabled         = false;
        this.TextName.Enabled               = false;
        this.TextPhone.Enabled              = false;
        this.ButtonSubmit.Enabled           = false;
        this.ButtonSubmitCity.Enabled       = false;
        this.ButtonSubmitPostalCode.Enabled = false;
    }
Ejemplo n.º 10
0
    protected void ButtonSaveChanges_Click(object sender, EventArgs e)
    {
        // Check for dirty fields, one by one
        int    currentUserId = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
        Person currentUser   = Person.FromIdentity(currentUserId);

        AuditedPerson aperson = AuditedPerson.FromPerson(Person, currentUser, "PersonBasicDetails");

        if (this.TextName.Text != Person.Name)
        {
            if (!string.IsNullOrEmpty(aperson.PartyEmail))
            {
                msgAskAboutPPAddress.Visible = true; //Show "alert" panel
                divMessage.InnerHtml         =
                    Server.HtmlEncode(
                        this.GetLocalResourceObject("Interface.Controls.EditPerson.MsgAskForChangeMail").ToString()).Replace("[", "<").Replace("]", ">");

                /*"[br/][br/]
                 * [span style='font-size:1.1em;font-weight: bold']You changed your name.[/span][br/][br/]
                 * Do you want yor party mail address @piratpartiet.se[br/]
                 * to be changed as well?[br/]
                 * [br/]"*/
            }
            aperson.Name = this.TextName.Text;  // causes a database op
        }

        if (this.TextStreet.Text != Person.Street)
        {
            aperson.Street = this.TextStreet.Text; // causes a database op
        }


        if (this.TextCity.Text != Person.CityName)
        {
            aperson.City = this.TextCity.Text; // causes two dbops
        }



        Cities cities          = Cities.FromPostalCode(this.TextPostalCode.Text.Replace(" ", ""), this.DropCountries.SelectedValue);
        int    personGeography = person.GeographyId;

        if (this.TextPostalCode.Text != Person.PostalCode)
        {
            aperson.PostalCode = this.TextPostalCode.Text; // causes two dbops
        }



        if (this.DropCountries.SelectedValue != Person.Country.Code)
        {
            aperson.Country = Country.FromCode(this.DropCountries.SelectedValue); // causes two dbops
        }

        Person tempPerson = Person.FromIdentity(this.Person.Identity);

        //important that this is after country, city and postcode, since they might resolve wrongly
        if (this.DropDownMunicipalities.SelectedValue != tempPerson.GeographyId.ToString())
        {
            aperson.Geography = Geography.FromIdentity(int.Parse(this.DropDownMunicipalities.SelectedValue)); // causes two dbops
        }

        this.LabelEmailMessage.Text     = "";
        this.LabelEmailMessage.CssClass = "";
        if (this.TextEmail.Text != Person.Email)
        {
            if (Formatting.ValidateEmailFormat(this.TextEmail.Text))
            {
                aperson.Email = this.TextEmail.Text; // causes dbop

                if (aperson.MailUnreachable)
                {
                    aperson.MailUnreachable     = false;
                    this.LabelEmailMessage.Text = string.Empty;
                }
            }
            else
            {
                this.TextEmail.CssClass         = "DirtyInput";
                this.LabelEmailMessage.Text     = "Invalid Email Not Saved";
                this.LabelEmailMessage.CssClass = "ErrorMessage";
                this.TextEmail.Focus();
            }
        }

        if (this.TextPhone.Text != Person.Phone)
        {
            string phone = Formatting.CleanNumber(this.TextPhone.Text);
            this.TextPhone.Text = phone;

            aperson.Phone = phone; // causes dbop
        }



        this.LabelBirthdateMessage.Text     = "";
        this.LabelBirthdateMessage.CssClass = "";
        DateTime birthdate = DateTime.MinValue;

        if (DateTime.TryParse(this.TextBirthdate.Text, out birthdate))
        {
            if (birthdate != Person.Birthdate)
            {
                aperson.Birthdate = birthdate; // causes dbop
            }
            this.TextBirthdate.CssClass     = string.Empty;
            this.LabelBirthdateMessage.Text = string.Empty;
        }
        else
        {
            this.TextBirthdate.CssClass         = "DirtyInput";
            this.LabelBirthdateMessage.Text     = "Invalid Date Not Saved";
            this.LabelBirthdateMessage.CssClass = "ErrorMessage";
            this.TextBirthdate.Focus();
        }

        PersonGender gender = (PersonGender)Enum.Parse(typeof(PersonGender), this.DropGenders.SelectedValue);

        if (gender != Person.Gender)
        {
            aperson.Gender = gender; // causes dbop
        }
        string currentHandle = this.TextHandle.Text;

        try
        {
            currentHandle = Person.Handle;
            if (currentHandle == null)
            {
                currentHandle = string.Empty;
            }

            this.LabelHandleMessage.Text = string.Empty;
            this.TextHandle.CssClass     = string.Empty;

            if (this.TextHandle.Text != currentHandle)
            {
                try
                {
                    aperson.Handle = this.TextHandle.Text;
                }
                catch (HandleException exh)
                {
                    this.TextHandle.CssClass = "DirtyInput";
                    if (exh.ErrorType == HandleErrorType.HandleNotFound)
                    {
                        this.LabelHandleMessage.Text = "Not Found";
                    }
                    else if (exh.ErrorType == HandleErrorType.HandleOccupied)
                    {
                        this.LabelHandleMessage.Text = "Already in use, contact [email protected] if it is yours.";
                    }
                    else
                    {
                        this.LabelHandleMessage.Text = "Invalid Handle";
                    }
                    this.LabelHandleMessage.CssClass = "ErrorMessage";
                    this.TextHandle.Focus();
                }
            }
        }
        catch (Exception ex)
        {
            currentHandle           = "";
            this.TextHandle.Text    = "Connection Error";
            this.TextHandle.ToolTip = ex.Message;
            this.TextHandle.Enabled = false;
        }


        if (this.TextPersonalNumber.Text != Person.PersonalNumber)
        {
            aperson.PersonalNumber = this.TextPersonalNumber.Text;
        }



        this.LabelBankAccountMessage.CssClass  =
            this.LabelBankNameMessage.CssClass = string.Empty;
        this.TextBankAccount.CssClass          =
            this.TextBankName.CssClass         = string.Empty;


        if (this.TextBankAccount.Text != Person.BankAccount || this.TextBankName.Text != Person.BankName || this.TextBankClearing.Text != Person.BankClearing)
        {
            // If we are saving the bank account, the name and account must either be both present
            // or both empty.


            if (this.TextBankName.Text.Trim() == string.Empty && this.TextBankAccount.Text.Trim() == string.Empty)
            {
                aperson.BankAccount = aperson.BankName = string.Empty;
            }
            else if (this.TextBankName.Text.Trim().Length > 1 && this.TextBankAccount.Text.Trim().Length > 4)
            {
                aperson.BankAccount  = Formatting.CleanNumber(this.TextBankAccount.Text.Trim()); // causes dbops
                aperson.BankClearing = Formatting.CleanNumber(this.TextBankClearing.Text.Trim());
                aperson.BankName     = this.TextBankName.Text.Trim();
            }
            else
            {
                // If we get here, only one of the fields have been set.

                this.TextBankName.CssClass            = "DirtyInput";
                this.TextBankAccount.CssClass         = "DirtyInput";
                this.LabelBankNameMessage.Text        = "Must specify bank AND account";
                this.LabelBankAccountMessage.Text     = "Must specify bank AND account";
                this.LabelBankNameMessage.CssClass    = "ErrorMessage";
                this.LabelBankAccountMessage.CssClass = "ErrorMessage";

                if (this.TextBankAccount.Text.Trim().Length > 4)
                {
                    this.TextBankName.Focus();
                }
                else
                {
                    this.TextBankAccount.Focus();
                }
            }
        }

        if (this.TextPersonalNumber.Text != Person.PersonalNumber)
        {
            // TODO: Check for validity

            //aperson.PersonalNumber = this.TextPersonalNumber.Text.Trim();
        }

        if (DataChanged != null)
        {
            DataChanged(this, new EventArgs());
        }
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _authority = Person.FromIdentity(Convert.ToInt32(HttpContext.Current.User.Identity.Name)).GetAuthority();

        if (!Page.IsPostBack)
        {
            // Initialize the fields from the Person object

            this.ButtonSaveChanges.Text = this.GetLocalResourceObject("Interface.Controls.Common.ButtonSaveChanges").ToString() /*Save Changes*/;

            // Member number

            this.TextMemberNumber.Text  = Person.Identity.ToString();
            this.LabelMemberNumber.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.MemberNumber").ToString() /*Member #*/ + "&nbsp;&nbsp;";

            // Name

            this.TextName.Text = Person.Name;
            this.TextName.Attributes.Add("onkeypress", "OnTextChange (this);");
            this.TextName.Attributes.Add("onchange", "OnTextChange (this);");
            this.LabelName.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.Name").ToString() /*Name*/ + "&nbsp;&nbsp;";

            // Street

            this.TextStreet.Text = Person.Street;
            this.TextStreet.Attributes.Add("onkeypress", "OnTextChange (this);");
            this.TextStreet.Attributes.Add("onchange", "OnTextChange (this);");
            this.LabelStreet.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.Street").ToString() /*Street*/ + "&nbsp;&nbsp;";

            // Postal code, city

            this.TextPostalCode.Text = Person.PostalCode;
            this.TextPostalCode.Attributes.Add("onkeypress", "OnTextChangePostals();");
            this.TextCity.Text = Person.CityName;
            this.TextCity.Attributes.Add("onkeypress", "OnTextChangePostals();");
            this.TextCity.Attributes.Add("onchange", "OnTextChangePostals();");
            this.LabelPostal.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.Postal").ToString() /*Postal code, CityName*/ + "&nbsp;&nbsp;";

            this.DropDownMunicipalities.Attributes.Add("onchange", "OnChangeMunicipality();");


            // Countries

            this.DropCountries.Attributes.Add("onchange", "OnChangeCountries();");
            this.LabelCountry.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.Country").ToString() /*Country*/ + "&nbsp;&nbsp;";

            Cities cities          = Cities.FromPostalCode(Person.PostalCode.Replace(" ", ""), person.Country);
            int    personGeography = person.GeographyId;
            DropDownMunicipalities.Items.Clear();
            bool foundCurrent = false;

            foreach (City city in cities)
            {
                Geographies subGeo = city.Geography.GetTree();
                foreach (Geography geo in subGeo)
                {
                    // ignore  if it is not a leaf
                    if (geo.ChildrenCount == 0)
                    {
                        DropDownMunicipalities.Items.Add(new ListItem(geo.Name, geo.GeographyId.ToString()));

                        if (geo.GeographyId == person.GeographyId)
                        {
                            foundCurrent = true;
                        }
                    }
                }
            }


            if (!foundCurrent)
            {
                DropDownMunicipalities.Items.Add(new ListItem(Person.Geography.Name, Person.GeographyId.ToString()));
            }

            DropDownMunicipalities.SelectedValue = Person.GeographyId.ToString();


            // Populate countries

            Countries countries = Countries.GetAll();

            foreach (Country country in countries)
            {
                DropCountries.Items.Add(new ListItem(country.Code + " " + country.Name, country.Code));
            }

            DropCountries.Items.FindByValue(Person.Country.Code).Selected = true;

            // Email

            this.TextEmail.Text = Person.Email;
            this.TextEmail.Attributes.Add("onkeypress", "OnTextChange (this);");
            this.TextEmail.Attributes.Add("onchange", "OnTextChange (this);");
            this.LabelEmail.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.Email").ToString() + "&nbsp;&nbsp;";

            if (Person.MailUnreachable)
            {
                this.LabelEmailMessage.Text     = "Unreachable!";
                this.LabelEmailMessage.CssClass = "ErrorMessage";
            }

            // Party Email

            this.TextPartyEmail.Text = Person.PartyEmail;
            if (Person.PartyEmail.Length > 2)
            {
                this.ButtonSendNewPassword.Enabled = true;
            }
            else
            {
                this.ButtonSendNewPassword.Visible = false;
            }

            this.LabelPartyEmail.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.PartyEmail").ToString() /*Party Email*/ + "&nbsp;&nbsp;";

            // Phone

            this.TextPhone.Text = Person.Phone;
            this.TextPhone.Attributes.Add("onkeypress", "OnTextChange(this);");
            this.TextPhone.Attributes.Add("onchange", "OnTextChange(this);");
            this.LabelPhone.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.Phone").ToString() /*Phone #*/ + "&nbsp;&nbsp;";

            // Birthdate

            this.TextBirthdate.Text = Person.Birthdate.ToShortDateString();
            this.TextBirthdate.Attributes.Add("onkeypress", "OnTextChange(this);");
            this.TextBirthdate.Attributes.Add("onchange", "OnTextChange(this);");
            this.LabelBirthdate.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.Birthdate").ToString() /*Birthdate*/ + "&nbsp;&nbsp;";

            // Gender

            this.DropGenders.SelectedValue = Person.Gender.ToString();
            this.DropGenders.Attributes.Add("onclick", "OnTextChange(this);");

            // Handle
            try
            {
                this.TextHandle.Text = Person.Handle;
            }
            catch (Exception ex)
            {
                this.TextHandle.Text    = "Connection Error";
                this.TextHandle.ToolTip = ex.Message;
                this.TextHandle.Enabled = false;
            }

            this.TextHandle.Attributes.Add("onkeypress", "OnTextChange(this);");
            this.TextHandle.Attributes.Add("onchange", "OnTextChange(this);");
            this.LabelHandle.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.ForumHandle").ToString() /*Forum Handle*/ + "&nbsp;&nbsp;";

            // Personal Number

            this.TextPersonalNumber.Text = Person.PersonalNumber;
            this.TextPersonalNumber.Attributes.Add("onkeypress", "OnTextChange (this);");
            this.TextPersonalNumber.Attributes.Add("onchange", "OnTextChange (this);");
            this.LabelPersonalNumber.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.PersonalNumber").ToString() /*Personal #*/ + "&nbsp;&nbsp;";

            // Bank name

            this.TextBankName.Text = Person.BankName;
            this.TextBankName.Attributes.Add("onkeypress", "OnTextChange (this);");
            this.TextBankName.Attributes.Add("onchange", "OnTextChange (this);");
            this.LabelBankName.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.BankName").ToString() /*Bank Name*/ + "&nbsp;&nbsp;";

            // Bank clearing#

            this.TextBankClearing.Text = Person.BankClearing;
            this.TextBankClearing.Attributes.Add("onkeypress", "OnTextChange (this);");
            this.TextBankClearing.Attributes.Add("onchange", "OnTextChange (this);");
            // this.LabelBankClearing.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.BankName").ToString()/*Bank Name*/ + "&nbsp;&nbsp;";

            // Bank account

            this.TextBankAccount.Text = Person.BankAccount;
            this.TextBankAccount.Attributes.Add("onkeypress", "OnTextChange (this);");
            this.TextBankAccount.Attributes.Add("onchange", "OnTextChange (this);");
            this.LabelBankAccount.Text = this.GetLocalResourceObject("Interface.Controls.EditPerson.BankAccount").ToString() /*Bank Account*/ + "&nbsp;&nbsp;";

            // Crypto key

            this.TextCryptoFingerprint.Enabled  = false;
            this.TextCryptoFingerprint.ReadOnly = true;

            if (Person.CryptoFingerprint.Length > 4)
            {
                this.TextCryptoFingerprint.Text = Person.CryptoFingerprint;
            }
            else
            {
                this.TextCryptoFingerprint.Text = "--";
            }

            // T-Shirt Size

            this.TextTShirtSize.Enabled  = false;
            this.TextTShirtSize.ReadOnly = true;
            this.TextTShirtSize.Text     = Person.TShirtSize;


            // If we are looking at ourselves, enable the bank fields, which are otherwise disabled

            if (Person.Identity == Convert.ToInt32(HttpContext.Current.User.Identity.Name))
            {
                this.TextBankName.ReadOnly     = false;
                this.TextBankClearing.ReadOnly = false;
                this.TextBankAccount.ReadOnly  = false;
            }
            else
            {
                if (!_authority.HasAnyPermission(Permission.CanEditPeople))
                {
                    this.TextBirthdate.ReadOnly         = true;
                    this.DropGenders.Enabled            = false;
                    this.TextCity.ReadOnly              = true;
                    this.TextEmail.ReadOnly             = true;
                    this.TextHandle.ReadOnly            = true;
                    this.TextMemberNumber.ReadOnly      = true;
                    this.TextName.ReadOnly              = true;
                    this.TextPartyEmail.ReadOnly        = true;
                    this.TextPersonalNumber.ReadOnly    = true;
                    this.TextPhone.ReadOnly             = true;
                    this.TextPostalCode.ReadOnly        = true;
                    this.TextStreet.ReadOnly            = true;
                    this.DropCountries.Enabled          = false;
                    this.DropDownMunicipalities.Enabled = false;
                    this.ButtonSendNewPassword.Enabled  = false;
                    this.ButtonSaveChanges.Visible      = false;
                }
            }
        }

        if (_authority.HasPermission(Permission.CanEditMailDB, Organization.PPSEid, -1, Authorization.Flag.AnyGeographyExactOrganization))
        {
            ButtonDeleteMail.Visible = true;
            if (TextPartyEmail.Text.Trim() != "")
            {
                ButtonDeleteMail.Enabled = true;
            }
            else
            {
                ButtonDeleteMail.Enabled = false;
            }
        }
    }
Ejemplo n.º 12
0
    protected void ButtonSubmitPostalCode_Click(object sender, EventArgs e)
    {
        // Lookup postal code

        string postalCode = this.TextPostalCode.Text.Trim().Replace(" ", "");

        Cities cities = Cities.FromPostalCode(postalCode, Country.FromCode("SE"));

        if (cities.Count == 1)
        {
            // Ok, we're done and resolved!

            this.LabelGeographySecondPrompt.Text       = "Postnumret ligger i ";
            this.LabelGeographyDeterminedLocation.Text = cities[0].Name + ", " + cities[0].Geography.Name + ".";

            this.DropCities.Visible         = false;
            this.ButtonSubmitCity.Visible   = false;
            this.PanelMainQuestions.Visible = true;
            this.TextName.Focus();
        }
        else if (cities.Count == 0)
        {
            // Unable to find postal code

            this.LabelGeographySecondPrompt.Text = "Hittar inte postnumret. Vilken kommun bor du i? ";
            this.DropCities.Items.Clear();
            this.DropCities.Items.Add(new ListItem("--Välj--", "0"));

            Geographies geos = Geographies.FromLevel(Country.FromCode("SE"), GeographyLevel.Municipality);

            foreach (Geography geo in geos)
            {
                this.DropCities.Items.Add(new ListItem(geo.Name, geo.Identity.ToString()));
            }

            this.LabelGeographyDeterminedLocation.Text = string.Empty;
            this.DropCities.Visible         = true;
            this.ButtonSubmitCity.Visible   = true;
            this.PanelMainQuestions.Visible = false;
            this.DropCities.Focus();
        }
        else
        {
            // More than one candidate

            this.LabelGeographySecondPrompt.Text = "Du har ett krångligt postnummer. Vilken kommun bor du i? ";
            this.DropCities.Items.Clear();
            this.DropCities.Items.Add(new ListItem("--Välj--", "0"));

            foreach (City city in cities)
            {
                this.DropCities.Items.Add(new ListItem(city.Geography.Name, city.GeographyId.ToString()));
            }

            this.LabelGeographyDeterminedLocation.Text = string.Empty;
            this.DropCities.Visible         = true;
            this.ButtonSubmitCity.Visible   = true;
            this.PanelMainQuestions.Visible = false;
            this.DropCities.Focus();
        }
    }