/// <summary> /// 修改密码 /// </summary> /// <param name="logid"></param> /// <param name="oldpwd"></param> /// <param name="newpwd"></param> /// <param name="msg"></param> /// <returns></returns> public string ChangePwd(string logid, string oldpwd, string newpwd, ref string msg) { int iret = -1; string sql = "select pwd from secuser where logid={0}"; IDataParameter[] p = new NGDataParameter[1]; p[0] = new NGDataParameter("logid", logid); string pwd = DbHelper.GetString(sql, p); //旧密码输入不正确 if (oldpwd != NGEncode.DecodePassword(pwd, 128)) { msg = "旧密码输入不正确"; return("-1"); } string endcodepwd = NGEncode.EncodePassword(newpwd, 128); sql = "update secuser set pwd='" + endcodepwd + "',chgpwd_date='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where logid='" + logid + "'"; iret = DbHelper.ExecuteNonQuery(sql); return("1"); }
/// <summary> /// 新增用户 /// </summary> /// <param name="logid">操作员id</param> /// <param name="username">操作员名字</param> /// <param name="pwd">密码</param> /// <returns></returns> public bool AddUser(string logid, string username, string pwd, long maxid) { string count = DbHelper.GetString("select count(*) from secuser where logid='" + logid + "'"); if (count.ToString() != "0") { throw new Exception("用户[" + logid + "]已存在!"); } string endcodepwd = NGEncode.EncodePassword(pwd, 128); string sql = "insert into secuser (logid,u_name,pwd,lg_sign,creadate) values ({0},{1},{2},{3},{4})"; IDataParameter[] p = new NGDataParameter[5]; p[0] = new NGDataParameter("logid", DbType.AnsiString); p[0].Value = logid; p[1] = new NGDataParameter("username", DbType.AnsiString); p[1].Value = username; p[2] = new NGDataParameter("pwd", DbType.AnsiString); p[2].Value = endcodepwd; p[3] = new NGDataParameter("lg_sign", DbType.AnsiString); p[3].Value = "1"; p[4] = new NGDataParameter("creadate", DbType.Date); p[4].Value = DateTime.Now; int iret = DbHelper.ExecuteNonQuery(sql, p); //处理fg_orgpop //string maxid = DbHelper.GetString("select MAX(id) from fg_orgpop"); //int id; //Int32.TryParse(maxid, out id); sql = "insert into fg_orgpop (id,ug_code,u_soft,ocode) values({0},{1},{2},{3})"; IDataParameter[] param = new NGDataParameter[4]; param[0] = new NGDataParameter("id", DbType.Int64); param[0].Value = maxid; param[1] = new NGDataParameter("ug_code", DbType.AnsiString); param[1].Value = username; param[2] = new NGDataParameter("u_soft", DbType.AnsiString); param[2].Value = "01";//类型,01是用户 param[3] = new NGDataParameter("ocode", DbType.AnsiString); param[3].Value = NG3.AppInfoBase.OCode; iret += DbHelper.ExecuteNonQuery(sql, param); if (iret > 0) { return(true); } else { return(false); } }
/// <summary> /// 重置密码 /// </summary> /// <param name="logid"></param> /// <param name="newpwd"></param> /// <param name="msg"></param> /// <returns></returns> public string ResetPwd(string logid, string newpwd, ref string msg) { int iret = -1; string endcodepwd = NGEncode.EncodePassword(newpwd, 128); string sql = "update secuser set pwd='" + endcodepwd + "',chgpwd_date='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where logid='" + logid + "'"; iret = DbHelper.ExecuteNonQuery(sql); return("1"); }