コード例 #1
0
ファイル: Game.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected void rptEvents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            MatchEventDTO  ev     = e.Item.DataItem as MatchEventDTO;
            MatchLineupDTO lineup = DataItem.Lineup.FirstOrDefault(l => l.Player_Id == ev.Player1_Id);

            if (lineup != null)
            {
                MatchEvent meControl     = null;
                Label      lblPlayerName = null;

                bool isOwnGoal = ev.Event_Cd == Constants.DB.EventTypeCodes.Goal && ((ev.EventFlags & Constants.DB.EventFlags.OwnGoal) > 0);

                if ((lineup.IsHomeTeamPlayer && !isOwnGoal) || (!lineup.IsHomeTeamPlayer && isOwnGoal))
                {
                    meControl     = e.Item.FindControl("meHome") as MatchEvent;
                    lblPlayerName = e.Item.FindControl("lblHomeEvent") as Label;
                }
                else
                {
                    meControl     = e.Item.FindControl("meAway") as MatchEvent;
                    lblPlayerName = e.Item.FindControl("lblAwayEvent") as Label;
                }

                meControl.Visible      = true;
                meControl.EventType_CD = ev.Event_Cd;
                meControl.Minute       = ev.Minute;
                meControl.EventFlags   = ev.EventFlags;
                meControl.Player1      = ev.Player1;
                meControl.Player2      = ev.Player2;
                lblPlayerName.Text     = FormatName(lineup.Player_FirstName, lineup.Player_LastName, lineup.Player_DisplayName, lineup.Player_CountryId) + ", " + ev.Minute.ToString();
            }
        }
コード例 #2
0
ファイル: MatchEdit.aspx.cs プロジェクト: agrzhibovetsky/uaf
        private MatchLineupDTO GetLineup(AutocompleteTextBox actbPlayer, int countryId, int shirtNum, int?lineupId, bool isSubstitute, bool isHomeTeamPlayer, int flags)
        {
            int playerId = 0;

            if (!actbPlayer.Value.IsEmpty() && !actbPlayer.Value.Equals("0"))
            {
                playerId = int.Parse(actbPlayer.Value);
            }
            else
            {
                if (actbPlayer.Text.Length > 0)
                {
                    string fName      = null;
                    string lName      = null;
                    int    spaceIndex = actbPlayer.Text.IndexOf(' ');
                    if (spaceIndex > 1)
                    {
                        fName = actbPlayer.Text.Substring(0, spaceIndex);
                        lName = actbPlayer.Text.Substring(spaceIndex + 1);
                    }
                    else
                    {
                        lName = actbPlayer.Text;
                    }



                    PlayerDTO newPlayer = new PlayerDTO()
                    {
                        First_Name     = fName,
                        Last_Name      = lName,
                        RequiresReview = true,
                        Country_Id     = countryId
                    };

                    playerId = new PlayerDTOHelper().SaveToDB(newPlayer);
                }
            }

            MatchLineupDTO hpml = new MatchLineupDTO
            {
                IsHomeTeamPlayer = isHomeTeamPlayer,
                Match_Id         = DataItem.Match_Id,
                IsSubstitute     = isSubstitute,
                Player_Id        = playerId,
                ShirtNum         = shirtNum,
                Flags            = flags
            };


            if (lineupId.HasValue)
            {
                hpml.MatchLineup_Id = lineupId.Value;
            }

            return(hpml);
        }
