public ActionResult initAdminUser(string username, string adminpassword) { using (var manage = new Data.CMSManage()) { var userinfo = new Entity.UserInfo(); userinfo.UserName = username; var roleinfo = manage.getRoleByReadPower("admin", 0); if (roleinfo != null) { userinfo.RoleId = roleinfo.RoleId; } else { userinfo.RoleId = 1; } userinfo.InDate = DateTime.Now; userinfo.IP = Fetch.getClientIP(); userinfo.VerifyMember = 1; userinfo.ComeFrom = "系统安装"; userinfo.LastLandDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); userinfo.LockUser = 0; manage.updateUser(userinfo); if (userinfo.UserId > 0)//更新密码 { manage.updatePassword(userinfo.UserId, Entity.passwordType.manage, adminpassword); manage.updatePassword(userinfo.UserId, Entity.passwordType.user, adminpassword); } } System.IO.File.WriteAllText(Fetch.getMapPath("/install/lock.ini"), "installdate:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), System.Text.Encoding.UTF8); return(this.getResult(Entity.Error.请求成功, "请求成功")); }
//新增用户 public bool InsertUser(string strName, string strPass, string strEmail, string strPhone, string strTel, string strAddress, string strIP) { userInfo = new Entity.UserInfo(strName,strPass,strEmail,strPhone,strTel,strAddress,strIP); if (sqlHelper.ExcuteCommandInt("insert into [User](Name,Pass,Email,Phone,Tel,Address,IP) values ('" + strName + "','" + strPass + "','" + strEmail + "','" + strPhone + "','" + strTel + "','" + strAddress + "','" + strIP + "')") > 0) return true; else return false; }
/// <summary> /// 更新最后登录时间 /// </summary> /// <param name="userinfo"></param> public void updateLastLandDate(Entity.UserInfo userinfo) { if (userinfo != null) { this.dbContext.Entry(userinfo).State = System.Data.Entity.EntityState.Modified; //最后登录时间 userinfo.LastLandDate = Config.SiteConfig.getLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); this.dbContext.SaveChanges(); } }
public static bool uRegister(Entity.UserInfo userinfo) { bool isNo = false; if (DAL.UserInfo_DAL.uRegister(userinfo) > 0) { isNo = true; } return(isNo); }
public static bool insertUserInfo(Entity.UserInfo UserInfo) { if (DAL.UserInfo_DAL.insertUserInfo(UserInfo) > 0) { return(true); } else { return(false); } }
//新增用户 public bool InsertUser(string strName, string strPass, string strEmail, string strPhone, string strTel, string strAddress, string strIP) { userInfo = new Entity.UserInfo(strName, strPass, strEmail, strPhone, strTel, strAddress, strIP); if (sqlHelper.ExcuteCommandInt("insert into [User](Name,Pass,Email,Phone,Tel,Address,IP) values ('" + strName + "','" + strPass + "','" + strEmail + "','" + strPhone + "','" + strTel + "','" + strAddress + "','" + strIP + "')") > 0) { return(true); } else { return(false); } }
public static string GetCp(Entity.UserInfo cp, int id) { return($@"匹配结果:您的cp资料如下 姓名:{cp.Name} QQ号:{cp.QQ} 微信号:{cp.WX} 自我介绍:{cp.Introduce} 你们的共同编号:{id.ToString("000")} 进群后请把备注改为共同编号 如有任何问题请联系负责人微信:selena1206"); }
public JsonResult check(string username, string password) { using (Data.CMSManage manage = new Data.CMSManage()) { var accounttype = string.Empty; if (Common.Utils.isMobile(username)) { accounttype = "mobile"; } else if (Common.Utils.isEmail(username)) { accounttype = "email"; } Entity.UserInfo userInfo = null; if (!string.IsNullOrEmpty(accounttype)) { var userBindInfo = manage.getUserBindInfo(accounttype, username); if (userBindInfo != null) { if (manage.checkUserPassword(userBindInfo.UserId, password, Entity.passwordType.manage)) { userInfo = manage.getUserInfo(userBindInfo.UserId); } } } else { userInfo = manage.checkLogin(username.ToLower(), password, Entity.passwordType.manage); } if (userInfo == null) { manage.Error = Entity.Error.错误; manage.Message = "验证失败!"; } else { if (userInfo.Deadline == null || (userInfo.Deadline != null && userInfo.Deadline.Value > Config.SiteConfig.getLocalTime())) { //设置管理员在线 Config.UserConfig.setAdminOnline(userInfo); } else { manage.Error = Entity.Error.错误; manage.Message = "管理员角色已过期!"; } } return(getResult(manage.Error, manage.Message)); } }
protected void btnSubmit_Click(object sender, EventArgs e) { this.lblHint.Text = ""; string UserName = this.txtUserName.Text; string UserPwd = this.txtUserPwd.Text; string UserSex = this.RadioButtonList1.SelectedValue; string Birthday = this.txtBirthday.Text; string Email = this.txtEmail.Text; if (UserName == "" || UserPwd == "" || UserSex == "" || Birthday == "" || Email == "") { this.lblHint.Text = "请将信息填写完整!"; } else if (UserPwd.Length < 6 || UserPwd.Length > 20) { this.lblHint.Text = "密码长度不得小于6位数或大于20位数!"; } else if (UserPwd != this.txtUserPwd1.Text) { this.lblHint.Text = "第二次输入的密码与第一次不相同!"; } else if (Regex.IsMatch(Birthday, "^[0-9]{4}-[0-9]{0,1}[1-9]{1}-[0-9]{0,1}[1-9]{1}$") == false) { this.lblHint.Text = "出生日期格式不正确!"; } else if (Regex.IsMatch(Email, "^[a-zA-Z0-9]+@[a-zA-Z0-9]+[\'.']com$") == false) { this.lblHint.Text = "电子邮箱格式不正确!"; } else { Entity.UserInfo userinfo = new Entity.UserInfo(); userinfo.UserName = UserName; userinfo.UserPwd = UserPwd; userinfo.UserSex = UserSex; userinfo.Birthday = Birthday; userinfo.Email = Email; if (BLL.UserInfo_BLL.uRegister(userinfo)) { Response.Write("<script>alert('注册成功!');window.location.href='Login.aspx';</script>"); } else { Response.Write("<script>alert('注册失败!')</script>"); } } }
public ActionResult updateUser(Entity.UserInfo userinfo) { using (var manage = new bitcms.Data.CMSManage()) { userinfo.UserId = this.userOnlineInfo.UserId; if (string.IsNullOrEmpty(userinfo.UserName)) { userinfo.UserName = this.userOnlineInfo.UserName; } manage.updateBasicUser(userinfo); Config.UserConfig.setUserOnline(userinfo); return(this.getResult(manage.Error, manage.Message)); } }
private void btnLogin_Click(object sender, EventArgs e) { Entity.UserInfo user = new Entity.UserInfo(); user.UserName = txtUserName.Text.Trim(); user.Pwd = txtPwd.Text.Trim(); BLL.UserManage um = new BLL.UserManage(); bool result = um.JudgeUser(user); if (result == true) { MessageBox.Show("登录成功!"); } else { MessageBox.Show("登录失败!"); } }
protected void Button1_Click(object sender, EventArgs e) { string UserName = this.TextBox1.Text; string UserPwd = this.TextBox2.Text; if (UserName == "" || UserPwd == "") { this.Label4.Text = "请将信息填写完整!"; } else if (UserPwd.Length < 6 || UserPwd.Length > 20) { this.Label4.Text = "密码长度不得小于6位数或大于20位数!"; } else { Entity.UserInfo UserInfo = new Entity.UserInfo(); UserInfo.UserName = UserName; UserInfo.UserPwd = UserPwd; DataTable dt = BLL.UserInfo_BLL.uLogin(UserInfo); if (dt.Rows.Count > 0) { if (this.CheckBox1.Checked == true) { HttpCookie uinfo = new HttpCookie("info"); uinfo.Values["uname"] = UserName; uinfo.Values["upwd"] = UserPwd; uinfo.Expires = DateTime.Now.AddDays(7); Response.Cookies.Add(uinfo); } Session["UserID"] = dt.Rows[0][0].ToString(); if (dt.Rows[0][1].ToString() == "1") { Session["permission"] = "true"; } Response.Redirect("Main.aspx"); } else { this.Label4.Text = "用户名或密码有误!"; } } }
protected void btnLogin_Click(object sender, EventArgs e) { this.lblHint.Text = ""; string UserName = this.txtUserName.Text; string UserPwd = this.txtUserPwd.Text; if (UserName == "" || UserPwd == "") { this.lblHint.Text = "请将信息填写完整"; } else { Entity.UserInfo userinfo = new Entity.UserInfo(); userinfo.UserName = UserName; userinfo.UserPwd = UserPwd; DataTable dt = BLL.UserInfo_BLL.uLogin(userinfo); if (dt.Rows.Count > 0) { if (this.CheckBox1.Checked == true) { HttpCookie uinfo = new HttpCookie("info"); uinfo.Values["uname"] = UserName; uinfo.Values["upwd"] = UserPwd; uinfo.Expires = DateTime.Now.AddDays(7); Response.Cookies.Add(uinfo); } Application.Lock(); Application["auname"] = UserName; if (UserName == "admin") { Session["admin"] = "admin"; Response.Redirect("admin.aspx"); } Session["UserID"] = dt.Rows[0][0].ToString(); this.lblHint.Text = "登陆成功!"; Response.Redirect("Main.aspx"); } else { this.lblHint.Text = "用户名或密码有误!登录失败!"; } } }
public JsonResult update(Entity.UserInfo info, string password) { using (var manage = new Data.CMSManage()) { string shows = this.getFormString("shows"); if (string.IsNullOrEmpty(shows)) { info.Show = 0; } else { var show = 0; if (shows.IndexOf(',') > 0) { var _shows = shows.Split(','); foreach (var _s in _shows) { show += Utils.strToInt(_s); } } else { show = Utils.strToInt(shows); } info.Show = show; } //更新操作 manage.updateUser(info); if (!string.IsNullOrEmpty(password)) { manage.updatePassword(info.UserId, 0, password); } if (info.RoleId > 0) { var roleInfo = manage.getRoleInfo(info.RoleId); if (roleInfo.RoleType == "admin")//管理员 { manage.updateAdminPassword(info.UserId); } } return(getResult(manage.Error, manage.Message)); } }
/// <summary> /// 自动登录 /// </summary> public static void zidonfLogin() { if (HttpContext.Current.Request.Cookies["info"] == null) { return; } string uname = HttpContext.Current.Request.Cookies["info"]["uname"]; string upwd = HttpContext.Current.Request.Cookies["info"]["upwd"]; Entity.UserInfo UserInfo = new Entity.UserInfo(); UserInfo.UserName = uname; UserInfo.UserPwd = upwd; DataTable dt = uLogin(UserInfo); if (dt.Rows.Count > 0) { HttpContext.Current.Session["UserID"] = dt.Rows[0][0].ToString(); } }
protected void Button1_Click(object sender, EventArgs e) { string UserName = this.TextBox1.Text; string UserPwd = this.TextBox2.Text; string Email = this.TextBox3.Text;; if (UserName == "" || UserPwd == "" || Email == "") { this.Label4.Text = "请将信息填写完整!"; } else if (UserPwd.Length < 6 || UserPwd.Length > 20) { this.Label4.Text = "密码长度不得小于6位数或大于20位数!"; } else if (UserPwd != this.TextBox5.Text) { this.Label4.Text = "第二次输入的密码与第一次不相同!"; } else if (Regex.IsMatch(Email, "^[a-zA-Z0-9]+@[a-zA-Z0-9]+[\'.']com$") == false) { this.Label4.Text = "电子邮箱格式不正确!"; } else { Entity.UserInfo UserInfo = new Entity.UserInfo(); UserInfo.UserName = UserName; UserInfo.UserPwd = UserPwd; UserInfo.Email = Email; if (BLL.UserInfo_BLL.insertUserInfo(UserInfo)) { Response.Write("<script>alert('注册成功!');window.location.href='Login.aspx';</script>"); } else { Response.Write("<script>alert('注册失败!')</script>"); } } }
//判断用户登录状态 public myLoginState CheckUser(string strUser, string strPass) { string strSql = "select UID,Name,Pass,Email,Phone,Tel,Address,IP,VIP.VName,VImg from [User],VIP where Name='" + strUser + "' and Pass='******' and VIP.VID=[User].VID"; //string strSql = "select Name,Pass from [User] where Name='" + strUser + "' and Pass='******'"; if (sqlHelper.GetdataSet(strSql).Tables[0].Rows.Count > 0) { //int intUID, string strName, string strPass, string strEmail, string strPhone, string strTel, string strAddress, string strIP DataRowView drv = sqlHelper.GetTableValue(strSql); userInfo = new Entity.UserInfo(int.Parse(drv["UID"].ToString()), drv["Name"].ToString(), drv["Pass"].ToString(), drv["Email"].ToString(), drv["Phone"].ToString(), drv["Tel"].ToString(), drv["Address"].ToString(), drv["IP"].ToString()); System.Web.HttpCookie cookie1 = new System.Web.HttpCookie("UserInfo"); cookie1.Values.Add("UID", drv["UID"].ToString()); cookie1.Values.Add("name", drv["Name"].ToString()); cookie1.Values.Add("pass", drv["Pass"].ToString()); cookie1.Values.Add("vipImg", drv["VImg"].ToString()); cookie1.Expires.AddHours(12); System.Web.HttpContext.Current.Response.AppendCookie(cookie1); return(myLoginState.LOGINSUSCCESS); } else { return(myLoginState.LOGINFAILED); } /*或者*/ //SqlDataReader dr = sqlHelper.GetDataReader(strSql); //if (dr.HasRows) //{ // userInfo = new Entity.UserInfo( dr[1].ToString(), dr[2].ToString(), dr[3].ToString(), dr[4].ToString(), dr[5].ToString(), dr[6].ToString(),dr[7].ToString()); // return myLoginState.LOGINSUSCCESS; //} //else // return myLoginState.LOGINFAILED; }
//判断用户登录状态 public myLoginState CheckUser(string strUser, string strPass) { string strSql = "select UID,Name,Pass,Email,Phone,Tel,Address,IP,VIP.VName,VImg from [User],VIP where Name='" + strUser + "' and Pass='******' and VIP.VID=[User].VID"; //string strSql = "select Name,Pass from [User] where Name='" + strUser + "' and Pass='******'"; if (sqlHelper.GetdataSet(strSql).Tables[0].Rows.Count > 0) { //int intUID, string strName, string strPass, string strEmail, string strPhone, string strTel, string strAddress, string strIP DataRowView drv = sqlHelper.GetTableValue(strSql); userInfo = new Entity.UserInfo(int.Parse(drv["UID"].ToString()), drv["Name"].ToString(), drv["Pass"].ToString(), drv["Email"].ToString(), drv["Phone"].ToString(), drv["Tel"].ToString(), drv["Address"].ToString(), drv["IP"].ToString()); System.Web.HttpCookie cookie1 = new System.Web.HttpCookie("UserInfo"); cookie1.Values.Add("UID",drv["UID"].ToString()); cookie1.Values.Add("name", drv["Name"].ToString()); cookie1.Values.Add("pass", drv["Pass"].ToString()); cookie1.Values.Add("vipImg", drv["VImg"].ToString()); cookie1.Expires.AddHours(12); System.Web.HttpContext.Current.Response.AppendCookie(cookie1); return myLoginState.LOGINSUSCCESS; } else { return myLoginState.LOGINFAILED; } /*或者*/ //SqlDataReader dr = sqlHelper.GetDataReader(strSql); //if (dr.HasRows) //{ // userInfo = new Entity.UserInfo( dr[1].ToString(), dr[2].ToString(), dr[3].ToString(), dr[4].ToString(), dr[5].ToString(), dr[6].ToString(),dr[7].ToString()); // return myLoginState.LOGINSUSCCESS; //} //else // return myLoginState.LOGINFAILED; }
public bool JudgeUser(Entity.UserInfo user) { DAL.UserManage um = new DAL.UserManage(); return(um.JudgeUser(user)); }
public JsonResult register(Entity.UserInfo userinfo, string password, string key = null, string verifykey = null) { if (this.config.EnabledRegisterVerifykey) { if (string.IsNullOrEmpty(key)) { key = "verifycode"; } var code = Config.UserConfig.getVerifyCode(key); if (string.IsNullOrEmpty(verifykey) || code == null || !code.Code.Equals(verifykey.ToLower())) { return(this.getResult(Entity.Error.错误, "验证码错误!")); } } if (userinfo != null && !string.IsNullOrEmpty(userinfo.UserName) && !string.IsNullOrEmpty(password)) { using (var manage = new Data.CMSManage()) { if (manage.checkUserName(userinfo.UserName, -1) > 0) { return(this.getResult(Entity.Error.错误, "账号已存在")); } userinfo.InDate = DateTime.Now; userinfo.IP = Fetch.getClientIP(); userinfo.VerifyMember = 1; //默认会员 if (userinfo.RoleId <= 0) { var roleInfo = manage.getRoleByScore("score", 0); if (roleInfo != null) { userinfo.RoleId = roleInfo.RoleId; } } //提交注册 manage.updateUser(userinfo); if (userinfo.UserId > 0) { //设置密码 manage.updatePassword(userinfo.UserId, Entity.passwordType.user, password); //更改积分 manage.insertScoreLog(userinfo.UserId, "register"); //设置会员在线 Config.UserConfig.setUserOnline(userinfo); } return(this.getResult(Entity.Error.请求成功, "注册成功", new { userid = userinfo.UserId })); } } else { return(this.getResult(Entity.Error.错误, "数据不完整")); } }
public JsonResult registerAccount(string account, string password, string accounttype, Entity.UserInfo userinfo, string verifykey) { var code = Config.UserConfig.getVerifyCode(account); if (code != null && code.Code.Equals(verifykey.ToLower())) { if (!string.IsNullOrEmpty(account) && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(accounttype)) { accounttype = accounttype.ToLower(); if (accounttype == "mobile") { if (!Utils.isMobile(account)) { return(this.getResult(Entity.Error.错误, "手机格式正确")); } } else if (accounttype == "email") { if (!Utils.isEmail(account)) { return(this.getResult(Entity.Error.错误, "email格式不正确")); } } using (var manage = new Data.CMSManage()) { if (manage.checkUserBindCode(accounttype, account) > 0) { return(this.getResult(Entity.Error.错误, "账号已存在")); } if (userinfo == null) { userinfo = new Entity.UserInfo(); } if (string.IsNullOrEmpty(userinfo.UserName)) { if (accounttype == "mobile") { userinfo.UserName = Utils.fuzzyString(account, 3, 4); } else if (accounttype == "email") { var name = Utils.subString(account, account.IndexOf('@')); userinfo.UserName = Utils.fuzzyString(account, 1, name.Length - 1); } else { userinfo.UserName = Utils.fuzzyString(account, 1, account.Length - 1); } } else if (manage.checkUserName(userinfo.UserName, -1) > 0) { return(this.getResult(Entity.Error.错误, "昵称已存在")); } userinfo.InDate = DateTime.Now; userinfo.IP = Fetch.getClientIP(); //默认会员 if (userinfo.RoleId <= 0) { var roleInfo = manage.getRoleByScore("score", 0); if (roleInfo != null) { userinfo.RoleId = roleInfo.RoleId; userinfo.VerifyMember = 1; } } //提交注册 manage.updateUser(userinfo); if (userinfo.UserId > 0) { //设置密码 manage.updatePassword(userinfo.UserId, Entity.passwordType.user, password); //绑定会员 manage.updateUserBind(accounttype, userinfo.UserId, account, userinfo.UserName, 1); //更改积分 manage.insertScoreLog(userinfo.UserId, "register"); //设置会员在线 Config.UserConfig.setUserOnline(userinfo); } return(this.getResult(Entity.Error.请求成功, "注册成功", new { userid = userinfo.UserId })); } } else { return(this.getResult(Entity.Error.错误, "数据不完整")); } } else { return(this.getResult(Entity.Error.错误, "验证码错误")); } }
public static DataTable uLogin(Entity.UserInfo userinfo) { return(DAL.UserInfo_DAL.uLogin(userinfo)); }
//填充学生报告的基本信息 public static Microsoft.Office.Interop.Word.Table BaseInfo(Microsoft.Office.Interop.Word.Table tb1, Entity.UserInfo userinfo, Entity.Join_Student user, string strKaHao) { if (tb1.Rows.Count == 4) { //在指定单元格填值 //第1行 tb1.Cell(1, 2).Range.Text = userinfo.StudentName; tb1.Cell(1, 4).Range.Text = (user.Sex == 1 ? "女" : "男"); //第2行 tb1.Cell(2, 2).Range.Text = user.SchoolName; tb1.Cell(2, 4).Range.Text = (userinfo.KeLei == 1 ? "文史" : "理工"); //第3行 tb1.Cell(3, 2).Range.Text = userinfo.ProvinceName; tb1.Cell(3, 4).Range.Text = user.GKYear.ToString(); //第4行 tb1.Cell(4, 2).Range.Text = strKaHao; tb1.Cell(4, 4).Range.Text = Basic.TypeConverter.StrToDateStr(DateTime.Now.ToString()); } return(tb1); }