// This sample shows the Entry form functionality of the Racetracker

// race management application. It is written in C#.NET

// with data stored in an XML file.

 

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using System.Data.OleDb;

using System.IO;

using System.Xml;

 

namespace RacetrackerCS

{

      /// <summary>

      /// Summary description for Form1.

      /// </summary>

      public class frmRacetracker : System.Windows.Forms.Form

      {

            private System.Windows.Forms.TabControl tabControl1;

            private System.Windows.Forms.TabPage tabPage2;

            private System.Windows.Forms.TabPage tabPage3;

            private System.Windows.Forms.TabPage tabPage4;

            private System.Windows.Forms.TabPage tabPage1;

            private System.Windows.Forms.Button btnSave;

            private System.Windows.Forms.Button btnAdd;

            private System.Windows.Forms.Button button1;

            private System.Windows.Forms.Label lblPosition;

            private System.Windows.Forms.Button btnLast;

            private System.Windows.Forms.Button btnNext;

            private System.Windows.Forms.Button btnPrev;

            private System.Windows.Forms.Button btnFirst;

            private System.Windows.Forms.Label label11;

            private System.Windows.Forms.ComboBox cboClass;

            private System.Windows.Forms.Label label12;

            private System.Windows.Forms.ComboBox cboGender;

            private System.Windows.Forms.TextBox txtZip;

            private System.Windows.Forms.Label label10;

            private System.Windows.Forms.TextBox txtEmail;

            private System.Windows.Forms.Label label9;

            private System.Windows.Forms.TextBox txtState;

            private System.Windows.Forms.Label label8;

            private System.Windows.Forms.TextBox txtLName;

            private System.Windows.Forms.Label label7;

            private System.Windows.Forms.Label label6;

            private System.Windows.Forms.TextBox txtBirthdate;

            private System.Windows.Forms.Label label5;

            private System.Windows.Forms.TextBox txtPhone;

            private System.Windows.Forms.Label label4;

            private System.Windows.Forms.TextBox txtCity;

            private System.Windows.Forms.Label label3;

            private System.Windows.Forms.TextBox txtAddress;

            private System.Windows.Forms.Label label2;

            private System.Windows.Forms.TextBox txtFName;

            private System.Windows.Forms.Label label1;

            private System.Windows.Forms.TextBox txtBibNumber;

            private System.Windows.Forms.Label label13;

            private System.Windows.Forms.TextBox txtID;

 

            private DataSet dsEntries = new DataSet();

            private BindingManagerBase bmb;

            private Boolean booNewRow = false;

 

            /// <summary>

            /// Required designer variable.

            /// </summary>

            private System.ComponentModel.Container components = null;

 

            public frmRacetracker()

            {

                  //

                  // Required for Windows Form Designer support

                  //

                  InitializeComponent();

 

                  //

                  // TODO: Add any constructor code after InitializeComponent call

                  //

 

                  // Populate the Class combo box.

                  DataSet dsRunClasses = new DataSet();

                  dsRunClasses.ReadXml(Directory.GetCurrentDirectory() + "\\_ClassRun.xml");

                  cboClass.DataSource = dsRunClasses;

                  cboClass.DisplayMember = "_ClassRun.Class";

                  cboClass.ValueMember = "_ClassRun.Class";

 

                  // Bind the controls to the Entry table fields.

                  dsEntries.ReadXml(Directory.GetCurrentDirectory() + "\\Entry.xml");

                  txtFName.DataBindings.Add("Text", dsEntries, "Entry.FirstName");

                  txtLName.DataBindings.Add("Text", dsEntries, "Entry.LastName");

 

                  txtAddress.DataBindings.Add("Text", dsEntries, "Entry.Address");

                  txtCity.DataBindings.Add("Text", dsEntries, "Entry.City");

                  txtState.DataBindings.Add("Text", dsEntries, "Entry.State");

                  txtZip.DataBindings.Add("Text", dsEntries, "Entry.Zip");

                  txtPhone.DataBindings.Add("Text", dsEntries, "Entry.Phone");

                  txtEmail.DataBindings.Add("Text", dsEntries, "Entry.Email");

                  txtBirthdate.DataBindings.Add("Text", dsEntries, "Entry.Birthdate");

                  cboGender.DataBindings.Add("Text", dsEntries, "Entry.Gender");

                  cboClass.DataBindings.Add("Text", dsEntries, "Entry.Class");

                  txtBibNumber.DataBindings.Add("Text", dsEntries, "Entry.BibNum");

                  txtID.DataBindings.Add("Text", dsEntries, "Entry.RaceKey");

 

                  bmb = this.BindingContext[dsEntries, "Entry"];

                  bmb.PositionChanged += new EventHandler(BindingManagerBase_PositionChanged);

                  bmb.Position = 0;

 

                  lblPosition.Text = String.Format("{0} of {1}", bmb.Position + 1, bmb.Count);

 

            }

 