コード例 #3
0
ファイル: Game.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected void rptLineup_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Pair           l  = e.Item.DataItem as Pair;
            MatchLineupDTO hp = l.First as MatchLineupDTO;
            MatchLineupDTO ap = l.Second as MatchLineupDTO;

            Label lblHPlayerNum = e.Item.FindControl("lblHPlayerNum") as Label;

            lblHPlayerNum.Text = hp.ShirtNum.HasValue & hp.ShirtNum > 0 ? hp.ShirtNum.Value.ToString() : string.Empty;

            Label lblAPlayerNum = e.Item.FindControl("lblAPlayerNum") as Label;

            lblAPlayerNum.Text = ap.ShirtNum.HasValue & ap.ShirtNum > 0 ? ap.ShirtNum.Value.ToString() : string.Empty;

            Panel     pHomePlayer = e.Item.FindControl("pHomePlayer") as Panel;
            HyperLink aHomePlayer = pHomePlayer.FindControl("aHomePlayer") as HyperLink;

            FormatPlayerHyperLink(aHomePlayer, hp);

            MatchEventDTO hPlayerSubstEvent = DataItem.Events.FirstOrDefault(ev => ev.Player1_Id == hp.Player_Id && ev.Event_Cd == Constants.DB.EventTypeCodes.Substitution);

            if (hPlayerSubstEvent != null)
            {
                Panel pHomePlayerSubs = e.Item.FindControl("pHomePlayerSubst") as Panel;
                pHomePlayerSubs.Visible = true;
                HyperLink aHomePlayerSubst = pHomePlayerSubs.FindControl("aHomePlayerSubst") as HyperLink;
                FormatPlayerSubstHyperLink(aHomePlayerSubst, hPlayerSubstEvent);
            }

            Panel     pAwayPlayer = e.Item.FindControl("pAwayPlayer") as Panel;
            HyperLink aAwayPlayer = pHomePlayer.FindControl("aAwayPlayer") as HyperLink;

            FormatPlayerHyperLink(aAwayPlayer, ap);

            MatchEventDTO aPlayerSubstEvent = DataItem.Events.FirstOrDefault(ev => ev.Player1_Id == ap.Player_Id && ev.Event_Cd == Constants.DB.EventTypeCodes.Substitution);

            if (aPlayerSubstEvent != null)
            {
                Panel pAwayPlayerSubs = e.Item.FindControl("pAwayPlayerSubst") as Panel;
                pAwayPlayerSubs.Visible = true;
                HyperLink aAwayPlayerSubst = pAwayPlayerSubs.FindControl("aAwayPlayerSubst") as HyperLink;
                FormatPlayerSubstHyperLink(aAwayPlayerSubst, aPlayerSubstEvent);
            }

            if (e.Item.ItemIndex == 10)
            {
                HtmlTableRow trRow = e.Item.FindControl("trPlayerRow") as HtmlTableRow;
                trRow.Attributes.Add("class", "trSub2");
            }
        }
コード例 #4
0
ファイル: Game.aspx.cs プロジェクト: agrzhibovetsky/uaf
 protected void FormatPlayerHyperLink(HyperLink h, MatchLineupDTO pl)
 {
     h.Text = FormatName(pl.Player_FirstName, pl.Player_LastName, pl.Player_DisplayName, pl.Player_CountryId);
     if ((pl.Flags & Constants.DB.LineupFlags.Goalkeeper) > 0)
     {
         h.Text += " (Вр) ";
     }
     if ((pl.Flags & Constants.DB.LineupFlags.Captain) > 0)
     {
         h.Text += " (K) ";
     }
     if ((pl.Flags & Constants.DB.LineupFlags.Debut) > 0)
     {
         h.Text += " (Дебют) ";
     }
     h.ToolTip     = FormatName(pl.Player_FirstName_Int, pl.Player_LastName_Int, null, pl.Player_CountryId);
     h.NavigateUrl = string.Format("Player.aspx?{0}={1}", Constants.QueryParam.PlayerId, pl.Player_Id);
 }
