Example #1
0
 private void PopulateOwnerList(Guid entrant_ID)
 {
     bool foundOwner = false;
     List<DogClasses> tblDogClasses;
     DogClasses dogClasses = new DogClasses();
     tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
     foreach (DogClasses dogClassesRow in tblDogClasses)
     {
         Guid dog_ID = new Guid(dogClassesRow.Dog_ID.ToString());
         List<DogOwners> lnkDogOwners;
         DogOwners dogOwners = new DogOwners();
         lnkDogOwners = dogOwners.GetDogOwnersByDog_ID(dog_ID);
         foreach (DogOwners row in lnkDogOwners)
         {
             AddOwnerToList(row.Owner_ID.ToString());
             foundOwner = true;
         }
     }
     if (foundOwner)
         divOwnerList.Visible = true;
 }
Example #2
0
        private void SetOwnerDogCounts(sss.tblOwnersDogsClassesDrawnListRow row, Guid show_ID)
        {
            RunningOrders.OwnerDogCount = 0;
            RunningOrders.OwnerDogsInClassCount = 0;
            RunningOrders.ClassesPerOwnerEnteredCount = 0;
            RunningOrders.ClassesPerDogEnteredCount = 0;

            List<Guid> ownerDogsList = new List<Guid>();
            List<Guid> ownerDogsInClassList = new List<Guid>();
            List<Guid> classesPerOwnerEnteredList = new List<Guid>();
            List<Guid> classesPerDogEnteredList = new List<Guid>();
            DogClasses dogClass = new DogClasses();
            List<DogClasses> dogClasses1 = dogClass.GetDog_ClassesByDog_ID((Guid)row.Dog_ID);
            foreach (DogClasses dogClass1 in dogClasses1)
            {
                ShowFinalClasses sfc = new ShowFinalClasses((Guid)dogClass1.Show_Final_Class_ID);
                if ((Guid)sfc.Show_ID == show_ID)
                {
                    if (classesPerDogEnteredList.IndexOf((Guid)dogClass1.Show_Entry_Class_ID) == -1)
                        classesPerDogEnteredList.Add((Guid)dogClass1.Show_Entry_Class_ID);
                }
            }
            DogOwners dogOwner = new DogOwners();
            List<DogOwners> dogOwnerList = dogOwner.GetDogOwnersByOwner_ID(row.Owner_ID);
            foreach (DogOwners dogOwnerRow in dogOwnerList)
            {
                List<DogClasses> dogClasses = dogClass.GetDog_ClassesByEntrant_ID(row.Entrant_ID);
                foreach (DogClasses dcRow in dogClasses)
                {
                    ShowFinalClasses sfc = new ShowFinalClasses((Guid)dcRow.Show_Final_Class_ID);
                    if ((Guid)sfc.Show_ID == show_ID)
                    {
                        Guid dog_ID = (Guid)dcRow.Dog_ID;
                        Guid dog_Class_ID = (Guid)dcRow.Dog_Class_ID;
                        Guid show_Entry_Class_ID = (Guid)dcRow.Show_Entry_Class_ID;
                        ShowEntryClasses sec = new ShowEntryClasses(show_Entry_Class_ID);
                        ClassNames cn = new ClassNames(int.Parse(sec.Class_Name_ID.ToString()));
                        if (cn.Class_Name_Description != "NFC")
                        {
                            if (ownerDogsList.IndexOf(dog_ID) == -1)
                                ownerDogsList.Add(dog_ID);
                            if (classesPerOwnerEnteredList.IndexOf(show_Entry_Class_ID) == -1)
                                classesPerOwnerEnteredList.Add(show_Entry_Class_ID);
                            if (dcRow.Show_Entry_Class_ID == sfc.Show_Entry_Class_ID)
                            {
                                if (ownerDogsInClassList.IndexOf(dog_ID) == -1)
                                    ownerDogsInClassList.Add(dog_ID);
                            }
                        }
                    }
                }
            }
            RunningOrders.OwnerDogCount = ownerDogsList.Count;
            RunningOrders.OwnerDogsInClassCount = ownerDogsInClassList.Count;
            RunningOrders.ClassesPerOwnerEnteredCount = classesPerOwnerEnteredList.Count;
            RunningOrders.ClassesPerDogEnteredCount = classesPerDogEnteredList.Count;
        }
Example #3
0
    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;
    }
