Exemplo n.º 1
0
 public int UpdateDogData(Dogs dog)
 {
     try
     {
         SqlCommand sqlCommand = new SqlCommand("DogsCrud", sqlConnection);
         sqlCommand.CommandType = CommandType.StoredProcedure;
         sqlCommand.Parameters.AddWithValue("@Dog", "Update");
         sqlCommand.Parameters.AddWithValue("@DogId", dog.DogId);
         sqlCommand.Parameters.AddWithValue("@DogName", dog.DogName);
         sqlCommand.Parameters.AddWithValue("@Breed", dog.Breed);
         sqlCommand.Parameters.AddWithValue("@Gender", dog.Gender);
         sqlCommand.Parameters.AddWithValue("@DogImage", dog.DogImage);
         sqlCommand.Parameters.AddWithValue("@UpdateDate", dog.UpdateDate.ToLongDateString());
         sqlConnection.Open();
         int dataUpdated = sqlCommand.ExecuteNonQuery();
         CloseAndDisposeCon();
         return(dataUpdated);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         CloseAndDisposeCon();
     }
 }
Exemplo n.º 2
0
        private string SaveRegNo()
        {
            string retVal = "";

            if (txtNewValue != null && !string.IsNullOrWhiteSpace(txtNewValue.Text))
            {
                Dogs        dogs    = new Dogs(_connString);
                List <Dogs> dogList = dogs.GetDogByRegNo(txtNewValue.Text);
                if (dogList.Count > 0)
                {
                    retVal = "A dog with this KC Registration Number already exists";
                }
                else if (dog != null)
                {
                    dog.Reg_No = txtNewValue.Text;
                    dog.Update_Dog(dog.Dog_ID, user_ID);
                }
            }
            else
            {
                retVal = "You must provide a KC Registration Number";
            }

            return(retVal);
        }