コード例 #5
0
ファイル: MatchEdit.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected void rptLineup_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Pair           uiPair     = e.Item.DataItem as Pair;
            MatchLineupDTO homePlayer = uiPair.First as MatchLineupDTO;
            MatchLineupDTO awayPlayer = uiPair.Second as MatchLineupDTO;

            AutocompleteTextBox actbHomePlayer          = e.Item.FindControl("actbHomePlayer") as AutocompleteTextBox;
            AutocompleteTextBox actbAwayPlayer          = e.Item.FindControl("actbAwayPlayer") as AutocompleteTextBox;
            TextBox             tbHomePlayerShirtNumber = e.Item.FindControl("tbHomePlayerShirtNumber") as TextBox;
            TextBox             tbAwayPlayerShirtNumber = e.Item.FindControl("tbAwayPlayerShirtNumber") as TextBox;
            HiddenField         hfHomePlayerLineupId    = e.Item.FindControl("hfHomePlayerLineupId") as HiddenField;
            HiddenField         hfAwayPlayerLineupId    = e.Item.FindControl("hfAwayPlayerLineupId") as HiddenField;
            CheckBox            cbHGoalkeeper           = e.Item.FindControl("cbHGoalkeeper") as CheckBox;
            CheckBox            cbAGoalkeeper           = e.Item.FindControl("cbAGoalkeeper") as CheckBox;
            CheckBox            cbHCaptain = e.Item.FindControl("cbHCaptain") as CheckBox;
            CheckBox            cbACaptain = e.Item.FindControl("cbACaptain") as CheckBox;
            CheckBox            cbHDebut   = e.Item.FindControl("cbHDebut") as CheckBox;
            CheckBox            cbADebut   = e.Item.FindControl("cbADebut") as CheckBox;

            actbHomePlayer.Value = homePlayer.Player_Id.ToString();
            if (homePlayer.Player_Id > 0)
            {
                actbHomePlayer.Text = FormatName(homePlayer.Player_FirstName, homePlayer.Player_LastName, homePlayer.Player_DisplayName, homePlayer.Player_CountryId);
            }
            tbHomePlayerShirtNumber.Text = homePlayer.ShirtNum.ToString();
            hfHomePlayerLineupId.Value   = homePlayer.MatchLineup_Id.ToString();

            actbAwayPlayer.Value = awayPlayer.Player_Id.ToString();
            if (awayPlayer.Player_Id > 0)
            {
                actbAwayPlayer.Text = FormatName(awayPlayer.Player_FirstName, awayPlayer.Player_LastName, awayPlayer.Player_DisplayName, awayPlayer.Player_CountryId);
            }
            tbAwayPlayerShirtNumber.Text = awayPlayer.ShirtNum.ToString();
            cbHCaptain.Checked           = (homePlayer.Flags & Constants.DB.LineupFlags.Captain) > 0;
            cbHGoalkeeper.Checked        = (homePlayer.Flags & Constants.DB.LineupFlags.Goalkeeper) > 0;
            cbHDebut.Checked             = (homePlayer.Flags & Constants.DB.LineupFlags.Debut) > 0;

            cbACaptain.Checked    = (awayPlayer.Flags & Constants.DB.LineupFlags.Captain) > 0;
            cbAGoalkeeper.Checked = (awayPlayer.Flags & Constants.DB.LineupFlags.Goalkeeper) > 0;
            cbADebut.Checked      = (awayPlayer.Flags & Constants.DB.LineupFlags.Debut) > 0;

            hfAwayPlayerLineupId.Value = awayPlayer.MatchLineup_Id.ToString();
        }
コード例 #6
0
        protected void rptMatches_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Header && HideHeader)
            {
                e.Item.Visible = false;
            }

            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                MatchDTO       match         = e.Item.DataItem as MatchDTO;
                MatchLineupDTO lineup        = match.Lineup[0];
                Label          lblMinute     = e.Item.FindControl("lblMinute") as Label;
                Label          matchNo       = e.Item.FindControl("lblMatchNo") as Label;
                bool           seasonChanged = false;
                if (match.Season_Id != _curSeasonId)
                {
                    _curSeasonId  = match.Season_Id;
                    seasonChanged = e.Item.ItemIndex > 0;
                }
                bool isFriendly = match.CompetitionStageName == null;

                string minuteStg = lineup.didntPlay ? string.Empty : lineup.minutesPlayed.ToString();

                if (lineup.cameAsSubstitute)
                {
                    minuteStg = "(" + minuteStg + ")";
                }

                lblMinute.Text = minuteStg;
                if (!lineup.didntPlay)
                {
                    lblMinute.CssClass = "playerFullMatch";
                }
                if (lineup.cameAsSubstitute)
                {
                    lblMinute.CssClass = "playerIn";
                }
                if (lineup.wasSubstituted)
                {
                    lblMinute.CssClass = "playerOut";
                }

                matchNo.Text = lineup.MatchNo > 0 ? lineup.MatchNo.ToString() : "";

                if ((lineup.IsHomeTeamPlayer && match.HomeTeamCountryCode != Constants.CountryCodeUA) || (!lineup.IsHomeTeamPlayer && match.AwayTeamCountryCode != Constants.CountryCodeUA))
                {
                    HtmlTableRow row = e.Item.FindControl("matchRow") as HtmlTableRow;
                    row.Style.Add(HtmlTextWriterStyle.Color, "#808080");
                }

                if (isFriendly)
                {
                    HtmlTableRow row = e.Item.FindControl("matchRow") as HtmlTableRow;
                    row.Style.Add(HtmlTextWriterStyle.Color, "#808080");
                }

                if (seasonChanged && !HideSeasonSeparator)
                {
                    HtmlTableRow row = e.Item.FindControl("matchRow") as HtmlTableRow;
                    row.Attributes["class"] += " new_competition";
                }
                //e.Item.

                Repeater rptEvents = e.Item.FindControl("rptEvents") as Repeater;
                rptEvents.ItemDataBound += rptEvents_ItemDataBound;
                rptEvents.DataSource     = match.Events.Where(me => me.Event_Cd != Constants.DB.EventTypeCodes.Substitution);
                rptEvents.DataBind();

                HyperLink hlPhoto = e.Item.FindControl("hlPhoto") as HyperLink;

                if (match.PhotoCount > 0)
                {
                    hlPhoto.ToolTip     = match.PhotoCount.ToString();
                    hlPhoto.NavigateUrl = ResolveClientUrl(string.Format("/UaFootball/WebApplication/Public/Photo.aspx?PlayerId={0}&MatchId={1}", PlayerId, match.Match_Id));
                }
                else
                {
                    hlPhoto.Visible = false;
                }

                Image iVideo = e.Item.FindControl("iVideo") as Image;
                iVideo.Visible = false;
            }
        }
