public void Enter(Calf calf)
 {
     _calf = calf;
     _calf._navMeshAgent.speed = _calf.animalStats.chaseSpeed;
     _calf.isChaseState        = true;
 }
        private List <Calf> selectCalfs(SqlCommand cmd)
        {
            cmd.CommandType = CommandType.StoredProcedure;
            SqlConnection con       = cmd.Connection;
            List <Calf>   listCalfs = new List <Calf>();

            con.Open();
            using (con)
            {
                SqlDataReader dr = cmd.ExecuteReader();

                //              [TagNo]                     0
                //   ,[RegistrationDate]                    1
                //   ,[AnimalType]                          2
                //,at.Description                           3
                //   ,[Gender]                              4
                //ID                                            5
                //   ,[BirthDate]                       6
                //   ,[Weight]                      7
                //   ,[Height]                      8
                //   ,[Length]                      9
                //   ,[Width]                       10
                //   ,[Price]                           11
                //   ,[Source]                          12
                //,aso.Description                      13
                //   ,[Breed]                                   14
                //,ab.Description                          15
                //   ,[Status]                                16
                //,ast.Description                     17
                //   ,[OtherDetails]                 18
                //   Mother                                19
                // Mother TagNo                     20              Added Apr-02
                //Father                                   21
                // Father TagNo                    22              Added Apr-02

                if (dr.HasRows)
                {
                    listCalfs = new List <Calf>();
                    while (dr.Read())
                    {
                        AnimalBreed currCattleBreed = new AnimalBreed           //14,15
                        {
                            ID          = Convert.ToInt32(dr[14]),
                            Description = Convert.ToString(dr[15])
                        };

                        AnimalSource currCattleSource = new AnimalSource  //12,13
                        {
                            ID          = Convert.ToInt32(dr[12]),
                            Description = Convert.ToString(dr[13])
                        };
                        AnimalStatus currCattleStatus = new AnimalStatus        //16 , 17
                        {
                            ID          = Convert.ToInt32(dr[16]),
                            Description = Convert.ToString(dr[17])
                        };
                        AnimalType currCattleType = new AnimalType()            //2, 3
                        {
                            ID          = Convert.ToInt32(dr[2]),
                            Description = Convert.ToString(dr[3])
                        };
                        Gender currCattleGender = new Gender()                  //4 , 5
                        {
                            Description = Convert.ToString(dr[4])
                        };

                        PhysicalAttributes currPhysicalAttribs = new PhysicalAttributes();

                        currPhysicalAttribs.Weight = Convert.ToDouble(dr[7]);   //7

                        Entities.Size currSize = new Entities.Size();           //TO avoid ambiguity among .Net's Size function

                        currSize.Height = Convert.ToDouble(dr[8]);
                        currSize.Length = Convert.ToDouble(dr[9]);
                        currSize.Width  = Convert.ToDouble(dr[10]);

                        currPhysicalAttribs.CurrentSize = currSize;

                        Cattle currCalfMother = new Cattle();
                        Cattle currCalfFather = new Cattle();

                        //Added April-02

                        currCalfMother.ID = Convert.ToInt32(dr[20]);

                        if (currCalfMother.ID == 0)
                        {
                            currCalfMother.TagNo = "Other Farm";
                        }
                        else
                        {
                            currCalfMother.TagNo = Convert.ToString(dr[19]);
                        }

                        currCalfFather.ID = Convert.ToInt32(dr[22]);

                        if (currCalfFather.ID == 0)
                        {
                            currCalfFather.TagNo = "Artificial Insemnation";
                        }
                        else
                        {
                            currCalfFather.TagNo = Convert.ToString(dr[21]);
                        }

                        //Addition Ends. April-02

                        Calf currCalf = new Calf
                        {
                            ID               = Convert.ToInt32(dr[5]),
                            TagNo            = Convert.ToString(dr[0]),
                            RegistrationDate = Convert.ToDateTime(dr[1]),
                            BirthDate        = Convert.ToDateTime(dr[6]),
                            Price            = Convert.ToInt32(dr[11]),
                            OtherDetails     = Convert.ToString(dr[18])
                        };

                        currCalf.Mother = currCalfMother;
                        currCalf.Father = currCalfFather;

                        currCalf.Breed  = currCattleBreed;
                        currCalf.Gender = currCattleGender;
                        currCalf.CurrPhysicalAttribs = currPhysicalAttribs;
                        currCalf.Source = currCattleSource;
                        currCalf.Status = currCattleStatus;
                        currCalf.Type   = currCattleType;

                        listCalfs.Add(currCalf);
                    }
                }
            }
            return(listCalfs);
        }
예제 #3
0
 public void Enter(Calf calf)
 {
     _calf                     = calf;
     _calf.isIdleState         = true;
     _calf._navMeshAgent.speed = 0;//
 }
예제 #4
0
 public void Enter(Calf calf)
 {
     _calf = calf;
     _calf.isDeathState          = true;
     _calf._navMeshAgent.enabled = false;
 }
        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;
        }