예제 #1
0
    protected void btn_changepass_Click(object sender, EventArgs e)
    {
        string         msg;
        HttpCookie     cookie   = Request.Cookies["Details"];
        string         sID      = cookie["UserID"].ToString();
        int            id       = int.Parse(sID);
        WS_UserProfile us       = new WS_UserProfile();
        string         oldpass  = us.UserPassword(id);
        string         newpass1 = txt_newpass.Text;
        string         newpass2 = txt_passconfirmation.Text;

        if (txt_oldpass.Text == oldpass)
        {
            if (newpass1 == newpass2)
            {
                us.NewPassword(id, newpass1);
                msg = "Password changed";
            }
            else
            {
                msg = " Change Failed. Wrong password confirmation";
            }
        }
        else
        {
            msg = "Change failed. old password is wrong";
        }

        Response.Write(msg);
    }
    protected void btn_updateprofile_Click(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["Details"];
        string     sID = cookie["UserID"].ToString();
        int        id = int.Parse(sID);
        string     fname, lname, country, gender, email, pass;
        int        age, updatemsg, credit;

        WS_UserProfile us = new WS_UserProfile();
        Service        s  = new Service();

        if (txt_fname_updatepage.Text == "")
        {
            fname = us.RetrieveFirstName(id);
        }
        else
        {
            fname = txt_fname_updatepage.Text;
        }

        if (txt_lname_updatepage.Text == "")
        {
            lname = us.RetrieveFLastName(id);
        }
        else
        {
            lname = txt_lname_updatepage.Text;
        }

        if (txt_age_updatepage.Text == "")
        {
            age = us.RetrieveAge(id);
        }

        else
        {
            age = int.Parse(txt_age_updatepage.Text);
        }

        if (txt_country_updatepage.Text == "")
        {
            country = us.RetrieveCountry(id);
        }
        else
        {
            country = txt_country_updatepage.Text;
        }

        if (txt_gender_updatepage.Text == "")
        {
            gender = us.RetrieveGender(id);
        }
        else
        {
            gender = txt_gender_updatepage.Text;
        }

        if (txt_email_updatepage.Text == "")
        {
            email = us.RetrieveEmail(id);
        }
        else
        {
            email = txt_email_updatepage.Text;
        }

        if (txt_creditcard_updatepage.Text == "")
        {
            credit = us.RetrieveCreditNum(id);
        }
        else
        {
            credit = int.Parse(txt_creditcard_updatepage.Text);
        }



        pass      = us.UserPassword(id);
        updatemsg = us.UserProfileUpdate(id, fname, lname, age, country, gender, email, credit, pass);
        if (updatemsg == 1)
        {
            Response.Write("Update Successful.");
        }
        else
        {
            Response.Write("Update failed.");
        }
    }