コード例 #7
0
ファイル: MatchEdit.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected override void DTOToUI(MatchDTO dtoObj)
        {
            bool isNationalTeamMatch = dtoObj.HomeNationalTeam_Id.HasValue;

            cbMatchKind.Checked = isNationalTeamMatch;
            actbHomeTeam.Text   = dtoObj.HomeTeamName;
            actbAwayTeam.Text   = dtoObj.AwayTeamName;

            if (isNationalTeamMatch)
            {
                actbHomeTeam.Value = dtoObj.HomeNationalTeam_Id.ToString();
                actbAwayTeam.Value = dtoObj.AwayNationalTeam_Id.ToString();
            }
            else
            {
                actbHomeTeam.Value = dtoObj.HomeClub_Id.ToString();
                actbAwayTeam.Value = dtoObj.AwayClub_Id.ToString();
            }

            if (dtoObj.Referee != null)
            {
                actbReferee.Text  = FormatName(dtoObj.Referee.FirstName, dtoObj.Referee.LastName, null, dtoObj.Referee.Country_Id);
                actbReferee.Value = dtoObj.Referee.Referee_Id.ToString();
            }
            ddlCompetitions.SelectedValue = dtoObj.Competition_Id.ToString();
            ddlSeasons.SelectedValue      = dtoObj.Season_Id.ToString();
            tbDate.Text = FormatDate(dtoObj.Date);
            ddlStadiums.SelectedValue   = dtoObj.Stadium.Stadium_ID.ToString();
            tbHomeTeamScore.Text        = dtoObj.HomeScore.ToString();
            tbAwayTeamScore.Text        = dtoObj.AwayScore.ToString();
            tbHomeTeamPenaltyScore.Text = dtoObj.HomePenaltyScore.ToString();
            tbAwayTeamPenaltyScore.Text = dtoObj.AwayPenaltyScore.ToString();
            tbSpecatators.Text          = dtoObj.Spectators.ToString();
            tbSpecialNotes.Text         = dtoObj.SpecialNote;
            tbSources.Text    = dtoObj.Sources;
            tbAdminNotes.Text = dtoObj.AdminNotes;
            SetAutocompleteTypes();
            SetCompetitionStages();
            if (dtoObj.CompetitionStage_Id.HasValue)
            {
                ddlStage.SelectedValue = dtoObj.CompetitionStage_Id.ToString();
            }

            List <Pair> uiLineup = new List <Pair>(23);

            if (isNewObject)
            {
                tbDate.Text = FormatDate(DateTime.Now);

                for (int i = 0; i < 25; i++)
                {
                    uiLineup.Add(new Pair(new MatchLineupDTO(), new MatchLineupDTO()));
                }
            }
            else
            {
                List <MatchLineupDTO> homePlayers = DataItem.Lineup.Where(l => l.IsHomeTeamPlayer && l.Player_Id != null).ToList();
                List <MatchLineupDTO> awayPlayers = DataItem.Lineup.Where(l => !l.IsHomeTeamPlayer && l.Player_Id != null).ToList();

                for (int i = 0; i < 30; i++)
                {
                    Pair uiLineupPair = new Pair();

                    if (homePlayers.Count > i)
                    {
                        uiLineupPair.First = homePlayers[i];
                    }
                    else
                    {
                        uiLineupPair.First = new MatchLineupDTO();
                    }

                    if (awayPlayers.Count > i)
                    {
                        uiLineupPair.Second = awayPlayers[i];
                    }
                    else
                    {
                        uiLineupPair.Second = new MatchLineupDTO();
                    }

                    uiLineup.Add(uiLineupPair);
                }
            }

            rptLineup.DataSource = uiLineup;
            rptLineup.DataBind();

            MatchLineupDTO homeCoach = DataItem.Lineup.SingleOrDefault(l => l.IsHomeTeamPlayer && l.CoachId != null);
            MatchLineupDTO awayCoach = DataItem.Lineup.SingleOrDefault(l => !l.IsHomeTeamPlayer && l.CoachId != null);

            if (homeCoach != null)
            {
                hfHomeCoachLineupId.Value   = homeCoach.MatchLineup_Id.ToString();
                actbHomeCoach.Value         = homeCoach.CoachId.ToString();
                actbHomeCoach.Text          = FormatName(homeCoach.Coach_FirstName, homeCoach.Coach_LastName, "", 0);
                cbHomeCoachInCharge.Checked = (homeCoach.Flags & Constants.DB.LineupFlags.CoachInCharge) > 0;
            }
            if (awayCoach != null)
            {
                hfAwayCoachLineupId.Value   = awayCoach.MatchLineup_Id.ToString();
                actbAwayCoach.Value         = awayCoach.CoachId.ToString();
                actbAwayCoach.Text          = FormatName(awayCoach.Coach_FirstName, awayCoach.Coach_LastName, "", 0);
                cbAwayCoachInCharge.Checked = (awayCoach.Flags & Constants.DB.LineupFlags.CoachInCharge) > 0;
            }

            for (int i = 0; i < 16; i++)
            {
                if (DataItem.Events.Count < i)
                {
                    DataItem.Events.Add(new MatchEventDTO());
                }
            }

            rptEvents.DataSource = DataItem.Events;
            rptEvents.DataBind();

            if (DataItem.Flags.HasValue && DataItem.Flags.Value > 0)
            {
                foreach (KeyValuePair <int, string> flag in UIHelper.MatchFlagsMap)
                {
                    if ((DataItem.Flags & flag.Key) > 0)
                    {
                        ListItem cb = cblMatchFlags.Items.FindByValue(flag.Key.ToString());
                        if (cb != null)
                        {
                            cb.Selected = true;
                        }
                    }
                }
            }

            rptNotes.DataSource = DataItem.Notes;
            rptNotes.DataBind();
        }