Exemplo n.º 3
0
        private void EditBreed()
        {
            int selectedBreed = -1;

            cboNewValue       = new ComboBox();
            cboNewValue.Width = panel1.Width;
            panel1.Controls.Add(cboNewValue);
            dog = new Dogs(_connString, new Guid(_dogID));
            DogBreeds        db        = new DogBreeds(_connString);
            List <DogBreeds> breedList = db.GetDog_Breeds();

            foreach (DogBreeds breed in breedList)
            {
                ComboBoxItem item = new ComboBoxItem();
                item.Text  = breed.Description;
                item.Value = breed.Dog_Breed_ID;
                cboNewValue.Items.Add(item);
                if (dog.Dog_Breed_ID == breed.Dog_Breed_ID)
                {
                    selectedBreed           = breed.Dog_Breed_ID;
                    lblCurrentValue.Text    = breed.Description;
                    lblCurrentValue.Visible = true;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get's <see cref="DogProfile"/> object for single dog, including basic details,
        /// biography, album images, and generated temperament scores
        /// </summary>
        /// <param name="id">Dog Id <see cref="int"/></param>
        /// <returns>Single <see cref="DogProfile"/> object</returns>
        public async Task <DogProfile> GetDogProfile(int id)
        {
            Dogs dog = await _dogRepository.FindFullDogProfileById(id);

            // if dog doesn't exist, return null
            if (dog == null)
            {
                return(null);
            }

            // initialize dog profile and map dog's basic details and album images
            DogProfile dogProfile = new DogProfile()
            {
                Dog         = _mapper.Map <Dog>(dog),
                AlbumImages = _mapper.Map <List <AlbumImage> >(dog.AlbumImages)
            };

            // if all temperament values are populated (not null or zero), generate and set temperament scores
            if (_temperamentRepository.HasCompletedTemperament(dog.Temperament))
            {
                dogProfile.HasTemperament    = true;
                dogProfile.TemperamentScores = GetTemperamentScores(dog.Temperament);
            }

            // if any biography properties are populated, map and set values
            if (HasBiography(dog.Biography))
            {
                dogProfile.HasBio = true;
                dogProfile.Bio    = _mapper.Map <DogBiography>(dog.Biography);
            }

            return(dogProfile);
        }
        static void Main(string[] args)
        {
            var dogsTable = new Dogs();

            var allDogs = dogsTable.All();

            foreach( var dog in allDogs )
            {
                Console.WriteLine( dog.Name );
            }

            var allDogsAndOwners = dogsTable.Query(
                                    @"
                                        SELECT
                                            D.Id, D.Name, D.Legs, D.HasTail,
                                            O.Id as [OwnerId], O.Name as [OwnerName],
                                            B.Name as [Breed]
                                        FROM dogs D
                                        INNER JOIN owners O ON o.id = d.ownerid
                                        INNER JOIN breeds B ON b.id = d.breedid
                                    " );

            foreach( var dog in allDogsAndOwners )
            {
                Console.WriteLine( "{0}\t{1}\t{2}", dog.Name, dog.OwnerName, dog.Breed );
            }

            Console.ReadLine();
        }
Exemplo n.º 6
0
        async Task ExecuteLoadDogsCommand()
        {
            IsBusy = true;

            try
            {
                if (Dogs.Count() > 0)
                {
                    return;
                }

                var dogs = await DogStore.GetItemsAsync(true);

                foreach (var dog in dogs)
                {
                    Dogs.Add(dog);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Determines if an individual dog (entity) has a completed profile by checking if all
        /// temperament ratings and basic details are populated or have value and if the 'about dog'
        /// biography is populated (just 'about dog', not all bio fields)
        /// </summary>
        /// <param name="dog"><see cref="Dogs"/> entity to check for completed profile</param>
        /// <returns><see cref="bool"/>, true if dog has completed profile</returns>
        private bool DogHasCompletedProfile(Dogs dog)
        {
            // check if temperament profile is completed
            if (!_temperamentRepository.HasCompletedTemperament(dog.Temperament))
            {
                return(false);
            }

            // check if biography:about dog is completed
            if (!dog.BiographyId.HasValue)
            {
                return(false);
            }
            else
            if (string.IsNullOrWhiteSpace(dog.Biography.AboutDoggo))
            {
                return(false);
            }

            // check if all basic details are populated or have value
            if (string.IsNullOrWhiteSpace(dog.Breed) ||
                string.IsNullOrWhiteSpace(dog.Biography?.AboutDoggo) ||
                !dog.Birthday.HasValue ||
                !dog.ProfileImageId.HasValue ||
                !dog.Weight.HasValue ||
                !dog.Gender.HasValue ||
                dog.Colors.Count < 1)
            {
                return(false);
            }

            // if dog passes all checks return true for completed profile
            return(true);
        }
Exemplo n.º 8
0
    private bool ValidEntry()
    {
        bool              valid   = true;
        Guid              show_ID = new Guid(Show_ID);
        Shows             show    = new Shows(_connString, show_ID);
        List <DogClasses> tblDogClasses;
        DogClasses        dogClasses = new DogClasses(_connString);
        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(_connString, 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 && row.Show_Entry_Class_ID != new Guid() && 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);
    }
Exemplo n.º 9
0
    private bool IsCorrectClassGender(Dogs dog)
    {
        bool             correctGender = false;
        ShowEntryClasses sec           = new ShowEntryClasses(_connString, new Guid(Show_Entry_Class_ID));
        DogGender        dg            = new DogGender(_connString, (int)dog.Dog_Gender_ID);

        switch (dg.Description)
        {
        case "Dog":
            if (sec.Class_Gender == Constants.CLASS_GENDER_DB || sec.Class_Gender == Constants.CLASS_GENDER_D)
            {
                correctGender = true;
            }
            break;

        case "Bitch":
            if (sec.Class_Gender == Constants.CLASS_GENDER_DB || sec.Class_Gender == Constants.CLASS_GENDER_B)
            {
                correctGender = true;
            }
            break;

        default:
            break;
        }

        return(correctGender);
    }
Exemplo n.º 10
0
    private void PopulateDogClassGridView()
    {
        List <DogClasses> tblDogClasses;
        DogClasses        dogClasses = new DogClasses(_connString);
        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.Show_Entry_Class_ID != null && row.Show_Entry_Class_ID != new Guid())
            {
                DogClasses dogClass = new DogClasses(_connString, (Guid)row.Dog_Class_ID);
                Dogs       dog      = new Dogs(_connString, (Guid)row.Dog_ID);
                dogClass.Dog_Class_ID = row.Dog_Class_ID;
                dogClass.Dog_KC_Name  = dog.Dog_KC_Name;
                ShowEntryClasses showEntryClass = new ShowEntryClasses(_connString, (Guid)row.Show_Entry_Class_ID);
                ClassNames       className      = new ClassNames(_connString, Int32.Parse(showEntryClass.Class_Name_ID.ToString()));
                dogClass.Class_Name_Description = string.Format("{0} : {1}", showEntryClass.Class_No, className.Description);
                if (!row.IsHandler_IDNull && row.Handler_ID != new Guid())
                {
                    People handler = new People(_connString, (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();
        }
    }
Exemplo n.º 11
0
    private void PopulateDog()
    {
        Guid dog_ID = new Guid(Dog_ID);
        Dogs dog    = new Dogs(_connString, dog_ID);

        Dog_KC_Name                = dog.Dog_KC_Name;
        Common.Dog_KC_Name         = Dog_KC_Name;
        txtKCName.Text             = Dog_KC_Name;
        txtPetName.Text            = dog.Dog_Pet_Name;
        lstDogBreeds.SelectedValue = dog.Dog_Breed_ID.ToString();
        lstGender.SelectedValue    = dog.Dog_Gender_ID.ToString();
        if (dog.Reg_No != null)
        {
            Reg_No        = dog.Reg_No.ToString();
            Common.Reg_No = Reg_No;
            txtRegNo.Text = Reg_No;
        }
        if (dog.Date_Of_Birth != null)
        {
            string format = "yyyy-MM-dd";
            Date_Of_Birth        = DateTime.Parse(dog.Date_Of_Birth.ToString()).ToString(format);
            Common.Date_Of_Birth = Date_Of_Birth;
            txtDogDOB.Text       = Date_Of_Birth;
        }
    }
Exemplo n.º 12
0
        private void EditFinalClass()
        {
            cboNewValue       = new ComboBox();
            cboNewValue.Width = panel1.Width;
            panel1.Controls.Add(cboNewValue);
            dog      = new Dogs(_connString, new Guid(_dogID));
            dogClass = new DogClasses(_connString, new Guid(_dogClassID));
            ShowFinalClasses        sfc     = new ShowFinalClasses(_connString);
            List <ShowFinalClasses> sfcList = sfc.GetShow_Final_ClassesByShow_Entry_Class_ID((Guid)dogClass.Show_Entry_Class_ID);

            if (sfcList.Count == 0)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Abort;
            }
            else
            {
                foreach (ShowFinalClasses showFinalClass in sfcList)
                {
                    ComboBoxItem item = new ComboBoxItem();
                    item.Text  = showFinalClass.Show_Final_Class_Description;
                    item.Value = showFinalClass.Show_Final_Class_ID;
                    cboNewValue.Items.Add(item);
                    if (dogClass.Show_Final_Class_ID == showFinalClass.Show_Final_Class_ID)
                    {
                        lblCurrentValue.Text    = showFinalClass.Show_Final_Class_Description;;
                        lblCurrentValue.Visible = true;
                    }
                }
            }
        }
Exemplo n.º 13
0
    private void PopulateListBoxes()
    {
        List <DogClasses> tblDogClasses;
        DogClasses        dogClasses = new DogClasses(_connString);
        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(_connString, (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(_connString);
            List <ShowEntryClasses> tblShowEntryClasses = showEntryClasses.GetShow_Entry_ClassesByShow_ID(show_ID);
            lstClasses.DataSource = tblShowEntryClasses;
            lstClasses.DataBind();
        }
    }
Exemplo n.º 14
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,DogName,Age,Breed,Illness,EnteredShelter")] Dogs dogs)
        {
            if (id != dogs.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dogs);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DogsExists(dogs.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dogs));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> PutDogs([FromRoute] int id, [FromBody] Dogs dogs)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != dogs.Id)
            {
                return(BadRequest());
            }

            _context.Entry(dogs).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DogsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 16
0
        public async Task <ActionResult <Dogs> > PostDogs(Dogs dogs)
        {
            _context.Dogs.Add(dogs);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetDogs", new { id = dogs.DogsId }, dogs));
        }
Exemplo n.º 17
0
        public async Task <IActionResult> Get()
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT Id, Name, OwnerId, Breed, Notes FROM Dog";
                    SqlDataReader reader = cmd.ExecuteReader();
                    List <Dogs>   dogs   = new List <Dogs>();

                    while (reader.Read())
                    {
                        Dogs dog = new Dogs
                        {
                            Id      = reader.GetInt32(reader.GetOrdinal("Id")),
                            Name    = reader.GetString(reader.GetOrdinal("Name")),
                            OwnerId = reader.GetInt32(reader.GetOrdinal("OwnerId")),
                            Breed   = reader.GetString(reader.GetOrdinal("Breed")),
                            Notes   = reader.GetString(reader.GetOrdinal("Notes"))
                        };

                        dogs.Add(dog);
                    }
                    reader.Close();

                    return(Ok(dogs));
                }
            }
        }
 /// <summary>
 /// Retrieves an Animal in FIFO ordering, based off the string parameter "pref":
 /// <para>
 /// If pref is "cat" and there are Cats in the shelter, returns the cat that's been the shelter the longest. If there are no cats in the shelter, returns null.
 /// </para>
 /// <para>
 /// If pref is "dog" and there are Dogs in the shelter, returns the dog that's been the shelter the longest. If there are no dogs in the shelter, returns null.
 /// </para>
 /// <para>
 /// If pref is "no preference" and there are Cats or Dogs in the shelter, returns whichever has been in the shelter the longest. If there are only Cats or Dogs, returns the animal that's been in the shelter the longest. If no animals are in the shelter, returns null.
 /// </para>
 /// </summary>
 /// <param name="pref">
 /// string: the preferred animal
 /// </param>
 /// <returns>
 /// Animal: the animal released from the shelter
 /// </returns>
 public Animal Dequeue(string pref)
 {
     if (pref == "no preference" && (PeekCats() != null || PeekDogs() != null))
     {
         if (PeekCats() != null && PeekDogs() != null)
         {
             DateTime oldestCat = PeekCats().DateTimeCaptured;
             DateTime oldestDog = PeekDogs().DateTimeCaptured;
             return(oldestCat < oldestDog ? (Animal)Cats.Dequeue() : (Animal)Dogs.Dequeue());
         }
         else if (PeekCats() != null)
         {
             return((Animal)Cats.Dequeue());
         }
         else
         {
             return((Animal)Dogs.Dequeue());
         }
     }
     else if (pref == "cat" && PeekCats() != null)
     {
         return((Animal)Cats.Dequeue());
     }
     else if (pref == "dog" && PeekDogs() != null)
     {
         return((Animal)Dogs.Dequeue());
     }
     return(null);
 }
Exemplo n.º 19
0
        public ActionResult DeleteConfirmed(int id)
        {
            Dogs dogs = db.Dogs.Find(id);

            db.Dogs.Remove(dogs);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 20
0
        public void DequeueDog()
        {
            //Remove from the dog list.
            var adoptedDog = Dogs.Dequeue();

            //Then remove from the overall list.
            All.DequeueAny(adoptedDog);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes new <see cref="DogMatches"/> object for a single dog
 /// with CompletedProfile bool property set to false. Used for returning a
 /// <see cref="DogMatches"/> object without any actual <see cref="List{Matches}}"/> matches.
 /// </summary>
 /// <param name="dog"><see cref="Dogs"/> object for single dog</param>
 /// <returns>New <see cref="DogMatches"/> instance for incomplete profile designation</returns>
 private static DogMatches IncompleteProfile(Dogs dog) =>
 new DogMatches()
 {
     DogId            = dog.Id,
     DogName          = dog.Name,
     OwnerName        = dog.Owner.UserName,
     CompletedProfile = false
 };
Exemplo n.º 22
0
    private bool ValidDog(bool isUpdate)
    {
        bool valid = true;

        if (!Is_Dam_Or_Sire)
        {
            if (string.IsNullOrEmpty(lstDogBreeds.SelectedValue) || lstDogBreeds.SelectedValue == "1")
            {
                MessageLabel.Text = "The dog's Breed must be specified.";
                valid             = false;
            }
            else if (string.IsNullOrEmpty(lstGender.SelectedValue) || lstGender.SelectedValue == "1")
            {
                MessageLabel.Text = "The dog's Gender must be specified.";
                valid             = false;
            }
            else if (string.IsNullOrEmpty(txtKCName.Text))
            {
                MessageLabel.Text = "The Kennel Club Name must be included.";
                valid             = false;
            }
            else if (string.IsNullOrEmpty(Reg_No))
            {
                MessageLabel.Text = "The Kennel Club Registration Number must be included.";
                valid             = false;
            }
        }
        else
        {
            if (string.IsNullOrEmpty(txtKCName.Text))
            {
                MessageLabel.Text = "The Kennel Club Name must be included.";
                valid             = false;
            }
        }
        if (!isUpdate)
        {
            List <Dogs> tblDogs;
            Dogs        dog = new Dogs(_connString);
            tblDogs = dog.GetDogs();
            foreach (Dogs d in tblDogs)
            {
                if (!d.IsReg_NoNull && d.Reg_No != "Unknown" && d.Reg_No == Reg_No)
                {
                    MessageLabel.Text = "A dog with this Kennel Club Registration Number already exists.";
                    valid             = false;
                }
                else if (!d.IsDog_KC_NameNull && d.Dog_KC_Name != "NAF" && d.Dog_KC_Name == Dog_KC_Name)
                {
                    MessageLabel.Text = "A dog with this Kennel Club Name already exists.";
                    valid             = false;
                }
            }
        }


        return(valid);
    }
        public void AddAnimal()
        {
            Console.Clear();
            Menus.PrintMammals();
            var input = Console.ReadKey(true).Key;

            switch (input)
            {
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                Dog newDog = new ArvochPolymorfism3.Dog();
                Console.WriteLine("Name: ");
                newDog.Name = Console.ReadLine();

                Console.WriteLine("Weight: ");
                newDog.Weight = int.Parse(Console.ReadLine());

                Console.WriteLine("Age: ");
                newDog.Age = int.Parse(Console.ReadLine());

                Console.WriteLine("Tail Length: ");
                newDog.TailLength = int.Parse(Console.ReadLine());

                Console.WriteLine("Does the dog have fur?");
                string hasFurController = Console.ReadLine();

                if (hasFurController == "y")
                {
                    newDog.HasFur = true;
                }
                else
                {
                    newDog.HasFur = false;
                }

                Dogs.Add(newDog);
                break;

            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                Console.Clear();
                Menus.PrintInsects();
                break;

            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                Console.Clear();
                Menus.PrintBirds();
                break;

            case ConsoleKey.D4:
            case ConsoleKey.NumPad4:
                Console.Clear();
                Menus.PrintReptiles();
                break;
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Writes new, single <see cref="Dogs"/> entity to database.
        /// </summary>
        /// <param name="dog"><see cref="Dogs"/> entity object</param>
        /// <returns>The new <see cref="Dogs"/> entity with sql generated id <see cref="int"/>.</returns>
        public async Task <Dogs> SaveNewDog(Dogs dog)
        {
            _dbSet.Add(dog);
            await _context.SaveChangesAsync();

            _logger.LogTrace($"New Dog {dog.Id} created by {dog.CreatedBy}");

            return(dog);
        }
Exemplo n.º 25
0
        public IActionResult Appointments(AppointmentsViewModel viewModel, int?id)
        {
            if (ModelState.IsValid)
            {
                if (id.HasValue)
                {
                    Dogs dogs = adminRepository.GetDogs(id.Value);
                    {
                        viewModel.DogId = dogs.DogId;
                    }
                }

                if (!personRepository.CheckIfUserExists(_userManager.GetUserId(User).ToString()))
                {
                    personRepository.AddUser(_userManager.GetUserId(User).ToString());
                }
                string UserId = _userManager.GetUserId(User).ToString();
                if (!appoinmentRepository.CheckUniqueDateByDogId(viewModel.Date, viewModel.DogId))
                {
                    appoinmentRepository.Add(new AppointmentsModel()
                    {
                        AppointmentId = viewModel.AppointmentId,
                        FirstName     = viewModel.FirstName,
                        LastName      = viewModel.LastName,
                        Date          = viewModel.Date,
                        DogId         = viewModel.DogId,
                        UserId        = UserId
                    });

                    ViewBag.message = "Your appointment was successful! See you soon!";
                }
                else
                {
                    ViewBag.message = "There already exists an appointment at this hour!";
                }

                return(View(viewModel));
            }
            //string connectionString = Configuration["ConnectionStrings:DefaultConnection"];
            //using (SqlConnection connection = new SqlConnection(connectionString))
            //{
            //    string insertString = $"Insert Into Appointments (FirstName, LastName, Date) Values ('{viewModel.FirstName}', '{viewModel.LastName}','{viewModel.Date}')";
            //    using (SqlCommand command = new SqlCommand(insertString, connection))
            //    {
            //        command.CommandType = CommandType.Text;
            //        connection.Open();
            //        command.ExecuteNonQuery();
            //        connection.Close();
            //    }
            //    return RedirectToAction("Appointments");
            //}
            else
            {
                return(View());
            }
        }
Exemplo n.º 26
0
    protected void btnAddDog_Click(object sender, EventArgs e)
    {
        SaveFormFields();
        StoreCommon();
        ResetFilter();

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

            Dogs dog = new Dogs(_connString);
            dog.Dog_KC_Name   = txtKCName.Text;
            dog.Dog_Pet_Name  = txtPetName.Text;
            dog.Dog_Breed_ID  = Int32.Parse(lstDogBreeds.SelectedValue);
            dog.Dog_Gender_ID = Int32.Parse(lstGender.SelectedValue);
            if (dog.Reg_No != Reg_No && !string.IsNullOrEmpty(Reg_No))
            {
                dog.Reg_No = Reg_No;
            }
            if (!string.IsNullOrEmpty(Date_Of_Birth))
            {
                if (dog.Date_Of_Birth.ToString() != Date_Of_Birth && !string.IsNullOrEmpty(Date_Of_Birth))
                {
                    dog.Date_Of_Birth = DateTime.Parse(Date_Of_Birth);
                }
                dog.Year_Of_Birth = short.Parse(DateTime.Parse(Date_Of_Birth).ToString("yyyy"));
            }

            Guid?dog_ID = dog.Insert_Dog(user_ID);

            if (dog_ID != null)
            {
                Dog_ID            = dog_ID.ToString();
                Common.Dog_ID     = Dog_ID;
                MessageLabel.Text = "Dog was added successfully";
                //ClearEntryFields();
                if (!string.IsNullOrEmpty(btnReturn.PostBackUrl))
                {
                    DivReturn.Visible = true;
                }

                divAddDog.Visible    = false;
                divNewDog.Visible    = true;
                divUpdateDog.Visible = true;
                PopulateDogGridView(null, 1);
                StoreCommon();
            }
            else
            {
                divAddDog.Visible    = true;
                divNewDog.Visible    = false;
                divUpdateDog.Visible = false;
            }
        }
    }
Exemplo n.º 27
0
 private void EditDam()
 {
     txtNewValue       = new TextBox();
     txtNewValue.Width = panel1.Width;
     panel1.Controls.Add(txtNewValue);
     dog = new Dogs(_connString, new Guid(_dogID));
     lblCurrentValue.Text    = dog.Dam;
     lblCurrentValue.Visible = true;
     txtNewValue.Text        = dog.Dam;
 }
Exemplo n.º 28
0
 public ActionResult Edit([Bind(Include = "Id,Name,Age,Race")] Dogs dogs)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dogs).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dogs));
 }
Exemplo n.º 29
0
        public IActionResult DeleteDog(int id)
        {
            Dogs         dog   = adminRepository.GetDogs(id);
            DogViewModel model = new DogViewModel
            {
                Name = $"{dog.Name}"
            };

            return(PartialView("~/Views/Administrator/_DeleteDog.cshtml", model));
        }
Exemplo n.º 30
0
        public async Task <IActionResult> Create([Bind("ID,DogName,Age,Breed,Illness,EnteredShelter")] Dogs dogs)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dogs);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dogs));
        }
