Esempio n. 1
0
        private void btnSelectCommodity_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var frmShow = new Goodies.FrmShow();
                frmShow.ShowDialog();

                var        goodyId = frmShow.Result;
                Data.Goody goody   = null;
                if (goodyId != Guid.Empty)
                {
                    goody             = Business.GetGoodiesBusiness().GetById(goodyId);
                    txtCommodity.Text = goody.CName;
                }
                else
                {
                    txtCommodity.Text = string.Empty;
                }


                SetUnitCountComboBox(goodyId);
            }
            catch (Exception ex)
            {
                AccountingKernel.Forms.Base.BaseWindow.ShowError(ex);
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// commodity selection event click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSelectCommodity_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var frmShow = new Goodies.FrmShow();
                frmShow.ShowDialog();

                var        goodyId = frmShow.Result;
                Data.Goody goody   = null;
                if (goodyId == Guid.Empty)
                {
                    txtCommodityCode.Text = string.Empty;
                    return;
                }
                goody = Business.GetGoodiesBusiness().GetById(goodyId);
                txtCommodityCode.Text = goody.CName;


                SetUnitCountComboBox(goodyId);
                var company = Business.GetComBusiness().GetByName(txtCompany.Text.Trim());

                txtUnitPrice.Text = Business.GetGoodiesBusiness().SetPrice(cmbUnitCount.SelectedValue.ToGUID(), goody, company).ToString(Localize.DoubleMaskType);
            }
            catch (Exception ex)
            {
                AccountingKernel.Forms.Base.BaseWindow.ShowError(ex);
            }
        }
        private void btnRegister_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var errorMessage = string.Empty;
                if (!ValidateForm(out errorMessage))
                {
                    throw new Exception(errorMessage);
                }

                var goodiesBusiness = Business.GetGoodiesBusiness();
                var goody           = goodiesBusiness.GetById(goodyId.ToGUID());
                if (goody == null)
                {
                    goody = new Data.Goody();
                }

                goody.CName             = txtGoodTitle.Text;
                goody.CNameEn           = txtGoodEngTitle.Text;
                goody.COrderPoint       = txtCOrderPoint.Text.ToNullableInt();
                goody.COrderMax         = txtCOrderMax.Text.ToNullableInt();
                goody.COrderMin         = txtCOrderMin.Text.ToNullableInt();
                goody.CPointCritical    = txtCPointCritical.Text.ToNullableInt();
                goody.CInventoryMax     = txtCInventoryMax.Text.ToNullableInt();
                goody.CBaseCountingUnit = cmbBaseCountingUnit.SelectedValue.ToGUID();
                goody.CType             = cmbType.SelectedValue.ToGUID();
                goody.CID1            = txtGoodCode.Text;
                goody.IdGoodiesGroups = Business.GetGoodiesGroupBusiness().GetByCode(txtMainGroupCode.Text + txtSubsidiaryGroupCode.Text, Common.Constants.CodeTitle.CommoditySubsidiaryGroup).ID;

                using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions()
                {
                    IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted,
                    Timeout = new TimeSpan(2, 0, 0)
                }))
                {
                    goodiesBusiness.Save(goody);

                    scope.Complete();
                }

                this.goodyId = goody.ID;

                this.Close();
            }
            catch (Exception ex)
            {
                AccountingKernel.Forms.Base.BaseWindow.ShowError(ex);
            }
        }
        private void SetUnitCountComboBox(Data.Goody goody)
        {
            try
            {
                var commodityConvertCountingUnits = Business.GetGoodyConvertCountingUnitBusiness().GetByGoodyId(goody.ID).ToList();
                var unitIds = commodityConvertCountingUnits.Where(r => r.CCCUIDBaseInfo1.HasValue).Select(r => r.CCCUIDBaseInfo1.Value).
                              Union(commodityConvertCountingUnits.Where(r => r.CCCUIDBaseInfo2.HasValue).Select(r => r.CCCUIDBaseInfo2.Value)).ToList();
                unitIds.Add(goody.CBaseCountingUnit.Value);

                cmbUnitCount.ItemsSource   = Business.GetBaseInfoBusiness().GetByIds(unitIds).ToList();
                cmbUnitCount.SelectedValue = goody.CBaseCountingUnit;
            }
            catch
            {
                throw;
            }
        }
        private void SetPrice(Data.Goody goody)
        {
            try
            {
                var company = Business.GetComBusiness().GetByName(txtCompany.Text.Trim());

                if (company == null || goody == null)
                {
                    txtUnitPrice.Text = string.Empty;
                }
                else
                {
                    txtUnitPrice.Text = Business.GetGoodiesBusiness().SetPrice(cmbUnitCount.SelectedValue.ToGUID(), goody, company).ToString(Localize.DoubleMaskType);
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 7
0
        private bool ValidateForm(Data.Goody goody, int secondUnitCount, out string errorMessage)
        {
            try
            {
                errorMessage = string.Empty;
                if (!goody.CBaseCountingUnit.HasValue)
                {
                    errorMessage += Localize.ex_no_base_count_unit + Environment.NewLine;
                }

                if (secondUnitCount <= 0)
                {
                    errorMessage = Localize.ex_invalid_unit_count_value + Environment.NewLine;
                }

                return(errorMessage == string.Empty);
            }
            catch
            {
                throw;
            }
        }
Esempio n. 8
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;
            }
        }