            /// <summary>

            /// Clean up any resources being used.

            /// </summary>

            protected override void Dispose( bool disposing )

            {

                  if( disposing )

                  {

                        if (components != null)

                        {

                              components.Dispose();

                        }

                  }

                  base.Dispose( disposing );

            }

 

            #region Windows Form Designer generated code

            /// <summary>

            /// Required method for Designer support - do not modify

            /// the contents of this method with the code editor.

            /// </summary>

            private void InitializeComponent()

            {

                  this.tabControl1 = new System.Windows.Forms.TabControl();

                  this.tabPage1 = new System.Windows.Forms.TabPage();

                  this.txtID = new System.Windows.Forms.TextBox();

                  this.label13 = new System.Windows.Forms.Label();

                  this.btnSave = new System.Windows.Forms.Button();

                  this.btnAdd = new System.Windows.Forms.Button();

                  this.button1 = new System.Windows.Forms.Button();

                  this.lblPosition = new System.Windows.Forms.Label();

                  this.btnLast = new System.Windows.Forms.Button();

                  this.btnNext = new System.Windows.Forms.Button();

                  this.btnPrev = new System.Windows.Forms.Button();

                  this.btnFirst = new System.Windows.Forms.Button();

                  this.label11 = new System.Windows.Forms.Label();

                  this.cboClass = new System.Windows.Forms.ComboBox();

                  this.label12 = new System.Windows.Forms.Label();

                  this.cboGender = new System.Windows.Forms.ComboBox();

                  this.txtZip = new System.Windows.Forms.TextBox();

                  this.txtEmail = new System.Windows.Forms.TextBox();

                  this.txtState = new System.Windows.Forms.TextBox();

                  this.txtLName = new System.Windows.Forms.TextBox();

                  this.txtBibNumber = new System.Windows.Forms.TextBox();

                  this.txtBirthdate = new System.Windows.Forms.TextBox();

                  this.txtPhone = new System.Windows.Forms.TextBox();

                  this.txtCity = new System.Windows.Forms.TextBox();

                  this.txtAddress = new System.Windows.Forms.TextBox();

                  this.txtFName = new System.Windows.Forms.TextBox();

                  this.label10 = new System.Windows.Forms.Label();

                  this.label9 = new System.Windows.Forms.Label();

                  this.label8 = new System.Windows.Forms.Label();

                  this.label7 = new System.Windows.Forms.Label();

                  this.label6 = new System.Windows.Forms.Label();

                  this.label5 = new System.Windows.Forms.Label();

                  this.label4 = new System.Windows.Forms.Label();

                  this.label3 = new System.Windows.Forms.Label();

                  this.label2 = new System.Windows.Forms.Label();

                  this.label1 = new System.Windows.Forms.Label();

                  this.tabPage2 = new System.Windows.Forms.TabPage();

                  this.tabPage3 = new System.Windows.Forms.TabPage();

                  this.tabPage4 = new System.Windows.Forms.TabPage();

                  this.tabControl1.SuspendLayout();

                  this.tabPage1.SuspendLayout();

                  this.SuspendLayout();

                  //

                  // tabControl1

                  //

                  this.tabControl1.Controls.Add(this.tabPage1);

                  this.tabControl1.Controls.Add(this.tabPage2);

                  this.tabControl1.Controls.Add(this.tabPage3);

                  this.tabControl1.Controls.Add(this.tabPage4);

                  this.tabControl1.Location = new System.Drawing.Point(24, 16);

                  this.tabControl1.Name = "tabControl1";

                  this.tabControl1.SelectedIndex = 0;

                  this.tabControl1.Size = new System.Drawing.Size(488, 256);

                  this.tabControl1.TabIndex = 0;

                  //

                  // tabPage1

                  //

                  this.tabPage1.Controls.Add(this.txtID);

                  this.tabPage1.Controls.Add(this.label13);

                  this.tabPage1.Controls.Add(this.btnSave);

                  this.tabPage1.Controls.Add(this.btnAdd);

                  this.tabPage1.Controls.Add(this.button1);

                  this.tabPage1.Controls.Add(this.lblPosition);

                  this.tabPage1.Controls.Add(this.btnLast);

                  this.tabPage1.Controls.Add(this.btnNext);

                  this.tabPage1.Controls.Add(this.btnPrev);

                  this.tabPage1.Controls.Add(this.btnFirst);

                  this.tabPage1.Controls.Add(this.label11);

                  this.tabPage1.Controls.Add(this.cboClass);

                  this.tabPage1.Controls.Add(this.label12);

                  this.tabPage1.Controls.Add(this.cboGender);

                  this.tabPage1.Controls.Add(this.txtZip);

                  this.tabPage1.Controls.Add(this.txtEmail);

                  this.tabPage1.Controls.Add(this.txtState);

                  this.tabPage1.Controls.Add(this.txtLName);

                  this.tabPage1.Controls.Add(this.txtBibNumber);

                  this.tabPage1.Controls.Add(this.txtBirthdate);

                  this.tabPage1.Controls.Add(this.txtPhone);

                  this.tabPage1.Controls.Add(this.txtCity);

                  this.tabPage1.Controls.Add(this.txtAddress);

                  this.tabPage1.Controls.Add(this.txtFName);

                  this.tabPage1.Controls.Add(this.label10);

                  this.tabPage1.Controls.Add(this.label9);

                  this.tabPage1.Controls.Add(this.label8);

                  this.tabPage1.Controls.Add(this.label7);

                  this.tabPage1.Controls.Add(this.label6);

                  this.tabPage1.Controls.Add(this.label5);

                  this.tabPage1.Controls.Add(this.label4);

                  this.tabPage1.Controls.Add(this.label3);

                  this.tabPage1.Controls.Add(this.label2);

                  this.tabPage1.Controls.Add(this.label1);

                  this.tabPage1.Location = new System.Drawing.Point(4, 22);

                  this.tabPage1.Name = "tabPage1";

                  this.tabPage1.Size = new System.Drawing.Size(480, 230);

                  this.tabPage1.TabIndex = 3;

                  this.tabPage1.Text = "Enter Racers";

                  this.tabPage1.Click += new System.EventHandler(this.tabPage4_Click);

                  //

                  // txtID

                  //

                  this.txtID.BackColor = System.Drawing.SystemColors.Control;

                  this.txtID.BorderStyle = System.Windows.Forms.BorderStyle.None;

                  this.txtID.Enabled = false;

                  this.txtID.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.txtID.Location = new System.Drawing.Point(416, 136);

                  this.txtID.Name = "txtID";

                  this.txtID.Size = new System.Drawing.Size(48, 13);

                  this.txtID.TabIndex = 63;

                  this.txtID.Text = "";

                  this.txtID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;

                  //

                  // label13

                  //

                  this.label13.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label13.Location = new System.Drawing.Point(376, 136);

                  this.label13.Name = "label13";

                  this.label13.Size = new System.Drawing.Size(32, 23);

                  this.label13.TabIndex = 62;

                  this.label13.Text = "ID:";

                  this.label13.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // btnSave

                  //

                  this.btnSave.Font = new System.Drawing.Font("Comic Sans MS", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.btnSave.Location = new System.Drawing.Point(408, 160);

                  this.btnSave.Name = "btnSave";

                  this.btnSave.Size = new System.Drawing.Size(56, 24);

                  this.btnSave.TabIndex = 61;

                  this.btnSave.Text = "Save";

                  this.btnSave.Click += new System.EventHandler(this.btnSave_Click);

                  //

                  // btnAdd

                  //

                  this.btnAdd.Font = new System.Drawing.Font("Comic Sans MS", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.btnAdd.Location = new System.Drawing.Point(352, 160);

                  this.btnAdd.Name = "btnAdd";

                  this.btnAdd.Size = new System.Drawing.Size(56, 24);

                  this.btnAdd.TabIndex = 60;

                  this.btnAdd.Text = "Add";

                  this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);

                  //

                  // button1

                  //

                  this.button1.Font = new System.Drawing.Font("Comic Sans MS", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.button1.Location = new System.Drawing.Point(296, 160);

                  this.button1.Name = "button1";

                  this.button1.Size = new System.Drawing.Size(56, 24);

                  this.button1.TabIndex = 59;

                  this.button1.Text = "Delete";

                  this.button1.Click += new System.EventHandler(this.button1_Click);

                  //

                  // lblPosition

                  //

                  this.lblPosition.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

                  this.lblPosition.Location = new System.Drawing.Point(160, 160);

                  this.lblPosition.Name = "lblPosition";

                  this.lblPosition.Size = new System.Drawing.Size(80, 23);

                  this.lblPosition.TabIndex = 58;

                  this.lblPosition.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

                  //

                  // btnLast

                  //

                  this.btnLast.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.btnLast.Location = new System.Drawing.Point(264, 160);

                  this.btnLast.Name = "btnLast";

                  this.btnLast.Size = new System.Drawing.Size(24, 24);

                  this.btnLast.TabIndex = 57;

                  this.btnLast.Text = ">|";

                  this.btnLast.Click += new System.EventHandler(this.btnLast_Click);

                  //

                  // btnNext

                  //

                  this.btnNext.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.btnNext.Location = new System.Drawing.Point(240, 160);

                  this.btnNext.Name = "btnNext";

                  this.btnNext.Size = new System.Drawing.Size(24, 24);

                  this.btnNext.TabIndex = 56;

                  this.btnNext.Text = ">";

                  this.btnNext.Click += new System.EventHandler(this.btnNext_Click);

                  //

                  // btnPrev

                  //

                  this.btnPrev.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.btnPrev.Location = new System.Drawing.Point(136, 160);

                  this.btnPrev.Name = "btnPrev";

                  this.btnPrev.Size = new System.Drawing.Size(24, 24);

                  this.btnPrev.TabIndex = 55;

                  this.btnPrev.Text = "<";

                  this.btnPrev.Click += new System.EventHandler(this.btnPrev_Click);

                  //

                  // btnFirst

                  //

                  this.btnFirst.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.btnFirst.Location = new System.Drawing.Point(112, 160);

                  this.btnFirst.Name = "btnFirst";

                  this.btnFirst.Size = new System.Drawing.Size(24, 24);

                  this.btnFirst.TabIndex = 54;

                  this.btnFirst.Text = "|<";

                  this.btnFirst.Click += new System.EventHandler(this.btnFirst_Click);

                  //

                  // label11

                  //

                  this.label11.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label11.Location = new System.Drawing.Point(304, 112);

                  this.label11.Name = "label11";

                  this.label11.Size = new System.Drawing.Size(40, 23);

                  this.label11.TabIndex = 53;

                  this.label11.Text = "Class:";

                  this.label11.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // cboClass

                  //

                  this.cboClass.ItemHeight = 13;

                  this.cboClass.Location = new System.Drawing.Point(344, 112);

                  this.cboClass.Name = "cboClass";

                  this.cboClass.Size = new System.Drawing.Size(120, 21);

                  this.cboClass.TabIndex = 52;

                  this.cboClass.SelectedIndexChanged += new System.EventHandler(this.cboClass_SelectedIndexChanged);

                  //

                  // label12

                  //

                  this.label12.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label12.Location = new System.Drawing.Point(184, 112);

                  this.label12.Name = "label12";

                  this.label12.Size = new System.Drawing.Size(58, 23);

                  this.label12.TabIndex = 51;

                  this.label12.Text = "Gender:";

                  this.label12.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // cboGender

                  //

                  this.cboGender.ItemHeight = 13;

                  this.cboGender.Location = new System.Drawing.Point(240, 112);

                  this.cboGender.Name = "cboGender";

                  this.cboGender.Size = new System.Drawing.Size(64, 21);

                  this.cboGender.TabIndex = 50;

                  //

                  // txtZip

                  //

                  this.txtZip.Location = new System.Drawing.Point(368, 64);

                  this.txtZip.Name = "txtZip";

                  this.txtZip.Size = new System.Drawing.Size(96, 20);

                  this.txtZip.TabIndex = 49;

                  this.txtZip.Text = "";

                  //

                  // txtEmail

                  //

                  this.txtEmail.Location = new System.Drawing.Point(248, 88);

                  this.txtEmail.Name = "txtEmail";

                  this.txtEmail.Size = new System.Drawing.Size(216, 20);

                  this.txtEmail.TabIndex = 47;

                  this.txtEmail.Text = "";

                  //

                  // txtState

                  //

                  this.txtState.Location = new System.Drawing.Point(288, 64);

                  this.txtState.Name = "txtState";

                  this.txtState.Size = new System.Drawing.Size(40, 20);

                  this.txtState.TabIndex = 45;

                  this.txtState.Text = "";

                  //

                  // txtLName

                  //

                  this.txtLName.Location = new System.Drawing.Point(312, 16);

                  this.txtLName.Name = "txtLName";

                  this.txtLName.Size = new System.Drawing.Size(152, 20);

                  this.txtLName.TabIndex = 43;

                  this.txtLName.Text = "";

                  //

                  // txtBibNumber

                  //

                  this.txtBibNumber.Location = new System.Drawing.Point(112, 136);

                  this.txtBibNumber.Name = "txtBibNumber";

                  this.txtBibNumber.Size = new System.Drawing.Size(48, 20);

                  this.txtBibNumber.TabIndex = 41;

                  this.txtBibNumber.Text = "";

                  //

                  // txtBirthdate

                  //

                  this.txtBirthdate.Location = new System.Drawing.Point(112, 112);

                  this.txtBirthdate.Name = "txtBirthdate";

                  this.txtBirthdate.Size = new System.Drawing.Size(80, 20);

                  this.txtBirthdate.TabIndex = 39;

                  this.txtBirthdate.Text = "";

                  //

                  // txtPhone

                  //

                  this.txtPhone.Location = new System.Drawing.Point(112, 88);

                  this.txtPhone.Name = "txtPhone";

                  this.txtPhone.Size = new System.Drawing.Size(80, 20);

                  this.txtPhone.TabIndex = 37;

                  this.txtPhone.Text = "";

                  //

                  // txtCity

                  //

                  this.txtCity.Location = new System.Drawing.Point(112, 64);

                  this.txtCity.Name = "txtCity";

                  this.txtCity.Size = new System.Drawing.Size(128, 20);

                  this.txtCity.TabIndex = 35;

                  this.txtCity.Text = "";

                  //

                  // txtAddress

                  //

                  this.txtAddress.Location = new System.Drawing.Point(112, 40);

                  this.txtAddress.Name = "txtAddress";

                  this.txtAddress.Size = new System.Drawing.Size(352, 20);

                  this.txtAddress.TabIndex = 33;

                  this.txtAddress.Text = "";

                  //

                  // txtFName

                  //

                  this.txtFName.Location = new System.Drawing.Point(112, 16);

                  this.txtFName.Name = "txtFName";

                  this.txtFName.Size = new System.Drawing.Size(112, 20);

                  this.txtFName.TabIndex = 31;

                  this.txtFName.Text = "";

                  //

                  // label10

                  //

                  this.label10.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label10.Location = new System.Drawing.Point(336, 64);

                  this.label10.Name = "label10";

                  this.label10.Size = new System.Drawing.Size(32, 23);

                  this.label10.TabIndex = 48;

                  this.label10.Text = "Zip:";

                  this.label10.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label9

                  //

                  this.label9.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label9.Location = new System.Drawing.Point(200, 88);

                  this.label9.Name = "label9";

                  this.label9.Size = new System.Drawing.Size(40, 23);

                  this.label9.TabIndex = 46;

                  this.label9.Text = "Email:";

                  this.label9.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label8

                  //

                  this.label8.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label8.Location = new System.Drawing.Point(240, 64);

                  this.label8.Name = "label8";

                  this.label8.Size = new System.Drawing.Size(48, 23);

                  this.label8.TabIndex = 44;

                  this.label8.Text = "State:";

                  this.label8.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label7

                  //

                  this.label7.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label7.Location = new System.Drawing.Point(232, 16);

                  this.label7.Name = "label7";

                  this.label7.Size = new System.Drawing.Size(80, 23);

                  this.label7.TabIndex = 42;

                  this.label7.Text = "Last Name:";

                  this.label7.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label6

                  //

                  this.label6.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label6.Location = new System.Drawing.Point(8, 136);

                  this.label6.Name = "label6";

                  this.label6.TabIndex = 40;

                  this.label6.Text = "Bib Number:";

                  this.label6.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label5

                  //

                  this.label5.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label5.Location = new System.Drawing.Point(8, 112);

                  this.label5.Name = "label5";

                  this.label5.TabIndex = 38;

                  this.label5.Text = "Birthdate:";

                  this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label4

                  //

                  this.label4.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label4.Location = new System.Drawing.Point(8, 88);

                  this.label4.Name = "label4";

                  this.label4.TabIndex = 36;

                  this.label4.Text = "Phone:";

                  this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label3

                  //

                  this.label3.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label3.Location = new System.Drawing.Point(8, 64);

                  this.label3.Name = "label3";

                  this.label3.TabIndex = 34;

                  this.label3.Text = "City:";

                  this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label2

                  //

                  this.label2.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label2.Location = new System.Drawing.Point(8, 40);

                  this.label2.Name = "label2";

                  this.label2.TabIndex = 32;

                  this.label2.Text = "Address:";

                  this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // label1

                  //

                  this.label1.Font = new System.Drawing.Font("Comic Sans MS", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

                  this.label1.Location = new System.Drawing.Point(8, 16);

                  this.label1.Name = "label1";

                  this.label1.TabIndex = 30;

                  this.label1.Text = "First Name:";

                  this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;

                  //

                  // tabPage2

                  //

                  this.tabPage2.Location = new System.Drawing.Point(4, 22);

                  this.tabPage2.Name = "tabPage2";

                  this.tabPage2.Size = new System.Drawing.Size(480, 230);

                  this.tabPage2.TabIndex = 0;

                  this.tabPage2.Text = "Set Start Times";

                  //

                  // tabPage3

                  //

                  this.tabPage3.Location = new System.Drawing.Point(4, 22);

                  this.tabPage3.Name = "tabPage3";

                  this.tabPage3.Size = new System.Drawing.Size(480, 230);

                  this.tabPage3.TabIndex = 1;

                  this.tabPage3.Text = "Enter Finish Times";

                  //

                  // tabPage4

                  //

                  this.tabPage4.Location = new System.Drawing.Point(4, 22);

                  this.tabPage4.Name = "tabPage4";

                  this.tabPage4.Size = new System.Drawing.Size(480, 230);

                  this.tabPage4.TabIndex = 2;

                  this.tabPage4.Text = "See Results";

                  //

                  // frmRacetracker

                  //

                  this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

                  this.ClientSize = new System.Drawing.Size(528, 322);

                  this.Controls.Add(this.tabControl1);

                  this.Name = "frmRacetracker";

                  this.Text = "Racetracker";

                  this.Load += new System.EventHandler(this.frmRacetracker_Load);

                  this.tabControl1.ResumeLayout(false);

                  this.tabPage1.ResumeLayout(false);

                  this.ResumeLayout(false);

 

            }

            #endregion

 

            /// <summary>

            /// The main entry point for the application.

            /// </summary>

            [STAThread]

            static void Main()

            {

                  Application.Run(new frmRacetracker());

 

            }

 

            private void frmRacetracker_Load(object sender, System.EventArgs e)

            {

           

            }

 

            private void textBox7_TextChanged(object sender, System.EventArgs e)

            {

           

            }

 

            private void tabPage4_Click(object sender, System.EventArgs e)

            {

           

            }

 

            private void cboClass_SelectedIndexChanged(object sender, System.EventArgs e)

            {

           

            }

 

            private void btnFirst_Click(object sender, System.EventArgs e)

            {

                  bmb.Position = 0;

            }

 

            private void btnPrev_Click(object sender, System.EventArgs e)

            {

                  bmb.Position--;

            }

 

            private void btnNext_Click(object sender, System.EventArgs e)

            {

                  bmb.Position++;

            }

 

            private void btnLast_Click(object sender, System.EventArgs e)

            {

                  bmb.Position = bmb.Count - 1;

            }

 

            private void BindingManagerBase_PositionChanged(object sender, EventArgs e)

            {

                  // Format birthdate and update position label when moving between records.

                  txtBirthdate.Text = DateTime.Parse(txtBirthdate.Text).ToString("d");

                  lblPosition.Text = String.Format("{0} of {1}", bmb.Position + 1, bmb.Count);

            }

 

            private void btnSave_Click(object sender, System.EventArgs e)

            {

 

                  int intPosition = bmb.Position;

 

                  // If this is a new entry (Add button clicked), add a new row.

                  // Otherwise, save the current row.

 

                  if (booNewRow)

                  {

                        booNewRow = false;

     

                        DataRow drNewRow = dsEntries.Tables["Entry"].NewRow();

                        //DataRow dr;

                        int intCurKey;

                        int intNewKey = 0;

     

                        // Save the current form values.

                        string strFName = txtFName.Text;

                        string strLName = txtLName.Text;

                        string strAddress = txtAddress.Text;

                        string strCity = txtCity.Text;

                        string strState = txtState.Text;

                        string strZip = txtZip.Text;

                        string strPhone = txtPhone.Text;

                        string strEmail = txtEmail.Text;

                        string strBirthdate = txtBirthdate.Text;

                        string strGender = cboGender.Text;

                        string strClass = cboClass.Text;

                        string strBibNum = txtBibNumber.Text;

     

                        // Get new key.

                        foreach (DataRow dr in dsEntries.Tables["Entry"].Rows)

                        {

                              intCurKey = int.Parse(dr["RaceKey"].ToString());

                            if (intCurKey > intNewKey)

                                intNewKey = intCurKey;

                        }

                        intNewKey++;

                       

                        // Populate and add the new data row.

                        drNewRow["FirstName"] = strFName;

                        drNewRow["LastName"] = strLName;

                        drNewRow["RaceKey"] = intNewKey;

                        drNewRow["Address"] = strAddress;

                        drNewRow["City"] = strCity;

                        drNewRow["State"] = strState;

                        drNewRow["Zip"] = strZip;

                        drNewRow["Phone"] = strPhone;

                        drNewRow["Email"] = strEmail;

                        if (txtBirthdate.Text == "")

                            drNewRow["Birthdate"] = DBNull.Value;

                        else

                            drNewRow["Birthdate"] = DateTime.Parse(strBirthdate);

                        drNewRow["Gender"] = strGender;

                        drNewRow["Class"] = strClass;

                        if (txtBibNumber.Text == "")

                            drNewRow["BibNum"] = DBNull.Value;

                        else

                            drNewRow["BibNum"] = int.Parse(strBibNum);

                        dsEntries.Tables["Entry"].Rows.Add(drNewRow);

 

                        // Update the .xml file.   

                        try

                        {

                              XmlDocument xmldoc = new XmlDocument();

                              xmldoc.Load(Directory.GetCurrentDirectory() + "\\Entry.xml");

                              XmlElement xmlEl = xmldoc.CreateElement("Entry");

                              xmldoc.DocumentElement.AppendChild(xmlEl);

     

                              XmlElement xmlChildEl;

     

                              xmlChildEl = xmldoc.CreateElement("RaceKey");

                              XmlText xmlText = xmldoc.CreateTextNode(intNewKey.ToString());

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("FirstName");

                              xmlText = xmldoc.CreateTextNode(strFName);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("LastName");

                              xmlText = xmldoc.CreateTextNode(strLName);

                              xmlChildEl.AppendChild(xmlText);;

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("Address");

                              xmlText = xmldoc.CreateTextNode(strAddress);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("City");

                              xmlText = xmldoc.CreateTextNode(strCity);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("State");

                              xmlText = xmldoc.CreateTextNode(strState);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("Zip");

                              xmlText = xmldoc.CreateTextNode(strZip);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("Phone");

                              xmlText = xmldoc.CreateTextNode(strPhone);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("Email");

                              xmlText = xmldoc.CreateTextNode(strEmail);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("Birthdate");

                              xmlText = xmldoc.CreateTextNode(strBirthdate);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("Gender");

                              xmlText = xmldoc.CreateTextNode(strGender);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("Class");

                              xmlText = xmldoc.CreateTextNode(strClass);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmlChildEl = xmldoc.CreateElement("BibNum");

                              xmlText = xmldoc.CreateTextNode(strBibNum);

                              xmlChildEl.AppendChild(xmlText);

                              xmlEl.AppendChild(xmlChildEl);

     

                              xmldoc.Save(Directory.GetCurrentDirectory() + "\\Entry.xml");

                        }

                        catch (Exception ex)

                        {

                              MessageBox.Show(ex.Message);

                        }

     

                        // Refresh the data set.

                        dsEntries.Clear();

                        dsEntries.ReadXml(Directory.GetCurrentDirectory() + "\\Entry.xml");

     

                        // Go to the new record.

                        bmb.Position = bmb.Count - 1;

 

                        lblPosition.Text = String.Format("{0} of {1}", bmb.Position + 1, bmb.Count);

                  }

                  else

                  {

                        // Save combo box values.

                        string strGender = cboGender.Text;

                        string strClass = cboClass.Text;

 

                        // Force a refresh.

                        bmb.Position = intPosition;

 

                        dsEntries.Tables["Entry"].Rows[intPosition]["FirstName"] = txtFName.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["LastName"] = txtLName.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["Address"] = txtAddress.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["City"] = txtCity.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["State"] = txtState.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["Zip"] = txtZip.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["Phone"] = txtPhone.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["Email"] = txtEmail.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["Birthdate"] = txtBirthdate.Text;

                        dsEntries.Tables["Entry"].Rows[intPosition]["Gender"] = strGender;

                        dsEntries.Tables["Entry"].Rows[intPosition]["Class"] = strClass;

                        dsEntries.Tables["Entry"].Rows[intPosition]["BibNum"] = txtBibNumber.Text;

 

                        // Update the .xml file.   

                        try

                        {

                              dsEntries.WriteXml(Directory.GetCurrentDirectory() + "\\Entry.xml");

                        }    

                        catch (Exception ex)

                        {

                              MessageBox.Show(ex.Message);

                        }

                  }

            }

 

            private void btnAdd_Click(object sender, System.EventArgs e)

            {

                  booNewRow = true;

                  txtFName.Text = "";

                  txtLName.Text = "";

                  txtAddress.Text = "";

                  txtCity.Text = "";

                  txtState.Text = "";

                  txtZip.Text = "";

                  txtPhone.Text = "";

                  txtEmail.Text = "";

                  txtBirthdate.Text = "";

                  cboGender.Text = "";

                  cboClass.Text = "";

                  txtBibNumber.Text = "";

                  txtID.Text = "";

            }

 

            private void button1_Click(object sender, System.EventArgs e)

            {

                  int intPosition = bmb.Position;

 

                  dsEntries.Tables["Entry"].Rows[bmb.Position].Delete();

                  dsEntries.AcceptChanges();

 

                  // Update the .xml file.   

                  try

                  {

                        dsEntries.WriteXml(Directory.GetCurrentDirectory() + "\\Entry.xml");

                  }

                  catch (Exception ex)

                  {

                        MessageBox.Show(ex.Message);

                  }

 

                  bmb.Position = bmb.Count - 1;

                  bmb.Position = intPosition;

                  lblPosition.Text = String.Format("{0} of {1}", bmb.Position + 1, bmb.Count);

            }

      }

}