コード例 #1
0
ファイル: DogSetup.aspx.cs プロジェクト: BadgerTadger/DSM
    private bool DeleteDogOwners(Guid dog_ID, Guid user_ID)
    {
        bool             deletedOK = false;
        List <DogOwners> lnkDogOwners;
        DogOwners        dogOwners = new DogOwners(_connString);

        lnkDogOwners = dogOwners.GetDogOwnersByDog_ID(dog_ID);
        foreach (DogOwners row in lnkDogOwners)
        {
            bool ownerFound = false;
            for (int i = 0; i < Common.DogOwnerList.Count; i++)
            {
                if (Common.DogOwnerList[i].Person_ID == row.Owner_ID)
                {
                    ownerFound = true;
                }
            }
            if (!ownerFound)
            {
                DogOwners dogOwner = new DogOwners(_connString, row.Dog_Owner_ID);
                dogOwner.DeleteDogOwner = true;
                deletedOK = dogOwner.Update_Dog_Owner(row.Dog_Owner_ID, user_ID);
            }
        }
        return(deletedOK);
    }
コード例 #2
0
ファイル: DogSetup.aspx.cs プロジェクト: BadgerTadger/DSM
    private bool InsertDogOwners(Guid dog_ID, Guid user_ID)
    {
        bool insertOK = true;

        for (int i = 0; i < Common.DogOwnerList.Count; i++)
        {
            bool             ownerFound = false;
            List <DogOwners> lnkDogOwners;
            DogOwners        dogOwners = new DogOwners(_connString);
            lnkDogOwners = dogOwners.GetDogOwnersByDog_ID(dog_ID);
            foreach (DogOwners row in lnkDogOwners)
            {
                if (Common.DogOwnerList[i].Person_ID == row.Owner_ID)
                {
                    ownerFound = true;
                }
            }
            if (!ownerFound)
            {
                DogOwners dogOwner = new DogOwners(_connString);
                dogOwner.Dog_ID   = dog_ID;
                dogOwner.Owner_ID = Common.DogOwnerList[i].Person_ID;

                Guid?dog_Owner_ID = dogOwner.Insert_Dog_Owner(user_ID);

                if (dog_Owner_ID == null)
                {
                    insertOK = false;
                }
            }
        }
        return(insertOK);
    }
コード例 #3
0
ファイル: DogSetup.aspx.cs プロジェクト: BadgerTadger/DSM
    private void PopulateOwnerList()
    {
        bool             foundOwner = false;
        Guid             dog_ID     = new Guid(Current_Dog_ID);
        List <DogOwners> lnkDogOwners;
        DogOwners        dogOwners = new DogOwners(_connString);

        lnkDogOwners = dogOwners.GetDogOwnersByDog_ID(dog_ID);
        foreach (DogOwners row in lnkDogOwners)
        {
            AddOwnerToList(row.Owner_ID.ToString());
            foundOwner = true;
        }
        if (foundOwner)
        {
            divOwnerList.Visible = true;
        }
    }
コード例 #4
0
ファイル: EntryList.aspx.cs プロジェクト: BadgerTadger/DSM
 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(_connString);
             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(_connString, (Guid)dogClassRow.Dog_ID);
                     dogList.AddDog(dog);
                     List <DogOwners> lnkDog_Owners;
                     DogOwners        dogOwner = new DogOwners(_connString);
                     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(_connString, dogOwnerRow.Owner_ID);
                             dogOwnerList.AddOwner(person);
                         }
                         gvOwners.DataSource = dogOwnerList.MyDogOwnerList;
                         gvOwners.DataBind();
                     }
                     dogList.SortDogList();
                     gvDogs.DataSource = dogList.MyDogList;
                     gvDogs.DataBind();
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: frmMain.cs プロジェクト: BadgerTadger/DSM
        private void LinkDogToOwner(Guid owner_ID, Guid dog_ID)
        {
            bool createLink = true;

            DogOwners        dogOwners    = new DogOwners(Utils.ConnectionString());
            List <DogOwners> dogOwnerList = dogOwners.GetDogOwnersByDog_ID(dog_ID);

            foreach (DogOwners dogOwner in dogOwnerList)
            {
                dogOwner.DeleteDogOwner = true;
                dogOwner.Update_Dog_Owner(dogOwner.Dog_Owner_ID, user_ID);
            }

            if (createLink)
            {
                dogOwners.Dog_ID   = dog_ID;
                dogOwners.Owner_ID = owner_ID;
                dogOwners.Insert_Dog_Owner(user_ID);
            }
        }
