Exemple #1
0
        private void SetAIHistory()
        {
            this.AIHistories = new List <AIHistory>();
            AIHistory ins;

            SqlConnection sqlConn = DataBaseConnection.SqlConn();

            using (var con = sqlConn)
            {
                con.Open();

                using (SqlCommand cmd = new SqlCommand("exec " + StoredProcedures.GetAIHistory + " @AnimalId", con))
                {
                    cmd.Parameters.AddWithValue("@AnimalId", this.AnimalId);

                    using (var drI = cmd.ExecuteReader())
                    {
                        while (drI.Read())
                        {
                            ins         = new AIHistory();
                            ins.TubeId  = Convert.ToInt32(drI["TubeId"]);
                            ins.AIDate  = Convert.ToDateTime(drI["ModifiedDate"]);
                            ins.MaleId  = Convert.ToInt32(drI["AnimalId"]);
                            ins.MaleTag = drI["TagNumber"].ToString();

                            this.AIHistories.Add(ins);
                        }
                    }
                }

                con.Close();
                con.Dispose();
            }
        }
Exemple #2
0
        private string GetBestAIMale()
        {
            var grouped = this.AIHistories
                          .GroupBy(s => s.MaleId)
                          .Select(g => new { MaleId = g.Key, Count = g.Count() }).ToList();

            var ordered = grouped.OrderByDescending(x => x.Count).ToList();

            int Best = ordered.First().MaleId;

            AIHistory Selected = this.AIHistories.Where(x => x.MaleId == Best).ToList().First();

            return(Selected.MaleTag);
        }
Exemple #3
0
        private void SetAIHistory()
        {
            this.AIHistories = new List<AIHistory>();
            AIHistory ins;

            SqlConnection sqlConn = DataBaseConnection.SqlConn();

            using (var con = sqlConn)
            {
                con.Open();

                using (SqlCommand cmd = new SqlCommand("exec " + StoredProcedures.GetAIHistory + " @AnimalId", con))
                {
                    cmd.Parameters.AddWithValue("@AnimalId", this.AnimalId);

                    using (var drI = cmd.ExecuteReader())
                    {
                        while (drI.Read())
                        {
                            ins = new AIHistory();
                            ins.TubeId = Convert.ToInt32(drI["TubeId"]);
                            ins.AIDate = Convert.ToDateTime(drI["ModifiedDate"]);
                            ins.MaleId = Convert.ToInt32(drI["AnimalId"]);
                            ins.MaleTag = drI["TagNumber"].ToString();

                            this.AIHistories.Add(ins);
                        }
                    }
                }

                con.Close();
                con.Dispose();
            }
        }