Exemplo n.º 31
0
 private void EditMeritPoints()
 {
     numNewValue         = new NumericUpDown();
     numNewValue.Minimum = 0;
     numNewValue.Maximum = 500;
     panel1.Controls.Add(numNewValue);
     dog = new Dogs(_connString, new Guid(_dogID));
     lblCurrentValue.Text    = dog.Merit_Points.ToString();
     lblCurrentValue.Visible = true;
     numNewValue.Value       = (decimal)dog.Merit_Points;
 }
Exemplo n.º 32
0
    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();
            }
        }
    }
Exemplo n.º 33
0
    private void PopulateDog()
    {
        Guid dog_ID = new Guid(Dog_ID);
        Dogs dog = new Dogs(dog_ID);

        Dog_KC_Name = dog.Dog_KC_Name;
        Common.Dog_KC_Name = Dog_KC_Name;
        txtKCName.Text = Dog_KC_Name;
        txtPetName.Text = dog.Dog_Pet_Name;
        lstDogBreeds.SelectedValue = dog.Dog_Breed_ID.ToString();
        lstGender.SelectedValue = dog.Dog_Gender_ID.ToString();
        if (dog.Reg_No != null)
        {
            Reg_No = dog.Reg_No.ToString();
            Common.Reg_No = Reg_No;
            txtRegNo.Text = Reg_No;
        }
        if (dog.Date_Of_Birth != null)
        {
            string format = "yyyy-MM-dd";
            Date_Of_Birth = DateTime.Parse(dog.Date_Of_Birth.ToString()).ToString(format);
            Common.Date_Of_Birth = Date_Of_Birth;
            txtDogDOB.Text = Date_Of_Birth;
        }
    }
