public void Update_TestCase8() { TaiKhoanDAO dao = new TaiKhoanDAO(); TAIKHOAN taiKhoan = new TAIKHOAN { MaTaiKhoan = TestCommon.LEN_10, TenDangNhap = TestCommon.LEN_10, MatKhau = TestCommon.LEN_10, NgayThayDoi = TestCommon.LEN_8, MaNhanVien = TestCommon.LEN_10 }; dao.Save(db, taiKhoan); TAIKHOAN taiKhoanUpdate = new TAIKHOAN { MaTaiKhoan = TestCommon.LEN_10, NgayThayDoi = TestCommon.LEN_8, MaNhanVien = TestCommon.LEN_10 }; string actual = dao.Save(db, taiKhoanUpdate); // Biến kết quả string expected = "1111"; // Test Assert.Equals(expected, actual); }
private void btnThemTK_Click(object sender, EventArgs e) { if (txtTenTK.Text.Equals("") || txtMKMoi.Text.Equals("") || txtMKMoi2.Text.Equals("")) { MessageBox.Show("Vui lòng nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } QLNS.Services.LogIn logInSer = new QLNS.Services.LogIn(); TaiKhoanInfo taikhoan = new TaiKhoanInfo(); taikhoan.ID = txtTenTK.Text; if (logInSer.CheckAcc(taikhoan)) { MessageBox.Show("Trùng tên tài khoản", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!txtMKMoi.Text.Equals(txtMKMoi2.Text)) { MessageBox.Show("Mật khẩu nhập lại không trùng khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } taikhoan.LoaiTK = 2; taikhoan.Pass = txtMKMoi.Text; TaiKhoanDAO taikhoanDao = new TaiKhoanDAO(); taikhoanDao.InsertAccount(taikhoan); }
public ActionResult Upimg(TaiKhoan tk, HttpPostedFileBase img) { //string fileContent = string.Empty; //string fileContentType = string.Empty; //byte[] uploadedFile = new byte[img.InputStream.Length]; //img.InputStream.Read(uploadedFile, 0, uploadedFile.Length); //// Initialization. //fileContent = Convert.ToBase64String(uploadedFile); //fileContentType = img.ContentType; //string filePath = Path.Combine(Server.MapPath("/Temp"), Path.GetFileName(img.FileName)); if (img != null && img.ContentLength > 0) { img.SaveAs(Server.MapPath("~/Content/Data/image/") + img.FileName); tk.hinh = "Content/Data/image/" + img.FileName; var dao = new TaiKhoanDAO(); bool kt = dao.upHinhTen(tk); if (kt) { TempData["testmsg"] = "Đổi ảnh đại diện thành công."; } else { TempData["testmsg"] = "Có lỗi trong quá trình đổi ảnh đại diện. Vui long thử lại sau."; } } return(RedirectToAction("Index")); }
/// <summary> /// Kiểm tra thông tin đăng nhập /// </summary> /// <param name="user"></param> /// <param name="pass"></param> /// <returns></returns> public static bool DangNhap(TextBox user, TextBox pass) { TaiKhoanDTO tkdto = new TaiKhoanDTO(); tkdto.TenDangNhap = user.Text; tkdto.MatKhau = pass.Text; DataTable table = TaiKhoanDAO.DangNhap(tkdto); if (table.Rows.Count == 1) { string str = table.Rows[0]["MatKhau"].ToString(); if (str == tkdto.MatKhau) { return(true); } else { return(false); } } else { return(false); } }
private void btnDoiMK_Click(object sender, EventArgs e) { if (txtMKCu.Text.Equals("") || txtMKMoi.Text.Equals("") || txtMKMoi2.Text.Equals("")) { MessageBox.Show("Vui lòng nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!txtMKMoi.Text.Equals(txtMKMoi2.Text)) { MessageBox.Show("Mật khẩu nhập lại sai", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } TaiKhoanInfo tk = new TaiKhoanInfo(); tk.Pass = txtMKCu.Text; if (!tk.Pass.Equals(taikhoan.Pass)) { MessageBox.Show("Sai mật khẩu hiện tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } taikhoan.Pass = txtMKMoi.Text; TaiKhoanDAO taikhoanDao = new TaiKhoanDAO(); taikhoanDao.UpdatePassWord(taikhoan.ID, taikhoan.Pass); MessageBox.Show("Thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); }
public JsonResult TaiKhoan_GetAll() { var dao = new TaiKhoanDAO(); var result = dao.GetTaiKhoan_All(); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(string id) { TaiKhoanDAO taiKhoanDAO = new TaiKhoanDAO(); taiKhoanDAO.Delete(id); return(RedirectToAction("Index")); }
// GET: Auth public ActionResult Login() { Session.RemoveAll(); TaiKhoanDAO user = CookieHelper.checkCookie(); return(View(user)); }
public ActionResult SignUp(TaiKhoan user) { var dao = new TaiKhoanDAO(); //dao.TaiKhoanInsert(user); return(RedirectToAction("Index", "Home")); }
private void btndoimk_Click(object sender, EventArgs e) { TaiKhoanDTO tk = new TaiKhoanDTO(); if (txtmkcu.Text == "" || txtmkmoi.Text == "" || txtxacnhan.Text == "") { MessageBox.Show("Chưa nhập đầy đủ thông tin"); } else { if (TaiKhoanDAO.DangNhap(txttk.Text, txtmkcu.Text) == true) { if (txtmkmoi.Text == txtxacnhan.Text) { tk.TaiKhoan = txttk.Text; tk.MatKhau = txtmkmoi.Text; TaiKhoanDAO.DoiMK(tk); MessageBox.Show("Đổi mật khẩu thành công"); } else { txtmkmoi.Focus(); MessageBox.Show("Mật khẩu không trùng khớp", "Thông Báo", MessageBoxButtons.OK); } } else { MessageBox.Show("Vui lòng xem lại tài khoản hoặc mật khẩu của bạn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public ActionResult Sua(TaiKhoan tk) { Web_ThucPhamDbContext db = new Web_ThucPhamDbContext(); if (ModelState.IsValid) { var dao = new TaiKhoanDAO(); var result = dao.Sua(tk); if (result) { SetAlert("Cập nhật tài khoản " + tk.TenHienThi + " thành công", "success"); logger.Info("Cập nhật tài khoản " + tk.TenHienThi + " thành công!"); if (Session["returnUrl"] == null) { return(Redirect("/Admin/Home/Index")); } else { return(Redirect(Session["returnUrl"].ToString())); } } else { SetAlert("Cập nhật tài khoản " + tk.TenHienThi + " không thành công", "error"); logger.Info("Cập nhật tài khoản " + tk.TenHienThi + " không thành công!"); ModelState.AddModelError("", "Cập nhật không thành công"); } } return(View()); }
//LoginGG public ActionResult LoginGoogle(string name, string email) { var dao = new TaiKhoanDAO(); int result_tk = dao.Create_TaiKhoan("Khách Hàng", email, ""); if (result_tk == 1) { //TempData["NewCustomer"] = user; // Set the auth cookie FormsAuthentication.SetAuthCookie(email, false); SessionHelper.SetSession(new AccLogin() { TaiKhoan1 = email, MatKhau = "" }); return(RedirectToAction("Index", "Home", new { area = "" })); } if (result_tk == 2) { var result2 = dao.GetTaiKhoan(email); SessionHelper.SetSession(new AccLogin() { TaiKhoan1 = result2.Taikhoan, MatKhau = result2.matkhau }); return(View("Index")); } else { return(View("Index")); } }
public ActionResult InfoUser(int id) { TaiKhoanDAO dao = new TaiKhoanDAO(); var result = dao.Detail(id); return(View(result)); }
public ActionResult DoiMK(TaiKhoan tk, string matkhau, string matkhaumoi, string reMKmoi) { if (tk.matKhau == matkhau) { tk.matKhau = EncryptorMD5.MD5Hash(matkhaumoi); if (matkhaumoi == reMKmoi) { var doi = new TaiKhoanDAO().DoiMK(tk); if (doi) { TempData["testmsg"] = "Đổi mật khẩu thành công."; } else { TempData["testmsg"] = "Có lỗi trong quá trình Đổi mật khẩu. Vui lòng thử lại sau."; } } else { TempData["testmsg"] = "Xác nhận lại mật khẩu không đúng."; } } else { TempData["testmsg"] = "Mật khẩu cũ không đúng."; return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { string path = "Source.Areas.Admin.Controllers"; ControllerDescriptor controller = filterContext.ActionDescriptor.ControllerDescriptor; if (controller.ControllerType.FullName.Contains(path)) { TaiKhoanDAO user = HttpContext.Current.Session["User"] == null ? null : (TaiKhoanDAO)HttpContext.Current.Session["User"]; if (user == null) { string url = "/Auth/Login?url=/Admin/" + controller.ControllerName + "/" + filterContext.ActionDescriptor.ActionName; filterContext.Result = new RedirectResult(url); } else if (user.QuyenHan != 0 && user.QuyenHan != 1) { filterContext.Result = new RedirectResult("/Auth/Unauthorized"); } else if (user.QuyenHan == 1) { if (!(controller.ControllerName.Equals("DonHang") || (controller.ControllerName.Equals("Ajax") && filterContext.ActionDescriptor.ActionName.Equals("UpdateInvoiceStatus")) || (controller.ControllerName.Equals("Home") && !filterContext.ActionDescriptor.ActionName.Equals("Index")))) { filterContext.Result = new RedirectResult("/Auth/Unauthorized"); } } } }
public ActionResult Register(TaiKhoanDAO user, string rePass, string GioiTinh) { bool check = true; try { if (string.IsNullOrEmpty(user.TenTaiKhoan) || string.IsNullOrEmpty(user.MatKhau) || string.IsNullOrEmpty(user.SDT) || string.IsNullOrEmpty(user.DiaChi)) { ViewBag.error = "Vui lòng nhập đầy đủ thông tin"; return(View(user)); } if (!user.MatKhau.Equals(rePass)) { ViewBag.error = "Mật khẩu không khớp. Vui lòng thử lại"; return(View(user)); } if (GioiTinh != null) { user.GioiTinh = true; } else { user.GioiTinh = false; } check = TaiKhoan_Service.Insert(user); } catch (Exception e) { ViewBag.error = e.Message; return(View(user)); } return(RedirectToAction("Login", "Auth")); }
public static Boolean Delete(String tenTaiKhoan) { if (TaiKhoanDAO.IsExist(tenTaiKhoan)) { return(TaiKhoanDAO.Delete(tenTaiKhoan)); } return(false); }
public static Boolean Update(TaiKhoanDTO taiKhoanDTO) { if (TaiKhoanDAO.IsExist(taiKhoanDTO.TenTaiKhoan)) { return(TaiKhoanDAO.Update(taiKhoanDTO)); } return(false); }
public static Boolean Insert(TaiKhoanDTO taiKhoanDTO) { if (!TaiKhoanDAO.IsExist(taiKhoanDTO.TenTaiKhoan)) { return(TaiKhoanDAO.Insert(taiKhoanDTO)); } return(false); }
protected void ButtonLogin_Click(object sender, EventArgs e) { TaiKhoanDAO tkDao = new TaiKhoanDAO(); List<TaiKhoanDTO> tk = tkDao.SelectTaiKhoan_Username(TextBoxUsername.Text); Label1.Text = tk[0].PASSWORD1; if (tk[0].PASSWORD1 == TextBoxPassword.Text) Label1.Text = "dung"; }
public IEnumerable <TaiKhoan> Get() { TaiKhoanDAO tkO = new TaiKhoanDAO(); TaiKhoan[] tk = new TaiKhoan[tkO.getDsTaiKhoan().Count]; tk = tkO.getDsTaiKhoan().ToArray(); return(tk); }
public ActionResult AddNew() { TaiKhoanDAO TKdao = new TaiKhoanDAO(); var ListTK = TKdao.Listof(); ViewBag.TK = ListTK; return(View()); }
//Tạo tài khoản mới public static bool TaoTaiKhoanMoi(TaiKhoanDTO tkDTO) { if (!TaiKhoanDAO.KiemTraTaiKhoanTonTai(tkDTO.TenTaiKhoan)) { return(TaiKhoanDAO.TaoTaiKhoanMoi(tkDTO)); } return(false); }
public TaiKhoanConvert Get(string email, string provider) { TaiKhoanDAO tkO = new TaiKhoanDAO(); TaiKhoanConvert tk = new TaiKhoanConvert(); tk = tkO.getTaiKhoan(email, provider); return(tk); }
// GET: Admin/TaiKhoan/TkKhachHang public ActionResult TkKhachHang(string tukhoa, int page = 1, int pageSize = 20) { var dao = new TaiKhoanDAO(); var model = dao.TatCaTkKhachHang(tukhoa, page, pageSize); ViewBag.TuKhoa = tukhoa; return(View(model)); }
public static bool ThemTaiKhoan(taiKhoanDTO tk) { if (!TaiKhoanDAO.KTTaiKhoanTonTai(tk.Username)) { return(TaiKhoanDAO.ThemTaiKhoan(tk)); } return(false); }
public static bool KhoiPhucLoaiTaiKhoan(int maLoaiTaiKhoan) { if (LoaiTaiKhoanDAO.KhoiPhucLoaiTaiKhoan(maLoaiTaiKhoan)) { return(TaiKhoanDAO.KhoiPhucTaiKhoanTheoLoai(maLoaiTaiKhoan)); } return(false); }
public ActionResult FacebookCallback(string code) { var fb = new FacebookClient(); dynamic result = fb.Post("oauth/access_token", new { client_id = ConfigurationManager.AppSettings["FbAppId"], client_secret = ConfigurationManager.AppSettings["FbAppSecret"], redirect_uri = RedirectUri.AbsoluteUri, code = code }); var accessToken = result.access_token; // Store the access token in the session for farther use Session["AccessToken"] = accessToken; // update the facebook client with the access token so // we can make requests on behalf of the user fb.AccessToken = accessToken; // Get the user's information dynamic me = fb.Get("me?fields=name,id,email,picture"); string email = me.email; string name = me.name; string id = me.id; string picture = "https://graph.facebook.com/" + id + "/picture?type=normal"; var dao = new TaiKhoanDAO(); int result_tk = dao.Create_TaiKhoan("Khách Hàng", email, ""); if (result_tk == 1) { //TempData["NewCustomer"] = user; // Set the auth cookie FormsAuthentication.SetAuthCookie(email, false); SessionHelper.SetSession(new AccLogin() { TaiKhoan1 = email, MatKhau = "" }); return(RedirectToAction("Index", "Home", new { area = "" })); } if (result_tk == 2) { var result2 = dao.GetTaiKhoan(email); SessionHelper.SetSession(new AccLogin() { TaiKhoan1 = result2.Taikhoan, MatKhau = result2.matkhau }); return(View("Index")); } else { return(View("Index")); } }
public static TaiKhoanDTO LayDSNhanVienCaTruong() { DataRow dr = TaiKhoanDAO.LayDSNhanVienCaTruong(); TaiKhoanDTO tk = new TaiKhoanDTO(); tk.TenTaiKhoan = dr["TenTaiKhoan"].ToString(); tk.MatKhau = dr["MatKhau"].ToString(); return(tk); }
public JsonResult ThayDoiTrangThai(long id) { var result = new TaiKhoanDAO().ThayDoiTrangThai(id); return(Json(new { trangthai = result })); }
public ActionResult Sua(int id) { if (Request["returnUrl"] != null) { Session["returnUrl"] = Request["returnUrl"]; } var taikhoan = new TaiKhoanDAO().ViewDetailByID(id); return(View(taikhoan)); }
protected void ButtonLogin_Click(object sender, EventArgs e) { TaiKhoanDAO tkDao = new TaiKhoanDAO(); List<TaiKhoanDTO> tk = tkDao.SelectTaiKhoan_Username(TextBoxUsername.Text); if (tk[0].PASSWORD1 == TextBoxPassword.Text) { Session["IsLogin"] = 1; Session["Username"] = tk[0].USERNAME1; Session["MaDN"] = tk[0].MADN1; Response.Redirect("TrangChuDoanhNghiep.aspx"); } else { Label1.Text = "Đăng nhập không thành công. Vui lòng thử lại!"; Label1.Visible = true; } }