コード例 #6
0
ファイル: frmManageEntry.cs プロジェクト: BadgerTadger/DSM
        private void PopulateEntrants()
        {
            _entrantData.Columns.Clear();
            DataColumn dcFullName  = new DataColumn("FullName");
            DataColumn dcEntrantID = new DataColumn("EntrantID");

            _entrantData.Columns.Add(dcFullName);
            _entrantData.Columns.Add(dcEntrantID);
            object[] dataRow = new object[2];

            string          connString  = Utils.ConnectionString();
            Entrants        entrants    = new Entrants(connString);
            List <Entrants> entrantList = entrants.GetEntrantsByShow_ID(_show_ID, true);

            foreach (Entrants entrant in entrantList)
            {
                _prev_Owner_ID = new Guid();
                DogClasses        dc     = new DogClasses(connString);
                List <DogClasses> dcList = dc.GetDog_ClassesByEntrant_ID((Guid)entrant.Entrant_ID);
                foreach (DogClasses dogClass in dcList)
                {
                    DogOwners        dogOwners = new DogOwners(connString);
                    List <DogOwners> doList    = dogOwners.GetDogOwnersByDog_ID((Guid)dogClass.Dog_ID);
                    foreach (DogOwners owner in doList)
                    {
                        if (owner.Owner_ID != _prev_Owner_ID)
                        {
                            People person = new People(connString, (Guid)owner.Owner_ID);
                            dataRow[0] = person.Person_FullName;
                            dataRow[1] = entrant.Entrant_ID;

                            _entrantData.Rows.Add(dataRow);
                        }
                        _prev_Owner_ID = owner.Owner_ID;
                    }
                }
            }
            selectEntrant.PeopleData = _entrantData;
        }
コード例 #7
0
    private void PopulateOwnerList(Guid entrant_ID)
    {
        bool foundOwner = false;
        List <DogClasses> tblDogClasses;
        DogClasses        dogClasses = new DogClasses(_connString);

        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(_connString);
            lnkDogOwners = dogOwners.GetDogOwnersByDog_ID(dog_ID);
            foreach (DogOwners row in lnkDogOwners)
            {
                AddOwnerToList(row.Owner_ID.ToString());
                foundOwner = true;
            }
        }
        if (foundOwner)
        {
            divOwnerList.Visible = true;
        }
    }
コード例 #8
0
ファイル: DogSetup.aspx.cs プロジェクト: BadgerTadger/DSM
    private short HasOwnerChanges()
    {
        bool             Changed = false;
        short            del     = Constants.DATA_NO_CHANGE;
        short            ins     = Constants.DATA_NO_CHANGE;
        List <DogOwners> lnkDogOwners;
        DogOwners        dogOwners = new DogOwners(_connString);
        Guid             dog_ID    = new Guid(Current_Dog_ID);

        lnkDogOwners = dogOwners.GetDogOwnersByDog_ID(dog_ID);
        foreach (DogOwners dogOwnersRow in lnkDogOwners)
        {
            bool foundOwner = false;
            if (Common.DogOwnerList != null && Common.DogOwnerList.Count != 0)
            {
                for (int i = 0; i < Common.DogOwnerList.Count; i++)
                {
                    if (Common.DogOwnerList[i].Person_ID == dogOwnersRow.Owner_ID)
                    {
                        //Dog in table still exists in list
                        foundOwner = true;
                    }
                }
            }
            if (!foundOwner)
            {
                //Dog in table no longer exists in list (deleted)
                Changed = true;
            }
        }
        if (Changed)
        {
            del = Constants.DATA_DELETED;
        }

        Changed = false;
        if (Common.DogOwnerList != null && Common.DogOwnerList.Count != 0)
        {
            for (int i = 0; i < Common.DogOwnerList.Count; i++)
            {
                bool foundOwner = false;
                foreach (DogOwners dogOwnersRow in lnkDogOwners)
                {
                    if (Common.DogOwnerList[i].Person_ID == dogOwnersRow.Owner_ID)
                    {
                        //Dog in List already exists in table
                        foundOwner = true;
                    }
                }
                if (!foundOwner)
                {
                    //Dog in list does not exist in table (inserted)
                    Changed = true;
                }
            }
        }
        else
        {
            if (lnkDogOwners.Count > 0)
            {
                Changed = true;
            }
        }
        if (Changed)
        {
            ins = Constants.DATA_INSERTED;
        }

        return(del += ins);
    }
