protected void Button_Register_Click(object sender, EventArgs e) { ConnectDatabase aLayer = new ConnectDatabase(); if (aLayer.CheckUserID(txtUserID.Text)) { Response.Write("<script>alert('Same UserID aleady exit!!');</script>"); } else { if (aLayer.SaveUserInformation(txtUserID.Text, txtUserPasswd.Text, txtUserName.Text, txtUserEmail.Text, txtUserMobile.Text)) { Response.Write("<script>alert('Register Success ^^');window.location = 'UserLogin.aspx';</script>"); return; } else { Response.Write("<script>alert('Can not use database table');window.location = 'ViewUserPage.aspx';</script>"); return; } } }
protected void btnLogin_Click(object sender, EventArgs e) { ConnectDatabase aLayer = new ConnectDatabase(); if (aLayer.CheckUserID(txtUserID.Text)) { if (aLayer.CheckUser_Passwd(txtUserPasswd.Text)) { if (txtUserID.Text == "Admin") { if (txtUserPasswd.Text == "Admin") { Response.Write("<script>alert('Move to Manager Page');window.location = 'ViewManagerPage.aspx';</script>"); } } else { HttpCookie acookie = new HttpCookie("UserID"); acookie.Values["UserID"] = txtUserID.Text; acookie.Expires.AddDays(30); Session["User_ID"] = txtUserID.Text; Response.Cookies.Add(acookie); Response.Write("<script>alert('Your login success');window.location = 'ViewUserPage.aspx';</script>"); } } else { ClearTextBox(); Response.Write("<script>alert('Can not find password');</script>"); } } else { ClearTextBox(); Response.Write("<script>alert('Can not find User ID');</script>"); } }