public static string schsave(string dotype, string schid, string username, string usertid, string password) { string ret = ""; //Com.DataPack.DataRsp<Com.DataPack.UserInfo> rsp = Com.Public.UserFuncSoure(Com.SoureSession.jsid, Com.SoureSession.jstoken); //if (rsp.code == "ERROR_TOKEN") //{ // ret = "expire"; //} if (Com.SoureSession.Soureuserid == null) { ret = "expire"; } else { try { //学校名不能为空, if (string.IsNullOrEmpty(username)) { ret += "名称不能为空!"; } //学校名不能为空, if (password == "123456") { ret += "修改的密码不能为初始密码!"; } if (ret == "") { if (dotype == "UpdatePw") { if (Com.SoureSession.Soureuserpw != password) { SchSystem.BLL.SchUserInfo schbll = new SchSystem.BLL.SchUserInfo(); bool result = schbll.UpdatePw(int.Parse(usertid), Com.Public.StrToMD5(password)); Com.SoureSession.Soureuserpw = password; if (result) { ret = "success"; } else { ret = "error"; } } else { ret = "与原来密码一样"; } } } } catch (Exception ex) { ret = ex.Message; } } return(ret); }
public static string schsave(string dotype, string schid, string username, string usertid, string password) { string ret = ""; try { //学校名不能为空, if (string.IsNullOrEmpty(username)) { ret += "名称不能为空!"; } //学校名不能为空, if (password == "123456") { ret += "修改的密码不能为初始密码!"; } if (ret == "") { if (dotype == "UpdatePw") { if (Com.Session.userpw != password) { SchSystem.BLL.SchUserInfo schbll = new SchSystem.BLL.SchUserInfo(); bool result = schbll.UpdatePw(int.Parse(usertid), Com.Public.StrToMD5(password)); Com.Session.userpw = password; if (result) { ret = "success"; } else { ret = "error"; } } else { ret = "与原来密码一样"; } } } } catch (Exception ex) { ret = ex.Message; } return(ret); }
public static string usersave(string dotype, string schid, string systype, string userid, string usercode, string usertname, string usertel, string userpst, string usertitle, string usermobile, string username, string userpw, string usersex, string userstat, string usersub, string userdpts, string userroles) { //解密 RSA RSACryptoService rsa = new RSACryptoService(PublicProperty.PrivateKey, PublicProperty.PublicKey); if (userpw != "") { userpw = Com.Public.SqlEncStr(rsa.Decrypt(userpw)); } string ret = ""; if (Com.Session.userid == null) { ret = "expire"; } else { try { if (string.IsNullOrEmpty(schid) || schid == "0") { ret += "非法的学校!"; } SchSystem.BLL.SchUserInfo userbll = new SchSystem.BLL.SchUserInfo(); SchSystem.Model.SchUserInfo usermodel = new SchSystem.Model.SchUserInfo(); if (!Com.Public.isVa(schid, "")) { ret += "无跨界权限;"; } //判断编号及账号是否有重复,生成密码加密 if (dotype == "e") { //if (userbll.ExistsUserCode(int.Parse(userid), usercode, int.Parse(schid))) //{ // ret += "用户编号重复!"; //} if (username != "") { if (userbll.ExistsUserName(int.Parse(userid), username)) { ret += "账号重复!"; } else if (!userbll.ExistsUserName(0, username)) { userbll.UpdateUserName(username, int.Parse(userid)); } } } if (dotype == "a") { //if (userbll.ExistsUserCode(0, usercode, int.Parse(schid))) //{ // ret += "用户编号重复!"; //} if (username != "") { /*if (userbll.ExistsUserName(0, username, int.Parse(schid))) * { * ret += "账号重复!"; * }*/ StringBuilder sbExists = new StringBuilder(); string utname = ""; if (userbll.ExistsUserName(0, username)) { SchSystem.BLL.SchUserDeptV bllusdpt = new SchSystem.BLL.SchUserDeptV(); DataTable dt = bllusdpt.GetList("DepartName,UserTname", "UserName='******'").Tables[0]; DataRow[] dr = dt.Select(); foreach (DataRow item in dr) { sbExists.Append(item["DepartName"].ToString() + "、"); utname = item["UserTname"].ToString(); } //ret += "账号重复!"; ret += sbExists.ToString().Substring(0, sbExists.ToString().Length - 1); ret += "," + utname; } } } if (ret == "") { usermodel.LastRecTime = DateTime.Now; usermodel.LastRecUser = Com.Session.userid; usermodel.Mobile = usermobile; usermodel.Postion = userpst; usermodel.Sex = int.Parse(usersex); if (!string.IsNullOrEmpty(userstat)) { usermodel.AccStat = int.Parse(userstat); } else { usermodel.AccStat = 2; } usermodel.SubCode = usersub; usermodel.SysType = int.Parse(systype); usermodel.Telno = usertel; usermodel.Title = usertitle; usermodel.UserNo = usercode; usermodel.UserTname = usertname; if (dotype == "e") { if (!string.IsNullOrEmpty(userpw) && !string.IsNullOrEmpty(username)) { userpw = Com.Public.StrToMD5(userpw); if (userpw == Com.Public.StrToMD5("123456"))//如果重置密码时保存 { userbll.UpdatePw(int.Parse(userid), userpw); } } usermodel.UserId = int.Parse(userid); userbll.UpdateUser(usermodel); } if (dotype == "a") { //必须有账号和密码 if (!string.IsNullOrEmpty(userpw) && !string.IsNullOrEmpty(username)) { usermodel.PassWord = Com.Public.StrToMD5("123456"); //SchManagerInfoSystem.Common.DESEncrypt.Encrypt(userpw) ;添加时均为123456密码 } usermodel.RecTime = DateTime.Now; usermodel.RecUser = Com.Session.userid; usermodel.SchId = int.Parse(schid); usermodel.UserName = username; userid = userbll.Add(usermodel).ToString(); } //添加或更新关联部门 SchSystem.BLL.SchUserDept userdeptbll = new SchSystem.BLL.SchUserDept(); if (userdpts == null) { userdpts = "0"; } userdeptbll.DoUserDept(userid, Com.Session.userid, schid, userdpts); //添加或更新关联角色 SchSystem.BLL.SchUserRole userrolebll = new SchSystem.BLL.SchUserRole(); if (userroles == null) { userroles = "0"; } userrolebll.DoUserRole(userid, Com.Session.userid, schid, userroles); ret = "success"; } } catch (Exception ex) { ret = ex.Message; } } return(ret); }