public async Task <tbUser> Insert(tbUser model) { try { model.PasswordEncript = AppHelper.GetMD5HashData(model.Password); IEnumerable <tbUser> user = await base.Data.QueryAsync <tbUser> ( "[Test].[SP_User_Insert]", new { Username = model.Username, PasswordEncript = model.PasswordEncript, Firstname = model.Firstname, Lastname = model.Lastname, IsAdmin = model.IsAdmin, Mobile = model.Mobile, IsActive = model.IsActive, Email = model.Email, CreateDate = DateTime.Now, BranchId = model.BranchId }, commandType : CommandType.StoredProcedure ); return(user.FirstOrDefault()); } catch { return(null); } }
//处理BeginRequest事件的实际代码 void Application_AcquireRequestState(object sender, EventArgs e) { context = ((HttpApplication)sender).Context; request = context.Request; session = context.Session; requestPath = request.Path; defaultPath = request.ApplicationPath + "/Default.aspx"; //仅处理向页面的请求,排除向资源文件的请求,排除非文件夹admin下的所有文件和后台首页 //admin/index.aspx可以被任何已登陆用户访问,所以排除 if (requestPath.IndexOf(".aspx") != -1 && !requestPath.StartsWith(defaultPath)) { tbUser user = (tbUser)session[Constant.User]; if (user == null) { //还没有登陆 //context.Response.Redirect("~/Default.aspx"); context.Response.Write("<script>parent.location.href='" + request.ApplicationPath + "/Default.aspx';</script>"); context.Response.End(); } else { bool isGranted = IsGranted(user.usertype, requestPath); if (isGranted == false) { //没有权限访问 context.Response.Redirect("~/403.html"); } } } }
public HttpResponseMessage Login([FromBody] LoginBindingModel loginModel) { try { using (TLC_DBEntities entities = new TLC_DBEntities()) { tbUser tbUserModel = entities.tbUsers.Where(user => user.vcUserName == loginModel.UserName && user.vcPassword == loginModel.Password).FirstOrDefault(); if (tbUserModel != null) { string baseToken = loginModel.UserName + ':' + loginModel.Password; string encodedToken = Convert.ToBase64String(Encoding.UTF8.GetBytes(baseToken)); UserBindingModel userModel = new UserBindingModel { Token = encodedToken, UserKey = tbUserModel.kUser.ToString(), UserName = tbUserModel.vcUserName.ToString(), ClientKey = tbUserModel.kLookClient.ToString() }; return(Request.CreateResponse(HttpStatusCode.OK, userModel)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid username or password")); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <ActionResult> Authenticate([FromBody] viRegisterUserModel model) { var rp = db.GetRepository <tbUser>(true) as UserService; var eu = await rp.GetFirstOrDefaultAsync(predicate : x => x.Username == model.Username, disableTracking : true); if (eu != null) { return(BadRequest("Бундай фойдаланувчи бор")); } var u = new tbUser(); u.FirstName = model.FirstName; u.LastName = model.LastName; u.Username = model.Username; u.Password = model.Password; u.Phone = model.Phone; u.RoleId = 2; u.Status = 1; u.CreateUser = 1; u.CreateDate = DateTime.Now; await rp.InsertAsync(u); await db.SaveChangesAsync(); var rpUser = db.GetRepository <tbUser>(true) as UserService; var user = rpUser.Authenticate(model.Username, model.Password); return(Ok(user)); }
public static string GetUserByID(int userID) { string str = string.Empty; try { IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; tbUser temp = new tbUser(); AchieveDBEntities myDbContext = new AchieveDBEntities(); List <tbUser> templist = myDbContext.tbUser.Where(p => p.ID == userID).ToList(); if (templist != null && templist.Count > 0) { temp = templist[0]; temp.Password = ""; str = JsonConvert.SerializeObject(temp, Formatting.Indented, timeFormat); str = ResponseHelper.ResponseMsg("1", "取数成功", str); } else { str = JsonConvert.SerializeObject(temp, Formatting.Indented, timeFormat); str = ResponseHelper.ResponseMsg("-1", "用户ID不存在", str); } } catch (Exception ex) { str = ResponseHelper.ResponseMsg("-1", ex.Message, ""); } return(str); }
public static string Logon(LogonModel logon) { var db = new AuthorityRepository(); tbUser user = db.GetEntitie <tbUser>(p => p.userID == logon.userID); if (user == null) { return(string.Format("登录失败:用户\"{0}\"不存在!", logon.userID)); } if (user.userPassword != logon.userPassword) { return(string.Format("登录失败:输入的密码不正确!")); } var role = db.GetEntitie <tbRole>(p => p.ID == user.roleID); if (role.disabled) { return(string.Format("登录失败:用户\"{0}\"所属的权限组已被停用!", logon.userID)); } user.lastLogIP = logon.logIP; user.lastLogTime = DateTime.Now; user.logTimes = user.logTimes + 1; Account.currentUser = user; db.Update((tbUser)user); return(string.Empty); }
private void btSignUp_Click(object sender, RoutedEventArgs e) { tbUser user = new tbUser { UserName = txtUser.Text, Password = txtPassword.Password, Email = txtEmail.Text, Phone = txtPhone.Text, }; db.tbUsers.Add(user); db.SaveChanges(); if (ImagePath != "") { string newPath = Environment.CurrentDirectory + $"\\Images\\Users\\{user.ID}.png"; File.Copy(ImagePath, newPath); user.Image = newPath; db.SaveChanges(); } MessageBox.Show("Done!"); Main_Screen main = new Main_Screen(); main.Show(); Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindUserType(); if (Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); user = userBLL.GetModel(id); txtLoginName.Text = user.loginname; txtLoginName.Enabled = false; txtRealName.Text = user.realname; ddlUserType.Items.FindByValue(user.usertype.ToString()).Selected = true; ddlUserType.Enabled = false; if (user.usertype == 3) { BindClass(); ddlClass.Items.FindByValue(user.classid.ToString()).Selected = true; ddlClass.Enabled = true; } else { ddlClass.Enabled = false; } } } }
public HttpResponseMessage Login(JObject jsonJObject) { try { using (var context = new UserDbDataContext()) { var entity = JsonConvert.DeserializeObject <dynamic>(jsonJObject.ToString()); dynamic device = entity.Device; String email = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "Email"); String username = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "UserName"); String password = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "Password"); String deviceId = DataAccess.UtilFolder.Converts.ToStringFromDynamic(device, "DeviceId"); String devicetoken = DataAccess.UtilFolder.Converts.ToStringFromDynamic(device, "Token"); tbUser user = UserInfo.Login(context, username, email, password, deviceId, devicetoken); return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.OK, new { user.FullName, user.Email, user.ImageUrl, user.LastLogin, user.UserName, user.Token })); } } catch (Exception e) { return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.NotFound, new ErrorCls(e.Message))); } }
public static void ReloadInfoUser() { string DUser = Auth.GetCookie("DUser"); if (DUser == DDefault.SAdminID) { HttpContext.Current.Session["DUserName"] = "******"; HttpContext.Current.Session["DUserAvatar"] = "defaultavatar.png"; Auth.SetCookie("DGroupId", 0); } else { DBAdmin db = new DBAdmin(); tbUser tbUser = db.tbUsers.Where(p => p.Username == DUser).FirstOrDefault(); if (tbUser == null) { return; } HttpContext.Current.Session["DUserName"] = tbUser.Fullname; HttpContext.Current.Session["DUserAvatar"] = string.IsNullOrEmpty(tbUser.AvatarUrl) ? "defaultavatar.png" : tbUser.AvatarUrl; // tbGroupId tbGroupUser tbMemberGroup = db.tbGroupUsers.Where(x => x.tbUserId == tbUser.tbUserId).FirstOrDefault(); if (tbMemberGroup == null) { Auth.SetCookie("DGroupId", -1); } else { Auth.SetCookie("DGroupId", tbMemberGroup.tbGroupId); } } }
public ActionResult DeleteConfirmed(short id) { tbUser tbUser = db.tbUser.Find(id); db.tbUser.Remove(tbUser); db.SaveChanges(); return(RedirectToAction("Index")); }
public static string GetUserMenu(int userID, string token) { string str = string.Empty; try { IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; tbUser temp = new tbUser(); AchieveDBEntities myDbContext = new AchieveDBEntities(); int count = myDbContext.tbUserToken.Where(p => p.UserId == userID && p.Token == token).Count <tbUserToken>(); if (count <= 0) { throw new Exception("帐号异常,请退出系统!"); } List <tbUser> templist = myDbContext.tbUser.Where(p => p.ID == userID).ToList(); if (templist != null && templist.Count > 0) { var query = from ur in myDbContext.tbUserRole join rmb in myDbContext.tbRoleMenu on ur.RoleId equals rmb.RoleId join m in myDbContext.tbMenu on rmb.MenuId equals m.Id where ur.UserId == userID && m.ParentId == 0 orderby m.ParentId, m.Sort select m; List <MenuTreeModel> list = new List <MenuTreeModel>(); if (query != null) { foreach (var tp in query) { MenuTreeModel m = new MenuTreeModel(); m.Id = tp.Id.ToString(); m.Icon = tp.Icon; m.MenuName = tp.Name; m.ParentId = tp.ParentId.ToString(); m.Url = tp.LinkAddress; m.Node = GetChildMenu(userID, tp.Id); list.Add(m); } } str = JsonConvert.SerializeObject(list, Formatting.Indented, timeFormat); str = ResponseHelper.ResponseMsg("1", "取数成功", str); } else { str = JsonConvert.SerializeObject(temp, Formatting.Indented, timeFormat); str = ResponseHelper.ResponseMsg("-1", "用户ID不存在", str); } } catch (Exception ex) { str = ResponseHelper.ResponseMsg("-1", ex.Message, ""); } return(str); }
/// <summary> /// 删除所选 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbtnDelete_Click(object sender, EventArgs e) { int countSuccess = 0; int countFail = 0; for (int i = 0; i < gvwData.Rows.Count; i++) { CheckBox cbx = (CheckBox)gvwData.Rows[i].FindControl("chkbOne"); if (cbx.Checked == true) { int id = Convert.ToInt32(gvwData.DataKeys[i].Value); tbUser user = userBLL.GetModel(id); switch (user.usertype) { case 1: //删除管理员 userBLL.Delete(id); DbHelperSQL.ExecuteSql("delete from tbMessage where userid=" + id); countSuccess++; break; case 2: //删除教师 bool b = DbHelperSQL.Exists("select id from tbGrant where userid=" + id); if (b == false) { //执行删除 userBLL.Delete(id); DbHelperSQL.ExecuteSql("delete from tbMessage where userid=" + id); countSuccess++; } else { countFail++; } break; case 3: //删除学生 userBLL.Delete(id); DbHelperSQL.ExecuteSql("delete from tbAnswerOfPaper where userid=" + id); DbHelperSQL.ExecuteSql("delete from tbScore where userid=" + id); countSuccess++; break; } } } BindData(); String message = "成功删除" + countSuccess + "条记录!"; if (countFail != 0) { message += "<br/>还存在" + countFail + "条记录拒绝删除!"; message += "<br/>可能原因:该教师存在授课!"; } MyUtil.ShowMessage(this, message); }
public ActionResult Edit([Bind(Include = "UserID,UserName,LoginID,PassWord,Name,Surname,authtype")] tbUser tbUser) { if (ModelState.IsValid) { db.Entry(tbUser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbUser)); }
public ActionResult Index([Bind(Include = "tbUserId,Username,Fullname,Password,IsDisable")] tbUser tbUser, HttpPostedFileBase file) { string userid = Auth.GetCookie("DUser"); tbUser tbUserOld = db.tbUsers.Where(x => x.Username == userid).FirstOrDefault(); if (tbUser == null) { return(HttpNotFound()); } if (ModelState.IsValid) { tbUserOld.Fullname = tbUser.Fullname; tbUserOld.Password = DreamCMS.Encrypt.DHash.Encrypt(tbUser.Password); // AVATAR if (file != null) { if (HttpPostedFileBaseExtensions.IsImage(file)) { string ext = Path.GetExtension(file.FileName).ToLower(); //string pic = Path.GetFileName(file.FileName); string path = Path.Combine(Server.MapPath("~/Areas/Admin/upload/avatar"), tbUserOld.Username + ext); //delele old file if (!string.IsNullOrEmpty(tbUserOld.AvatarUrl)) { string fullPath = Path.Combine(Server.MapPath("~/Areas/Admin/upload/avatar"), tbUserOld.AvatarUrl); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } // file is uploaded file.SaveAs(path); tbUserOld.AvatarUrl = tbUser.Username + ext; } } db.SaveChanges(); Auth.ReloadInfoUser(); ViewBag.MsgResult = true; tbUserOld.Password = DreamCMS.Encrypt.DHash.Decrypt(tbUserOld.Password); return(View("__Cms/Account/Profile", tbUserOld)); } ViewBag.MsgResult = false; ViewBag.MsgText = "Cập nhật thông tin thất bại!!!"; tbUserOld.Password = DreamCMS.Encrypt.DHash.Decrypt(tbUserOld.Password); return(View("__Cms/Account/Profile", tbUserOld)); }
public ActionResult Create([Bind(Include = "UserName,LoginID,PassWord,Name,Surname,authtype")] tbUser tbUser) { if (ModelState.IsValid) { db.tbUser.Add(tbUser); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbUser)); }
/// <summary> /// 重置密码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lbtnReset_Click(object sender, EventArgs e) { LinkButton lbtn = (LinkButton)sender; int id = Convert.ToInt32(lbtn.CommandArgument); tbUser user = userBLL.GetModel(id); user.userpwd = MyUtil.MD5("888888"); userBLL.Update(user); BindData(); MyUtil.ShowMessage(this, "新的密码为888888!"); }
public static string AddUser(string Userstr) { string str = string.Empty; try { tbUser tb = JsonConvert.DeserializeObject <tbUser>(Userstr); string passWord = Base64Helper.DecodeBase64(tb.Password); string password = Md5Helper.GetMD5String(passWord); tbUser newtb = new tbUser() { AccountName = tb.AccountName, CreateBy = tb.CreateBy, CreateTime = DateTime.Now, Description = tb.Description, Email = tb.Email, IfChangePwd = tb.IfChangePwd, IsAble = tb.IsAble, MobilePhone = tb.MobilePhone, Password = password, RealName = tb.RealName, UpdateTime = DateTime.Now, UpdateBy = tb.CreateBy }; AchieveDBEntities myDbContext = new AchieveDBEntities(); int DataCount = myDbContext.tbUser.Where(p => p.AccountName == newtb.AccountName).Count <tbUser>(); if (DataCount > 0) { throw new Exception(string.Format("帐号名:{0}重复,请重新输入", newtb.AccountName)); } DataCount = myDbContext.tbUser.Where(p => p.Email == newtb.Email).Count <tbUser>(); if (DataCount > 0) { throw new Exception(string.Format("邮箱:{0}重复,请重新输入", newtb.Email)); } DataCount = myDbContext.tbUser.Where(p => p.MobilePhone == newtb.MobilePhone).Count <tbUser>(); if (DataCount > 0) { throw new Exception(string.Format("手机号:{0}重复,请重新输入", newtb.MobilePhone)); } myDbContext.tbUser.Add(newtb); myDbContext.SaveChanges(); str = ResponseHelper.ResponseMsg("1", "保存成功", ""); } catch (Exception ex) { str = ResponseHelper.ResponseMsg("-1", ex.Message, ""); } return(str); }
// GET: Userconfig/Delete/5 public ActionResult Delete(short?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbUser tbUser = db.tbUser.Find(id); if (tbUser == null) { return(HttpNotFound()); } return(View(tbUser)); }
public static string UpdateUserAllinfo(string Userstr) { string str = string.Empty; try { tbUser tb = JsonConvert.DeserializeObject <tbUser>(Userstr); AchieveDBEntities myDbContext = new AchieveDBEntities(); tbUser data = myDbContext.tbUser.Where(p => p.ID == tb.ID).FirstOrDefault(); string passWord = Base64Helper.DecodeBase64(tb.Password); string password = Md5Helper.GetMD5String(passWord); data.AccountName = tb.AccountName; data.Description = tb.Description; data.Email = tb.Email; data.IfChangePwd = tb.IfChangePwd; data.IsAble = tb.IsAble; data.MobilePhone = tb.MobilePhone; data.Password = password; data.RealName = tb.RealName; data.UpdateBy = tb.UpdateBy; data.UpdateTime = DateTime.Now; int DataCount = myDbContext.tbUser.Where(p => p.AccountName == data.AccountName && p.ID != data.ID).Count <tbUser>(); if (DataCount > 0) { throw new Exception(string.Format("帐号名:{0}重复,请重新输入", data.AccountName)); } DataCount = myDbContext.tbUser.Where(p => p.Email == data.Email && p.ID != data.ID).Count <tbUser>(); if (DataCount > 0) { throw new Exception(string.Format("邮箱:{0}重复,请重新输入", data.Email)); } DataCount = myDbContext.tbUser.Where(p => p.MobilePhone == data.MobilePhone && p.ID != data.ID).Count <tbUser>(); if (DataCount > 0) { throw new Exception(string.Format("手机号:{0}重复,请重新输入", data.MobilePhone)); } myDbContext.SaveChanges(); str = ResponseHelper.ResponseMsg("1", "更新成功", ""); } catch (Exception ex) { str = ResponseHelper.ResponseMsg("-1", ex.Message, ""); } return(str); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbUser tbUser = db.tbUsers.Find(id); if (tbUser == null) { return(HttpNotFound()); } tbUser.Password = DreamCMS.Encrypt.DHash.Decrypt(tbUser.Password); return(View("__Cms/Users/Edit", tbUser)); }
public ActionResult profileDev(string id, string value, string type) { string opr = ""; tbUser dev = new tbUser(); int userID = Convert.ToInt32(id); dev = db.tbUsers.Find(userID); switch (type) { case "name": int i = 2; string[] names = value.Split(new char[] { ' ' }, i); dev.firstName = names[0]; dev.lastName = names[1]; break; case "num": value = value.Trim(); dev.contactNumber = value; break; case "add": dev.address = value; break; case "loc": int j = 2; string[] address = value.Split(new char[] { '|' }, j); dev.city = address[0]; dev.country = address[1]; break; case "over": dev.tbClients.First().overview = value; break; } try { db.SaveChanges(); opr = "success"; } catch { opr = "failed"; } return(Json(new { name = value, oper = opr })); }
private String GetWhereSql() { StringBuilder sb = new StringBuilder(); sb.Append(" 1=1 "); if (txtWord.Text.Trim() != "") { sb.Append(" and (messagetitle like '%" + txtWord.Text.Trim() + "%' or messagecontent like '%" + txtWord.Text.Trim() + "%')"); } tbUser user = (tbUser)Session[Constant.User]; if (user.usertype == 2) { sb.Append(" and userid=" + user.id); } return(sb.ToString()); }
public async Task <UserResponse> RegisterUserAsync(RegisterUserModel model) { var eu = await db.tbUsers.FirstOrDefaultAsync(x => x.Username == model.Username); if (eu != null) { return new UserResponse() { Status = 0, StatusMessage = "User exits" } } ; var role = db.spRoles.Find(1); if (role == null) { var r = new spRole(); r.Name = "Admin"; r.UserAccess = ",999"; await db.spRoles.AddAsync(r); await db.SaveChangesAsync(); } var u = new tbUser(); u.FirstName = model.FirstName; u.LastName = model.LastName; u.Username = model.Username; u.Password = HashSha256.Get(model.Password); u.EMail = model.EMail; u.RoleId = 1; await db.tbUsers.AddAsync(u); await db.SaveChangesAsync(); return(await AuthenticateAsync(new UserRequest() { Username = model.Username, Password = model.Password })); } }
protected void Page_Load(object sender, EventArgs e) { if (!String.IsNullOrEmpty(hfPageIndex.Value)) { pageIndex = Convert.ToInt32(hfPageIndex.Value); } if (!String.IsNullOrEmpty(hfPageSize.Value)) { pageSize = Convert.ToInt32(hfPageSize.Value); } user = (tbUser)Session[Constant.User]; if (!IsPostBack) { BindSubject(); BindData(); } }
public ActionResult Index() { string userid = Auth.GetCookie("DUser"); // Nếu là tài khoản thường if (userid != DDefault.SAdminID) { tbUser tbUser = db.tbUsers.Where(x => x.Username == userid).FirstOrDefault(); if (tbUser == null) { return(HttpNotFound()); } tbUser.Password = DreamCMS.Encrypt.DHash.Decrypt(tbUser.Password); return(View("__Cms/Account/Profile", tbUser)); } return(View("__Cms/Account/Index")); }
public ActionResult DeleteConfirmed(int id) { tbUser tbUser = db.tbUsers.Find(id); //delele old file if (!string.IsNullOrEmpty(tbUser.AvatarUrl)) { string fullPath = Path.Combine(Server.MapPath("~/Areas/Admin/upload/avatar"), tbUser.AvatarUrl); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } db.tbUsers.Remove(tbUser); db.SaveChanges(); return(RedirectToAction("Index")); }
public static tbUser Register(UserDbDataContext context, String username, String fullname, String password, String email, String imageUrl, String deviceId, String deviceToken) { var user = context.tbUsers.SingleOrDefault(x => x.UserName == username || x.Email == email); if (user != null) { throw new Exception("Email hoặc UserName đã tồn tại"); } user = new tbUser() { UserName = username, FullName = fullname, Email = email, ImageUrl = imageUrl, Password = password, LastLogin = new DateTime().ToUniversalTime().Subtract( new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc) ).TotalMilliseconds, Token = StringUtils.encryptPassword(username + new DateTime().ToString()) }; context.tbUsers.InsertOnSubmit(user); tbDevice device = context.tbDevices.SingleOrDefault(x => x.DeviceId.Equals(deviceId)); if (device == null) { context.tbDevices.InsertOnSubmit(new tbDevice() { DeviceId = deviceId, Token = deviceToken, UserName = username }); } else { device.UserName = username; device.Token = deviceToken; } context.SubmitChanges(); return(user); }
/// <summary> /// Hàm kiểm tra dành cho đăng nhập /// <para>Được sử riêng cho trang Login</para> /// </summary> /// <param name="username">Tài khoản</param> /// <param name="password">Mật khẩu</param> /// <param name="remember">Ghi nhớ tài khoản bằng Cookie</param> /// <returns>bool</returns> public static bool CheckLogin(string username, string password, bool remember = false) { if (username == DDefault.SAdminID && password == DDefault.SAdminPW) { //Setup quyền cho Supper Admin SetCookie("DUser", DDefault.SAdminID); ReloadInfoUser(); if (remember) { SetCookie(DDefault.NameCookieRemember, username, 24 * DDefault.DayCookiesLogin); } else { ClearCookie(DDefault.NameCookieRemember); } return(true); } //Check tài khoàn đăng nhập = database thông thường else { DBAdmin db = new DBAdmin(); password = DHash.Encrypt(password); tbUser tbUser = db.tbUsers.Where(p => p.Username == username && p.Password == password).FirstOrDefault(); if (tbUser == null) { return(false); } SetCookie("DUser", tbUser.Username); ReloadInfoUser(); if (remember) { SetCookie(DDefault.NameCookieRemember, username); } else { ClearCookie(DDefault.NameCookieRemember); } return(true); } }
private String GetWhereSql() { StringBuilder sb = new StringBuilder(); sb.Append(" 1=1 "); tbUser user = (tbUser)Session[Constant.User]; if (user.usertype == 2) { //教师(管理员的公告) sb.Append(" and (usertype=1 or usertype=2 )"); } if (user.usertype == 3) { //学生(管理员和教师的公告) sb.Append(" and (usertype=1 or userid in (select distinct userid from tbUser,tbGrant where tbUser.classid=tbGrant.classid and tbUser.id=" + user.id + "))"); } return(sb.ToString()); }