public int changeteam(tblteams tm) { using (var db = new BFdbContext()) { var team = db.tblteams.FirstOrDefault(p => p.teamid == tm.teamid); if (team == null) { return(-1); } if (team.Status.Value == 0) { return(-2); } if (db.tblteams.Any(p => p.teamid != tm.teamid && p.match_id == team.match_id && p.Teamname == tm.Teamname)) { return(-3); } string sql = string.Format("update tbl_match_users set teamname='{0}' where teamid='{1}'", tm.Teamname, tm.teamid); db.ExecuteSqlCommand(sql); team.Teamname = tm.Teamname; return(db.Update <tblteams>(team)); } }
/// <summary> /// 更新队伍 /// </summary> /// <param name="ent"></param> /// <returns></returns> public int EditTeam(tblteams ent) { using (var db = new BFdbContext()) { tblteams team = db.tblteams.FirstOrDefault(p => p.teamid == ent.teamid); team.Userid = ent.Userid; team.Company = ent.Company; team.Lineid = ent.Lineid; team.Status = ent.Status; return(db.Update <tblteams>(team)); } }
/// <summary> /// 更新会员 /// </summary> /// <param name="ent"></param> /// <returns></returns> public int EditMember(tblusers ent) { using (var db = new BFdbContext()) { tblusers usr = db.tblusers.FirstOrDefault(p => p.userid == ent.userid); usr.Passwd = ent.Passwd; usr.sexy = ent.sexy; usr.cardtype = ent.cardtype; usr.cardno = ent.cardno; usr.birthday = ent.birthday; usr.Status = ent.Status; return(db.Update <tblusers>(usr)); } }
/// <summary> /// 更新线路 /// </summary> /// <param name="ent"></param> /// <returns></returns> public int EditLine(tblline ent) { using (var db = new BFdbContext()) { tblline line = db.tblline.FirstOrDefault(p => p.Lineid == ent.Lineid); line.Name = ent.Name; line.Content = ent.Content; line.Players = ent.Players; line.Count = ent.Count; line.Conditions = ent.Conditions; line.Status = ent.Status; return(db.Update <tblline>(line)); } }
/// <summary> /// 选择路线 /// </summary> /// <param name="id"></param> /// <param name="lid"></param> /// <returns></returns> public int SelectLine(string id, string lid) { using (var db = new BFdbContext()) { int teamid = int.Parse(id); var team = db.tblteams.FirstOrDefault(p => p.teamid == id); if (team == null) { return(-1); } team.Lineid = lid;//int.Parse(lid); return(db.Update <tblteams>(team)); } }
/// <summary> /// 修改密码 /// </summary> /// <param name="userid"></param> /// <param name="oldpwd"></param> /// <param name="newpwd"></param> /// <returns></returns> public int UpdatePwd(string userid, string oldpwd, string newpwd) { using (var db = new BFdbContext()) { var usr = db.tblusers.FirstOrDefault(p => p.userid == userid && p.Passwd == oldpwd && p.Status == 0); if (usr == null) { return(-1); } else { usr.Passwd = newpwd; return(db.Update <tblusers>(usr)); } } }
/// <summary> /// 重置密码 /// </summary> /// <param name="usrid"></param> /// <param name="pwd"></param> /// <returns></returns> public int ResetPwd(string mobile, string pwd) { using (var db = new BFdbContext()) { var usr = db.tblusers.FirstOrDefault(p => p.Mobile == mobile && p.Status == 0); if (usr == null) { return(-1); } else { usr.Passwd = pwd; return(db.Update <tblusers>(usr)); } } }
/// <summary> /// 更新用户新 /// </summary> /// <param name="ent"></param> /// <returns></returns> public int EditUser(sysuser ent) { using (var db = new BFdbContext()) { if (db.sysuser.Any(u => u.Username == ent.Username && u.Userid != ent.Userid)) { throw new ValidException("Username", "已存在此名称的用户!"); } sysuser usr = db.sysuser.FirstOrDefault(p => p.Userid == ent.Userid); usr.Email = ent.Email; usr.Password = ent.Password; usr.Delflag = ent.Delflag; usr.Username = ent.Username; usr.Modifydate = DateTime.Now; return(db.Update <sysuser>(usr)); } }
/// <summary> /// 更新团队 /// </summary> /// <param name="com"></param> /// <returns></returns> public int UpdateCompany(tblcompany com) { using (var db = new BFdbContext()) { var tcom = db.tblcompany.FirstOrDefault(p => p.userid == com.userid); if (tcom == null) { return(-1); } tcom.Area = com.Area; tcom.Contacts = com.Contacts; tcom.Moblie = com.Moblie; tcom.Name = com.Name; return(db.Update <tblcompany>(tcom)); } }
/// <summary> /// 设置密码 /// </summary> /// <param name="usrid"></param> /// <param name="pwd"></param> /// <returns></returns> public int SubmitPwd(string usrid, string pwd) { using (var db = new BFdbContext()) { var usr = db.tblusers.FirstOrDefault(p => p.userid == usrid && p.Status == 4); if (usr == null) { return(-1); } else { usr.Status = 0; usr.Passwd = pwd; return(db.Update <tblusers>(usr)); } } }
/// <summary> /// 更新赛事 /// </summary> /// <param name="ent"></param> /// <returns></returns> public int EditMatch(tblmatch ent) { using (var db = new BFdbContext()) { tblmatch match = db.tblmatch.FirstOrDefault(p => p.Match_id == ent.Match_id); match.Match_name = ent.Match_name; match.Content = ent.Content; match.Area1 = ent.Area1; match.Area2 = ent.Area2; match.Date1 = ent.Date1; match.Date2 = ent.Date2; match.Date3 = ent.Date3; match.Date4 = ent.Date4; match.Pic1 = ent.Pic1; match.Pic2 = ent.Pic2; match.Status = ent.Status; return(db.Update <tblmatch>(match)); } }
/// <summary> /// 删除用户 /// </summary> /// <param name="id"></param> /// <param name="by"></param> /// <returns></returns> public string DelUser(string id, string by) { try { using (BFdbContext db = new BFdbContext()) { TBUSER user = db.TBUSER.FirstOrDefault(p => p.USERID == id && p.DELFLAG == "0"); user.DELFLAG = "1"; user.UPDATEDATE = DateTime.Now; user.UPDATEID = by; return(db.Update <TBUSER>(user).ToString()); } } catch (Exception ex) { log.Error(ex); throw GetFault(ex); } }
/// <summary> /// 用户登录 /// </summary> /// <param name="name"></param> /// <param name="pwd"></param> /// <returns></returns> public sysuser Login(string name, string pwd) { using (BFdbContext db = new BFdbContext()) { IEnumerable <sysuser> users = db.FindAll <sysuser>(p => p.Logincode == name && p.Password == pwd && p.Delflag == false); if (users.Count() < 1) { return(null); } else { sysuser usr = users.First(); usr.Lastlogindate = DateTime.Now; usr.Logincount = usr.Logincount.GetValueOrDefault(0) + 1; db.Update <sysuser>(usr); return(usr); } } }
public int UpdateUser(tblusers usr) { using (var db = new BFdbContext()) { if (db.tblusers.Any(p => p.cardno == usr.cardno && p.userid != usr.userid)) { return(-2); } int yearold = SetYearOld(usr.birthday.Value); if (yearold > 60 || yearold < 16) { return(-3); } var tusr = db.tblusers.FirstOrDefault(p => p.userid == usr.userid); if (tusr == null) { return(-1); } else { tusr.birthday = usr.birthday; tusr.cardno = usr.cardno; tusr.cardtype = usr.cardtype; tusr.Mobile = usr.Mobile; tusr.Name = usr.Name; tusr.sexy = usr.sexy; tusr.Isupt = "1"; tusr.Ismod = "1"; tusr.Modtime = DateTime.Now; // or match_id='6a61b95b-2d5d-4373-abaf-bf4e4c438800') string sql = string.Format(@"update tbl_match_users set birthday='{0}',age={1},cardno='{2}',cardtype='{3}',sexy={4},mobile='{5}',nickname='{6}' where userid='{7}' and (match_id in (select match_id from tbl_match where status in (0,1)) or match_id='c83aa363-873e-489e-ac07-373489c94320')", tusr.birthday.Value.ToString("yyyy-MM-dd"), SetYearOld(tusr.birthday.Value), tusr.cardno, tusr.cardtype, tusr.sexy, tusr.Mobile, tusr.Name, tusr.userid); db.ExecuteSqlCommand(sql); return(db.Update <tblusers>(tusr)); } } }
/// <summary> /// 忘记密码时,生成验证码 /// </summary> /// <param name="mobile"></param> /// <returns></returns> public int GetGSMS(string mobile) { using (var db = new BFdbContext()) { tblusers usr = db.tblusers.FirstOrDefault(p => p.Mobile == mobile && p.Status == 0); if (usr == null) { return(-1); } usr.mono = VerifyCode.Get6SzCode(); int res = db.Update <tblusers>(usr); if (res > 0) { SMSHepler.SendGetSms(mobile, usr.mono); } return(res); } }
/// <summary> /// 修改密码 /// </summary> /// <param name="userid"></param> /// <param name="oldpwd"></param> /// <param name="newpwd"></param> /// <param name="by"></param> /// <returns></returns> public string UpdatePwd(string userid, string oldpwd, string newpwd, string by) { try { using (BFdbContext db = new BFdbContext()) { var user = db.TBUSER.Find(userid); if (user.PWD != oldpwd) { return("-1"); } user.PWD = newpwd; user.UPDATEDATE = DateTime.Now; user.UPDATEID = by; return(db.Update <TBUSER>(user).ToString()); } } catch (Exception ex) { log.Error(ex); throw GetFault(ex); } }