Exemplo n.º 1
0
        public static List <Cattle> GetUserAnimals(int UId, int AnimalID)
        {
            ac.OpenConnection();


            List <Cattle> cattle = new List <Cattle>();

            //parameter and variable of this Procedure
            string[] variables = new string[] { "@UID", "@AnimalID" };
            string[] values    = new string[] { "" + UId, "" + AnimalID };

            //get data from  database
            DataTable data = ac.ExecuteDataTableProcedure("GetOneAnimal", variables, values, ac);


            if (data.Rows.Count != 0)
            {
                foreach (DataRow row in data.Rows)
                {
                    //offspring
                    List <Cattle> offSpring = new List <Cattle>();

                    //frame size
                    FrameSize frmeSize = (FrameSize)Enum.Parse(typeof(FrameSize), row["CattleFrameSize"].ToString());
                    //Breeding status
                    BreedingStatus bStatus = (BreedingStatus)Enum.Parse(typeof(BreedingStatus), row["CattleBreedingStatus"].ToString());
                    //Status Enum
                    StatusEnum sStatus = (StatusEnum)Enum.Parse(typeof(StatusEnum), row["AnimalStatus"].ToString());
                    //Gender Enum
                    GenderEnum gEnum = (GenderEnum)Enum.Parse(typeof(GenderEnum), row["AnimalGender"].ToString());
                    //animal type
                    AnimalTypeEnum animalType = (AnimalTypeEnum)Enum.Parse(typeof(AnimalTypeEnum), row["AnimalType"].ToString());


                    cattle.Add
                    (
                        new Cattle
                        (
                            int.Parse(row["AnimalTid"].ToString()), row["AnimalBreed"].ToString(), gEnum, double.Parse(row["AnimalAge"].ToString()),
                            int.Parse(row["AnimalYear"].ToString()), int.Parse(row["AnimalMonth"].ToString()), int.Parse(row["AnimalDay"].ToString()),
                            animalType, row[4].ToString(), row[5].ToString(), (int)(Math.Round(double.Parse(row["AnimalAge"].ToString()) / 24)), int.Parse(row["personid"].ToString()),
                            row["personname"].ToString(), row["personSurname"].ToString(), DateTime.Parse(row["personDOB"].ToString()),


                            int.Parse(row["CattleID"].ToString()), int.Parse(row["CattleParentFatherID"].ToString()), int.Parse(row["CattleParentMotherID"].ToString()), (row["CattleImage"].ToString())
                            , offSpring, sStatus, double.Parse(row["CattleScotralSize"].ToString()), row["CattleColor"].ToString(),
                            bStatus, frmeSize,


                            double.Parse(row["CattleBirthWeight"].ToString()), double.Parse(row["CattleWeaningWeight"].ToString()), double.Parse(row["CattlePostWeaningWeight"].ToString()),
                            double.Parse(row["CattleAdultSxWeight"].ToString()), double.Parse(row["CattleCurrentAdultWeight"].ToString()), DateTime.Parse(row["CattleCurrentWeightDateTaken"].ToString()), null, null, null

                        ));
                }
            }



            return(cattle);
        }
Exemplo n.º 2
0
        public Cattle
        (
            int aId, string aBreed, GenderEnum aGender, double aAge, int aYear, int aMonth, int aDay,
            AnimalTypeEnum aType, string aIdentifactionChar, string aCustomeIdentifaction,
            int oId,

            int pId, string pName, string pSurname, DateTime dob,

            int cId, int cParentFId, int cParentMId, string cImagePath, List <Cattle> cOffSpring,

            StatusEnum status, double cScotralSize, string cColor, BreedingStatus cBreedingStatus,

            FrameSize cFrameSize, double cBirthWeight, double cWeaningWeight, double cPostWeaningWeight,

            double cAdultSxWeight, double cCurrentAdultWeight, DateTime cCurrentWeightDateTaken, List <string> cDiagnoses, List <double> cAdultWeightHistory, List <DateTime> cAdultWeightDateHistory, DateTime aDOB



        )
            : base(aId, aBreed, aGender, aAge, aYear, aMonth, aDay, aType,
                   oId, pId, pName, pSurname, dob, status, aIdentifactionChar, aCustomeIdentifaction)
        {
            this.cId        = cId;
            this.cParentFId = cParentFId;
            this.cParentMId = cParentMId;
            this.cImagePath = cImagePath;
            this.cOffSpring = cOffSpring;


            this.cScotralSize            = cScotralSize;
            this.cColor                  = cColor;
            this.cBreedingStatus         = cBreedingStatus;
            this.cFrameSize              = cFrameSize;
            this.cBirthWeight            = cBirthWeight;
            this.cWeaningWeight          = cWeaningWeight;
            this.cPostWeaningWeight      = cPostWeaningWeight;
            this.cAdultSxWeight          = cAdultSxWeight;
            this.cCurrentAdultWeight     = cCurrentAdultWeight;
            this.cCurrentWeightDateTaken = cCurrentWeightDateTaken;

            //------
            this.cDiagnoses = cDiagnoses;
            this.cAdultWeightDateHistory = cAdultWeightDateHistory;
            this.cAdultWeightHistory     = cAdultWeightHistory;
            //------
            this.aDOB = aDOB;
        }
