protected void btnAddCompetitor_Click(object sender, EventArgs e)
    {
        SaveFormFields();
        StoreCommon();

        if (ValidEntry())
        {
            MembershipUser userInfo = Membership.GetUser();
            Guid user_ID = (Guid)userInfo.ProviderUserKey;

            Entrants entrant = new Entrants();
            Guid show_ID = new Guid(Show_ID);
            entrant.Show_ID = show_ID;
            if(Catalogue)
                entrant.Catalogue = Catalogue;
            if (Overnight_Camping)
                entrant.Overnight_Camping = Overnight_Camping;
            if (!string.IsNullOrEmpty(Overpayment))
                entrant.Overpayment = decimal.Parse(Overpayment);
            if (!string.IsNullOrEmpty(Underpayment))
                entrant.Underpayment = decimal.Parse(Underpayment);
            if (Offer_Of_Help)
                entrant.Offer_Of_Help = Offer_Of_Help;
            if (!string.IsNullOrEmpty(Help_Details))
                entrant.Help_Details = Help_Details;
            if (Withold_Address)
                entrant.Withold_Address = Withold_Address;
            if (Send_Running_Order)
                entrant.Send_Running_Order = Send_Running_Order;
            if (!string.IsNullOrEmpty(Entry_Date))
            {
                if (entrant.Entry_Date.ToString() != Entry_Date && !string.IsNullOrEmpty(Entry_Date))
                    entrant.Entry_Date = DateTime.Parse(Entry_Date);
            }

            Guid? entrant_ID = entrant.Insert_Entrant(user_ID);

            if (entrant_ID != null)
            {
                Entrant_ID = entrant_ID.ToString();
                Common.Entrant_ID = Entrant_ID;
                bool insertFailed = false;
                for (int i = 0; i < Common.MyDogList.Count; i++)
                {
                    DogClasses dogClass = new DogClasses();
                    dogClass.Entrant_ID = entrant_ID;
                    dogClass.Dog_ID = Common.MyDogList[i].Dog_ID;

                    Guid? dog_Class_ID = dogClass.Insert_Dog_Class(user_ID);

                    if (dog_Class_ID == null)
                        insertFailed = true;
                }
                if (!insertFailed)
                {
                    string returnChars = Common.AppendReturnChars(Request.QueryString, "coc");
                    Server.Transfer("~/Competitors/AddDogToClasses.aspx?" + returnChars);
                }
                else
                {
                    MessageLabel.Text = "Dog_Classes Insert Failed!";
                }
            }
            else
            {
                MessageLabel.Text = "Entrants Insert Failed!";
            }
        }
    }
    private bool InsertDogClass(Guid entrant_ID, Guid user_ID)
    {
        bool insertOK=true;
        for (int i = 0; i < Common.MyDogList.Count; i++)
        {
            bool dogFound = false;
            List<DogClasses> tblDogClasses;
            DogClasses dogClasses = new DogClasses();
            tblDogClasses=dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
            foreach (DogClasses row in tblDogClasses)
            {
                if (Common.MyDogList[i].Dog_ID == row.Dog_ID)
                {
                    dogFound = true;
                }
            }
            if (!dogFound)
            {

                DogClasses dogClass = new DogClasses();
                dogClass.Entrant_ID = entrant_ID;
                dogClass.Dog_ID = Common.MyDogList[i].Dog_ID;

                Guid? dog_Class_ID = dogClass.Insert_Dog_Class(user_ID);

                if (dog_Class_ID == null)
                    insertOK = false;

            }
        }
        return insertOK;
    }
    protected void btnAddDogClass_Click(object sender, EventArgs e)
    {
        GetFormFields();
        StoreCommon();
        if (ValidEntry())
        {
            MembershipUser userInfo = Membership.GetUser();
            Guid user_ID = (Guid)userInfo.ProviderUserKey;

            List<DogClasses> tblDogClasses;
            DogClasses dogClasses = new DogClasses();
            Guid dog_ID = new Guid(Dog_ID);
            Guid show_Entry_Class_ID = new Guid(Show_Entry_Class_ID);
            Guid entrant_ID = new Guid(Entrant_ID);
            tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
            bool rowUpdated = false;
            bool success = false;
            foreach (DogClasses row in tblDogClasses)
            {
                if (dog_ID == row.Dog_ID && !rowUpdated)
                {
                    if (row.IsShow_Entry_Class_IDNull || (!row.IsShow_Entry_Class_IDNull && row.Show_Entry_Class_ID == show_Entry_Class_ID))
                    {
                        Dog_Class_ID = row.Dog_Class_ID.ToString();
                        Guid dog_Class_ID = new Guid(Dog_Class_ID);
                        DogClasses dogClass = new DogClasses(dog_Class_ID);
                        dogClass.Show_Entry_Class_ID = show_Entry_Class_ID;
                        if (!string.IsNullOrEmpty(Special_Request))
                            dogClass.Special_Request = Special_Request;
                        if (!string.IsNullOrEmpty(Handler_ID))
                        {
                            if (GetClassName(show_Entry_Class_ID) != "NFC")
                            {
                                Guid handler_ID = new Guid(Handler_ID);
                                dogClass.Handler_ID = handler_ID;
                            }
                        }
                        dogClass.DeleteDogClass = false;
                        if (dogClass.Update_Dog_Class(dog_Class_ID, user_ID))
                        {
                            rowUpdated = true;
                            success = true;
                        }
                    }
                }
            }
            if (!rowUpdated)
            {
                DogClasses dogClass = new DogClasses();
                dogClass.Entrant_ID = entrant_ID;
                dogClass.Dog_ID = dog_ID;
                dogClass.Show_Entry_Class_ID = show_Entry_Class_ID;
                if (!string.IsNullOrEmpty(Special_Request))
                    dogClass.Special_Request = Special_Request;
                if (!string.IsNullOrEmpty(Handler_ID))
                {
                    if (GetClassName(show_Entry_Class_ID) != "NFC")
                    {
                        Guid handler_ID = new Guid(Handler_ID);
                        dogClass.Handler_ID = handler_ID;
                    }
                }
                Guid? dog_Class_ID = new Guid?();
                dog_Class_ID = dogClass.Insert_Dog_Class(user_ID);
                if (dog_Class_ID != null)
                    success = true;
            }
            if (success)
            {
                ShowEntryClasses showEntryClass = new ShowEntryClasses(show_Entry_Class_ID);
                int class_Name_ID = Int32.Parse(showEntryClass.Class_Name_ID.ToString());
                ClassNames className = new ClassNames(class_Name_ID);
                string class_Name_Description = className.Description;
                Dogs dog = new Dogs(dog_ID);
                MessageLabel.Text = string.Format("{0} was successfully added to {1}.", dog.Dog_KC_Name, class_Name_Description);
                PopulateDogClassGridView();
                ClearFormFields();
            }
        }
    }