//checkbox事件 protected void Button1_Click(object sender, EventArgs e) { string value = ""; try { value = menuHelper.GetSaveMenu(); } catch (Exception ex) { Utility.Alert(this.Page, ex.Message, "UserFunctionSetting.aspx"); return; } UserTableBLL bll = new UserTableBLL(); UserInfo user = bll.GetUserByUserId(userId); user.Synchronize = 1; user.UserFunction = value; user.ModifyDate = DateTime.Now; bool success = bll.UpdateUser(user); if (success) { Session["UserFunction"] = value; Response.Redirect(Request.Url.ToString()); } else { Utility.Alert(this.Page, "修改失败!"); } }
protected void Page_Load(object sender, EventArgs e) { UserTableBLL bll = new UserTableBLL(); if (!Page.IsPostBack) { string dirPath = Server.MapPath("~/Images/Users/"); DataTable name_dt = FileHelper.GetFileName(dirPath); DataTable user_dt = bll.GetUserList(); foreach (DataRow name_dr in name_dt.Rows) { bool hasFile = false; string fileName = name_dr["FileName"].ToString(); foreach (DataRow user_dr in user_dt.Rows) { string userImage = user_dr["UserImage"].ToString(); if (fileName == userImage) { hasFile = true; } } if (!hasFile) { string path = dirPath + fileName; FileHelper.DeleteFile(path); } } } }
//登录按钮 protected void SubmitButtom_Click(object sender, EventArgs e) { string userName = this.UserName.Text.Trim(); string userPassword = this.UserPassword.Text.Trim(); if (userName == "") { Utility.Alert(this, "用户名未填写!"); return; } if (userPassword == "") { Utility.Alert(this, "密码未填写!"); return; } //保留用户名Cookie Response.Cookies["UserCookie"].Value = userName; Response.Cookies["UserCookie"].Expires = DateTime.MaxValue; UserTableBLL bll = new UserTableBLL(); bool success = bll.UserLogin(userName, userPassword); if (success) { Session["TodayDate"] = DateTime.Now.ToString("yyyy-MM-dd"); UserInfo user = bll.GetUserByUserPassword(userName, userPassword); UserHelper.SaveSession(user); Response.Cookies["ThemeCookie"].Value = user.UserTheme; Response.Cookies["ThemeCookie"].Expires = DateTime.MaxValue; string url = Request.QueryString["url"]; if (url == "" || url == null) { url = "Default.aspx"; } Response.Redirect(url); } else { Utility.Alert(this, "登录失败!"); } }
public void Execute(IJobExecutionContext context) { log.Info("开始用户自动服务。"); try { UserTableBLL bll = new UserTableBLL(); DataTable dt = bll.GetUserList(); log.Info("用户数:" + dt.Rows.Count); } catch (Exception ex) { log.Error(ex.Message + Environment.NewLine + ex.StackTrace); JobExecutionException jobException = new JobExecutionException(ex); throw jobException; } }
//切换主题 protected void ImageButton_Command(object sender, CommandEventArgs e) { int userId = 0; string theme = e.CommandArgument.ToString(); Response.Cookies["ThemeCookie"].Value = theme; Response.Cookies["ThemeCookie"].Expires = DateTime.MaxValue; if (Session["UserID"] != null && Session["UserID"].ToString() != "") { userId = Convert.ToInt32(Session["UserID"]); UserTableBLL bll = new UserTableBLL(); UserInfo user = bll.GetUserByUserId(userId); user.UserTheme = theme; user.ModifyDate = DateTime.Now; bll.UpdateUser(user); } Response.Redirect(Request.Url.ToString()); }
public void Init() { bll = new UserTableBLL(); }
public static string GetUserName(string from) { UserTableBLL bll = new UserTableBLL(); UserInfo user = new UserInfo(); string userName = ""; do { userName = from + Utility.GetRandomNumber(10000, 99999); user = bll.GetUserByUserName(userName); } while (user.UserID > 0); return userName; }