protected void btnlogin_Click(object sender, EventArgs e) { try { string username = Regex.Replace(txtusername.Text, @"[^\w]", ""); string password = Regex.Replace(txtpassword.Text, @"[^\w]", ""); if (username == "") { lblmsg.Visible = true; lblmsg.Text = "Username must not be empty."; mtop.Style["margin-top"] = "40px"; } else if (password == "") { lblmsg.Visible = true; lblmsg.Text = "Password must not be empty."; mtop.Style["margin-top"] = "40px"; } else { ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter(); string ucheck = ta.checkbyusername(username).ToString(); string pcheck = ta.passwordcheck(username, password).ToString(); if (Convert.ToInt32(ucheck) == 0) { lblmsg.Visible = true; lblmsg.Text = "Username doesn't Exist."; mtop.Style["margin-top"] = "40px"; } else if (Convert.ToInt32(pcheck) == 0) { lblmsg.Visible = true; lblmsg.Text = "Username/Password Is incorrect."; mtop.Style["margin-top"] = "40px"; } else if (username == "admin") { Session["username"] = username; Session["logintype"] = "admin"; Response.Redirect("dashboard.aspx"); } else { Session["username"] = username; Session["logintype"] = "user"; Response.Redirect("dashboard.aspx"); } } } catch (Exception ex) { lblmsg.Visible = true; lblmsg.Text = ex.ToString(); mtop.Style["margin-top"] = "40px"; } }
protected void btnsend_Click(object sender, EventArgs e) { String username = (String)Session["username"]; String Name = txtname.Text.ToString(); String pass = txtpassword.Text.ToString(); ProjectDatasetTableAdapters.usersTableAdapter ds = new ProjectDatasetTableAdapters.usersTableAdapter(); String count = ds.passwordcheck(username, pass).ToString(); if (Convert.ToInt32(count) > 0) { ds.updatefullname(Name, username); lblmsg.Visible = true; lblmsg.Style["background"] = "#4CAF50!important"; lblmsg.Text = "Name Successfully Changed"; mtop.Style["margin-top"] = "40px"; } else { lblmsg.Visible = true; lblmsg.Text = "Password Is Incorrect"; mtop.Style["margin-top"] = "40px"; } }