Exemplo n.º 34
0
    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();
        }
    }
Exemplo n.º 35
0
 protected void AddDogToList(string current_Dog_ID)
 {
     Guid dog_ID = new Guid(current_Dog_ID);
     Dogs dog = new Dogs(dog_ID);
     DogList dogList = new DogList();
     dogList.MyDogList = Common.MyDogList;
     Dogs dg = null;
     if (dogList.MyDogList != null)
         dg = dogList.MyDogList.Find(delegate(Dogs d) { return d.Dog_ID == dog_ID; });
     if (dg == null)
     {
         int dogCount = dogList.AddDog(dog);
         PopulateDogGridView(dogList.MyDogList);
         Common.MyDogList = dogList.MyDogList;
     }
 }
Exemplo n.º 36
0
    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;
    }
Exemplo n.º 37
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();
                 }
             }
         }
     }
 }
Exemplo n.º 38
0
    private bool HasChanges(Dogs dog)
    {
        bool Changed = false;
        if (dog.Dog_KC_Name != txtKCName.Text)
            Changed = true;
        if (dog.Dog_Pet_Name != txtPetName.Text)
            Changed = true;
        if (dog.Dog_Breed_ID != Int32.Parse(lstDogBreeds.SelectedValue))
            Changed = true;
        if (dog.Dog_Gender_ID != Int32.Parse(lstGender.SelectedValue))
            Changed = true;
        if (dog.Reg_No != Reg_No && !string.IsNullOrEmpty(Reg_No))
            Changed = true;
        if (dog.Date_Of_Birth == null && !string.IsNullOrEmpty(Date_Of_Birth))
            Changed = true;
        if(dog.Date_Of_Birth != null && !string.IsNullOrEmpty(Date_Of_Birth))
            if(dog.Date_Of_Birth.ToString() != Date_Of_Birth)
                Changed=true;

        return Changed;
    }
Exemplo n.º 39
0
    private void PopulateDam()
    {
        Guid dam_ID = new Guid(Dam_ID);
        Dogs dog = new Dogs(dam_ID);

        txtDamKCName.Text = dog.Dog_KC_Name;
        txtDamPetName.Text = dog.Dog_Pet_Name;

        if (dog.Dog_Breed_ID != null && dog.Dog_Breed_ID != 1)
        {
            int dog_Breed_ID = Int32.Parse(dog.Dog_Breed_ID.ToString());
            DogBreeds dogBreeds = new DogBreeds(dog_Breed_ID);
            txtDamBreed.Text = dogBreeds.Description;
        }
        if (dog.Dog_Gender_ID != null && dog.Dog_Gender_ID != 1)
        {
            int dog_Gender_ID = Int32.Parse(dog.Dog_Gender_ID.ToString());
            DogGender dogGender = new DogGender(dog_Gender_ID);
            txtDamGender.Text = dogGender.Description;
        }
        divGetDam.Visible = false;
        divChangeDam.Visible = true;
        divDamDetails.Visible = true;
    }
Exemplo n.º 40
0
 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();
     }
 }
Exemplo n.º 41
0
 private bool HasDogChanges()
 {
     bool Changed = false;
     if (!string.IsNullOrEmpty(Current_Dog_ID))
     {
         Guid dog_ID = new Guid(Current_Dog_ID);
         Dogs dog = new Dogs(dog_ID);
         if (dog.Reg_No != Reg_No && !string.IsNullOrEmpty(Reg_No))
             Changed = true;
         if (dog.Date_Of_Birth == null && !string.IsNullOrEmpty(Date_Of_Birth))
             Changed = true;
         if (dog.Date_Of_Birth != null && !string.IsNullOrEmpty(Date_Of_Birth))
         {
             if (string.Compare(DateTime.Parse(dog.Date_Of_Birth.ToString()).ToString("yyyy-MM-dd"), Date_Of_Birth) != 0)
                 Changed = true;
         }
         if (dog.Merit_Points == null && !string.IsNullOrEmpty(Merit_Points))
             Changed = true;
         if (dog.Merit_Points != null && !string.IsNullOrEmpty(Merit_Points))
         {
             if (dog.Merit_Points != short.Parse(Merit_Points) && !string.IsNullOrEmpty(Merit_Points))
                 Changed = true;
         }
         if (dog.NLWU == null && NLWU)
             Changed = true;
         if (dog.NLWU != null)
         {
             if ((bool)dog.NLWU != NLWU)
                 Changed = true;
         }
     }
     return Changed;
 }
Exemplo n.º 42
0
    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(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();
                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();
                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();
                    List<DogDams> lnkDogDams;
                    lnkDogDams = dogDam.GetDogDamsByDog_ID(dog_ID);
                    if (lnkDogDams.Count == 0)
                    {
                        DogDams newDogDams = new DogDams();
                        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(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();
                    List<DogSires> lnkDogSires;
                    lnkDogSires = dogSire.GetDogSiresByDog_ID(dog_ID);
                    if (lnkDogSires.Count == 0)
                    {
                        DogSires newDogSires = new DogSires();
                        newDogSires.Dog_ID = dog_ID;
                        newDogSires.Sire_ID = new Guid(Sire_ID);
                        Guid? dog_Sire_ID = newDogSires.Insert_Dog_Sire(user_ID);
                    }
                    else
                    {
                        Guid dog_Sire_ID = lnkDogSires[0].Dog_Sire_ID;
                        DogSires newDogSires = new DogSires(dog_Sire_ID);
                        newDogSires.Sire_ID = new Guid(Sire_ID);
                        newDogSires.Update_Dog_Sire(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.";
                }
            }
        }
    }
Exemplo n.º 43
0
    private bool ValidDog(bool isUpdate)
    {
        bool valid = true;
        if (!Is_Dam_Or_Sire)
        {
            if (string.IsNullOrEmpty(lstDogBreeds.SelectedValue) || lstDogBreeds.SelectedValue == "1")
            {
                MessageLabel.Text = "The dog's Breed must be specified.";
                valid = false;
            }
            else if (string.IsNullOrEmpty(lstGender.SelectedValue) || lstGender.SelectedValue == "1")
            {
                MessageLabel.Text = "The dog's Gender must be specified.";
                valid = false;
            }
            else if (string.IsNullOrEmpty(txtKCName.Text))
            {
                MessageLabel.Text = "The Kennel Club Name must be included.";
                valid = false;
            }
            else if (string.IsNullOrEmpty(Reg_No))
            {
                MessageLabel.Text = "The Kennel Club Registration Number must be included.";
                valid = false;
            }
        }
        else
        {
            if (string.IsNullOrEmpty(txtKCName.Text))
            {
                MessageLabel.Text = "The Kennel Club Name must be included.";
                valid = false;
            }
        }
        if (!isUpdate)
        {
            List<Dogs> tblDogs;
            Dogs dog = new Dogs();
            tblDogs = dog.GetDogs();
            foreach (Dogs d in tblDogs)
            {
                if (!d.IsReg_NoNull && d.Reg_No != "Unknown" && d.Reg_No == Reg_No)
                {
                    MessageLabel.Text = "A dog with this Kennel Club Registration Number already exists.";
                    valid = false;
                }
                else if (!d.IsDog_KC_NameNull && d.Dog_KC_Name != "NAF" && d.Dog_KC_Name == Dog_KC_Name)
                {
                    MessageLabel.Text = "A dog with this Kennel Club Name already exists.";
                    valid = false;
                }
            }
        }

        return valid;
    }
Exemplo n.º 44
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;
 }
