Ejemplo n.º 1
0
 protected void JqgridHomeTeam_RowEditing(object sender, JQGridRowEditEventArgs e)
 {
     using (var dc = ThaitaeDataDataContext.Create())
     {
         var team = dc.TeamMatches.Single(item => item.TeamMatchId == Convert.ToInt32(e.RowKey));
         team.TeamGoalFor = Convert.ToInt32(e.RowData["TeamGoalFor"]);
         team.TeamRedCard = Convert.ToInt32(e.RowData["TeamRedCard"]);
         team.TeamYellowCard = Convert.ToInt32(e.RowData["TeamYellowCard"]);
         if (team.TeamGoalFor == -1 && team.TeamRedCard == -1 && team.TeamYellowCard == -1)
         {
             team.TeamEdited = 0;
             team.TeamStatus = 0;
             team.TeamGoalAgainst = 0;
             team.TeamGoalFor = 0;
             team.TeamRedCard = 0;
             team.TeamYellowCard = 0;
         }
         else
         {
             team.TeamEdited = 1;
             var teamAgainst = dc.TeamMatches.Single(item => item.MatchId == Convert.ToInt32(e.ParentRowKey) && item.TeamHome == 0);
             teamAgainst.TeamGoalAgainst = Convert.ToInt32(e.RowData["TeamGoalFor"]);
             if (teamAgainst.TeamEdited == 1)
             {
                 if (team.TeamGoalFor < teamAgainst.TeamGoalFor)
                 {
                     team.TeamStatus = 3;
                     teamAgainst.TeamStatus = 1;
                 }
                 else if (team.TeamGoalFor > teamAgainst.TeamGoalFor)
                 {
                     team.TeamStatus = 1;
                     teamAgainst.TeamStatus = 3;
                 }
                 else
                 {
                     team.TeamStatus = 2;
                     teamAgainst.TeamStatus = 2;
                 }
                 dc.SubmitChanges();
                 CalculateTeamResult(team, teamAgainst, Convert.ToInt32(Session["seasonid"]));
             }
         }
         dc.SubmitChanges();
         var removePlayerList =
         dc.PlayerMatches.Where(item => item.TeamId == team.TeamId && item.MatchId == team.MatchId && item.SeasonId == team.SeasonId);
         dc.PlayerMatches.DeleteAllOnSubmit(removePlayerList);
         dc.SubmitChanges();
         for (int i = 0; i < team.TeamGoalFor; i++)
         {
             var player = new PlayerMatch { PlayerGoal = 1, TeamId = team.TeamId, MatchId = team.MatchId, SeasonId = team.SeasonId };
             dc.PlayerMatches.InsertOnSubmit(player);
             dc.SubmitChanges();
         }
         for (int i = 0; i < team.TeamRedCard; i++)
         {
             var player = new PlayerMatch { PlayerRedCard = 1, TeamId = team.TeamId, MatchId = team.MatchId, SeasonId = team.SeasonId };
             dc.PlayerMatches.InsertOnSubmit(player);
             dc.SubmitChanges();
         }
         for (int i = 0; i < team.TeamYellowCard; i++)
         {
             var player = new PlayerMatch { PlayerYellowCard = 1, TeamId = team.TeamId, MatchId = team.MatchId, SeasonId = team.SeasonId };
             dc.PlayerMatches.InsertOnSubmit(player);
             dc.SubmitChanges();
         }
     }
 }
Ejemplo n.º 2
0
 partial void DeletePlayerMatch(PlayerMatch instance);
Ejemplo n.º 3
0
 partial void UpdatePlayerMatch(PlayerMatch instance);
Ejemplo n.º 4
0
 partial void InsertPlayerMatch(PlayerMatch instance);
Ejemplo n.º 5
0
		private void detach_PlayerMatches(PlayerMatch entity)
		{
			this.SendPropertyChanging();
			entity.Player = null;
		}
Ejemplo n.º 6
0
		private void attach_PlayerMatches(PlayerMatch entity)
		{
			this.SendPropertyChanging();
			entity.Player = this;
		}