public ActionResult Team_Add(f_team model, List <int> ids) { string sql = string.Format("insert into f_team(name,leaderid,abilityid,del) values('{0}',{1},{2},0);SELECT @@IDENTITY", model.name, model.leaderid, model.abilityid); int teamid = Convert.ToInt32(DbHelperMySQL.GetSingle(sql)); int result = 0; foreach (var item in ids) { sql = string.Format("insert into f_team_user(teamid,userid) values({0},{1})", teamid, item); int count = DbHelperMySQL.ExecuteSql(sql); result += count; } return(Json(Result.AutoResult(result == ids.Count ? 1 : 0), JsonRequestBehavior.AllowGet)); }
public ActionResult Team_Edit(f_team model, List <int> ids) { string sql = string.Format("update f_team t set name='{0}',leaderid={1},abilityid={2} where t.id={3}", model.name, model.leaderid, model.abilityid, model.id); int count = DbHelperMySQL.ExecuteSql(sql); sql = string.Format("delete from f_team_user where teamid={0}", model.id); count = DbHelperMySQL.ExecuteSql(sql); int result = 0; foreach (var item in ids) { sql = string.Format("insert into f_team_user(teamid,userid) values({0},{1})", model.id, item); count = DbHelperMySQL.ExecuteSql(sql); result += count; } return(Json(Result.AutoResult(result == ids.Count ? 1 : 0), JsonRequestBehavior.AllowGet)); }