コード例 #8
0
ファイル: MatchEdit.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected override MatchDTO UIToDTO()
        {
            bool     isNationalTeamMatch = cbMatchKind.Checked;
            int?     homeTeamId          = actbHomeTeam.Value.ParseInt(false);
            int?     awayTeamId          = actbAwayTeam.Value.ParseInt(false);
            short?   homePenScore        = tbHomeTeamPenaltyScore.Text.Length > 0 ? (short?)short.Parse(tbHomeTeamPenaltyScore.Text) : null;
            short?   awayPenScore        = tbAwayTeamPenaltyScore.Text.Length > 0 ? (short?)short.Parse(tbAwayTeamPenaltyScore.Text) : null;
            int?     refereeId           = actbReferee.Value.ParseInt(true);
            MatchDTO MatchToSave         = new MatchDTO
            {
                HomeClub_Id         = isNationalTeamMatch ? null : homeTeamId,
                HomeNationalTeam_Id = isNationalTeamMatch ? homeTeamId : null,
                AwayClub_Id         = isNationalTeamMatch ? null : awayTeamId,
                AwayNationalTeam_Id = isNationalTeamMatch ? awayTeamId : null,
                HomeScore           = short.Parse(tbHomeTeamScore.Text),
                AwayScore           = short.Parse(tbAwayTeamScore.Text),
                HomePenaltyScore    = homePenScore,
                AwayPenaltyScore    = awayPenScore,
                Competition_Id      = GetDropdownValue(ddlCompetitions).Value,
                Season_Id           = GetDropdownValue(ddlSeasons).Value,
                Stadium             = new StadiumDTO
                {
                    Stadium_ID = GetDropdownValue(ddlStadiums).Value
                },
                CompetitionStage_Id = ddlStage.SelectedValue.ParseInt(true),
                Match_Id            = DataItem.Match_Id,
                Spectators          = tbSpecatators.Text.ParseInt(false),
                Referee             = refereeId == null ? null : new RefereeDTO
                {
                    Referee_Id = refereeId.Value
                },
                Lineup      = new List <MatchLineupDTO>(),
                Events      = new List <MatchEventDTO>(),
                SpecialNote = tbSpecialNotes.Text.Length > 0 ? tbSpecialNotes.Text : null,
                AdminNotes  = string.IsNullOrWhiteSpace(tbAdminNotes.Text) ? null : tbAdminNotes.Text,
                Sources     = string.IsNullOrWhiteSpace(tbSources.Text) ? null : tbSources.Text
            };

            DateTime date = DateTime.Now;

            if (DateTime.TryParse(tbDate.Text, out date))
            {
                MatchToSave.Date = date;
            }

            int matchFlag = 0;

            foreach (ListItem li in cblMatchFlags.Items)
            {
                if (li.Selected)
                {
                    int flag = int.Parse(li.Value);
                    matchFlag |= flag;
                }
            }

            MatchToSave.Flags = matchFlag;

            int homeCountryId = GetCountryId(isNationalTeamMatch, homeTeamId);
            int awayCountryId = GetCountryId(isNationalTeamMatch, awayTeamId);

            foreach (RepeaterItem ri in rptLineup.Items)
            {
                AutocompleteTextBox actbHomePlayer          = ri.FindControl("actbHomePlayer") as AutocompleteTextBox;
                AutocompleteTextBox actbAwayPlayer          = ri.FindControl("actbAwayPlayer") as AutocompleteTextBox;
                TextBox             tbHomePlayerShirtNumber = ri.FindControl("tbHomePlayerShirtNumber") as TextBox;
                TextBox             tbAwayPlayerShirtNumber = ri.FindControl("tbAwayPlayerShirtNumber") as TextBox;
                HiddenField         hfHomePlayerLineupId    = ri.FindControl("hfHomePlayerLineupId") as HiddenField;
                HiddenField         hfAwayPlayerLineupId    = ri.FindControl("hfAwayPlayerLineupId") as HiddenField;
                CheckBox            cbHGoalkeeper           = ri.FindControl("cbHGoalkeeper") as CheckBox;
                CheckBox            cbAGoalkeeper           = ri.FindControl("cbAGoalkeeper") as CheckBox;
                CheckBox            cbHCaptain = ri.FindControl("cbHCaptain") as CheckBox;
                CheckBox            cbACaptain = ri.FindControl("cbACaptain") as CheckBox;
                CheckBox            cbHDebut   = ri.FindControl("cbHDebut") as CheckBox;
                CheckBox            cbADebut   = ri.FindControl("cbADebut") as CheckBox;

                if (actbHomePlayer.Text.Length > 0 && tbHomePlayerShirtNumber.Text.Length > 0)
                {
                    int            hLineupFlag = 0 | (cbHGoalkeeper.Checked ? Constants.DB.LineupFlags.Goalkeeper : 0) | (cbHCaptain.Checked ? Constants.DB.LineupFlags.Captain : 0) | (cbHDebut.Checked ? Constants.DB.LineupFlags.Debut : 0);
                    MatchLineupDTO hpml        = GetLineup(actbHomePlayer, homeCountryId, int.Parse(tbHomePlayerShirtNumber.Text), int.Parse(hfHomePlayerLineupId.Value), ri.ItemIndex > 10, true, hLineupFlag);
                    MatchToSave.Lineup.Add(hpml);
                }
                if (actbAwayPlayer.Text.Length > 0 && tbAwayPlayerShirtNumber.Text.Length > 0)
                {
                    int            aLineupFlag = 0 | (cbAGoalkeeper.Checked ? Constants.DB.LineupFlags.Goalkeeper : 0) | (cbACaptain.Checked ? Constants.DB.LineupFlags.Captain : 0) | (cbADebut.Checked ? Constants.DB.LineupFlags.Debut : 0);
                    MatchLineupDTO apml        = GetLineup(actbAwayPlayer, awayCountryId, int.Parse(tbAwayPlayerShirtNumber.Text), int.Parse(hfAwayPlayerLineupId.Value), ri.ItemIndex > 10, false, aLineupFlag);
                    MatchToSave.Lineup.Add(apml);
                }
            }

            if (!string.IsNullOrEmpty(actbHomeCoach.Value) && !string.IsNullOrEmpty(actbHomeCoach.Text))
            {
                MatchLineupDTO homeCoachLineupDTO = new MatchLineupDTO
                {
                    IsHomeTeamPlayer = true,
                    Match_Id         = DataItem.Match_Id,
                    IsSubstitute     = false,
                    CoachId          = int.Parse(actbHomeCoach.Value),
                    ShirtNum         = null,
                    MatchLineup_Id   = string.IsNullOrEmpty(hfHomeCoachLineupId.Value) ? 0 : int.Parse(hfHomeCoachLineupId.Value),
                    Flags            = cbHomeCoachInCharge.Checked ? Constants.DB.LineupFlags.CoachInCharge : 0
                };
                MatchToSave.Lineup.Add(homeCoachLineupDTO);
            }

            if (!string.IsNullOrEmpty(actbAwayCoach.Value) && !string.IsNullOrEmpty(actbAwayCoach.Text))
            {
                MatchLineupDTO awayCoachLineupDTO = new MatchLineupDTO
                {
                    IsHomeTeamPlayer = false,
                    Match_Id         = DataItem.Match_Id,
                    IsSubstitute     = false,
                    CoachId          = int.Parse(actbAwayCoach.Value),
                    ShirtNum         = null,
                    MatchLineup_Id   = string.IsNullOrEmpty(hfAwayCoachLineupId.Value) ? 0 : int.Parse(hfAwayCoachLineupId.Value),
                    Flags            = cbAwayCoachInCharge.Checked ? Constants.DB.LineupFlags.CoachInCharge : 0
                };
                MatchToSave.Lineup.Add(awayCoachLineupDTO);
            }

            foreach (RepeaterItem ri in rptEvents.Items)
            {
                TextBox             tbMinute      = ri.FindControl("tbMinute") as TextBox;
                HiddenField         hfEventId     = ri.FindControl("hfMatchEventId") as HiddenField;
                DropDownList        ddlEventType  = ri.FindControl("ddlEventTypeCd") as DropDownList;
                AutocompleteTextBox actbPlayer1   = ri.FindControl("actbEventPlayer1") as AutocompleteTextBox;
                AutocompleteTextBox actbPlayer2   = ri.FindControl("actbEventPlayer2") as AutocompleteTextBox;
                CheckBoxList        cblEventFlags = ri.FindControl("cblEventFlags") as CheckBoxList;

                bool isValid = tbMinute.Text.Length > 0 && actbPlayer1.Value.Length > 0;
                if (ddlEventType.SelectedValue == Constants.DB.EventTypeCodes.Substitution)
                {
                    isValid &= actbPlayer2.Value.Length > 0;
                }

                if (isValid)
                {
                    MatchEventDTO newEvent = new MatchEventDTO
                    {
                        Event_Cd      = ddlEventType.SelectedValue,
                        MatchEvent_Id = hfEventId.Value.Length > 0 ? int.Parse(hfEventId.Value) : 0,
                        Minute        = int.Parse(tbMinute.Text),
                        Player1_Id    = int.Parse(actbPlayer1.Value),
                        Player2_Id    = actbPlayer2.Value.Length > 0 ? (int?)int.Parse(actbPlayer2.Value) : null,
                        Match_Id      = DataItem.Match_Id
                    };

                    if (newEvent.Player1_Id > 0)
                    {
                        int eventFlags = 0;
                        foreach (ListItem item in cblEventFlags.Items)
                        {
                            if (item.Selected)
                            {
                                eventFlags |= int.Parse(item.Value);
                            }
                        }

                        newEvent.EventFlags = eventFlags;
                        MatchToSave.Events.Add(newEvent);
                    }
                }
            }

            foreach (string noteCodeDropdownId in Request.Form.AllKeys.Where(k => k.StartsWith("matchNoteCode_")))
            {
                MatchNoteDTO newNote = new MatchNoteDTO {
                    Code = Request.Form[noteCodeDropdownId], Text = Request.Form[noteCodeDropdownId.Replace("Code", "Text")]
                };
                if (!string.IsNullOrEmpty(newNote.Text))
                {
                    MatchToSave.Notes.Add(newNote);
                }
            }


            return(MatchToSave);
        }
