/// <summary> /// 注册账号 /// </summary> /// <param name="mobile"></param> /// <param name="smscode"></param> /// <param name="password"></param> /// <returns></returns> public string regist(string username, string password, string mobile, string realname, string smscode) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名或密码为空,因此无法提交!", data = null })); } if (!Utils.IsSafeSqlString(username)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您输入的用户名包含不安全的字符,因此无法提交!", data = null })); } if (getJ(username.Trim()) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您所输入的用户名已被使用过, 请输入其他的用户名!", data = null })); } if (getM(mobile.Trim()) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您所输入的手机号码已被使用过, 请输入其他的手机号码!", data = null })); } using (var db = new shhouseEntities()) { var intuser = db.Database.ExecuteSqlCommand(adduser, new SqlParameter[] { new SqlParameter("@parentid", "0"), new SqlParameter("@parentpath", ""), new SqlParameter("@mobile", mobile.Trim()), new SqlParameter("@telfirst", ""), new SqlParameter("@tel", ""), new SqlParameter("@linkman", ""), new SqlParameter("@area", ""), new SqlParameter("@city", 3), new SqlParameter("@storetotal", "0"), new SqlParameter("@housetotal", "5"), new SqlParameter("@agenttotal", "0"), new SqlParameter("@refamount", "7"), new SqlParameter("@userid2", "0"), new SqlParameter("@username", Utils.CheckData(username.Trim())), new SqlParameter("@realname", Utils.CheckData(realname.Trim())), new SqlParameter("@password", Utils.MD5(password.Trim())), new SqlParameter("@addip", Utils.GetRealIP()), new SqlParameter("@roleid", 4), new SqlParameter("@origin", ""), new SqlParameter("@originpath", ""), new SqlParameter("@ismobilelock", "0"), new SqlParameter("@validity_begintime", "1990-1-1"), new SqlParameter("@validity_endtime", "1990-1-1") }); if (intuser.ToString() == "-99") { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名重复,请重新输入!", data = null })); } else if (CharString.IntConvert(intuser) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "注册成功!", data = null })); } } return(""); }
/// <summary> /// 注册账号 http://192.168.1.223/GR_Home/RegistByMobile /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <param name="mobile">手机号码</param> /// <param name="realname">真实姓名</param> /// <param name="smscode">验证码</param> /// <returns></returns> public string RegistByMobile(string password, string mobile, string smscode) { if (string.IsNullOrEmpty(password)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名或密码为空,提交失败!", data = null })); } if (!Utils.IsSafeSqlString(mobile)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您输入的手机号码包含不安全的字符,因此无法提交!", data = null })); } if (User_Common.IsHaveMobile(mobile.Trim()) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您所输入的手机号码已被使用过, 请输入其他的手机号码!", data = null })); } using (var db = new shhouseEntities()) { var uservalidityrecord = db.user_validityrecord.SqlQuery(" select top 1 * from user_validityrecord where Mobile = " + mobile + " and codetype = 1 and checkcode = '" + smscode + "'" + " and state = 0 and validity > getdate() order by validity desc ").FirstOrDefault(); if (uservalidityrecord == null) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "验证码错误或已经失效请重新获取!", data = null })); } uservalidityrecord.state = "1"; db.SaveChanges(); var intuser = db.Database.ExecuteSqlCommand(User_Common.GR_adduserbymobile_sql, new SqlParameter[] { new SqlParameter("@parentid", "0"), new SqlParameter("@parentpath", ""), new SqlParameter("@mobile", mobile.Trim()), new SqlParameter("@telfirst", ""), new SqlParameter("@tel", ""), new SqlParameter("@linkman", ""), new SqlParameter("@area", ""), new SqlParameter("@city", 3), new SqlParameter("@storetotal", "0"), new SqlParameter("@housetotal", "5"), new SqlParameter("@agenttotal", "0"), new SqlParameter("@refamount", "7"), new SqlParameter("@userid2", "0"), //new SqlParameter("@username", Utils.CheckData(username.Trim())), //new SqlParameter("@realname", Utils.CheckData(realname.Trim())), new SqlParameter("@password", Utils.MD5(password.Trim())), new SqlParameter("@addip", Utils.GetRealIP()), new SqlParameter("@roleid", 5), //为五的时候为个人会员 new SqlParameter("@origin", ""), new SqlParameter("@originpath", ""), new SqlParameter("@ismobilelock", "0"), new SqlParameter("@validity_begintime", "1990-1-1"), new SqlParameter("@validity_endtime", "1990-1-1"), new SqlParameter("@deptname", ""), new SqlParameter("@company", ""), new SqlParameter("@address", "") }); if (intuser.ToString() == "-99") { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "手机号码重复,请重新输入!", data = null })); } else if (CharString.IntConvert(intuser) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 1, msg = "注册成功!", data = null })); } else { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "注册失败,网络异常!", data = null })); } } return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "网络异常", data = null })); }