Exemplo n.º 1
0
        /// <summary>
        /// 保存资料
        /// </summary>
        protected void SaveInfo()
        {
            SysUser su = SysUserAction.LocalUser;

            DataEntities ent  = new DataEntities();
            int          id   = WS.RequestInt("id");
            SysUser      user = new SysUser();

            if (id > 0)
            {
                user = (from l in ent.SysUser where l.ID == id select l).FirstOrDefault();
            }
            else if (txt_Password.Text.Length == 0)
            {
                Js.AlertAndGoback("新增用户时,密码不能为空");
            }

            user.UserName = txt_UserName.Text;
            if (txt_Password.Text.Length > 0)
            {
                user.UserPass = Voodoo.Security.Encrypt.Md5(txt_Password.Text);
            }

            user.Email       = txt_Email.Text;
            user.TelNumber   = txt_TelNumber.Text;
            user.Department  = su.Department;
            user.UserGroup   = su.UserGroup;
            user.ChineseName = txt_ChineseName.Text;
            user.Enabled     = chk_Enable.Checked;

            if (id <= 0)
            {
                user.LastLoginTime = DateTime.Now;
                user.LastLoginIP   = WS.GetIP();
                Result r = SysUserAction.UserAdd(user);

                if (r.Success)
                {
                    Js.AlertAndChangUrl(r.Text, "List.aspx");
                }
                else
                {
                    Js.AlertAndGoback(r.Text);
                }
            }
            else
            {
                ent.SaveChanges();
                Js.AlertAndChangUrl("修改成功!", "List.aspx");
            }
            ent.Dispose();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 保存资料
        /// </summary>
        protected void SaveInfo()
        {
            SysUser user = new SysUser();

            if (WS.RequestInt("id") > 0)
            {
                user = SysUserView.GetModelByID(WS.RequestInt("id").ToString());
            }
            else if (txt_Password.Text.Length == 0)
            {
                Js.AlertAndGoback("新增用户时,密码不能为空");
            }

            user.UserName = txt_UserName.Text;
            if (txt_Password.Text.Length > 0)
            {
                user.UserPass = Voodoo.Security.Encrypt.Md5(txt_Password.Text);
            }

            user.SafeQuestion = ddl_Question.SelectedValue;
            user.SafeAnswer   = txt_Answer.Text;
            user.Email        = txt_Email.Text;
            user.TelNumber    = txt_TelNumber.Text;
            user.Department   = ddl_Department.SelectedValue.ToInt32();
            user.UserGroup    = ddl_Group.SelectedValue.ToInt32();
            user.ChineseName  = txt_ChineseName.Text;
            user.Enabled      = chk_Enable.Checked;

            if (WS.RequestInt("id") > 0)
            {
                //修改
                SysUserView.Update(user);
                Js.AlertAndChangUrl("修改成功!", "SysUserList.aspx");
            }
            else
            {
                user.LastLoginTime = DateTime.Now;
                user.LastLoginIP   = WS.GetIP();
                Result r = SysUserAction.UserAdd(user);

                if (r.Success)
                {
                    Js.AlertAndChangUrl(r.Text, "SysUserList.aspx");
                }
                else
                {
                    Js.AlertAndGoback(r.Text);
                }
            }
        }