コード例 #9
0
ファイル: Game.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterClientScriptInclude(Constants.Paths.ColorboxKey, Page.ResolveClientUrl(Constants.Paths.ColorboxPath));
            if (!IsPostBack)
            {
                if (Request[Constants.QueryParam.ObjectId] != null)
                {
                    int objectId = int.Parse(Request[Constants.QueryParam.ObjectId]);
                    DataItem = new MatchDTOHelper().GetFromDB(objectId);

                    string thumbPath = "\\thumb\\";
                    if (DataItem.HomeTeamLogo != null)
                    {
                        iHomeTeamLogo.ImageUrl = PathHelper.GetWebPath(this, Constants.Paths.MutlimediaWebRoot, DataItem.HomeTeamLogo.FilePath + thumbPath, DataItem.HomeTeamLogo.FileName);
                    }
                    if (DataItem.AwayTeamLogo != null)
                    {
                        iAwayTeamLogo.ImageUrl = PathHelper.GetWebPath(this, Constants.Paths.MutlimediaWebRoot, DataItem.AwayTeamLogo.FilePath + thumbPath, DataItem.AwayTeamLogo.FileName);
                    }

                    if ((DataItem.Flags & Constants.DB.MatchFlags.GoldenGoalRule) > 0)
                    {
                        DataItem.SpecialNote += "Матч закончился в дополнительное время по правилу золотого гола";
                    }

                    /*lblSpecialNotes.Text = DataItem.SpecialNote;
                     * lblSpecialNotes.Visible = !DataItem.SpecialNote.IsEmpty();*/

                    int imageCount = DataItem.Multimedia.Count(m => m.MultimediaType_CD == Constants.DB.MutlimediaTypes.Image);
                    int videoCount = DataItem.Multimedia.Count(m => m.MultimediaType_CD == Constants.DB.MutlimediaTypes.Video);
                    hlPhoto.Text        = "Фото (" + imageCount.ToString() + ")";
                    hlVideo.Text        = "Видео (" + videoCount.ToString() + ")";
                    hlPhoto.NavigateUrl = ResolveClientUrl("~/WebApplication/Public/Photo.aspx?MatchId=") + DataItem.Match_Id.ToString();
                    hlVideo.NavigateUrl = ResolveClientUrl("~/WebApplication/Public/Video.aspx?MatchId=") + DataItem.Match_Id.ToString();

                    List <MatchLineupDTO> homePlayers  = DataItem.Lineup.Where(l => l.IsHomeTeamPlayer && l.CoachId == null).ToList();
                    List <MatchLineupDTO> awayPlayers  = DataItem.Lineup.Where(l => !l.IsHomeTeamPlayer && l.CoachId == null).ToList();
                    MatchLineupDTO        homeCoachDTO = DataItem.Lineup.FirstOrDefault(l => l.CoachId.HasValue && l.IsHomeTeamPlayer);
                    MatchLineupDTO        awayCoachDTO = DataItem.Lineup.FirstOrDefault(l => l.CoachId.HasValue && !l.IsHomeTeamPlayer);
                    if (homeCoachDTO != null)
                    {
                        hlHomeTeamCoach.Text        = string.Concat(homeCoachDTO.Coach_FirstName, " ", homeCoachDTO.Coach_LastName);
                        hlHomeTeamCoach.NavigateUrl = ResolveClientUrl("~/WebApplication/Public/Coach.aspx?objectId=" + homeCoachDTO.CoachId);
                        ltHomeCoachInCharge.Visible = (homeCoachDTO.Flags & Constants.DB.LineupFlags.CoachInCharge) > 0;
                    }
                    if (awayCoachDTO != null)
                    {
                        hlAwayTeamCoach.Text        = string.Concat(awayCoachDTO.Coach_FirstName, " ", awayCoachDTO.Coach_LastName);
                        hlAwayTeamCoach.NavigateUrl = ResolveClientUrl("~/WebApplication/Public/Coach.aspx?objectId=" + awayCoachDTO.CoachId);
                        ltAwayCoachInCharge.Visible = (awayCoachDTO.Flags & Constants.DB.LineupFlags.CoachInCharge) > 0;
                    }

                    int         rowsCount = Math.Max(homePlayers.Count, awayPlayers.Count);
                    List <Pair> uiLineup  = new List <Pair>(rowsCount);
                    Pair        a         = new Pair();
                    for (int i = 0; i < rowsCount; i++)
                    {
                        Pair uiLineupPair = new Pair();

                        if (homePlayers.Count > i)
                        {
                            uiLineupPair.First = homePlayers[i];
                        }
                        else
                        {
                            uiLineupPair.First = new MatchLineupDTO();
                        }

                        if (awayPlayers.Count > i)
                        {
                            uiLineupPair.Second = awayPlayers[i];
                        }
                        else
                        {
                            uiLineupPair.Second = new MatchLineupDTO();
                        }

                        uiLineup.Add(uiLineupPair);
                    }


                    rptLineup.DataSource = uiLineup;
                    rptLineup.DataBind();

                    rptEvents.DataSource = DataItem.Events.Where(ev => ev.Event_Cd != Constants.DB.EventTypeCodes.Substitution).OrderBy(ev => ev.Minute);
                    rptEvents.DataBind();

                    rptNotes.DataSource = DataItem.Notes;
                    rptNotes.DataBind();

                    Controls.MatchNotes[] matchNotes = { mnSpect, mnAwayLineup, mnHomeLineup, mnAwayCoach, mnNoSpect, mnHomeCoach };
                    foreach (Controls.MatchNotes mn in matchNotes)
                    {
                        mn.DataSource = DataItem.Notes;
                        mn.DataBind();
                    }

                    lblStadiumDisq.Visible  = (DataItem.Flags.HasValue && ((DataItem.Flags & Constants.DB.MatchFlags.StadiumDisqualifiedNoSpectators) > 0));
                    lblNeutralField.Visible = (DataItem.Flags.HasValue && ((DataItem.Flags & Constants.DB.MatchFlags.NeutralField) > 0));
                }
            }
        }