コード例 #9
0
ファイル: DogSetup.aspx.cs プロジェクト: BadgerTadger/DSM
    protected void btnSaveDog_Click(object sender, EventArgs e)
    {
        SaveFormFields();
        StoreCommon();

        MembershipUser userInfo       = Membership.GetUser();
        Guid           user_ID        = (Guid)userInfo.ProviderUserKey;
        bool           Changed        = false;
        string         petName        = null;
        bool           DogChanges     = false;
        bool           DogSuccess     = false;
        bool           OwnerChanges   = false;
        bool           OwnerSuccess   = false;
        bool           BreederChanges = false;
        bool           BreederSuccess = false;

        if (!string.IsNullOrEmpty(Current_Dog_ID))
        {
            Guid dog_ID = new Guid(Current_Dog_ID);
            Dogs dog    = new Dogs(_connString, dog_ID);
            petName = dog.Dog_Pet_Name;
            if (ValidDog())
            {
                if (HasDogChanges())
                {
                    DogChanges = true;
                    if (dog.Merit_Points.ToString() != Merit_Points && !string.IsNullOrEmpty(Merit_Points))
                    {
                        dog.Merit_Points = short.Parse(Merit_Points);
                    }
                    if (dog.NLWU == null && NLWU)
                    {
                        dog.NLWU = NLWU;
                    }
                    if (dog.NLWU != null)
                    {
                        if ((bool)dog.NLWU != NLWU)
                        {
                            dog.NLWU = null;
                        }
                    }

                    DogSuccess = dog.Update_Dog(dog_ID, user_ID);
                    if (!DogSuccess)
                    {
                        MessageLabel.Text += " Update_Dog Failed!";
                    }

                    if (!string.IsNullOrEmpty(btnReturn.PostBackUrl))
                    {
                        DivReturn.Visible = true;
                    }
                }
                else
                {
                    DogSuccess = true;
                }

                List <DogOwners> lnkDogOwners;
                DogOwners        dogOwners = new DogOwners(_connString);
                lnkDogOwners = dogOwners.GetDogOwnersByDog_ID(dog_ID);
                bool insertOK = true;
                bool deleteOK = true;
                switch (HasOwnerChanges())
                {
                case Constants.DATA_NO_CHANGE:
                    OwnerSuccess = true;
                    break;

                case Constants.DATA_INSERTED:
                    OwnerChanges = true;
                    insertOK     = InsertDogOwners(dog_ID, user_ID);
                    if (insertOK)
                    {
                        OwnerSuccess = true;
                    }
                    else
                    {
                        MessageLabel.Text = "Insert_Dog_Owners Failed";
                    }
                    break;

                case Constants.DATA_DELETED:
                    OwnerChanges = true;
                    deleteOK     = DeleteDogOwners(dog_ID, user_ID);
                    if (deleteOK)
                    {
                        OwnerSuccess = true;
                    }
                    else
                    {
                        MessageLabel.Text = "Delete_Dog_Owners Failed";
                    }
                    break;

                case Constants.DATA_INSERTED_AND_DELETED:
                    OwnerChanges = true;
                    insertOK     = InsertDogOwners(dog_ID, user_ID);
                    deleteOK     = DeleteDogOwners(dog_ID, user_ID);
                    if (insertOK && deleteOK)
                    {
                        OwnerSuccess = true;
                    }
                    else
                    {
                        MessageLabel.Text = string.Empty;
                        if (!insertOK)
                        {
                            MessageLabel.Text = "Insert_Dog_Owners Failed";
                        }
                        if (!deleteOK)
                        {
                            MessageLabel.Text += "Delete_Dog_Owners Failed";
                        }
                    }
                    break;

                default:
                    break;
                }
                List <DogBreeders> lnkDogBreeders;
                DogBreeders        dogBreeders = new DogBreeders(_connString);
                lnkDogBreeders = dogBreeders.GetDogBreedersByDog_ID(dog_ID);
                insertOK       = true;
                deleteOK       = true;
                switch (HasBreederChanges())
                {
                case Constants.DATA_NO_CHANGE:
                    BreederSuccess = true;
                    break;

                case Constants.DATA_INSERTED:
                    BreederChanges = true;
                    insertOK       = InsertDogBreeders(dog_ID, user_ID);
                    if (insertOK)
                    {
                        BreederSuccess = true;
                    }
                    else
                    {
                        MessageLabel.Text = "Insert_Dog_Breeders Failed";
                    }
                    break;

                case Constants.DATA_DELETED:
                    BreederChanges = true;
                    deleteOK       = DeleteDogBreeders(dog_ID, user_ID);
                    if (deleteOK)
                    {
                        BreederSuccess = true;
                    }
                    else
                    {
                        MessageLabel.Text = "Delete_Dog_Breeders Failed";
                    }
                    break;

                case Constants.DATA_INSERTED_AND_DELETED:
                    BreederChanges = true;
                    insertOK       = InsertDogBreeders(dog_ID, user_ID);
                    deleteOK       = DeleteDogBreeders(dog_ID, user_ID);
                    if (insertOK && deleteOK)
                    {
                        BreederSuccess = true;
                    }
                    else
                    {
                        MessageLabel.Text = string.Empty;
                        if (!insertOK)
                        {
                            MessageLabel.Text = "Insert_Dog_Breeders Failed";
                        }
                        if (!deleteOK)
                        {
                            MessageLabel.Text += "Delete_Dog_Breeders Failed";
                        }
                    }
                    break;

                default:
                    break;
                }
                if (HasDamChanges())
                {
                    DogDams        dogDam = new DogDams(_connString);
                    List <DogDams> lnkDogDams;
                    lnkDogDams = dogDam.GetDogDamsByDog_ID(dog_ID);
                    if (lnkDogDams.Count == 0)
                    {
                        DogDams newDogDams = new DogDams(_connString);
                        newDogDams.Dog_ID = dog_ID;
                        newDogDams.Dam_ID = new Guid(Dam_ID);
                        Guid?dog_Dam_ID = newDogDams.Insert_Dog_Dams(user_ID);
                    }
                    else
                    {
                        Guid    dog_Dam_ID = lnkDogDams[0].Dog_Dam_ID;
                        DogDams newDogDams = new DogDams(_connString, dog_Dam_ID);
                        newDogDams.Dam_ID = new Guid(Dam_ID);
                        newDogDams.Update_Dog_Dams(dog_Dam_ID, user_ID);
                    }
                    Changed = true;
                }
                if (HasSireChanges())
                {
                    DogSires        dogSire = new DogSires(_connString);
                    List <DogSires> lnkDogSires;
                    lnkDogSires = dogSire.GetDogSiresByDog_ID(dog_ID);
                    if (lnkDogSires.Count == 0)
                    {
                        DogSires newDogSires = new DogSires(_connString);
                        newDogSires.Dog_ID  = dog_ID;
                        newDogSires.Sire_ID = new Guid(Sire_ID);
                        Guid?dog_Sire_ID = newDogSires.Insert_Dog_Sires(user_ID);
                    }
                    else
                    {
                        Guid     dog_Sire_ID = lnkDogSires[0].Dog_Sire_ID;
                        DogSires newDogSires = new DogSires(_connString, dog_Sire_ID);
                        newDogSires.Sire_ID = new Guid(Sire_ID);
                        newDogSires.Update_Dog_Sires(dog_Sire_ID, user_ID);
                    }
                    Changed = true;
                }
                if (OwnerChanges || BreederChanges || DogChanges)
                {
                    Changed = true;
                }
                if (OwnerChanges && !OwnerSuccess)
                {
                    MessageLabel.Text += " Error with Owner Changes!";
                }
                if (BreederChanges && !BreederSuccess)
                {
                    MessageLabel.Text += " Error with Breeder Changes!";
                }
                if (DogChanges && !DogSuccess)
                {
                    MessageLabel.Text += " Error with Dog Changes!";
                }
                if (Changed)
                {
                    if (OwnerSuccess && BreederSuccess && DogSuccess)
                    {
                        MessageLabel.Text = string.Format("{0} was updated successfully.", petName);
                        PopulateDog();
                    }
                    else
                    {
                        MessageLabel.Text = string.Format("{0}{1}", "Problem!", MessageLabel.Text);
                    }
                }
                else
                {
                    MessageLabel.Text = "Update cancelled as no changes have been made.";
                }
            }
        }
    }