protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["user"] == null) { Response.Redirect("~/ThaPoTuMi/Home"); } UserAcc user = UserAccService.GetUser(Session["user"].ToString()); txtEmail.Text = user.Email; lbPoint.Text = "Your point is: " + user.Point; drTitle.DataSource = TitleService.GetTitleSuitable(user.Point); drTitle.DataTextField = "TitleName"; drTitle.DataValueField = "TitleID"; drTitle.DataBind(); if (drTitle.SelectedItem == null) { btnChangeTitle.Enabled = false; } if (user.TitleID == 0) { btnRemoveTitle.Visible = true; } } }
protected void btnLogin_Click(object sender, EventArgs e) { string username = txtUserName1.Text; string password = txtPassword1.Text; int isLogin = UserAccService.CheckLogin(username, password); if (isLogin == 1) { UserAcc user = UserAccService.GetUser(username); Session["user"] = username; Session["type"] = user.Type; Response.Redirect("~/ThaPoTuMi/Home"); } else { Label3.Text = "Wrong username or password"; } }