Ejemplo n.º 1
0
        public void AddPurchase(PurchaseAdapterEntities entities)
        {
            using (var transaction = Sessions.NewSession.BeginTransaction())
            {
                //write in Purchases table
                var purchasesEntity = new Purchases();
                purchasesEntity.MethodOfPayment = entities.MethodOfPayment;
                purchasesEntity.PurchaseDateTime = entities.PurchaseDateTime;
                purchasesEntity.aspnet_Users = Sessions.NewSession.Get<aspnet_Users>(entities.UserID);
                Sessions.NewSession.SaveOrUpdate(purchasesEntity);
                Sessions.NewSession.Flush();

                //write in PurchasesNote table
                foreach (int item in entities.GoodsIDs)
                {
                    var purchasesNoteEntity = new PurchasesNote();
                    purchasesNoteEntity.Purchases = Sessions.NewSession.Get<Purchases>(purchasesEntity.ID);
                    purchasesNoteEntity.Goods = Sessions.NewSession.Get<Goods>(item);

                    //purchasesNoteEntity.PurchasesID = purchasesEntity.ID;
                    purchasesNoteEntity.GoodsID = item;

                    Sessions.NewSession.SaveOrUpdate(purchasesNoteEntity);
                    Sessions.NewSession.Flush();
                }

                transaction.Commit();
            }
        }
Ejemplo n.º 2
0
        void Button_Save_Click(object sender, EventArgs e)
        {
            if (Session["OrderList"] != null)
            {
                PurchaseAdapterEntities purchaseAdapterEntities = new PurchaseAdapterEntities();
                List<Goods> orderList = new List<Goods>();
                orderList = (List<Goods>)Session["OrderList"];
                IList<int> list1 = new List<int>();

                for (int i = 0; i < orderList.Count; i++)
                {
                    list1.Add(orderList[i].ID);
                }

                purchaseAdapterEntities.GoodsIDs = list1;

                if (ProfileControl1.DropDownList_MethodOfPay.SelectedIndex == 0)
                {
                    purchaseAdapterEntities.MethodOfPayment = true;
                }
                else
                {
                    purchaseAdapterEntities.MethodOfPayment = false;
                }

                purchaseAdapterEntities.PurchaseDateTime = DateTime.Now;
                purchaseAdapterEntities.UserID = userID;

                PurchasesActions purchasesActions = new PurchasesActions();
                purchasesActions.AddPurchase(purchaseAdapterEntities);
            }
        }
Ejemplo n.º 3
0
 public void AddPurchase(PurchaseAdapterEntities entities)
 {
     PurchasesCRUD purchasesCRUD = new PurchasesCRUD();
     purchasesCRUD.AddPurchase(entities);
 }