Example #4
0
 private void PopulateDogList(Guid entrant_ID)
 {
     if (Common.MyDogList == null)
     {
         List<DogClasses> tblDogClasses;
         DogClasses dogClasses = new DogClasses();
         tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
         foreach (DogClasses dogClassesRow in tblDogClasses)
         {
             AddDogToList(dogClassesRow.Dog_ID.ToString());
         }
     }
 }
Example #5
0
 private bool DeleteDogClass(Guid entrant_ID, Guid user_ID)
 {
     bool deletedOK = false;
     List<DogClasses> tblDogClasses;
     DogClasses dogClasses = new DogClasses();
     tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
     foreach (DogClasses row in tblDogClasses)
     {
         bool dogFound = false;
         for (int i = 0; i < Common.MyDogList.Count; i++)
         {
             if (Common.MyDogList[i].Dog_ID == row.Dog_ID)
             {
                 dogFound = true;
             }
         }
         if (!dogFound)
         {
             DogClasses dc = new DogClasses((Guid)row.Dog_Class_ID);
             dc.DeleteDogClass = true;
             deletedOK = dc.Update_Dog_Class((Guid)row.Dog_Class_ID, user_ID);
         }
     }
     return deletedOK;
 }
Example #6
0
    private short HasDogChanges()
    {
        bool Changed = false;
        short del = Constants.DATA_NO_CHANGE;
        short ins = Constants.DATA_NO_CHANGE;
        List<DogClasses> tblDogClasses;
        DogClasses dogClasses = new DogClasses();
        Guid entrant_ID = new Guid(Entrant_ID);
        tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
        foreach (DogClasses dogClassesRow in tblDogClasses)
        {
            bool foundDog = false;
            for (int i = 0; i < Common.MyDogList.Count; i++)
            {
                if (Common.MyDogList[i].Dog_ID == dogClassesRow.Dog_ID)
                    //Dog in table still exists in list
                    foundDog = true;
            }
            if (!foundDog)
                //Dog in table no longer exists in list (deleted)
                Changed = true;
        }
        if (Changed)
            del = Constants.DATA_DELETED;

        Changed = false;
        for (int i = 0; i < Common.MyDogList.Count; i++)
        {
            bool foundDog = false;
            foreach (DogClasses dogClassesRow in tblDogClasses)
            {
                if (Common.MyDogList[i].Dog_ID == dogClassesRow.Dog_ID)
                    //Dog in List already exists in table
                    foundDog = true;
            }
            if (!foundDog)
                //Dog in list does not exist in table (inserted)
                Changed = true;
        }
        if (Changed)
            ins = Constants.DATA_INSERTED;

        return del += ins;
    }
Example #7
0
 private void PopulateDogList()
 {
     List<DogClasses> tblDog_Classes;
     DogClasses dogClasses = new DogClasses();
     Guid entrant_ID = new Guid(Common.Entrant_ID);
     DogList dogList = new DogList();
     tblDog_Classes = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
     if (tblDog_Classes != null && tblDog_Classes.Count > 0)
     {
         DogOwnerList dogOwnerList = new DogOwnerList();
         foreach (DogClasses dogClassRow in tblDog_Classes)
         {
             Dogs dog = new Dogs((Guid)dogClassRow.Dog_ID);
             dogList.AddDog(dog);
         }
     }
     if (dogList != null)
         Common.MyDogList = dogList.MyDogList;
 }