Exemplo n.º 45
0
    private void PopulateDogGridView(List<Dogs> tblDogs, int pageNo)
    {
        if (tblDogs == null)
        {
            tblDogs = Common.Dog_GridViewData;
        }
        List<Dogs> newDogs = new List<Dogs>();

        int itemsperPage = Int32.Parse(WebConfigurationManager.AppSettings["GridItemsPerPage"]);
        int startRowIndex = (pageNo -1) * itemsperPage;
        int currentIndex = 0;
        int itemsRead = 0;
        int totalRecords = tblDogs.Count;
        foreach (Dogs row in tblDogs)
        {
            if (itemsRead < itemsperPage && currentIndex < totalRecords && currentIndex >= startRowIndex)
            {
                Dogs newDog = new Dogs();
                newDog.Dog_ID = row.Dog_ID;
                newDog.Dog_KC_Name = row.Dog_KC_Name;
                newDog.Dog_Pet_Name = row.Dog_Pet_Name;
                if (!row.IsReg_NoNull)
                    newDog.Reg_No = row.Reg_No;
                DogBreeds dogBreeds = new DogBreeds(Convert.ToInt32(row.Dog_Breed_ID));
                newDog.Dog_Breed_Description = dogBreeds.Description;
                DogGender dogGender = new DogGender(Convert.ToInt32(row.Dog_Gender_ID));
                newDog.Dog_Gender = dogGender.Description;
                newDogs.Add(newDog);
                itemsRead++;
            }
            currentIndex++;
        }
        lblTotalPages.Text = CalculateTotalPages(totalRecords).ToString();

        lblCurrentPage.Text = CurrentPage.ToString();

        if (CurrentPage == 1)
        {
            Btn_Previous.Enabled = false;

            if (Int32.Parse(lblTotalPages.Text) > 0)
            {
                Btn_Next.Enabled = true;
            }
            else
                Btn_Next.Enabled = false;

        }

        else
        {
            Btn_Previous.Enabled = true;

            if (CurrentPage == Int32.Parse(lblTotalPages.Text))
                Btn_Next.Enabled = false;
            else Btn_Next.Enabled = true;
        }
        DogGridView.DataSource = newDogs;
        DogGridView.DataBind();
    }
Exemplo n.º 46
0
    private bool IsCorrectClassGender(Dogs dog)
    {
        bool correctGender = false;
        ShowEntryClasses sec = new ShowEntryClasses(new Guid(Show_Entry_Class_ID));
        DogGender dg = new DogGender((int)dog.Dog_Gender_ID);
        switch (dg.Description)
        {
            case "Dog":
                if (sec.Class_Gender == Constants.CLASS_GENDER_DB || sec.Class_Gender == Constants.CLASS_GENDER_D)
                    correctGender = true;
                break;
            case "Bitch":
                if (sec.Class_Gender == Constants.CLASS_GENDER_DB || sec.Class_Gender == Constants.CLASS_GENDER_B)
                    correctGender = true;
                break;
            default:
                break;
        }

        return correctGender;
    }
Exemplo n.º 47
0
 protected void DogGridView_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         string Dog_ID = ((HiddenField)e.Row.FindControl("hdnID")).Value;
         GridView gvClasses = e.Row.FindControl("ClassGridView") as GridView;
         List<DogClasses> tblDog_Classes;
         DogClasses dogClasses = new DogClasses();
         if (!string.IsNullOrEmpty(Dog_ID))
         {
             Guid dog_ID = new Guid(Dog_ID);
             tblDog_Classes = dogClasses.GetDog_ClassesByDog_ID(dog_ID);
             if (tblDog_Classes != null && tblDog_Classes.Count > 0)
             {
                 List<DogClasses> dogClassList = new List<DogClasses>();
                 foreach (DogClasses row in tblDog_Classes)
                 {
                     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)
                 {
                     gvClasses.DataSource = dogClassList;
                     gvClasses.DataBind();
                 }
             }
         }
     }
 }
Exemplo n.º 48
0
    private void PopulateDog()
    {
        Guid current_dog_ID = new Guid(Current_Dog_ID);
        Dogs dog = new Dogs(current_dog_ID);

        txtKCName.Text = dog.Dog_KC_Name;
        txtPetName.Text = dog.Dog_Pet_Name;
        lblNLWU.Text = string.Format("Tick this box if {0} is no longer with us.", dog.Dog_Pet_Name);

        if (dog.Dog_Breed_ID != null)
        {
            int dog_Breed_ID = Int32.Parse(dog.Dog_Breed_ID.ToString());
            DogBreeds dogBreeds = new DogBreeds(dog_Breed_ID);
            txtDogBreed.Text = dogBreeds.Description;
        }
        if (dog.Dog_Gender_ID != null)
        {
            int dog_Gender_ID = Int32.Parse(dog.Dog_Gender_ID.ToString());
            DogGender dogGender = new DogGender(dog_Gender_ID);
            txtDogGender.Text = dogGender.Description;
        }
        if (dog.Reg_No != null)
        {
            Reg_No = dog.Reg_No.ToString();
            Common.Reg_No = Reg_No;
            txtRegNo.Text = Reg_No;
        }
        if (dog.Date_Of_Birth != null)
        {
            string format = "yyyy-MM-dd";
            Date_Of_Birth = DateTime.Parse(dog.Date_Of_Birth.ToString()).ToString(format);
            Common.Date_Of_Birth = Date_Of_Birth;
            txtDogDOB.Text = Date_Of_Birth;
        }
        if (dog.Merit_Points != null)
        {
            Merit_Points = dog.Merit_Points.ToString();
            Common.Merit_Points = Merit_Points;
            txtMeritPoints.Text = Merit_Points;
        }
        else
        {
            Merit_Points = "0";
            Common.Merit_Points = Merit_Points;
            txtMeritPoints.Text = Merit_Points;
        }
        if (dog.NLWU != null)
        {
            NLWU = (bool)dog.NLWU;
            Common.NLWU = NLWU;
            chkNLWU.Checked = NLWU;
        }
        DogDams dogDams = new DogDams();
        List<DogDams> lnkDogDams;
        lnkDogDams = dogDams.GetDogDamsByDog_ID(dog.Dog_ID);
        if (lnkDogDams.Count != 0)
        {
            Dam_ID = lnkDogDams[0].Dam_ID.ToString();
            Common.Dam_ID = Dam_ID;
            PopulateDam();
        }
        DogSires dogSires = new DogSires();
        List<DogSires> lnkDogSires;
        lnkDogSires = dogSires.GetDogSiresByDog_ID(dog.Dog_ID);
        if (lnkDogSires.Count != 0)
        {
            Sire_ID = lnkDogSires[0].Sire_ID.ToString();
            Common.Sire_ID = Sire_ID;
            PopulateSire();
        }
    }
