예제 #1
0
        internal static List <Visit> GetVisitsWithinDates(DateTime start, DateTime end)
        {
            List <Visit> list = new List <Visit>();;

            using (ISession session = NHibernateHelper.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var res = session.CreateQuery(" FROM Visit WHERE VisitTime >= :start " +
                                                  "AND VisitTime <= :end order by VisitTime")
                              .SetParameter("start", start)
                              .SetParameter("end", end)
                              .List <Visit>();
                    list = (List <Visit>)res;


                    //var res = session.CreateQuery("from Kid k where k.FirstName + ' ' + k.LastName = :name")
                    //  .SetParameter("name", kidName)
                }
            }

            return(list);
        }
예제 #2
0
        private Boolean RegisterVisit(string kidName)
        {
            Visit v = new Visit();
            Kid   k = GetKid(kidName);

            v.KidId = k;
            using (ISession session = NHibernateHelper.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        session.Save(v);
                        transaction.Commit();
                    }
                    catch (GenericADOException e)
                    {
                        Console.WriteLine(e.StackTrace);
                        return(false);
                    }
                }
            }
            return(true);
        }
예제 #3
0
        public static object getAllKids()
        {
            List <object> list = new List <object>();

            list.Add("");
            using (ISession session = NHibernateHelper.OpenSession())
            {
                if (session != null)
                {
                    using (ITransaction transaction = session.BeginTransaction())
                    {
                        var res = session.CreateCriteria(typeof(Kid)).List <Kid>();
                        foreach (var item in res)
                        {
                            if (item.Deleted == false)
                            {
                                list.Add(item.FirstName + " " + item.LastName);
                            }
                        }
                    }
                }
            }
            return(list);
        }