private void XoaTaiKhoan() { string TenDangNhap = ""; if (Request.Params["TenDangNhap"] != null) { TenDangNhap = Request.Params["TenDangNhap"]; if (TenDangNhap.ToLower() != "admin") { int kq = QuanLi.XoaTaiKhoan(TenDangNhap); if (kq != -1) { Response.Write("1"); } else { Response.Write("Có lỗi khi xóa!"); } } else { Response.Write("Không được xóa tài khoản Admin"); } } }
private void HienThiThongTin(string id) { if (thaotac == "chinh-sua") { btThemMoi.Text = "Chỉnh Sửa"; tbTenDangNhap.Enabled = false; DataTable dt = new DataTable(); dt = QuanLi.LayTaiKhoanTheoTen(id); if (dt.Rows.Count > 0) { tbTenDangNhap.Text = dt.Rows[0]["taiKhoan"].ToString(); tbHoTen.Text = dt.Rows[0]["hoTen"].ToString(); tbNgaySinh.Text = dt.Rows[0]["ngaySinh"].ToString().Split(' ')[0]; //lưu lại mật khẩu cũ vào trường ẩn để lấy lại khi ko cập nhật mật khẩu mới hdMatKhauCu.Value = dt.Rows[0]["matKhau"].ToString(); // bỏ yêu cầu bắt buộc nhập mật khẩu khi cập nhật RequiredFieldValidator2.Visible = false; } } else { btThemMoi.Text = "Thêm Mới"; } }
protected void lbtDangNhap_Click(object sender, EventArgs e) { DataTable dt = QuanLi.DangNhap(tbTenDangNhap.Text, MaHoa.MaHoaMD5(tbMatKhau.Text)); if (dt.Rows.Count > 0) { Session["DangNhap"] = "1"; //Gán thêm thông tin tài khoản đã đăng nhập Session["TenDangNhap"] = dt.Rows[0]["hoTen"]; Response.Redirect("Admin.aspx"); } else { ltrThongBao.Text = "<div class='ThongBao'>Tên đăng nhập hoặc mật khẩu không chính xác!</div>"; } }
protected void btThemMoi_Click(object sender, EventArgs e) { if (thaotac == "them-moi") { string matKhau = ""; if (matKhau != null) { matKhau = MaHoa.MaHoaMD5(tbMatKhau.Text); } else { matKhau = MaHoa.MaHoaMD5(hdMatKhauCu.Value);//TRƯỜNG hợp ko nhập mật khẩu thì lấy lại mật khẩu cũ } int kq = QuanLi.ThemMoiTaiKhoan(tbHoTen.Text, tbNgaySinh.Text, tbTenDangNhap.Text, matKhau); if (kq != -1) { ltrThongBao.Text = "<div class='thongBaoTaoThanhCong' style='color:#ff006e;font-size:16px;padding-bottom:20px;text-align:center;font-weight:bold'>Đã tạo tài khoản: " + tbTenDangNhap.Text + "</div>"; Response.Redirect("Admin.aspx?module=tai-khoan"); } else { ltrThongBao.Text = "<div class='thongBaoTaoThanhCong' style='color:#ff006e;font-size:16px;padding-bottom:20px;text-align:center;font-weight:bold'>Tài khoản đã tồn tại!</div>"; } } else { string matKhau = MaHoa.MaHoaMD5(tbMatKhau.Text); int kq = QuanLi.ChinhSuaTaiKhoan( id, tbHoTen.Text, tbNgaySinh.Text, matKhau); if (kq > 0) { Response.Redirect("Admin.aspx?module=tai-khoan"); } else { ltrThongBao.Text = "<div class='thongBaoTaoThanhCong' style='color:red;font-size:16px;padding-bottom:20px;text-align:center;font-weight:bold'>Lỗi khi chỉnh sửa: " + tbTenDangNhap.Text + "</div>"; } } }
private void LayTaiKhoan() { DataTable dt = QuanLi.LayDanhSachTaiKhoan(); for (int i = 0; i < dt.Rows.Count; i++) { ltrTaiKhoan.Text += @" <tr id='maDong_" + dt.Rows[i]["taiKhoan"] + @"'> <td class='cotTenDK'>" + dt.Rows[i]["taiKhoan"] + @"</td> <td class='cotHoTen'>" + dt.Rows[i]["hoTen"] + @"</td> <td class='cotNgaySinh'>" + dt.Rows[i]["ngaySinh"].ToString().Split(' ')[0] + @"</td> <td class='cotCongCu'> <a href='Admin.aspx?module=tai-khoan&thaotac=chinh-sua&id=" + dt.Rows[i]["taiKhoan"] + @"' class='sua' title='Sửa'></a> <a href=javascript:XoaTaiKhoan('" + dt.Rows[i]["taiKhoan"] + @"') class='xoa' title='Xóa'></a> </td> </tr> "; } }