Exemplo n.º 49
0
    protected void btnUpdateDog_Click(object sender, EventArgs e)
    {
        SaveFormFields();
        StoreCommon();

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

            Guid dog_ID = new Guid(Dog_ID);
            Dogs dog = new Dogs(dog_ID);
            if (HasChanges(dog))
            {
                dog.Dog_KC_Name = txtKCName.Text;
                dog.Dog_Pet_Name = txtPetName.Text;
                dog.Dog_Breed_ID = Int32.Parse(lstDogBreeds.SelectedValue);
                dog.Dog_Gender_ID = Int32.Parse(lstGender.SelectedValue);
                if (dog.Reg_No != Reg_No && !string.IsNullOrEmpty(Reg_No))
                    dog.Reg_No = Reg_No;
                if (!string.IsNullOrEmpty(Date_Of_Birth))
                {
                    if (dog.Date_Of_Birth.ToString() != Date_Of_Birth && !string.IsNullOrEmpty(Date_Of_Birth))
                        dog.Date_Of_Birth = DateTime.Parse(Date_Of_Birth);
                    dog.Year_Of_Birth = short.Parse(DateTime.Parse(Date_Of_Birth).ToString("yyyy"));
                }

                bool valid = dog.Update_Dog(dog_ID, user_ID);

                if (valid)
                {
                    Dog_ID = dog_ID.ToString();
                    Common.Dog_ID = Dog_ID;
                    MessageLabel.Text = "Dog was updated successfully";
                    //ClearEntryFields();
                    if (!string.IsNullOrEmpty(btnReturn.PostBackUrl))
                        DivReturn.Visible = true;

                    divAddDog.Visible = false;
                    divNewDog.Visible = true;
                    divUpdateDog.Visible = true;
                    PopulateDogGridView(null, 1);
                    StoreCommon();
                }
                else
                {
                    divAddDog.Visible = false;
                    divNewDog.Visible = true;
                    divUpdateDog.Visible = true;
                }
            }
            else
            {
                MessageLabel.Text = "Update cancelled as no changes have been made.";
                divAddDog.Visible = false;
                divNewDog.Visible = true;
                divUpdateDog.Visible = true;
            }
        }
    }
Exemplo n.º 50
0
    protected void btnDogSearch_Click(object sender, EventArgs e)
    {
        //ResetPage();
        //ClearEntryFields();
        string searchValue = txtDogFilter.Text;
        Dogs dog = new Dogs();
        List<Dogs> tblDogs = null;

        if (DogSearchType.SelectedValue == "c")
            searchValue = string.Format("%{0}", searchValue);

        switch (DogFilterBy.SelectedValue)
        {
            case "KC_Name":
                tblDogs = dog.GetDogsLikeDog_KC_Name(searchValue);
                break;
            case "Pet_Name":
                tblDogs = dog.GetDogsLikeDog_Pet_Name(searchValue);
                break;
            case "Breed_ID":
                DogBreeds dogBreeds = new DogBreeds();
                List<DogBreeds> lkpDogBreeds = null;
                lkpDogBreeds = dogBreeds.GetDog_BreedsByDog_Breed_Description(searchValue);
                tblDogs = dog.GetDogsByDog_Breed_ID(lkpDogBreeds);
                break;
            default:
                tblDogs = dog.GetDogs();
                break;
        }

        Common.Dog_GridViewData = tblDogs;
        PopulateDogGridView(Common.Dog_GridViewData, 1);
        txtDogFilter.Text = string.Empty;
        DogFilterBy.SelectedIndex = -1;
        DogSearchType.SelectedIndex = -1;
    }
Exemplo n.º 51
0
    private void PopulateSire()
    {
        Guid sire_ID = new Guid(Sire_ID);
        Dogs dog = new Dogs(sire_ID);

        txtSireKCName.Text = dog.Dog_KC_Name;
        txtSirePetName.Text = dog.Dog_Pet_Name;

        if (dog.Dog_Breed_ID != null && dog.Dog_Breed_ID != 1)
        {
            int dog_Breed_ID = Int32.Parse(dog.Dog_Breed_ID.ToString());
            DogBreeds dogBreeds = new DogBreeds(dog_Breed_ID);
            txtSireBreed.Text = dogBreeds.Description;
        }
        if (dog.Dog_Gender_ID != null && dog.Dog_Gender_ID != 1)
        {
            int dog_Gender_ID = Int32.Parse(dog.Dog_Gender_ID.ToString());
            DogGender dogGender = new DogGender(dog_Gender_ID);
            txtSireGender.Text = dogGender.Description;
        }
        divGetSire.Visible = false;
        divChangeSire.Visible = true;
        divSireDetails.Visible = true;
    }