using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CareersOnlineLibrary;
using CareersOnlineLibrary.Entity;
using CareersOnlineLibrary.Controller;
namespace WebApplication1.Account
{
public partial class ChangePassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitialisePage();
}
}
private void InitialisePage()
{
CareersOnlineController controller = new CareersOnlineController();
//let's get the user profile
TRAProfile profile;
profile = controller.GetTRAProfileByProfileID(int.Parse(Session["UserID"].ToString()));
controller = null;
profile = null;
}
protected void CancelPushButton_Click(object sender, EventArgs e)
{
Response.Redirect("~/Default.aspx");
}
protected void ChangePasswordPushButton_Click(object sender, EventArgs e)
{
CareersOnlineController controller = new CareersOnlineController();
//let's get the user profile
TRAProfile profile;
profile = controller.GetTRAProfileByProfileID(int.Parse(Session["UserID"].ToString()));
profile.Password = CurrentPassword.Text;
profile.NewPassword = NewPassword.Text;
//change the password
int successful = controller.UpdatePassWord(profile);
if (successful > 0)
{
//show confimation pop up and redirect to home page
string message = "User password was updated successfully.";
string HomePage = Request.Url.ToString();
HomePage = HomePage.Replace("/Account/ChangePassword.aspx", "/Default.aspx");
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}
else
{
string message = "The current password you provided is incorrect.";
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("");
ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
}
controller = null;
profile = null;
}
}
}