public AddAgeClassViewModel(int tournamentId) { _ageClass = new AgeClass() { TournamentId = tournamentId }; }
public static void Main(string[] args) { AgeClass Asmuo = new AgeClass("Justina", "Bauz", new DateTime(2018, 2, 13)); Console.WriteLine("Vardas - {0}, Pavarde - {1}, Gimimo Metai - {2}, Metai - {3}", Asmuo.Vardas, Asmuo.Pavarde, Asmuo.GimimoMetai, Asmuo.GetAge()); }
public void GetAgeTest() { AgeClass Asmuo = new AgeClass("Juste", "Bauz", new DateTime(2018, 2, 13)); int expected = 1; int actual = Asmuo.GetAge(); Assert.AreEqual(expected, actual); }
public void GetAgeTest() { AgeClass Age = new AgeClass(); Age.GimimoMetai = DateTime(2018, 2, 13); int expected = 1; int actual = Age.GetAge(); Assert.AreEqual(expected, actual); }
public object[] AgeData(int?number1, int?number2, int?number3) { List <AgeClass> agc = new List <AgeClass>(); DataContext da = new DataContext(); string age = "", age1 = "", age2 = "", age3 = "", age4 = "", age5 = ""; int Count = 0, Count1 = 0, Count2 = 0, Count3 = 0, Count4 = 0, Count5 = 0; if (!number1.HasValue && !number2.HasValue && !number3.HasValue) { foreach (Patient p in da.Patients) { int Age = Convert.ToInt32(p.Age); if (Age < 13) { age = "Less than 13"; Count++; } if ((Age >= 13) && (Age <= 18)) { age1 = "13 - 18"; Count1++; } if ((Age >= 19) && (Age <= 30)) { age2 = "19 - 30"; Count2++; } if ((Age >= 31) && (Age <= 45)) { age3 = "31 - 45"; Count3++; } if ((Age >= 46) && (Age <= 60)) { age4 = "46 - 60"; Count4++; } if (Age >= 61) { age5 = "61 Above"; Count5++; } } AgeClass obj = new AgeClass(age, Count); AgeClass obj1 = new AgeClass(age1, Count1); AgeClass obj2 = new AgeClass(age2, Count2); AgeClass obj3 = new AgeClass(age3, Count3); AgeClass obj4 = new AgeClass(age4, Count4); AgeClass obj5 = new AgeClass(age5, Count5); agc.Add(obj); agc.Add(obj1); agc.Add(obj2); agc.Add(obj3); agc.Add(obj4); agc.Add(obj5); } if (number1.HasValue) { age1 = number1.ToString(); var ag = (from e in da.Patients.ToList() where e.Age == number1.Value.ToString() select e.Age).ToList(); foreach (var p in ag) { Count1++; } AgeClass obj1 = new AgeClass(age1, Count1); agc.Add(obj1); } if (number2.HasValue && number3.HasValue) { foreach (Patient p in da.Patients) { int Age = Convert.ToInt32(p.Age); if ((Age >= number2.Value) && (Age <= number3.Value)) { age1 = number2.Value.ToString() + "-" + number3.Value.ToString(); Count1++; } } AgeClass obj1 = new AgeClass(age1, Count1); agc.Add(obj1); } var chartData = new object[agc.Count + 1]; chartData[0] = new object[] { "Age Group", "Age Count" }; int count = 0; foreach (var i in agc) { count++; chartData[count] = new object[] { i.AgeG, i.count }; } return(chartData); }
public void LoadData() { ISession session = NHibernateHelper.GetCurrentSession(); ITransaction tx = session.BeginTransaction(); females = Individual.LoadAllFemales(session); adult = session.Get <AgeClass>("A"); unknown = session.Get <ReproductiveState>("U"); BindingList <ReproductiveState> states = new BindingList <ReproductiveState>(session .CreateQuery("from ReproductiveState").List <ReproductiveState>()); this.comboBoxState.DataSource = states; this.comboBoxStateNew.DataSource = new BindingList <ReproductiveState>(states); // Get troop visit before this date TroopVisit mostRecentTroopVisit = session .CreateQuery("select tv from TroopVisit as tv " + "left join fetch tv.Troop as t " + //"left join fetch tv.Observers " + "where t.TroopID = :troopID and " + "tv.Date < :date " + "order by tv.Date desc") .SetParameter <string>("troopID", DailyData.Current.TroopVisit.Troop.TroopID) .SetParameter <DateTime>("date", DailyData.Current.TroopVisit.Date.Date) .SetMaxResults(1) .UniqueResult <TroopVisit>(); // If we have a previous troop visit date, then lets get all the // previous reproductive states if (mostRecentTroopVisit != null) { initialReproductiveStates = (List <IndividualReproductiveState>)session .CreateQuery("select r from IndividualReproductiveState as r " + "left join fetch r.TroopVisit as tv " + "left join fetch tv.Observers " + "where tv = :troopVisit ") .SetParameter <TroopVisit>("troopVisit", mostRecentTroopVisit) .SetResultTransformer(new DistinctRootEntityResultTransformer()) .List <IndividualReproductiveState>(); } List <IndividualReproductiveState> tempReproductivestateList = new List <IndividualReproductiveState>(initialReproductiveStates); // Lets also get all the current ones for today, if they are already entered if (DailyData.Current.RetrievedData) { todaysReproductiveStates = (List <IndividualReproductiveState>)session .CreateQuery("select r from IndividualReproductiveState as r " + "left join fetch r.TroopVisit as tv " + "left join fetch tv.Observers " + "where tv = :troopVisit ") .SetParameter <TroopVisit>("troopVisit", DailyData.Current.TroopVisit) .SetResultTransformer(new DistinctRootEntityResultTransformer()) .List <IndividualReproductiveState>(); // List todays entries if there are any foreach (IndividualReproductiveState s in todaysReproductiveStates) { bool replacement = false; for (int i = 0; i < todaysReproductiveStates.Count; i++) { if (tempReproductivestateList[i].Individual.ID == s.Individual.ID) { tempReproductivestateList[i] = s; replacement = true; break; } } if (!replacement) { tempReproductivestateList.Add(s); } } } tx.Commit(); females = females.FindAll(new Predicate <Individual>(x => x.CurrentTroop(DailyData.Current.TroopVisit.Date) != null && x.CurrentTroop(DailyData.Current.TroopVisit.Date).TroopID == DailyData.Current.TroopVisit.Troop.TroopID)); // Add any new individuals from previous page females.AddRange(DailyData.Current.NewIndividuals.FindAll( new Predicate <Individual>(x => x.Sex == Individual.SexEnum.F))); // Remove females who already have entries foreach (IndividualReproductiveState irs in tempReproductivestateList) { int index = females.FindIndex(new Predicate <Individual>(x => x.ID == irs.Individual.ID)); if (index >= 0) { females.RemoveAt(index); } } if (females.Count == 0) { this.comboBoxFemales.Enabled = false; this.buttonAdd.Enabled = false; this.comboBoxStateNew.Enabled = false; } else { this.comboBoxFemales.DataSource = females; } // Set missing individuals to unknown automatically // Check to see if the individual was not seen today, replace with unknown if so for (int i = 0; i < tempReproductivestateList.Count; i++) { IndividualReproductiveState current = tempReproductivestateList[i]; // We do not need to replace exising unknow entries for today if (current.State != unknown && current.TroopVisit.Date.Date != DailyData.Current.TroopVisit.Date.Date && DailyData.Current.MissingToday.FindIndex( x => x.ID == current.Individual.ID) > -1) { IndividualReproductiveState irs = new IndividualReproductiveState(); irs.TroopVisit = DailyData.Current.TroopVisit; irs.Individual = current.Individual; irs.State = unknown; irs.Comments = "AUTOMATICALLY GENERATED ENTRY :- Not seen on this troop visit."; tempReproductivestateList[i] = irs; } } // Finally lets remove any individuals who have been listed as migrated // fropm the list foreach (Individual i in DailyData.Current.MigratedToday) { int index = tempReproductivestateList.FindIndex(x => x.Individual.ID == i.ID); if (index >= 0) { tempReproductivestateList.RemoveAt(index); } } this.boundReproductiveStates = new SortableBindingList <IndividualReproductiveState>(tempReproductivestateList); this.dataGridView1.DataSource = boundReproductiveStates; FinishedLoading(this, null); }