private void CellChanged(object sender, EventArgs e)
 {
     try
     {
         ThisCard = ThisCourse.ScoreCards.Item(dg1.CurrentCell.RowNumber);
         ThisHole = ThisCard.holes.Item(dg1.CurrentCell.ColumnNumber - 2);
     }
     catch
     {
         ThisCard = null;
         ThisHole = null;
     }
 }
        private void GetGolfCourses()
        {
            //Go out to the database and get the golf course info here
            ICourseInfo course = new ICourseInfo();

            course.NumberOfHoles = 9;
            course.Name          = "My Back Yard";
            course.Par           = CoursePar._35;
            course.Slope         = 127;

            Tees tee;

            for (int k = 0; k < course.Hole.Count; k++)
            {
                tee = (Tees)course.Hole[k];
                tee.BlueDistance  = 450;
                tee.WhiteDistance = 430;
                tee.RedDistance   = 400;
                tee.Par           = k < 5 ? 4 : 5;
                tee.HoleNumber    = k + 1;
            }

            IScoreCardInfo card = new IScoreCardInfo();

            card.PlayDate = DateTime.Now;

            IHoleDetailInfo detail;

            for (int k = 0; k < course.NumberOfHoles; k++)
            {
                detail                = new IHoleDetailInfo();
                detail.Hole           = k + 1;
                detail.TeeClub        = GolfClubs.Driver;
                detail.HitFairway     = true;
                detail.ScondClub      = GolfClubs.Nine_wood;
                detail.GoodSecondShot = true;
                detail.ShotsToGreen   = 2;
                detail.Putts          = 2;
                detail.TotalShots     = 4;
                detail.Par            = ((Tees)course.Hole[k]).Par;
                detail.TeeBox         = YardMarker.White;
                card.holes.Add(detail);
            }
            course.ScoreCards.Add(card);

            GolfCourses.Add(course);
        }
        private void CourseStats(object s, TreeViewEventArgs e)
        {
            float FairwaysHit = 0;
            float GreensInReg = 0;
            float Putting     = 0;
            float MaxPutts    = 0;
            float MinPutts    = 99;
            float AvgPutts    = 0;

            if (e.Node.Tag is IScoreCardInfo)
            {
                ThisCard = (IScoreCardInfo)e.Node.Tag;
                foreach (IHoleDetailInfo h in ThisCard.holes)
                {
                    FairwaysHit += h.HitFairway ? 1 : 0;
                    GreensInReg += h.GreenInReg ? 1 : 0;
                    Putting     += h.Putts;
                    if (h.Putts > MaxPutts)
                    {
                        MaxPutts = h.Putts;
                    }
                    if (h.Putts < MinPutts)
                    {
                        MinPutts = h.Putts;
                    }
                    AvgPutts += h.Putts;
                }
                FairwaysHit /= ThisCard.holes.Count;
                Putting     /= (ThisCard.holes.Count * 2);
                GreensInReg /= ThisCard.holes.Count;
                AvgPutts    /= ThisCard.holes.Count;

                lblFairwaysHit.Text = (FairwaysHit * 100).ToString();
                lblGreens.Text      = (GreensInReg * 100).ToString();
                lblPutting.Text     = (Putting * 100).ToString();
                lblMaxPutts.Text    = MaxPutts.ToString();
                lblAvgPutts.Text    = AvgPutts.ToString();
                lblMinPutts.Text    = MinPutts.ToString();

                //I will let you figure out the rest of the stats. :)
            }
        }
        private void NewCard(object sender, EventArgs e)
        {
            IScoreCardInfo card = new IScoreCardInfo(ThisCourse.NumberOfHoles);

            ThisCourse.ScoreCards.Add(card);

            ArrayList scores = new ArrayList();

            scores.Add(card.PlayDate.ToShortDateString());
            scores.Add(card.RoundScore);
            foreach (IHoleDetailInfo h in card.holes)
            {
                h.Par = ((Tees)ThisCourse.Hole[h.Hole - 1]).Par;
                scores.Add(h.TotalShots);
            }

            DataSet   ds = (DataSet)dg1.DataSource;
            DataTable DT = ds.Tables[dg1.DataMember];

            DT.Rows.Add(scores.ToArray());
        }
 // ----- add method ------
 public void Add(IScoreCardInfo ScoreCard)
 {
     mCol.Add(ScoreCard.PlayDate, ScoreCard);
 }