protected void BtnLogin_Click(object sender, EventArgs e) { Member obj = new Member(); string us = txtUserName.Text; string pw = txtPassword.Text; obj.UserName = us; if (obj.exist(us)) { Member mb = obj.getItem(us); if (mb.Pass == StringProc.MD5Hash(pw)) { if (mb.Role == 1) { Session["role"] = true; } else { Session["role"] = false; } Session["username"] = us; Response.Redirect("~"); } else { lblMessage.Text = "Mật Khẩu Sai"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true); } } else { lblMessage.Text = "Tài Khoản Không tồn Tại"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true); } }
protected void BtnLogin_Click(object sender, EventArgs e) { Customer obj = new Customer(); string us = txtUserName.Text; string pw = txtPassword.Text; obj.Username = us; if (obj.exist(us)) { Customer c = obj.getItem(us); if (c.Password == StringProc.MD5Hash(pw)) { Session["username_home"] = us; Response.Redirect("~/Home/index.aspx"); } else { lblMessage.Text = "Mật Khẩu Sai"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true); } } else { lblMessage.Text = "Tài Khoản Không tồn Tại"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true); } }
protected void Button1_Click(object sender, EventArgs e) { Session["loginname"] = txt_username.Text; Session["pass"] = txt_password.Text; string ten = Session["loginname"].ToString(); string pass = Session["pass"].ToString(); string passmd5 = StringProc.MD5Hash(pass); if (Member.ktDangNhap(ten, passmd5)) { Response.Redirect("index.aspx"); } else { Response.Write("Đăng Nhập Thất Bại"); } }
protected int KTDangNhap() { string name = txtU.Text.Trim(); string pass = StringProc.MD5Hash(txtP.Text.Trim()); string sQuery = "SELECT COUNT(*) FROM Member WHERE username=@us and pass=@pass"; SqlParameter[] pars = { new SqlParameter("@us", SqlDbType.VarChar, 50) { Value = name }, new SqlParameter("@pass", SqlDbType.VarChar, 255) { Value = pass }, }; return(DataProvider.executeScalar(sQuery, pars)); }
protected void btn_update_Click(object sender, EventArgs e) { string username = lb_username.Text; string name = txtName.Text; string pass = StringProc.MD5Hash(txtPassword.Text); string phone = txtPhone.Text; int role = Convert.ToInt32(ddl_user.SelectedValue); if (role == -1) { txtKQ.InnerText = "Role của bạn đang bọ bỏ trống"; } if (Member.update_member(username, name, phone, pass, role)) { Response.Write("<script>alert('Cập nhật thành công');</script>"); } else { Response.Write("<script>alert('Cập nhật thất bại');</script>"); } }
protected void Login_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-98N0JM4\SQL_EN2012;Initial Catalog=doan_asp_DB;Integrated Security=True")) { conn.Open(); string query = "SELECT Count(1) FROM member WHERE username=@username AND pass=@pwd AND xoa = 0 "; SqlCommand cmd = new SqlCommand(query, conn); cmd.Parameters.AddWithValue("@username", user_name.Text.Trim()); cmd.Parameters.AddWithValue("@pwd", StringProc.MD5Hash(pwd.Text.Trim())); int count = Convert.ToInt32(cmd.ExecuteScalar()); if (count == 1) { Session["username"] = user_name.Text.Trim(); Response.Redirect("Default.aspx"); conn.Close(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMess", "Swal.fire('Username or Password wrong!')", true); } } }