示例#1
0
        private void SetStores(Data.StoreOrder storeOrder, Data.BaseInfo repository, Data.Goody goody, Data.Com company, Data.PriceList priceList)
        {
            try
            {
                switch (this.FormMode)
                {
                case Common.Enum.FormMode.New:
                    SetStoresForNew(storeOrder, repository, goody, company, priceList);
                    break;

                case Common.Enum.FormMode.Edit:
                    SetStoresForEdit(storeOrder, repository, goody, company, priceList);
                    break;

                default:
                    break;
                }

                if (storeOrder.OId == null)
                {
                    storeOrder.OId = Business.GetStoreOrderBusiness().GetMaxOIdByRepository(repository);
                    Business.GetStoreOrderBusiness().SubmitChanges();
                }
            }
            catch
            {
                throw;
            }
        }
示例#2
0
        private void SetStoresForEdit(Data.StoreOrder storeOrder, Data.BaseInfo repository, Data.Goody goody, Data.Com company, Data.PriceList priceList)
        {
            try
            {
                using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted,
                    Timeout = new TimeSpan(2, 0, 0)
                }))
                {
                    var storeDetails  = Business.GetStoreOrderDetailBusiness().GetByStoreOrderId(storeOrder.Id).ToList();
                    var currentStores = Business.GetStoreSBusiness().GetByStoreOrderDetailIds(storeDetails.Select(r => r.Id).ToList());
                    var stores        = new List <Data.Store>();
                    foreach (var item in storeDetails)
                    {
                        var currentStore  = currentStores.Find(r => r.IdStoreOrderDetail == item.Id);
                        var previousStore = Business.GetStoreSBusiness().GetLastForCommodity(item.IdCommodity);
                        var remained      = 0;
                        if (previousStore != null)
                        {
                            remained = previousStore.SRemained.ToInt();
                        }


                        var coef  = Business.GetGoodyConvertCountingUnitBusiness().FindCoefficient(item.IdCommodity, goody.CBaseCountingUnit.ToGUID(), item.ODCountingUnit);
                        var store = new Data.Store()
                        {
                            IdStoreOrderDetail = item.Id,
                            RegDate            = currentStore == null ? DateTime.Now : currentStore.RegDate,
                            EditDate           = DateTime.Now,
                            SCount             = item.ODCount,
                            SRemained          = remained + currentStore.SCount - (item.ODCount * coef).ToInt(),
                            Sname            = repository.Id,
                            IdStoreOperation = Common.Constants.StoreOperation.PurchaseInvoice,
                            IdCommodity      = item.IdCommodity
                        };

                        Business.GetStoreSBusiness().Insert(store);
                        item.IdStoreS = store.Id;
                    }

                    Business.GetStoreOrderDetailBusiness().SubmitChanges();

                    Business.GetStoreSBusiness().Delete(currentStores);


                    scope.Complete();
                }
            }
            catch
            {
                throw;
            }
        }
示例#3
0
        private void btnSave_click(object sender, RoutedEventArgs e)
        {
            try
            {
                var entity = Business.GetBaseInfoBusiness().GetById(EntityId.ToGUID());
                if (entity == null)
                {
                    entity     = new Data.BaseInfo();
                    entity.PID = this.PID;
                }

                entity.AssignName = txtAssignName.Text;
                entity.Explain    = txtExplain.Text;
                entity.Priority   = txtPriority.Text.ToInt();

                Business.GetBaseInfoBusiness().Save(entity);
            }
            catch
            {
                throw;
            }
        }