public UsersEntity ReadUsers(UsersEntity entity) { //logic goes here UsersDao UserDao = new UsersDao(); return UserDao.ReadUsers(entity); }
public ActionResult Edit(long id) { var dao = new UsersDao(); var model = dao.UserGetById(id); return(View(model)); }
public void Insert(UsersEntity entity) { //logic goes here UsersDao UserDao = new UsersDao(); UserDao.Insert(entity); }
public ActionResult Index() { var dao = new UsersDao(); var model = dao.ListUsers(); return(View(model)); }
/// <summary> /// 点击列表头时,数据自动填充 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (this.dataGridView.Rows.Count > 0) { DataGridViewRow currentRow = this.dataGridView.Rows[e.RowIndex]; this.userId.Text = currentRow.Cells["UsersId"].Value.ToString(); this.userName.Text = currentRow.Cells["UsersName"].Value.ToString(); this.userEmail.Text = currentRow.Cells["UsersEmail"].Value.ToString(); user = UsersDao.GetById(this.userId.Text); SetPrivilege(); if (user.UsersIsactive) { this.delBtn.Visible = true; this.activeBtn.Visible = false; this.resetPwdBtn.Enabled = true; this.saveBtn.Enabled = true; } else { this.delBtn.Visible = false; this.activeBtn.Visible = true; this.resetPwdBtn.Enabled = false; this.saveBtn.Enabled = false; } } }
private void confirmBtn_Click(object sender, EventArgs e) { this.ValidateChildren(ValidationConstraints.Enabled & ValidationConstraints.TabStop & ValidationConstraints.Selectable); if (!VTMS.ControlLib.ValidatorManager.ValidateControls(this)) { MessageBox.Show("控件内容不合法"); return; } if (this.currentPwd.Text.Equals(this.reCurrentPwd.Text)) { ep.Clear(); if (Utilities.Md5Encrypt(this.originPwd.Text).Equals(LoginForm.user.Password)) { LoginForm.user.Password = Utilities.Md5Encrypt(this.reCurrentPwd.Text); UsersDao.Update(LoginForm.user); MessageUtil.ShowTips("密码已经更新成功,下次登录时将生效。"); this.Close(); } else { ep.SetError(this.originPwd, "密码不正确"); this.originPwd.SelectAll(); } } else { ep.SetError(this.reCurrentPwd, "两次输入的密码不一致"); this.reCurrentPwd.SelectAll(); } }
public ActionResult Login(User user) { if (ModelState.IsValid) { var dao = new UsersDao(); var result = dao.Login(user.UserName, Encryptor.MD5Hash(user.Password)); if (result == 1) { var usr = dao.UserGetById(user.UserName); var userSession = new Common.UserLogin(); userSession.UserName = usr.UserName; userSession.UserID = usr.ID; Session.Add(Common.CommonConstant.User_Session, userSession); return(RedirectToAction("Index", "Users")); } else if (result == 0) { ModelState.AddModelError("", "Username or Password is incorrect!"); } else if (result == -1) { ModelState.AddModelError("", "Account is locked!"); } else { ModelState.AddModelError("", "Account is not sign up!"); } } return(View("Login")); }
public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { var dao = new UsersDao(); var result = dao.Login(model.UserName, Md5Encryptor.Md5Hash(model.Password)); if (result == 0) { var user = dao.GetById(model.UserName); var userSession = new UserLogin(); userSession.UserName = user.UserName; Session.Add(CommonConstants.USER_SESSION, userSession); return(RedirectToAction("Index", "Home")); } else if (result == 1) { ModelState.AddModelError("", "Username is not exist"); TempData["AlertMessage"] = "Username is not exist"; TempData["AlertType"] = "alert-danger"; } else { ModelState.AddModelError("", "Wrong Password"); TempData["AlertMessage"] = "Wrong password"; TempData["AlertType"] = "alert-danger"; } } return(View("Index")); }
public static void Buy(IApplicationBuilder app) { app.Run(async context => { var userId = context.Session.GetInt32("users_id"); if (userId == null) { if (context.Request.Cookies.ContainsKey("users_id")) { userId = int.Parse(context.Request.Cookies["users_id"]); var usersName = context.Request.Cookies["users_name"]; context.Session.SetInt32("users_id", (int)userId); context.Session.SetString("users_name", usersName); } context.Response.Headers.Add("result", "error"); return; } var courseId = int.Parse(context.Request.Headers["course_id"]); var usersDao = new UsersDao(); usersDao.AddCourseToUser((int)userId, courseId); var purchaseDao = new PurchaseDao(); var price = int.Parse(context.Request.Headers["price"]); var newPurchase = new Purchase((int)userId, courseId, DateTime.Now, price); purchaseDao.Save(newPurchase); context.Response.Headers.Add("result", "ok"); }); }
/// <summary> /// 激活按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void activeBtn_Click(object sender, EventArgs e) { user.UsersIsactive = true; UsersDao.Update(user); ClearControlContent(); LoadGridView(); }
public void OnGet(string courseId) { var id = int.Parse(courseId); var courseDao = new CourseDao(); Course = courseDao.GetById(id); var commentDao = new CommentDao(); Comments = commentDao.GetByCourseId(id); var usersId = HttpContext.Session.GetInt32("users_id"); if (usersId == null && HttpContext.Request.Cookies.ContainsKey("users_id")) { usersId = int.Parse(HttpContext.Request.Cookies["users_id"]); var usersName = HttpContext.Request.Cookies["users_name"]; HttpContext.Session.SetInt32("users_id", (int)usersId); HttpContext.Session.SetString("users_name", usersName); } UserIsAuthorized = usersId != null; if (UserIsAuthorized) { var usersCourses = new UsersDao().GetCourses((int)usersId); UserHasThisCourse = usersCourses.Select(c => c.Id).Contains(id); } }
public IActionResult OnGet() { var usersId = HttpContext.Session.GetInt32("users_id"); if (usersId == null) { if (HttpContext.Request.Cookies.ContainsKey("users_id")) { usersId = int.Parse(HttpContext.Request.Cookies["users_id"]); var usersName = HttpContext.Request.Cookies["users_name"]; HttpContext.Session.SetInt32("users_id", (int)usersId); HttpContext.Session.SetString("users_name", usersName); } else { return(Redirect("SignIn")); } } var usersDao = new UsersDao(); Users = usersDao.GetById((int)usersId); Courses = usersDao.GetCourses((int)usersId); var purchaseDao = new PurchaseDao(); Purchases = purchaseDao.GetByUsersId((int)usersId); foreach (var purchase in Purchases) { purchase.CourseName = Courses.First(c => c.Id == purchase.CourseId).Name; } return(null); }
public JsonResult ChangStatus(long id) { var result = new UsersDao().ChangStatus(id); return(Json(new { status = result })); }
/// <summary> /// 创建用户 /// </summary> /// <param name="us"></param> /// <returns></returns> public bool CreateUser(Users us) { UsersDao ud = new UsersDao(); if (ud.Insert(us) > 0) return true; return false; }
/// <summary> /// 获取所有用户信息 /// </summary> /// <param name="where">查询条件</param> /// <returns></returns> public List<Users> GetAllUser(string where) { UsersDao ud = new UsersDao(); Users user = new Users(); user.Where = where; return ud.Select(user); }
/// <summary> /// 删除用户 /// </summary> /// <param name="us"></param> /// <returns></returns> public bool DeleteUser(Users us) { UsersDao ud = new UsersDao(); us.Status = (int)DataStatusEnum.Disabled; if (ud.Update(us) > 0) return true; return false; }
public async Task UserList(IUser User = null) { var result = UsersDao.GetUserList(); foreach (var user in result) { var discorduser = Program._client.GetUser(Convert.ToUInt64(user.UserId)); await Context.Channel.SendMessageAsync($"{discorduser.Username} is in tha list"); } }
public static Users One(String codeUsers, String password) { try { return(UsersDao.getOneUsers(codeUsers, password)); } catch (Exception ex) { throw new Exception("Impossible d'atteindre l'enregistrement", ex); } }
public bool Delete(long id) { try { return(UsersDao.getDeleteUsers(id)); } catch (Exception ex) { throw new Exception("Impossible de supprimer cette enregistrement", ex); } }
public bool Update() { try { return(UsersDao.getUpdateUsers(users)); } catch (Exception ex) { throw new Exception("Impossible de modifier cette enregistrement", ex); } }
public Users Insert() { try { return(UsersDao.getAjoutUsers(users)); } catch (Exception ex) { throw new Exception("Impossible d'inserer cette enregistrement", ex); } }
public static List <Users> Liste(String query) { try { return(UsersDao.getListUsers(query)); } catch (Exception ex) { throw new Exception("Impossible de retourner la liste des élements", ex); } }
public static Users One(long id) { try { return(UsersDao.getOneUsers(id)); } catch (Exception ex) { throw new Exception("Impossible d'atteindre l'enregistrement", ex); } }
public JsonResult ChangeOption(int?id) { HttpCookie httpCookie = new HttpCookie("user_id", id.ToString()); httpCookie.Expires.AddDays(10); Response.Cookies.Set(httpCookie); var dao = new UsersDao(); return(Json(JsonRequestBehavior.AllowGet)); }
private static void SignIn(HttpContext context) { var name = context.Request.Headers["name"]; var password = context.Request.Headers["password"]; var user = new UsersDao().TrySignin(name, password); if (context.Request.Headers["remember"].ToString() == "true") { RememberUser(context, user); } MakeResponse(context, user); }
/// <summary> /// 用户帐号焦点离开事件,获取用户信息或者取得最新帐号 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void userId_Leave(object sender, EventArgs e) { if (VTMS.Common.Utilities.IsNullOrEmpty(this.userId.Text)) { this.userId.Text = UsersDao.GenerateId(); this.delBtn.Visible = false; user = null; this.saveBtn.Enabled = true; } }
public void setUp() { //INDbUnitTest dataBase = new SqlDbUnitTest("Data Source=(local);Initial Catalog=artsurvey;Persist Security Info=True;User ID=sa;Password=lotus"); //dataBase.ReadXmlSchema("../../etc/artsurvey.xsd"); //DataTableCollection dtc = dataBase.GetDataSetFromDb().Tables; //foreach (DataTable dt in dtc) //{ // StringCollection sc = new StringCollection(); // sc.Add(dt.TableName); // dataBase.GetDataSetFromDb(sc).WriteXmlSchema("etc//" + dt.TableName + ".schema.xml"); // dataBase.GetDataSetFromDb(sc).WriteXml("etc//" + dt.TableName + ".data.xml"); //} this.usersDao = new UsersDao(); }
private static void SignUp(HttpContext context) { var name = context.Request.Headers["name"]; var password = context.Request.Headers["password"]; var valid = Validate(name, password); if (!valid) { MakeErrorResponse(context); return; } var user = new UsersDao().TrySignup(name, password); MakeResponse(context, user); }
/// <summary> /// 检查用户名密码,取得用户信息 /// </summary> /// <returns></returns> private bool CheckPrivilege() { try { //取得用户信息 if (user == null) { user = UsersDao.GetById(this.userId.Text); } } catch (Exception e) { return(false); } //验证密码 string pwd = Utilities.Md5Encrypt(this.password.Text); if (LoginForm.user != null) { if (!user.UsersIsactive) { MessageBox.Show("用户已锁定,请联系管理员重新激活!"); return(false); } if (user.Password.Equals(Utilities.Md5Encrypt(this.password.Text))) { LoginForm.user.LoginDate = VehicleDao.GetCurrentDate(); LoginForm.user.LoginServer = server.Text; return(true); } else { MessageBox.Show("密码错误,请重试!"); return(false); } } else { MessageBox.Show("用户名不存在!"); this.userName.Text = ""; } return(false); }
public ActionResult Edit(User user) { if (ModelState.IsValid) { var dao = new UsersDao(); var encrytedMD5Pass = Encryptor.MD5Hash(user.Password); user.Password = encrytedMD5Pass; var result = dao.Update(user); if (result) { SetAlert("Edit users success!", "success"); return(RedirectToAction("Index", "Users")); } else { ModelState.AddModelError("", "Update not susccess!"); } } return(View("Index")); }
public ActionResult Index(LoginModel model) { var dao = new UsersDao(); string Password = Encryptor.MD5Hash(model.Password); var result = dao.Login(model.UserName, Password); if (result) { var user = dao.GetById(model.UserName); var userSession = new UserLogin(); userSession.UserName = user.UserName; userSession.UserID = user.UserId; Session.Add(CommonConstants.USER_SESSION, userSession); return(RedirectToAction("Index", "Index")); } else { ModelState.AddModelError("", "Đăng nhập không đúng."); } return(View()); }
/// <summary> /// 重置密码按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void resetPwdBtn_Click(object sender, EventArgs e) { string password = VTMS.Common.Utilities.GeneratePassword(); user.Password = VTMS.Common.Utilities.Md5Encrypt(password); try { UsersDao.Update(user); VTMS.Common.Utilities.sendEmail(user.UsersEmail, password); MessageUtil.ShowTips("密码重置成功!"); } catch (Exception ex) { MessageUtil.ShowTips("密码重置失败!错误信息为:" + ex.Message); } ClearControlContent(); }
public ActionResult Create(User user) { if (ModelState.IsValid) { var dao = new UsersDao(); var encrytedMD5Pass = Encryptor.MD5Hash(user.Password); user.Password = encrytedMD5Pass; var id = dao.Insert(user); if (id > 0) { SetAlert("Add users success!", "success"); return(RedirectToAction("Index", "Users")); } else { ModelState.AddModelError("", "Additional user!"); } } return(View("Index")); }
private void password_Enter(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(this.userId.Text)) { return; } //if (string.IsNullOrWhiteSpace(this.server.Text)) //{ // return; //} user = UsersDao.GetById(this.userId.Text); if (user != null) { this.userName.Text = user.UsersName; } else { MessageBox.Show("用户名不存在!"); this.userName.Text = ""; } }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var identity = new ClaimsIdentity(context.Options.AuthenticationType); var userSelector = new UsersDao(); //var userData = (User) userSelector.SelectOneRow(context.UserName, context.Password); var userData = (User)userSelector.SelectByEmail(context.UserName); if (userData != null && userData.Password != null && HashingUtil.VerifyPassword(context.Password, userData.Password)) { //identity.AddClaim(new Claim(ClaimTypes. identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, userData.UserId.ToString())); identity.AddClaim(new Claim(ClaimTypes.Name, userData.Email)); context.Validated(identity); } else { context.SetError("invalid_grant", "Provided username and password is incorrect"); context.Rejected(); } }
/// <summary> /// 获取简单的用户信息 /// </summary> /// <returns></returns> public List<Users> GetDirectUser() { UsersDao ud = new UsersDao(); Users user = new Users(); user.Status = (int)AccountStatusEnum.Active; DataSet ds = ud.SelectDirectUser(user); return ConvertDirectUsers(ds); }
public List<UsersEntity> ReadList() { UsersDao UserDao = new UsersDao(); return UserDao.ReadList(); }
public UsersEntity Read(int id) { UsersDao UserDao = new UsersDao(); return UserDao.Read(id); }
/// <summary> /// 编辑用户 /// </summary> /// <param name="us"></param> /// <returns></returns> public bool UpdateUser(Users us) { UsersDao ud = new UsersDao(); if (ud.Update(us) > 0) return true; return false; }
public List<UsersEntity> GetApproverList() { UsersDao UserDao = new UsersDao(); return UserDao.GetApproverList(); }
//public void Update(UsersEntity entity) //{ // UsersDao UserDao = new UsersDao(); // UserDao.Update(entity); //} public void Delete(int ID) { UsersDao UserDao = new UsersDao(); UserDao.Delete(ID); }