Example #1
0
 /*Deleting the Swim Meet from list and the textbox*/
 private void btnDeleteSwimMeet_Click(object sender, EventArgs e)
 {
     sog.UpdateDelete();
     try
     {
         SwimMeets.RemoveAt(lbSwimMeets.SelectedIndex);
         lbSwimMeets.Items.Remove(lbSwimMeets.SelectedItem);
         rtb.Text = "";
         lbSwimMeets.SelectedIndex = 0;
         DefaultValues();
     }
     catch
     {
     }
 }
Example #2
0
        private void btnAddSwimMeet_Click(object sender, EventArgs e)
        {
            int noOfLanes = 0;

            if (Int32.TryParse(txtLanes.Text, out noOfLanes))
            {
                PoolType course;
                switch (lsbCourse.SelectedIndex)
                {
                case 0:
                    course = PoolType.SCM;
                    break;

                case 1:
                    course = PoolType.SCY;
                    break;

                case 2:
                    course = PoolType.LCM;
                    break;

                default:
                    course = PoolType.SCM;
                    break;
                }
                SwimMeet aSwimMeet = new SwimMeet(txtMeetName.Text, dtpStart.Value.Date, dtpEnd.Value.Date, course, noOfLanes);
                SwimMeets.Add(aSwimMeet);
                formMain.SwimMeets = SwimMeets;
                lsbSwimMeets.Items.Add(aSwimMeet.Name);
                txtMeetName.Clear();
                txtLanes.Clear();
                lblError.Text = "";
            }
            else if (dtpStart.Value > dtpEnd.Value)
            {
                lblError.Text = "End date should be later than start date";
            }
            else
            {
                lblError.Text = "Number of lanes should be integer";
            }
        }
Example #3
0
        /*Adding New Swim Meet*/
        private void btnAddSwimMeet_Click(object sender, EventArgs e)
        {
            sog.AddAssign();
            //Checking the Name
            if (string.IsNullOrEmpty(txtName.Text))
            {
                MessageBox.Show("Please Enter Swim Name", "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            //Checking Number of Lanes
            if (string.IsNullOrEmpty(txtNoOfLane.Text))
            {
                MessageBox.Show("Please Enter Number of Lane", "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            // Checking if End date is past of Start Dates
            if (dtpEndDate.Value < dtpStartDate.Value)
            {
                MessageBox.Show("End date is earlier compared to start date", "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                //getting the cousrse value form the user
                PoolType courseSwimMeet;

                switch (lbCourse.SelectedIndex)
                {
                case 0:
                    courseSwimMeet = PoolType.SCM;
                    break;

                case 1:
                    courseSwimMeet = PoolType.SCY;
                    break;

                case 2:
                    courseSwimMeet = PoolType.LCM;
                    break;

                default:
                    courseSwimMeet = PoolType.SCM;
                    break;
                }

                int noOfLanes = 0;
                //Converting the sring NO of Lanes ot int type
                try
                {
                    noOfLanes = Int32.Parse(txtNoOfLane.Text);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Cannot enter the Number of Lanes\n" + exception.Message, "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                //Creating New Swim Meet
                SwimMeet newSwimMeet = new SwimMeet(txtName.Text, dtpStartDate.Value.Date, dtpEndDate.Value.Date, courseSwimMeet, noOfLanes);

                //Making Sure that all textbox are filled
                if (!string.IsNullOrEmpty(txtName.Text) || !string.IsNullOrEmpty(txtNoOfLane.Text))
                {
                    //adding the SwimMeet
                    SwimMeets.Add(newSwimMeet);
                    home           = new Home();
                    home.SwimMeets = SwimMeets;
                    //Displaying Swim Meet in the list
                    lbSwimMeets.Items.Add(newSwimMeet.Name);
                }
                else
                {
                    MessageBox.Show("Make sure that All fields are filled", "ATTENTION", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                DefaultValues();
            }
            catch
            {
                MessageBox.Show("Unable to Add the new Swim Meet", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }