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;
     }
 }
        public IScoreCardInfo(int numHoles)
        {
            holes = new IHoleDetailInfos();
            IHoleDetailInfo h;

            for (int k = 0; k < numHoles; k++)
            {
                h            = new IHoleDetailInfo();
                h.TotalShots = 0;
                h.Hole       = k + 1;
                h.Putts      = 0;
                holes.Add(h);
            }

            mDate = DateTime.Now;
        }
        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);
        }
 // ----- add method ------
 public void Add(IHoleDetailInfo hole)
 {
     mCol.Add(hole.ToString(), hole);
     mCol.TrimToSize();
 }
        public HoleDetail(ref ICourseInfo ThisCourse, ref IHoleDetailInfo hole)
        {
            InitializeComponent();

            //Dont forget to initailize tab order and speedkeys, etc
            this.BackColor      = Color.LightGreen;
            cmdSave.BackColor   = Color.SandyBrown;
            cmdCancel.BackColor = Color.SandyBrown;

            mHole          = hole;
            lblCourse.Text = ThisCourse.Name;
            foreach (Tees tee in ThisCourse.Hole)
            {
                if (tee.HoleNumber == mHole.Hole)
                {
                    distance = tee;
                    break;
                }
            }

            lblHole.Text = "Hole: " + mHole.Hole.ToString();
            lblPar.Text  = "Par: " + mHole.Par.ToString();

            optBlue.CheckedChanged  += new EventHandler(this.YardClick);
            optWhite.CheckedChanged += new EventHandler(this.YardClick);
            optRed.CheckedChanged   += new EventHandler(this.YardClick);
            switch (hole.TeeBox)
            {
            case YardMarker.Blue:
                optBlue.Checked = true;
                TeeBox          = YardMarker.Blue;
                break;

            case YardMarker.Red:
                optRed.Checked = true;
                TeeBox         = YardMarker.Red;
                break;

            case YardMarker.White:
            default:
                optWhite.Checked = true;
                TeeBox           = YardMarker.White;
                break;
            }

            //This is how you enumerate an enumeration
            //Bet you didn't know you could do this.
            GolfClubs G = GolfClubs.One_iron;

            while (G <= GolfClubs.Putter)
            {
                cmbFirstClub.Items.Add(G);
                if (mHole.TeeClub == G)
                {
                    cmbFirstClub.SelectedIndex = cmbFirstClub.Items.Count - 1;
                }

                cmbSecondClub.Items.Add(G);
                if (mHole.ScondClub == G)
                {
                    cmbSecondClub.SelectedIndex = cmbSecondClub.Items.Count - 1;
                }

                G++;
            }

            cmdSave.DialogResult   = DialogResult.OK;
            cmdCancel.DialogResult = DialogResult.Cancel;
            cmdSave.Click         += new EventHandler(SaveHole);

            chkFairway.Checked       = hole.HitFairway;
            chkGoodHit.Checked       = hole.GoodSecondShot;
            txtShots2Green.MaxLength = 3;
            txtShots2Green.Text      = hole.ShotsToGreen.ToString();
            txtShots2Green.KeyPress += new KeyPressEventHandler(OnlyNumbers);
            txtPutts.MaxLength       = 3;
            txtPutts.Text            = hole.Putts.ToString();
            txtPutts.KeyPress       += new KeyPressEventHandler(OnlyNumbers);
            txtTotal.MaxLength       = 3;
            txtTotal.Text            = hole.TotalShots.ToString();
            txtTotal.KeyPress       += new KeyPressEventHandler(OnlyNumbers);

            //Consider adding a databinding or validation to the totals
            //text box so it automatically totals the shots2green and putts TextBoxes.
        }