Beispiel #1
0
        // 修改货品类别
        public static void ModifyGoodType(GoodsType gt)
        {
            //ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory();
            ISession          session = NHibernateHelper.sessionFactory.OpenSession();
            ITransaction      tx      = session.BeginTransaction();
            IQuery            query   = session.CreateQuery("FROM GoodsType WHERE GoodsTypeID = :sGoodsTypeID").SetString("sGoodsTypeID", gt.GoodsTypeID.ToString());
            IList <GoodsType> eList   = query.List <GoodsType>();

            try
            {
                foreach (GoodsType item in eList)
                {
                    item.GoodsTypeName = gt.GoodsTypeName;
                    item.GoodsTypePID  = gt.GoodsTypePID;
                    session.Update(item);
                }
                tx.Commit();
                session.Close();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                tx.Rollback();
                session.Close();
            }
        }
Beispiel #2
0
        // 添加货品类别
        public static void AddGoodType(GoodsType gt)
        {
            //ISessionFactory sessionFactory = new Configuration().Configure().BuildSessionFactory();
            ISession     session = NHibernateHelper.sessionFactory.OpenSession();
            ITransaction tx      = session.BeginTransaction();

            try
            {
                session.Save(gt);
                tx.Commit();
                session.Close();
                //更新dslocal
                FillGoodType();
            }
            catch (Exception e)
            {
                Debug.Assert(false, e.Message);
                tx.Rollback();
                session.Close();
            }
        }
Beispiel #3
0
 /// <summary>
 /// 添加商品类型
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public bool AddGoodsType(GoodsType type)
 {
     _context.GoodsTypes.Add(type);
     return(_context.SaveChanges() > 0);
 }