Example #1
0
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        if (txtUserName.Text.Trim() == "")
        {
            MessageBox.Show(this, "请正确填写信息再提交保存!");
            return;
        }

        WebSite.Model.Mod_User dto = new WebSite.Model.Mod_User();

        if (id != 0)
        {
            dto = BUser.GetModel(id);
        }
        //基本信息
        dto.State = int.Parse(rblState.SelectedValue);
        if (txtPassword.Text.Trim() != "0|0|0|0")
        {
            if (txtPassword.Text.Trim() == txtRePassword.Text.Trim())
            {
                dto.Password = StringHelper.GetMD5(txtPassword.Text.Trim());
            }
            else
            {
                MessageBox.Show(this, "密码输入不一致!");
                return;
            }
        }
        dto.UserName  = txtUserName.Text.Trim();
        dto.RealName  = txtRealName.Text.Trim();
        dto.Sex       = rblSex.SelectedValue;
        dto.BirthDate = txtBirthDate.Value.Trim();
        dto.Mobile    = txtMobile.Text.Trim();
        dto.Email     = txtEmail.Text.Trim();


        if (BUser.Exists(string.Format("UserName='******' AND ID!={1}", dto.UserName, dto.ID)))
        {
            MessageBox.Show(this, "该帐号已存在,请重新输入!");
            return;
        }

        //账户信息

        dto.WebSiteID  = AdminManage.WebSiteID;
        dto.Model      = Model;
        dto.ModifyDate = DateTime.Now;

        if (id != 0)
        {
            BUser.Update(dto);
        }
        else
        {
            BUser.Add(dto);
        }

        MessageBox.ShowRedirect(this, "信息保存成功!", "Column/User/List.aspx?" + StringHelper.DelUrlParameter("ID"));
    }
Example #2
0
    public static void SetLoginLog(int uid, int websiteid)
    {
        WebSite.BLL.Bll_User BUser = new WebSite.BLL.Bll_User();

        WebSite.Model.Mod_User MUser = BUser.GetModel(uid);
        if (MUser != null)
        {
            //操作最近登录
            MUser.LoginIP      = MUser.NewLoginIP;
            MUser.LoginDate    = MUser.NewLoginDate;
            MUser.NewLoginIP   = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            MUser.NewLoginDate = DateTime.Now;
            BUser.Update(MUser);
            //记录用户日志
        }
    }