public int TeamDown(List <string> ids) { using (var db = new BFdbContext()) { int res = 0; using (var tx = db.BeginTransaction()) { try { foreach (string id in ids) { string sqlteam = string.Format("update tbl_teams set eventid=2 where teamid='{0}'", id); db.ExecuteSqlCommand(sqlteam); string sqlusers = string.Format("update tbl_match_users set isdown='1' where teamid='{0}'", id); db.ExecuteSqlCommand(sqlusers); } tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } } return(res); } }
public int AllTeamDown(string matchid) { using (var db = new BFdbContext()) { int res = 0; using (var tx = db.BeginTransaction()) { try { string sqlteam = string.Format("update tbl_teams set eventid=2 where status=0 and match_id='{0}'", matchid); db.ExecuteSqlCommand(sqlteam); string sqlusers = string.Format("update tbl_match_users set isdown='1' where status=1 and match_id='{0}'", matchid); db.ExecuteSqlCommand(sqlusers); tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } } return(res); } }
public int TeamDis(TeamDisEntiyList r) { using (var db = new BFdbContext()) { int res = -1; using (var tx = db.BeginTransaction()) { try { for (int i = 0; i < r.teams.Count; i++) { string id = r.teams[i].teamid; tblteams team = db.tblteams.FirstOrDefault(p => p.teamid == id); team.Lineid = r.lineid; team.Linesid = r.linesid; team.Teamno = r.teams[i].Teamno.PadLeft(5, '0'); db.TUpdate <tblteams>(team); //BuildSerial1(id,team.Teamno); } db.SaveChanges(); tx.Commit(); res = 0; } catch (Exception ex) { tx.Rollback(); throw ex; } } return(res); } }
/// <summary> /// 删除队伍 /// </summary> /// <param name="ids"></param> /// <returns></returns> public int DeleteTeam(List <string> ids) { using (var db = new BFdbContext()) { int res = 0; using (var tx = db.BeginTransaction()) { try { foreach (string id in ids) { tblteams ent = db.tblteams.FirstOrDefault(p => p.teamid == id); ent.Status = 2; db.TUpdate <tblteams>(ent); } db.SaveChanges(); tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } } return(res); } }
public string UpdateDict(List <CMNDICT> dictEntity) { try { var rs = false; using (BFdbContext db = new BFdbContext()) { using (db.BeginTransaction()) { foreach (var entity in dictEntity) { db.TUpdate <CMNDICT>(entity); } } db.SaveChanges(); rs = true; } return(rs ? "0" : "-1"); } catch (Exception ex) { log.Error(ex); throw GetFault(ex); } }
public string AddDict(List <CMNDICT> dictEntity) { try { var rs = false; using (BFdbContext db = new BFdbContext()) { db.ExecuteSqlCommand("delete from cmn_dict where dictid='3000'"); using (db.BeginTransaction()) { foreach (var entity in dictEntity) { db.TInsert <CMNDICT>(entity); } } db.SaveChanges(); rs = true; } return(rs ? "0" : "-1"); } catch (Exception ex) { log.Error(ex); throw GetFault(ex); } }
public string EditUserRule(string userid, string ruleids) { try { using (BFdbContext db = new BFdbContext()) { var tran = db.BeginTransaction(); db.ExecuteSqlCommand(string.Format("delete from cmn_relation where userid='{0}'", userid)); var rids = ruleids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var id in rids) { db.ExecuteSqlCommand(string.Format(@"insert into cmn_relation(userid, device, layer, ruleid) select '{0}',a.device,a.layer,a.id from cmn_rule a where a.id='{1}'", userid, id)); } tran.Commit(); return(""); } } catch (Exception ex) { log.Error(ex); throw GetFault(ex); } }
/// <summary> /// 添加关系 /// </summary> /// <param name="role"></param> /// <param name="menuids"></param> /// <returns></returns> public string AddRoleMenu(string role, string menuids) { try { using (BFdbContext db = new BFdbContext()) { var tran = db.BeginTransaction(); db.ExecuteSqlCommand(string.Format("delete from tb_rolemenurelation where roleid='{0}'", role)); //角色ID var rids = menuids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (var id in rids) { db.ExecuteSqlCommand(string.Format("insert into tb_rolemenurelation(roleid, menuid) values('{0}','{1}')", role, id)); } tran.Commit(); return(""); } } catch (Exception ex) { log.Error(ex); throw GetFault(ex); } }
/// <summary> /// 删除用户 /// </summary> /// <param name="ids"></param> /// <returns></returns> public int DeleteUser(List <string> ids) { using (var db = new BFdbContext()) { int res = 0; using (var tx = db.BeginTransaction()) { try { foreach (string id in ids) { sysuser ent = db.sysuser.FirstOrDefault(p => p.Userid == id); ent.Delflag = true; db.TUpdate <sysuser>(ent); } db.SaveChanges(); tx.Commit(); } catch (Exception ex) { tx.Rollback(); throw ex; } } return(res); } }