/// <summary> /// register store order detail /// </summary> private StoreOrderDetail RegisterStoreDetail(StoreOrder storeOrder, Data.PriceList priceList) { try { var commodity = Business.GetGoodiesBusiness().GetByName(txtCommodity.Text); if (commodity == null) { throw new Exception(Localize.ex_commodity_not_found); } var storeOrderDetailBusiness = Business.GetStoreOrderDetailBusiness(); var storeOrderDetail = Business.GetStoreOrderDetailBusiness().GetByCommodity(storeOrder, commodity.ID, cmbUnitCount.SelectedValue.ToGUID()); if (storeOrderDetail == null) { storeOrderDetail = new StoreOrderDetail(); } var company = Business.GetComBusiness().GetByName(txtCompany.Text.Trim()); storeOrderDetail.IdStoreOrder = storeOrder.Id; storeOrderDetail.IdCommodity = commodity.ID; storeOrderDetail.ODCountingUnit = cmbUnitCount.SelectedValue.ToGUID(); storeOrderDetail.ODCount = storeOrderDetail.ORemained = txtCount.Text.ToInt(); storeOrderDetail.ODMoney = priceList.PLPrice * txtCount.Text.ToInt(); //storeOrderDetail.ODDiscount = txtDicountPrice.Text.ToDecimal(); storeOrderDetail.ODDescription = txtComment.Text; Business.GetStoreOrderDetailBusiness().Save(storeOrderDetail); return(storeOrderDetail); } catch { throw; } }
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; } }
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; } }