public ActionResult LoginCustomer(string txtEmail, string txtPassWord) { CustomerAccountDAO customerAccountDAO = new CustomerAccountDAO(); var result = customerAccountDAO.CheckLogin(txtEmail, Encryptor.MD5Hash(txtPassWord)); if (result == 1) { var customer = customerAccountDAO.getCustomerAccount(txtEmail); var customersession = new CustomerLogin(); customersession.Email = customer.Email; customersession.PassWord = customer.PassWord; customersession.Name = customer.Name; Session.Add(Common.CommonConstants.Customer_SESSION, customersession); return(Redirect("/")); } else if (result == 0) { TempData["msg"] = MessageBox.Show("Tài Khoản Không Tồn Tại"); } else if (result == -1) { ModelState.AddModelError("", "Bạn đã điền sai password"); } return(View()); }
public ActionResult Information(CustomerAccount customerAccount, string newPassword) { CustomerAccountDAO customerAccountDAO = new CustomerAccountDAO(); customerAccount.PassWord = Common.Encryptor.MD5Hash(customerAccount.PassWord); customerAccount.ConfirmPassWord = Common.Encryptor.MD5Hash(customerAccount.ConfirmPassWord); if (customerAccountDAO.CheckPass(customerAccount) != 1) { TempData["msg"] = MessageBox.Show("Bạn đã nhập sai mật khẩu"); return(Redirect("/quan-li-tai-khoan")); } customerAccount.PassWord = Common.Encryptor.MD5Hash(newPassword); int check = customerAccountDAO.Edit(customerAccount); if (check > 0) { Session[Common.CommonConstants.Customer_SESSION] = null; TempData["msg"] = MessageBox.Show("Cập Nhập Thành Công Mời Bạn Đăng Nhập Lại"); return(Redirect("/")); } else { TempData["msg"] = MessageBox.Show("Cập Nhập Thất Bại, Bạn đã điền sai mật khẩu"); return(Redirect("/quan-li-tai-khoan")); } }
public ActionResult LoginCustomer(string txtEmail, string txtPassWord) { CustomerAccountDAO customerAccountDAO = new CustomerAccountDAO(); var result = customerAccountDAO.CheckLogin(txtEmail, Encryptor.MD5Hash(txtPassWord)); if (result == 1) { var customer = customerAccountDAO.getCustomerAccount(txtEmail); var customersession = new CustomerLogin(); customersession.Email = customer.Email; customersession.PassWord = customer.PassWord; customersession.Name = customer.Name; Session.Add(Common.CommonConstants.Customer_SESSION, customersession); return(Redirect("/")); } else if (result == 0) { TempData["msg"] = "<script>alert('tên đăng nhập không tồn tại!')</script>"; } else if (result == -1) { //ModelState.AddModelError("", "Bạn đã điền sai password"); TempData["msg"] = "<script>alert('bạn đã điền sai mật khẩu!')</script>"; } return(Redirect("/")); }
public ActionResult Information() { var session = (Common.CustomerLogin)Session[Common.CommonConstants.Customer_SESSION]; if (session == null) { return(Redirect("/")); } CustomerAccountDAO customerAccountDAO = new CustomerAccountDAO(); var customer = customerAccountDAO.getCustomerAccount(session.Email); return(View(customer)); }
// GET: Order public ActionResult ManagerOrder(int count = 0) { var session = Session[CommonConstants.Customer_SESSION] as CustomerLogin; if (session == null) { return(Redirect("/")); } var customer = new CustomerAccountDAO().getCustomerAccount(session.Email); OrderDAO orderDAO = new OrderDAO(); var listOrder = orderDAO.ListOrder(count, customer.ID); List <SelectListItem> listQuantityOrder = new List <SelectListItem>() { new SelectListItem() { Text = "5 Hóa đơn gần nhất", Value = 5.ToString() }, new SelectListItem() { Text = "15 Hóa đơn gần nhất", Value = 15.ToString() }, new SelectListItem() { Text = "30 Hóa đơn gần nhất", Value = 30.ToString(), Selected = true }, new SelectListItem() { Text = "Tất cả hóa đơn", Value = 0.ToString() } }; foreach (var order in listQuantityOrder) { if (order.Value == count.ToString()) { order.Selected = true; } else { order.Selected = false; } } ViewBag.list = listQuantityOrder; return(View(listOrder)); }
public ActionResult Register(CustomerAccount customerAccount, string gioiTinh) { if (ModelState.IsValid == true) { customerAccount.GioiTinh = gioiTinh; customerAccount.PassWord = Encryptor.MD5Hash(customerAccount.PassWord); customerAccount.ConfirmPassWord = Encryptor.MD5Hash(customerAccount.ConfirmPassWord); CustomerAccountDAO customerAccountDAO = new CustomerAccountDAO(); var check = customerAccountDAO.CreateAccount(customerAccount); if (check == 1) { TempData["msg"] = MessageBox.Show("Đăng kí thành công"); return(RedirectToAction("Register", "User")); } else { TempData["msg"] = MessageBox.Show("Email này đã có người đăng kí"); } } return(View("Register")); }
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["KhoaBiMat"], redirect_uri = RedirectUri.AbsoluteUri, code = code, }); var accessToken = result.access_token; if (!string.IsNullOrEmpty(accessToken)) { fb.AccessToken = accessToken; dynamic me = fb.Get("me?fields=first_name,middle_name,last_name,id,email"); string email = me.email; string userName = me.email; string firstname = me.first_name; string middlename = me.middle_name; string lastname = me.last_name; CustomerAccount customerAccount = new CustomerAccount(); customerAccount.Email = email; customerAccount.Name = firstname + " " + middlename + " " + lastname; customerAccount.PassWord = Encryptor.MD5Hash("Huypro123"); customerAccount.TelephoneNumber = 0; customerAccount.ConfirmPassWord = Encryptor.MD5Hash("Huypro123"); customerAccount.GioiTinh = "Nam"; CustomerAccountDAO customerAccountDAO = new CustomerAccountDAO(); var check = customerAccountDAO.CreateFacebook(customerAccount); if (check > 0) { var customersession = new CustomerLogin(); customersession.Email = customerAccount.Email; customersession.Name = customerAccount.Name; Session.Add(Common.CommonConstants.Customer_SESSION, customersession); } } return(Redirect("/")); }