示例#1
0
        public void LoadKicker()
        {
            _fgResultList = new ArrayList();
             var fgCount = 0;
             _kicker = GetPlayerAt("PK", 1, false, false); //  depends on the Kicking unit being loaded
             string gameCode = String.Empty;
             string loWeek = "999999";
             string hiWeek = "000000";

             if (_kicker != null)
             {
            //  Get all the Scores for this kicker
            var ds = Utility.TflWs.GetScoresFor("3", _kicker.PlayerCode);
            var dt = ds.Tables["score"];
            if (dt.Rows.Count > 0)
            {
               string lastGameCode = string.Format("{0}{1}{2}", dt.Rows[0]["SEASON"],
                                                   dt.Rows[0]["WEEK"], dt.Rows[0]["GAMENO"]);

               foreach (DataRow dr in dt.Rows)
               {
                  //  for each score in the game

                  string gameWeek = string.Format("{0}{1}", dr["SEASON"], dr["WEEK"]);

                  gameCode = gameWeek + dr["GAMENO"];

                  if (gameCode != lastGameCode)
                  {
                     //  Add the result to the kickers list
                     SeasonOpposition so = GetLastOpp(lastGameCode, fgCount);
                     _fgResultList.Add(new FieldGoalResult(gameCode, so));
                     fgCount = 0;
                     lastGameCode = gameCode;
                  }
                  fgCount++;
                  if (string.Compare(gameWeek, loWeek) < 0) loWeek = gameWeek;
                  if (string.Compare(gameWeek, hiWeek) > 0) hiWeek = gameWeek;
               }
               _fgResultList.Add(new FieldGoalResult(gameCode, GetLastOpp(lastGameCode, fgCount)));
               //  How many weeks in the range
               _kicker.SetHiWeek(hiWeek);
               _kicker.SetLoWeek(loWeek);

               int nRange = WeekRange(loWeek, hiWeek);

               //  Add goose eggs for the difference
               int diff = nRange - _fgResultList.Count;
               var soDud = new SeasonOpposition("   ", false, 0);
               for (int i = 1; i < diff; i++)
                  _fgResultList.Add(new FieldGoalResult(loWeek, soDud));
            }
             }
        }