コード例 #1
0
        public StoreOrder RegisterStoreOrder(Data.Com company)
        {
            try
            {
                var storeOrder = Business.GetStoreOrderBusiness().GetById(StoreOrderId.ToGUID());

                if (storeOrder == null)
                {
                    storeOrder = new StoreOrder();
                }

                storeOrder.OId   = storeOrder.OId.IsNullOrEmpty() ? Business.GetStoreOrderBusiness().GetLastEditedOId(this.StoreOperationId) : storeOrder.OId;
                storeOrder.ODate = dtpIssueDate.Text;
                if (StoreOperationId == Common.Constants.StoreOperation.WarehouseReceipts)
                {
                    storeOrder.IdCompany = company.Id;
                }
                storeOrder.OReverse         = false;
                storeOrder.ODelete          = false;
                storeOrder.IdStoreOperation = this.StoreOperationId;
                Business.GetStoreOrderBusiness().Save(storeOrder);

                return(storeOrder);
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
 public void Insert(Data.Com company)
 {
     try
     {
         if (company.Id == Guid.Empty)
         {
             company.Id = Guid.NewGuid();
         }
         this.Table.Add(company);
         this.SubmitChanges();
     }
     catch
     {
         throw;
     }
 }
コード例 #3
0
        public void Delete(Data.Com entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                this.Table.Remove(entity);
                this.SubmitChanges();
            }
            catch
            {
                throw;
            }
        }
コード例 #4
0
 public void Save(Data.Com company)
 {
     try
     {
         if (company.Id == Guid.Empty)
         {
             this.Insert(company);
         }
         else
         {
             this.SubmitChanges();
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #5
0
        private void SetStoresForNew(Data.StoreOrder storeOrder, Data.BaseInfo repository, Data.Goody goody, Data.Com company, Data.PriceList priceList)
        {
            try
            {
                var coef = Business.GetGoodyConvertCountingUnitBusiness().FindCoefficient(goody.ID, goody.CBaseCountingUnit.ToGUID(), cmbUnitCount.SelectedValue.ToGUID());

                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(StoreOrderId).ToList();
                    var stores       = new List <Data.Store>();
                    foreach (var item in storeDetails)
                    {
                        var previousStore = Business.GetStoreSBusiness().GetLastForCommodity(item.IdCommodity);
                        var remained      = 0;
                        if (previousStore != null)
                        {
                            remained = previousStore.SRemained.ToInt();
                        }

                        var store = new Data.Store()
                        {
                            IdStoreOrderDetail = item.Id,
                            RegDate            = DateTime.Now,
                            SCount             = item.ODCount,
                            SRemained          = remained - (item.ODCount * coef).ToInt(),
                            Sname            = repository.Id,
                            IdStoreOperation = Common.Constants.StoreOperation.Order,
                            IdCommodity      = item.IdCommodity
                        };
                        Business.GetStoreSBusiness().Insert(store);

                        item.IdStoreS = store.Id;
                    }

                    Business.GetStoreOrderDetailBusiness().SubmitChanges();

                    scope.Complete();
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #6
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;
            }
        }