Example #8
0
    protected void btnUpdateCompetitor_Click(object sender, EventArgs e)
    {
        SaveFormFields();
        StoreCommon();
        if (ValidEntry())
        {
            MembershipUser userInfo = Membership.GetUser();
            Guid user_ID = (Guid)userInfo.ProviderUserKey;
            Guid entrant_ID = new Guid(Entrant_ID);
            bool EntrantChanges = false;
            bool EntrantSuccess = false;
            bool DogChanges = false;
            bool DogSuccess = false;
            if (HasEntrantChanges())
            {
                EntrantChanges = true;
                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);
                }
                EntrantSuccess = entrant.Update_Entrant(entrant_ID, user_ID);
            }
            else
                EntrantSuccess = true;

            List<DogClasses> tblDogClasses;
            DogClasses dogClasses = new DogClasses();
            tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
            bool insertOK = true;
            bool deleteOK = true;
            switch (HasDogChanges())
            {
                case Constants.DATA_NO_CHANGE:
                    DogSuccess = true;
                    break;
                case Constants.DATA_INSERTED:
                    DogChanges = true;
                    insertOK = InsertDogClass(entrant_ID, user_ID);
                    if (insertOK)
                        DogSuccess = true;
                    else
                        MessageLabel.Text = "Insert_Dog_Class Failed";
                    break;
                case Constants.DATA_DELETED:
                    DogChanges = true;
                    deleteOK = DeleteDogClass(entrant_ID, user_ID);
                    if (deleteOK)
                        DogSuccess = true;
                    else
                        MessageLabel.Text = "Delete_Dog_Class Failed";
                    break;
                case Constants.DATA_INSERTED_AND_DELETED:
                    DogChanges = true;
                    insertOK = InsertDogClass(entrant_ID, user_ID);
                    deleteOK = DeleteDogClass(entrant_ID, user_ID);
                    if (insertOK && deleteOK)
                        DogSuccess = true;
                    else
                    {
                        MessageLabel.Text = string.Empty;
                        if (!insertOK)
                            MessageLabel.Text = "Insert_Dog_Class Failed";
                        if (!deleteOK)
                            MessageLabel.Text += "Delete_Dog_Class Failed";
                    }
                    break;
                default:
                    break;
            }

            if (EntrantChanges && !EntrantSuccess)
                MessageLabel.Text = "Update_Entrant Failed!";
            if (DogChanges && !DogSuccess)
                MessageLabel.Text += " Error with Dog Changes!";
            if (!EntrantChanges && !DogChanges)
            {
                string returnChars = Common.AppendReturnChars(Request.QueryString, "coc");
                Server.Transfer("~/Competitors/AddDogToClasses.aspx?" + returnChars);
            }
            if (EntrantSuccess && DogSuccess)
            {
                string returnChars = Common.AppendReturnChars(Request.QueryString, "coc");
                Server.Transfer("~/Competitors/AddDogToClasses.aspx?" + returnChars);
            }
        }
    }