Exemplo n.º 3
0
        //get Offspring
        public static List <Cattle> GetAnimalsOffSpring(int UId, int AnimalID, string gender, Person person)
        {
            ac.OpenConnection();

//            create procedure GetAnimalOffspring
//@UID Bigint,
//@AID Bigint,
//@ParentGender varchar(100)

            List <Cattle> cattle = new List <Cattle>();

            //parameter and variable of this Procedure
            string[] variables = new string[] { "@UID", "@AID", "@ParentGender" };
            string[] values    = new string[] { "" + UId, AnimalID.ToString(), gender };

            //get data from  database
            DataTable data = ac.ExecuteDataTableProcedure("GetAnimalOffspring", variables, values, ac);



            if (data.Rows.Count != 0)
            {
                foreach (DataRow row in data.Rows)
                {
                    //A.PERSONID,
                    //A.AnimalTid	        0, A.AnimalType 1,	 A.AnimalBreed 2, A.AnimalCustomID 3,	 A.AnimalCurOwnerSignature 4,	 A.AnimalGender        5,
                    //A.AnimalAge            6, A.AnimalYear 7,	 A.AnimalMonth 8, A.AnimalDay      9,	 A.AnimalStatus            10,	 A.IdentificationChar  11,
                    //C.CattleParentFatherID 12,	C.CattleParentMotherID	13,C.CattleImage	14,C.CattleScotralSize	15,C.CattleColor	16,C.CattleBreedingStatus	17,
                    //C.CattleFrameSize	18,C.CattleBirthWeight	19,C.CattleWeaningWeight	20,C.CattlePostWeaningWeight	21,C.CattleAdultSxWeight 22,
                    //C.CattleCurrentAdultWeight 23,	C.CattleCurrentWeightDateTaken 24

                    //offspring
                    List <Cattle> offSpring = new List <Cattle>();
                    #region Enums
                    //frame size
                    FrameSize frmeSize = (FrameSize)Enum.Parse(typeof(FrameSize), row[19].ToString());
                    //Breeding status
                    BreedingStatus bStatus = (BreedingStatus)Enum.Parse(typeof(BreedingStatus), row[18].ToString());
                    //Status Enum
                    StatusEnum sStatus = (StatusEnum)Enum.Parse(typeof(StatusEnum), row[11].ToString());
                    //Gender Enum
                    GenderEnum gEnum = (GenderEnum)Enum.Parse(typeof(GenderEnum), row[6].ToString());
                    //animal type
                    AnimalTypeEnum animalType = (AnimalTypeEnum)Enum.Parse(typeof(AnimalTypeEnum), row[2].ToString());
                    #endregion

                    //weights
                    List <double>   weights    = DataAccessData.AnimalWeightHistory(person.PId, int.Parse(row[1].ToString())).Values.ToList();
                    List <DateTime> weightDate = DataAccessData.AnimalWeightHistory(person.PId, int.Parse(row[1].ToString())).Keys.ToList();
                    cattle.Add
                    (
                        new Cattle
                        (
                            int.Parse(row[1].ToString()), row[3].ToString(), gEnum, double.Parse(row[7].ToString()),
                            int.Parse(row[8].ToString()), int.Parse(row[9].ToString()), int.Parse(row[10].ToString()),
                            animalType, row[4].ToString(), row[5].ToString(), person.PId, person.PId, person.PName, person.PSurname, person.Dob, 14478899, int.Parse(row[13].ToString()), int.Parse(row[14].ToString()),
                            row[15].ToString()
                            , null,
                            sStatus, double.Parse(row[16].ToString()), row[17].ToString(),
                            bStatus, frmeSize,

                            double.Parse(row[20].ToString()), double.Parse(row[21].ToString()), double.Parse(row[22].ToString()),
                            double.Parse(row[23].ToString()), double.Parse(row[24].ToString()), DateTime.Parse(row[25].ToString()), null, weights, weightDate

                        ));
                }
            }


            return(cattle);
        }