Example #1
0
    protected void ButtonEdit_Click(object sender, EventArgs e)
    {
        bool   pet                  = false;
        bool   disabled             = false;
        string email                = Session["Email"].ToString().Trim();
        string name                 = TextBoxName.Text;
        string surname              = TextBoxContactAndSurname.Text;
        string address              = TextBoxAddress.Text;
        string postCode             = TextBoxPostCode.Text;
        string city                 = TextBoxCity.Text;
        string country              = TextBoxCountry.Text;
        string phone                = TextBoxPhone.Text;
        int    number_of_children   = Convert.ToInt32(TextBoxChildren.Text);
        int    number_of_cohabiters = Convert.ToInt32(TextBoxCohabitors.Text);

        if (CheckBoxPets.Checked == true)
        {
            pet = true;
        }

        if (CheckBoxDisability.Checked == true)
        {
            disabled = true;
        }

        client.EditStudentProfile(email, number_of_children, pet, number_of_cohabiters, disabled, name, surname, address, postCode, city, country, phone);

        Session["Number_of_children"] = Convert.ToInt32(TextBoxChildren.Text);
        Session["Pet"] = pet;
        Session["NumberOfCohabiters"] = Convert.ToInt32(TextBoxCohabitors.Text);
        Session["Disabled"]           = disabled;
        Session["Name"]     = TextBoxName.Text;
        Session["Surname"]  = TextBoxContactAndSurname.Text;
        Session["Address"]  = TextBoxAddress.Text;
        Session["PostCode"] = TextBoxPostCode.Text;
        Session["City"]     = TextBoxCity.Text;
        Session["Country"]  = TextBoxCountry.Text;
        Session["Phone"]    = TextBoxPhone.Text;

        if (client.EditStudentProfile(email, number_of_children, pet, number_of_cohabiters, disabled, name, surname, address, postCode, city, country, phone) == true)
        {
            LabelProfileEdit.Text = "Profile was updated successfully";
        }
        else
        {
            LabelProfileEdit.Text = "Profile update failed";
        }
    }