예제 #1
0
        public static int LoginGetUserID(string uName, string uPassword, bool uAccess)
        {
            //add access type
            int userID = DataAccessData.LoginUser(uName, uPassword, uAccess);

            return(userID);
        }
예제 #2
0
        public static Person GetPersonInfo(int userID)
        {
            //gets user data
            Person personData = DataAccessData.GetUserDetails(userID);

            return(personData);
        }
예제 #3
0
        public static Cattle GetCattleInfo(int OwnerID, Person person)
        {
            //get data from data model
            Cattle cattleSingu = null;

            CattleData = new List <Cattle>();
            CattleData.Clear();
            if (CattleData == null || CattleData.Count == 0)
            {
                List <Cattle> cattle = DataAccessData.GetUserAnimals(OwnerID, person);
                if (cattle.Count > 0)
                {
                    cattleSingu = cattle.ElementAt(0);
                    CattleData  = cattle;
                }
            }



            return(cattleSingu);
        }
예제 #4
0
        /// <summary>
        /// Login process
        /// </summary>
        /// <param name="uName"></param>
        /// <param name="uPassword"></param>
        /// <param name="uAccess"></param>
        /// <returns></returns>
        public static bool LoginValidateUser(string uName, string uPassword, bool uAccess)
        {
            bool validationStatus = DataAccessData.ValidateUserLogin(uName, uPassword, uAccess);

            return(validationStatus);
        }
예제 #5
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);
        }
예제 #6
0
        public static bool AddNewAnimal(Cattle P)
        {
            bool state = DataAccessData.AddNewAnimal(P.PId, P);

            return(state);
        }
예제 #7
0
        //sequence iD from database to add new Animal
        public static int  GetNewCattleID()
        {
            int id = DataAccessData.GetSeqAddNewAnimal();

            return(id);
        }