Example #9
0
 protected void EntryGridView_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         EntryGridRowIndex = e.Row.RowIndex;
         Entrant_ID = EntryGridView.DataKeys[EntryGridRowIndex].Value.ToString();
         if (!string.IsNullOrEmpty(Entrant_ID))
         {
             Guid entrant_ID = new Guid(Entrant_ID);
             GridView gvDogs = e.Row.FindControl("DogGridView") as GridView;
             GridView gvOwners = e.Row.FindControl("OwnerGridView") as GridView;
             List<DogClasses> tblDog_Classes;
             DogClasses dogClasses = new DogClasses();
             tblDog_Classes = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID, ExclNFC);
             if (tblDog_Classes != null && tblDog_Classes.Count > 0)
             {
                 DogOwnerList dogOwnerList = new DogOwnerList();
                 DogList dogList = new DogList();
                 foreach (DogClasses dogClassRow in tblDog_Classes)
                 {
                     Dogs dog = new Dogs((Guid)dogClassRow.Dog_ID);
                     dogList.AddDog(dog);
                     List<DogOwners> lnkDog_Owners;
                     DogOwners dogOwner = new DogOwners();
                     lnkDog_Owners = dogOwner.GetDogOwnersByDog_ID((Guid)dogClassRow.Dog_ID);
                     if (lnkDog_Owners != null && lnkDog_Owners.Count > 0)
                     {
                         foreach (DogOwners dogOwnerRow in lnkDog_Owners)
                         {
                             People person = new People(dogOwnerRow.Owner_ID);
                             dogOwnerList.AddOwner(person);
                         }
                         gvOwners.DataSource = dogOwnerList.MyDogOwnerList;
                         gvOwners.DataBind();
                     }
                     dogList.SortDogList();
                     gvDogs.DataSource = dogList.MyDogList;
                     gvDogs.DataBind();
                 }
             }
         }
     }
 }
    private bool ValidEntry()
    {
        bool valid = true;
        Guid show_ID = new Guid(Show_ID);
        Shows show = new Shows(show_ID);
        List<DogClasses> tblDogClasses;
        DogClasses dogClasses = new DogClasses();
        Guid entrant_ID = new Guid(Entrant_ID);
        tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
        short dogClassCount = 0;
        if (string.IsNullOrEmpty(Handler_ID) && lstClasses.SelectedItem.Text != "NFC")
        {
            MessageLabel.Text = "You must select the Handler.";
            valid = false;
        }
        if (!string.IsNullOrEmpty(Dog_ID) && lstClasses.SelectedItem.Text != "NFC")
        {
            Guid dog_ID = new Guid(Dog_ID);
            Dogs dog = new Dogs(dog_ID);
            if (!IsCorrectClassGender(dog))
            {
                MessageLabel.Text = "This dog is the wrong gender for this class.";
                valid = false;
            }
        }
        foreach (DogClasses row in tblDogClasses)
        {
            if (!row.IsShow_Entry_Class_IDNull && Dog_ID == row.Dog_ID.ToString())
            {
                if (Show_Entry_Class_ID == row.Show_Entry_Class_ID.ToString())
                {
                    MessageLabel.Text = string.Format("You have already entered this dog in {0}.", GetClassName((Guid)row.Show_Entry_Class_ID));
                    valid = false;
                }
                else if (lstClasses.SelectedItem.Text == "NFC" && GetClassName((Guid)row.Show_Entry_Class_ID) != "NFC")
                {
                    MessageLabel.Text = "This dog is already entered in other classes, so cannot be NFC";
                    valid = false;
                }
                else if (GetClassName((Guid)row.Show_Entry_Class_ID) == "NFC")
                {
                    MessageLabel.Text = "This dog is entered NFC so cannot be entered in other classes.";
                    valid = false;
                }
                if (valid)
                {
                    dogClassCount += 1;
                    if (dogClassCount >= show.MaxClassesPerDog)
                    {
                        MessageLabel.Text = string.Format("There is a maximum of {0} classes per dog for this show.", show.MaxClassesPerDog.ToString());
                        valid = false;
                    }
                }
            }
        }

        return valid;
    }
    private void PopulateListBoxes()
    {
        List<DogClasses> tblDogClasses;
        DogClasses dogClasses = new DogClasses();
        Guid entrant_ID = new Guid(Entrant_ID);
        tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
        List<Dogs> dogs = new List<Dogs>();
        foreach (DogClasses row in tblDogClasses)
        {
            Dogs dog = new Dogs((Guid)row.Dog_ID);
            Dogs dg = dogs.Find(delegate(Dogs d) { return d.Dog_ID == row.Dog_ID; });
            if (dg == null)
                dogs.Add(dog);
        }
        lstDogs.DataSource = dogs;
        lstDogs.DataBind();

        if (!string.IsNullOrEmpty(Show_ID))
        {
            Guid show_ID = new Guid(Show_ID);
            ShowEntryClasses showEntryClasses = new ShowEntryClasses();
            List<ShowEntryClasses> tblShowEntryClasses = showEntryClasses.GetShow_Entry_ClassesByShow_ID(show_ID);
            lstClasses.DataSource = tblShowEntryClasses;
            lstClasses.DataBind();
        }
    }
 private void PopulateDogClassGridView()
 {
     List<DogClasses> tblDogClasses;
     DogClasses dogClasses = new DogClasses();
     Guid entrant_ID = new Guid(Entrant_ID);
     tblDogClasses = dogClasses.GetDog_ClassesByEntrant_ID(entrant_ID);
     List<DogClasses> dogClassList = new List<DogClasses>();
     foreach (DogClasses row in tblDogClasses)
     {
         if (!row.IsShow_Entry_Class_IDNull)
         {
             DogClasses dogClass = new DogClasses((Guid)row.Dog_Class_ID);
             Dogs dog = new Dogs((Guid)row.Dog_ID);
             dogClass.Dog_Class_ID = row.Dog_Class_ID;
             dogClass.Dog_KC_Name = dog.Dog_KC_Name;
             ShowEntryClasses showEntryClass = new ShowEntryClasses((Guid)row.Show_Entry_Class_ID);
             ClassNames className = new ClassNames(Int32.Parse(showEntryClass.Class_Name_ID.ToString()));
             dogClass.Class_Name_Description = string.Format("{0} : {1}", showEntryClass.Class_No, className.Description);
             if (!row.IsHandler_IDNull)
             {
                 People handler = new People((Guid)row.Handler_ID);
                 dogClass.Handler_Name = string.Format("{0} {1}", handler.Person_Forename, handler.Person_Surname);
             }
             dogClassList.Add(dogClass);
         }
     }
     if (dogClassList != null)
     {
         DogClassGridView.DataSource = dogClassList;
         DogClassGridView.DataBind();
     }
 }
    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();
            }
        }
    }