コード例 #1
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);
        }
コード例 #2
0
ファイル: MatchEdit.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected void rptEvents_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            AutocompleteTextBox actbPlayer1 = e.Item.FindControl("actbEventPlayer1") as AutocompleteTextBox;
            AutocompleteTextBox actbPlayer2 = e.Item.FindControl("actbEventPlayer2") as AutocompleteTextBox;

            actbPlayer1.BehaviorId = "actbEventPlayer1" + e.Item.ItemIndex.ToString();
            actbPlayer2.BehaviorId = "actbEventPlayer2" + e.Item.ItemIndex.ToString();

            DropDownList ddlEventTypes = e.Item.FindControl("ddlEventTypeCd") as DropDownList;

            ddlEventTypes.DataBound     += new EventHandler(ddlEventTypes_DataBound);
            ddlEventTypes.DataTextField  = "Value";
            ddlEventTypes.DataValueField = "Key";
            ddlEventTypes.DataSource     = UIHelper.EventCodeMap;
            ddlEventTypes.DataBind();
            //CheckBoxList cblCardFlags = e.Item.FindControl("cblCardFlags") as CheckBoxList;
        }
コード例 #3
0
ファイル: MatchEdit.aspx.cs プロジェクト: agrzhibovetsky/uaf
        protected void rptLineup_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            AutocompleteTextBox actbHomePlayer = e.Item.FindControl("actbHomePlayer") as AutocompleteTextBox;
            AutocompleteTextBox actbAwayPlayer = e.Item.FindControl("actbAwayPlayer") as AutocompleteTextBox;

            actbAwayPlayer.BehaviorId = "awayPlayerAutocomplete" + e.Item.ItemIndex.ToString();
            actbHomePlayer.BehaviorId = "homePlayerAutocomplete" + e.Item.ItemIndex.ToString();
            //TextBox tbHomePlayerShirtNum = e.Item.FindControl("tbHomePlayerShirtNumber") as TextBox;
            //TextBox tbAwayPlayerShirtNum = e.Item.FindControl("tbAwayPlayerShirtNumber") as TextBox;
            //tbHomePlayerShirtNum.ID = "tbHomePlayerShirtNum" + e.Item.ItemIndex.ToString();
            //tbAwayPlayerShirtNum.ID = "tbAwayPlayerShirtNum" + e.Item.ItemIndex.ToString();
            if (e.Item.ItemIndex == 11)
            {
                HtmlTableRow tr = e.Item.FindControl("trLinup") as HtmlTableRow;
                tr.Attributes.Add("class", "trSub");
            }
        }
コード例 #4
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();
        }
コード例 #5
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);
        }