Exemple #1
0
    private void ResetPwd()
    {
        string userid = Request["userid"]; userid = userid.Trim();

        userinfo item = null;

        if (userid.Length > 0)
        {
            item = UserBll.Get(Convert.ToInt32(userid));
        }
        if (item != null)
        {
            item.User_Pwd = Encrypt_MD5.Encrypt("123456");

            LogType = SysLogType.修改.ToString();
        }

        item = UserBll.Save(item);

        LogDesc = string.Format("用户管理 {0}", string.Format("重置用户 {0} 密码.", item.User_ID));
        WriteSystemLog();

        DataContractJsonSerializer json = new DataContractJsonSerializer(item.GetType());

        json.WriteObject(Response.OutputStream, item);
        Response.End();
    }
    private void ChangePwd()
    {
        string   oldPwd = Request["oldPwd"]; string newPwd = Request["newPwd"]; string newPwd1 = Request["newPwd1"];
        userinfo objU = (userinfo)SysUser.Clone();

        if (Encrypt_MD5.Encrypt(oldPwd) == SysUser.User_Pwd)
        {
            objU.User_Pwd = Encrypt_MD5.Encrypt(newPwd);
            (new userinfo_Bll()).Modify(objU);
            SysUser = objU;
        }
        else
        {
            objU.User_No = "";
        }

        DataContractJsonSerializer json = new DataContractJsonSerializer(objU.GetType());

        json.WriteObject(Response.OutputStream, objU);
        Response.End();
    }
    private void ChangeConfiguration(string uid, string pwd, string url)
    {
        //读取程序集的配置文件
        Configuration config = WebConfigurationManager.OpenWebConfiguration("~/web.config");
        //获取appSettings节点
        AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");

        //删除name,然后添加新值
        appSettings.Settings.Remove("uid");
        appSettings.Settings.Add("uid", uid);

        appSettings.Settings.Remove("pwd");
        appSettings.Settings.Add("pwd", pwd);

        appSettings.Settings.Remove("url");
        appSettings.Settings.Add("url", url);

        appSettings.Settings.Remove("pwd_md5");
        appSettings.Settings.Add("pwd_md5", Encrypt_MD5.MD5ForPHP(pwd + uid));

        //保存配置文件
        config.Save();
    }
    public List <userinfo> GetUserList(string strUserName, string strPwd, ref string strErrMsg)
    {
        userinfo_Bll    Bms   = new userinfo_Bll();
        List <userinfo> listw = Bms.GetByFilter(new List <Filter> {
            new Filter {
                Name = "User_No", Op = FilterOp.Equals, Value = strUserName
            }, new Filter {
                Name = "User_RoleID", Op = FilterOp.Equals, Value = 0
            }
        }).ToList();

        if (listw == null || (listw != null && listw.Count == 0))
        {
            strErrMsg = "1";
            return(null);
        }
        List <userinfo> listw1 = listw.Where(w => w.User_No == strUserName && w.User_Pwd == Encrypt_MD5.Encrypt(strPwd)).ToList();

        if (listw1 == null || (listw1 != null && listw1.Count == 0))
        {
            strErrMsg = "2";
            return(null);
        }
        strErrMsg = "";
        return(listw1);
    }
Exemple #5
0
    private void SaveUserItem()
    {
        string userid         = Request["userid"]; userid = userid.Trim();
        string username       = Request["username"]; username = username.Trim();
        string userno         = Request["userno"]; userno = userno.Trim();
        string userphone      = Request["userphone"]; userphone = userphone.Trim();
        string userunit       = Request["userunit"]; userunit = userunit.Trim();
        string userdepartment = Request["userdepartment"]; userdepartment = userdepartment.Trim();
        string usergrade      = Request["usergrade"]; usergrade = usergrade.Trim();
        string userjsbj       = Request["userjsbj"]; userjsbj = userjsbj.Trim();

        userinfo item    = null;
        userinfo oldItem = null;
        DateTime dtNow   = DateTime.Now;

        if (userid.Length > 0)
        {
            item = UserBll.Get(Convert.ToInt32(userid));
        }
        if (item != null)
        {
            oldItem = UserBll.Clone(item);

            #region 修改
            item.User_No         = userno;
            item.User_Name       = username;
            item.User_Phone      = userphone;
            item.User_Uint       = userunit;
            item.User_Department = userdepartment;
            item.User_Role       = usergrade;
            item.User_Ext1       = userjsbj;
            #endregion

            LogType = SysLogType.修改.ToString();
        }
        else
        {
            #region 新增
            item = new userinfo
            {
                User_No         = userno,
                User_Name       = username,
                User_Phone      = userphone,
                User_Uint       = userunit,
                User_Department = userdepartment,
                User_Role       = usergrade,
                User_Pwd        = Encrypt_MD5.Encrypt("123456"),
                User_RoleID     = 1,
                User_Status     = "",
                User_Ext1       = userjsbj,
                User_CreateTime = dtNow
            };
            #endregion

            LogType = SysLogType.新增.ToString();
        }
        item = UserBll.Save(item);

        LogDesc = string.Format("用户管理 {0}", CompareEntityProperties(oldItem, item, true));
        WriteSystemLog();

        DataContractJsonSerializer json = new DataContractJsonSerializer(item.GetType());
        json.WriteObject(Response.OutputStream, item);
        Response.End();
    }