public static void UpdateGroupTeamByGroupMatch(Guid groupGuid, Guid teamGuid, DataTable dtGroupMatch) { var gt = new GroupTeam(); gt.GroupGuid = groupGuid; gt.TeamGuid = teamGuid; gt.PositionNo = 0; foreach (DataRow dr in dtGroupMatch.Rows) { var match = new Match((Guid) dr["MatchGuid"]); if (match != null) { if (match.Home == gt.TeamGuid) { gt.TotalPlayed++; if (match.ResultHome > match.ResultAway) { gt.HomeWon++; gt.HomePoints += 3; } else if (match.ResultHome == match.ResultAway) { gt.HomeDraw++; gt.HomePoints += 1; } else gt.HomeLost++; gt.HomeGoalFor += match.ResultHome; gt.HomeGoalAgainst += match.ResultAway; } else if (match.Away == gt.TeamGuid) { gt.TotalPlayed++; if (match.ResultAway > match.ResultHome) { gt.AwayWon++; gt.AwayPoints += 3; } else if (match.ResultAway == match.ResultHome) { gt.AwayDraw++; gt.AwayPoints += 1; } else gt.AwayLost++; gt.AwayGoalFor += match.ResultAway; gt.AwayGoalAgainst += match.ResultHome; } } } gt.HomeGoalDiff = Convert.ToInt16(gt.HomeGoalFor - gt.HomeGoalAgainst); gt.AwayGoalDiff = Convert.ToInt16(gt.AwayGoalFor - gt.AwayGoalAgainst); gt.TotalPoints = Convert.ToInt16(gt.HomePoints + gt.AwayPoints); gt.Update(); }
protected void btnSave_Click(object sender, EventArgs e) { try { var groupGuid = new Guid(lblGroupGuid.Text); Guid leagueGuid; Guid teamGuid; #region ListBox Multiple Value for RelationGroupTeam if (ddlGroupLeague.SelectedValue != Guid.Empty.ToString()) { Group.RemoveRelationGroupAllTeam(groupGuid); leagueGuid = new Guid(ddlGroupLeague.SelectedValue); foreach (ListItem item in lbLeagueTeam.Items) { teamGuid = new Guid(item.Value); if ((item.Selected) && (!GroupTeam.IsExistRelationGroupTeam(groupGuid, teamGuid))) { var gt = new GroupTeam(); gt.GroupGuid = groupGuid; gt.TeamGuid = teamGuid; gt.Insert(); } } ClientScript.RegisterClientScriptBlock(typeof (string), "updated", "alert('保存分组球队列表');", true); } else leagueGuid = SelectedLeague; #endregion if (leagueGuid == Guid.Empty) throw new Exception("No Selected League Guid"); var group = new Group(groupGuid); group.GroupGuid = groupGuid; group.GroupName = tbGroupName.Text; group.GroupOrder = Convert.ToInt16(tbGroupOrder.Text); group.LeagueGuid = leagueGuid; group.IsTable = cbIsTable.Checked; if (gvGroup.SelectedIndex != -1) { group.Update(); ClientScript.RegisterClientScriptBlock(typeof (string), "success", "alert('更新分组成功');", true); } else { group.Insert(); ClientScript.RegisterClientScriptBlock(typeof (string), "success", "alert('添加分组成功');", true); } gvGroup.SelectedIndex = -1; ResetForm(); BindGroupData(); } catch { if (SelectedLeague == Guid.Empty) ClientScript.RegisterClientScriptBlock(typeof (string), "failed", "alert('没有选择当前分类');", true); else ClientScript.RegisterClientScriptBlock(typeof (string), "failed", "alert('添加/更新分组失败');", true); } }
public static void UpdateGroupTeamByGroupMatch(Guid groupGuid, Guid teamGuid, DataTable dtGroupMatch) { var gt = new GroupTeam(); gt.GroupGuid = groupGuid; gt.TeamGuid = teamGuid; gt.PositionNo = 0; foreach (DataRow dr in dtGroupMatch.Rows) { var match = new Match((Guid)dr["MatchGuid"]); if (match != null) { if (match.Home == gt.TeamGuid) { gt.TotalPlayed++; if (match.ResultHome > match.ResultAway) { gt.HomeWon++; gt.HomePoints += 3; } else if (match.ResultHome == match.ResultAway) { gt.HomeDraw++; gt.HomePoints += 1; } else { gt.HomeLost++; } gt.HomeGoalFor += match.ResultHome; gt.HomeGoalAgainst += match.ResultAway; } else if (match.Away == gt.TeamGuid) { gt.TotalPlayed++; if (match.ResultAway > match.ResultHome) { gt.AwayWon++; gt.AwayPoints += 3; } else if (match.ResultAway == match.ResultHome) { gt.AwayDraw++; gt.AwayPoints += 1; } else { gt.AwayLost++; } gt.AwayGoalFor += match.ResultAway; gt.AwayGoalAgainst += match.ResultHome; } } } gt.HomeGoalDiff = Convert.ToInt16(gt.HomeGoalFor - gt.HomeGoalAgainst); gt.AwayGoalDiff = Convert.ToInt16(gt.AwayGoalFor - gt.AwayGoalAgainst); gt.TotalPoints = Convert.ToInt16(gt.HomePoints + gt.AwayPoints); gt.Update(); }