Example #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ls_user usr = new ls_user()
            {
                user_status = Convert.ToInt32(this.rblStatus.SelectedValue),
                user_email  = txtEmail.Text,
                user_salt   = Guid.NewGuid().ToString().Substring(0, 6),
                create_ip   = this.lblRegIP.Text,
                create_time = DateTime.Now,
                nick_name   = txtNickName.Text,
                real_name   = txtRealName.Text,
                user_gender = Convert.ToInt32(rblSex.SelectedValue),
                user_mobile = txtMobile.Text,
                user_name   = txtUserName.Text,
                user_avatar = txtAvatar.Text
            };

            if (!string.IsNullOrEmpty(txtBirthday.Text))
            {
                usr.user_birth = Convert.ToDateTime(txtBirthday.Text);
            }
            //为密码加密
            usr.user_password = DESEncrypt.Encrypt(txtPassword.Text, usr.user_salt);
            ls_user_bll userBLL = new ls_user_bll();

            if (userBLL.SaveUser(usr))
            {
                Response.Redirect("user_list.aspx");
            }
            else
            {
                lbError.Text = "保存失败";
            }
        }
Example #2
0
        protected void BindControl()
        {
            ls_user_bll bll = new ls_user_bll();
            ls_user     usr = bll.GetUserById(LSRequest.GetQueryInt("id"));

            if (usr == null)
            {
                Response.Redirect("user_list.aspx");
            }
            else
            {
                this.hidId.Value             = usr.id.ToString();
                this.txtEmail.Text           = usr.user_email;
                this.txtMobile.Text          = usr.user_mobile;
                this.txtUserName.Text        = usr.user_name;
                this.txtNickName.Text        = usr.nick_name;
                this.rblSex.SelectedIndex    = usr.user_gender;
                this.rblStatus.SelectedIndex = usr.user_status;
                this.txtAvatar.Text          = usr.user_avatar;
                if (usr.user_birth.HasValue)
                {
                    this.txtBirthday.Text = usr.user_birth.Value.ToString("yyyy-MM-dd");
                }
                this.txtAvatar.Text = usr.user_avatar;
            }
        }
Example #3
0
        public void UserNameValidate(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string userName = context.Request.Form["param"];
            string name     = context.Request.Form["name"];
            //判断userName是否重复
            ls_user_bll userBll = new ls_user_bll();

            if (userBll.IsUserNameExist(userName))
            {
                context.Response.Write(JSONHelper.SerializeObject(new { status = "n", info = "该用户已经存在" }));
            }
            else
            {
                context.Response.Write(JSONHelper.SerializeObject(new { status = "y", info = "该用户名可用" }));
            }
        }
Example #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text;
            string userPwd  = txtPassword.Text;

            if (Session[LSKeys.SESSION_LOGIN_SUM] == null)
            {
                Session[LSKeys.SESSION_LOGIN_SUM] = 1;
            }
            else
            {
                Session[LSKeys.SESSION_LOGIN_SUM] = Convert.ToInt32(Session[LSKeys.SESSION_LOGIN_SUM]) + 1;
            }
            if (Convert.ToInt32(Session[LSKeys.SESSION_LOGIN_SUM]) > 5)
            {
                msgtip.InnerText = "您登录失败已经超过五次,请关闭浏览器重试";
                return;
            }
            ls_user_bll userBLL = new ls_user_bll();
            ls_user     user    = userBLL.Login(userName, userPwd);

            if (user == null)
            {
                msgtip.InnerText = "用户名密码错误";
            }
            else
            {
                Session[LSKeys.SESSION_USER_INFO] = user;
                Response.Cookies[LSKeys.COOKIE_USER_NAME].Value = userName;
                Response.Cookies[LSKeys.COOKIE_PASSWORD].Value  = user.user_password;
                //登录成功记录登录日志
                if (sysConfig.log_status > 0)
                {
                    new ls_log_bll().SaveLog(new ls_log()
                    {
                        user_id     = user.id,
                        user_name   = user.nick_name,
                        action_type = LSEnums.ActionEnum.Login.ToString(),
                        add_time    = DateTime.Now,
                        user_ip     = LSRequest.GetIP()
                    });
                }
                Response.Redirect("index.aspx");
            }
        }
Example #5
0
        /// <summary>
        /// 判断是否登录
        /// </summary>
        /// <returns></returns>
        public bool IsLogin()
        {
            if (HttpContext.Current.Session[LSKeys.SESSION_USER_INFO] != null)
            {
                return(true);
            }
            string loginName = Utils.GetCookie(LSKeys.COOKIE_USER_NAME);
            string loginPwd  = Utils.GetCookie(LSKeys.COOKIE_PASSWORD);

            if (!string.IsNullOrEmpty(loginName) && !string.IsNullOrEmpty(loginPwd))
            {
                ls_user_bll userBLL = new ls_user_bll();
                ls_user     user    = userBLL.GetCookieUser(loginName, loginPwd);
                if (user != null)
                {
                    HttpContext.Current.Session[LSKeys.SESSION_USER_INFO] = user;
                    return(true);
                }
            }
            return(false);
        }
Example #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ls_user usr = new ls_user()
            {
                id          = Convert.ToInt32(this.hidId.Value),
                user_email  = this.txtEmail.Text,
                nick_name   = this.txtNickName.Text,
                user_status = Convert.ToInt32(this.rblStatus.SelectedValue),
                user_mobile = this.txtMobile.Text,
                user_gender = Convert.ToInt32(this.rblSex.SelectedValue),
                user_avatar = txtAvatar.Text
            };

            if (!string.IsNullOrEmpty(txtBirthday.Text))
            {
                usr.user_birth = Convert.ToDateTime(txtBirthday.Text);
            }
            ls_user_bll bll = new ls_user_bll();

            bll.UpdateUser(usr);
            JscriptMsg("修改成功", "user_list.aspx");
        }
Example #7
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        protected void BindUserList(string pageIndex = null)
        {
            string startTime = txtStartTime.Text;
            string endTime   = txtEndTime.Text;

            this.page = LSRequest.GetQueryInt("page", 1);
            if (!string.IsNullOrEmpty(pageIndex))
            {
                this.page = Convert.ToInt32(pageIndex);
            }
            this.pageSize = GetPageSize(10);
            string          name    = txtKeywords.Text;
            int             role_id = Utils.StrToInt(this.ddlRole.SelectedValue, 0);
            int             totalCount;
            IList <ls_user> users = new ls_user_bll().GetPagedUserList(this.page, this.pageSize, name, startTime, endTime, role_id, out totalCount);

            //为Repeater绑定数据
            rptList.DataSource = users;
            rptList.DataBind();
            string pageUrl = Utils.CombUrlTxt("user_list.aspx", "page={0}", "__id__");

            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, totalCount, pageUrl, 8);
        }
Example #8
0
        /// <summary>
        /// 删除按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            List <int> ids = new List <int>();

            for (int i = 0; i < rptList.Items.Count; i++)
            {
                CheckBox    cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                HiddenField hf = (HiddenField)rptList.Items[i].FindControl("hidId");
                if (cb.Checked)
                {
                    ids.Add(Convert.ToInt32(hf.Value));
                }
            }
            ls_user_bll userBLL = new ls_user_bll();

            if (userBLL.DeleteUsers(ids))
            {
                JscriptMsg("删除成功", Utils.CombUrlTxt("user_list.aspx", "page={0}", this.page.ToString()));
            }
            else
            {
                JscriptMsg("删除失败", "");
            }
        }