Ejemplo n.º 1
0
        internal static void PushVareDown(Vare v)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var res2= session.CreateQuery("select MAX(Rank) from Vare");
                    int i = (int)res2.UniqueResult();

                    int temp;
                    if (v.Rank != i)
                    {
                        temp = v.Rank;
                        v.Rank++;

                        var res = session.CreateQuery("from Vare Where Rank = :rank").SetParameter("rank", v.Rank);
                        Vare vv = (Vare)res.UniqueResult();
                        vv.Rank = temp;

                        session.Update(v);
                        session.Update(v);
                        transaction.Commit();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 internal static void LagreSalg(Vare v)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             Salg s = new Salg() { Pris = v.Pris, SlagsTid = DateTime.Now, VareId = v.Id};
             session.Save(s);
             transaction.Commit();
         }
     }
 }
Ejemplo n.º 3
0
 internal static void UpdateVare(Vare v)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             session.Update(v);
             transaction.Commit();
         }
     }
 }
Ejemplo n.º 4
0
        internal static void Save(Vare vare)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    int i = 0;
                    try
                    {
                        var res = session.CreateQuery("select MAX(Rank) from Vare");
                         i = (int)res.UniqueResult();
                        i++;
                    }
                    catch (Exception e)
                    {

                    }
                    if (i == 0)
                    {
                        i = 1;
                    }
                    vare.Rank = i;
                    Console.WriteLine(i);
                    session.Save(vare);
                    transaction.Commit();

                }
            }
        }
Ejemplo n.º 5
0
        internal static void PushVareUp(Vare v)
        {
            using (ISession session = NHibernateHelper.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    int temp;
                    if(v.Rank != 1){
                        temp= v.Rank;
                        v.Rank--;

                        var res = session.CreateQuery("from Vare Where Rank = :rank").SetParameter("rank", v.Rank);
                        Vare vv = (Vare)res.UniqueResult();
                        vv.Rank = temp;

                        session.Update(v);
                        session.Update(v);
                        transaction.Commit();
                    }
                }
            }
        }