//Changed
        //Shifted code from Save Button to interface Save() method overriding
        public void Save()
        {
            currCattle = new Cattle();

            //string _name = textBoxName.Text;
            //string _fatherName = textBoxFatherName.Text;
            //int _salary = Convert.ToInt32(textBoxSalary.Text);

            #region Validation for valid employee data

            //Check if all text boxes are empty

            IEnumerable <TextBox>  textBoxcollection  = EntryGrid.Children.OfType <TextBox>();
            IEnumerable <ComboBox> comboBoxcollection = EntryGrid.Children.OfType <ComboBox>();

            foreach (TextBox box in textBoxcollection)
            {
                if (string.IsNullOrWhiteSpace(box.Text))
                {
                    if (box.Name == "textBoxDescription" ||
                        box.Name == "textBoxHeight" ||
                        box.Name == "textBoxLength" ||
                        box.Name == "textBoxWidth" ||
                        box.Name == "textBoxPrice" ||
                        box.Name == "textBoxWeight")
                    {
                        //ignore
                    }
                    else
                    {
                        MessageBox.Show("Kindly Fill all the boxes.");
                        return;
                    }
                }
            }

            foreach (ComboBox combobox in comboBoxcollection)
            {
                if (combobox.SelectedIndex == -1)
                {
                    MessageBox.Show("Kindly Select all the Drop-Downs");
                    return;
                }
            }

            //CheckTextBoxes(this);


            #endregion

            try
            {
                if (string.IsNullOrWhiteSpace(textBoxPrice.Text))
                {
                    currCattle.Price = 0;
                }
                else
                {
                    currCattle.Price = Convert.ToInt32(textBoxPrice.Text);
                }

                PhysicalAttributes physicalAttrib = new PhysicalAttributes();
                Entities.Size      currSize       = new Entities.Size();

                if (string.IsNullOrWhiteSpace(textBoxHeight.Text))
                {
                    currSize.Height = 0;
                }
                else
                {
                    currSize.Height = Convert.ToDouble(textBoxHeight.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxLength.Text))
                {
                    currSize.Length = 0;
                }
                else
                {
                    currSize.Length = Convert.ToDouble(textBoxLength.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxWidth.Text))
                {
                    currSize.Width = 0;
                }
                else
                {
                    currSize.Width = Convert.ToDouble(textBoxWidth.Text);
                }


                if (string.IsNullOrWhiteSpace(textBoxWeight.Text))
                {
                    physicalAttrib.Weight = 0;
                }
                else
                {
                    physicalAttrib.Weight = Convert.ToDouble(textBoxWeight.Text);
                }

                physicalAttrib.CurrentSize = currSize;

                currCattle.CurrPhysicalAttribs = physicalAttrib;

                currCattle.TagNo     = textBoxTagNo.Text;
                currCattle.BirthDate = datePickerDOB.SelectedDate.Value;

                //List<MasterTables> masterList = new List<MasterTables>();

                //masterList.Add((MasterTables)comboBoxBreed.SelectedItem);
                //masterList.Add((MasterTables)comboBoxGender.SelectedItem);
                //masterList.Add((MasterTables)comboBoxSource.SelectedItem);

                //AnimalBreed breed = new AnimalBreed();
                //breed = (AnimalBreed)masterList[0];

                //currCattle.Breed = breed;

                //currCattle.Breed = (AnimalBreed)comboBoxBreed.SelectedItem;
                //currCattle.Gender = (Gender)comboBoxGender.SelectedItem;
                //currCattle.Source = (AnimalSource)comboBoxSource.SelectedItem;

                //Only IDs needed for insertion

                currCattle.Breed    = new AnimalBreed();
                currCattle.Breed.ID = ((MasterTables)comboBoxBreed.SelectedItem).ID;


                currCattle.Gender = new Gender();

                string g = ((string)comboBoxGender.SelectedItem);

                currCattle.Gender.Description = g;


                currCattle.Source    = new AnimalSource();
                currCattle.Source.ID = ((MasterTables)comboBoxSource.SelectedItem).ID;


                currCattle.Type    = new AnimalType();
                currCattle.Type.ID = ((MasterTables)comboBoxAnimalType.SelectedItem).ID;


                currCattle.Status    = new AnimalStatus();
                currCattle.Status.ID = ((MasterTables)comboBoxStatus.SelectedItem).ID;


                currCattle.OtherDetails = textBoxDescription.Text;

                animalHandler.Add(currCattle);
            }
            catch (FormatException fexcept)
            {
                MessageBox.Show("Kindly Enter the field in correct (numeric) format. Error on " + fexcept.Source + " .", "Invalid Entry");
                return;
            }

            //Added - 01 Jan
            //For Name/Father name not containing numbers

            catch (ArgumentException aexcept)
            {
                MessageBox.Show(aexcept.Message, "Invalid Entry!");
                return;
            }


            //Clear all the TextBoxes

            foreach (TextBox textbox in textBoxcollection)
            {
                textbox.Text = "";
            }

            foreach (ComboBox combobox in comboBoxcollection)
            {
                combobox.SelectedIndex = -1;
            }
        }
        public void Save()
        {
            currCalf = new Calf();

            //string _name = textBoxName.Text;
            //string _fatherName = textBoxFatherName.Text;
            //int _salary = Convert.ToInt32(textBoxSalary.Text);

            #region Validation for valid employee data

            //Check if all text boxes are empty

            IEnumerable <TextBox>  textBoxcollection  = EntryGrid.Children.OfType <TextBox>();
            IEnumerable <ComboBox> comboBoxcollection = EntryGrid.Children.OfType <ComboBox>();

            foreach (TextBox box in textBoxcollection)
            {
                if (string.IsNullOrWhiteSpace(box.Text))
                {
                    if (box.Name == "textBoxDescription" ||
                        box.Name == "textBoxHeight" ||
                        box.Name == "textBoxLength" ||
                        box.Name == "textBoxWidth" ||
                        box.Name == "textBoxPrice" ||
                        box.Name == "textBoxWeight")
                    {
                        //ignore
                    }
                    else
                    {
                        MessageBox.Show("Kindly Fill all the boxes.");
                        return;
                    }
                }
            }


            foreach (ComboBox combobox in comboBoxcollection)
            {
                if (combobox.SelectedIndex == -1)
                {
                    MessageBox.Show("Kindly Select all the Drop-Downs");
                    return;
                }
            }

            //Added Apr-02. Bug Fixed

            if (!datePickerDOB.SelectedDate.HasValue)
            {
                MessageBox.Show("Kindly Enter Date of Birth");
                return;
            }

            //CheckTextBoxes(this);


            #endregion

            try
            {
                currCalf.Price = 0;

                PhysicalAttributes physicalAttrib = new PhysicalAttributes();
                Entities.Size      currSize       = new Entities.Size();

                if (string.IsNullOrWhiteSpace(textBoxHeight.Text))
                {
                    currSize.Height = 0;
                }
                else
                {
                    currSize.Height = Convert.ToDouble(textBoxHeight.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxLength.Text))
                {
                    currSize.Length = 0;
                }
                else
                {
                    currSize.Length = Convert.ToDouble(textBoxLength.Text);
                }

                if (string.IsNullOrWhiteSpace(textBoxWidth.Text))
                {
                    currSize.Width = 0;
                }
                else
                {
                    currSize.Width = Convert.ToDouble(textBoxWidth.Text);
                }


                if (string.IsNullOrWhiteSpace(textBoxWeight.Text))
                {
                    physicalAttrib.Weight = 0;
                }
                else
                {
                    physicalAttrib.Weight = Convert.ToDouble(textBoxWeight.Text);
                }

                physicalAttrib.CurrentSize = currSize;

                currCalf.CurrPhysicalAttribs = physicalAttrib;

                currCalf.TagNo     = textBoxTagNo.Text;
                currCalf.BirthDate = datePickerDOB.SelectedDate.Value;

                //Only IDs needed for insertion

                currCalf.Breed    = new AnimalBreed();
                currCalf.Breed.ID = ((MasterTables)comboBoxBreed.SelectedItem).ID;


                currCalf.Gender             = new Gender();
                currCalf.Gender.Description = ((MasterTables)comboBoxGender.SelectedItem).Description;  //Modified 31 March

                currCalf.Source    = new AnimalSource();
                currCalf.Source.ID = ((MasterTables)comboBoxSource.SelectedItem).ID;


                currCalf.Type    = new AnimalType();
                currCalf.Type.ID = ((MasterTables)comboBoxAnimalType.SelectedItem).ID;

                //Commented on 01-Apr. No Status required for Calf
                //currCalf.Status = new AnimalStatus();
                //currCalf.Status.ID = ((MasterTables)comboBoxStatus.SelectedItem).ID;


                currCalf.OtherDetails = textBoxDescription.Text;

                Cattle mother = new Cattle();
                Cattle father = new Cattle();

                mother = (Cattle)comboBoxMother.SelectedItem;
                father = (Cattle)comboBoxFather.SelectedItem;

                currCalf.Mother = mother;
                currCalf.Father = father;

                //Added on Paril-02. Static Polymorphism for Calf Procedure
                //Whether it is for just calf
                //calf and mother
                //calf and father
                //or both

                if (mother.TagNo == "Other Farm")
                {
                    if (father.TagNo == "Artificial Insemnation")
                    {
                        animalHandler.Add(currCalf);
                    }
                    else
                    {
                        animalHandler.Add(currCalf, father.ID, 'N');
                    }
                }
                else
                {
                    if (father.TagNo == "Artificial Insemnation")
                    {
                        animalHandler.Add(currCalf, mother.ID, 'Y');
                    }
                    else
                    {
                        animalHandler.Add(currCalf, father.ID, mother.ID);
                    }
                }
            }

            catch (FormatException fexcept)
            {
                MessageBox.Show("Kindly Enter the field in correct (numeric) format. Error on " + fexcept.Source + " .", "Invalid Entry");
                return;
            }

            //Added - 01 Jan
            //For Name/Father name not containing numbers

            catch (ArgumentException aexcept)
            {
                MessageBox.Show(aexcept.Message, "Invalid Entry!");
                return;
            }


            //Clear all the TextBoxes

            foreach (TextBox textbox in textBoxcollection)
            {
                textbox.Text = "";
            }

            foreach (ComboBox combobox in comboBoxcollection)
            {
                combobox.SelectedIndex = -1;
            }

            datePickerDOB.SelectedDate = null;
        }