Esempio n. 1
0
        // Открытие карточки товара

        private void dgGoods_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (dgGoods.SelectedItem != null)
            {
                GoodsInDeal goodsInDeal = (GoodsInDeal)dgGoods.SelectedItem;
                Application.Current.Properties["id"] = goodsInDeal.ID_Goods;
                NavigationService.Content            = new GoodsPage();
            }
        }
Esempio n. 2
0
        // Событие добавления товара

        private void btnAddNewGoods_Click(object sender, RoutedEventArgs e)
        {
            _newGoodsInDeal.Goods = _databasenEtities.Goods.Single(a => a.ID == _newGoodsInDeal.ID_Goods);

            if (_newGoodsInDeal.Goods.CountUnits >= _newGoodsInDeal.CountUnits)
            {
                _goodsInDealList.Add(_newGoodsInDeal);

                // Подсчет общей суммы

                decimal price = Decimal.Parse(tbPrice.Text, CultureInfo.InvariantCulture);
                price       += _newGoodsInDeal.CountUnits * _newGoodsInDeal.Goods.Price;
                tbPrice.Text = price.ToString();

                _newGoodsInDeal.Goods.CountUnits -= _newGoodsInDeal.CountUnits;

                gNewGoods.DataContext = _newGoodsInDeal = new GoodsInDeal();
                dgGoods.Items.Refresh();
            }
            else
            {
                MessageService.MetroMessageDialog("Количесто товара не достаточно", "Вы ввели количество товара больше чем есть в наличие.");
            }
        }
Esempio n. 3
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Deal deal        = _newDeal = new Deal();
                    _newGoodsInDeal  = new GoodsInDeal();
                    _goodsInDealList = new List <GoodsInDeal>();
                    List <CardClient> companyList = new List <CardClient> {
                        new CardClient()
                    };

                    if (!_isNewRecord)
                    {
                        deal = _databasenEtities.Deal.Single(a => a.ID == _ID_Row);
                        _goodsInDealList.AddRange(_databasenEtities.GoodsInDeal.Where(a => a.Deal.ID == deal.ID));
                        ID_User = deal.ID_Staff;
                    }

                    Staff[] staffArr = _databasenEtities.Staff.ToArray();
                    companyList.AddRange(_databasenEtities.CardClient.Where(a => !String.IsNullOrEmpty(a.NameCompany)).ToArray());
                    ConditionDeal[] conditionDealArr = _databasenEtities.ConditionDeal.OrderBy(a => a.Name).ToArray();
                    TypeGoods[] typeGoodsArr         = _databasenEtities.TypeGoods.OrderBy(a => a.Name).ToArray();
                    People[] peopleArr;

                    if (deal.People != null && deal.People.CardClient != null && deal.People.CardClient.NameCompany != "")
                    {
                        peopleArr = _databasenEtities.People.Where(a => a.ID_CardClient == deal.People.ID_CardClient).ToArray();
                    }
                    else
                    {
                        peopleArr = _databasenEtities.People.ToArray();
                    }

                    Dispatcher.Invoke(() =>
                    {
                        gbDeal.DataContext      = deal;
                        cbCompany.ItemsSource   = companyList;
                        cbStaff.DataContext     = this;
                        cbStaff.ItemsSource     = staffArr;
                        cbPeople.ItemsSource    = peopleArr;
                        cbStatus.ItemsSource    = conditionDealArr;
                        cbTypeGoods.ItemsSource = typeGoodsArr;
                        dgGoods.ItemsSource     = _goodsInDealList;
                        gNewGoods.DataContext   = _newGoodsInDeal;

                        if (_isNewRecord)
                        {
                            cbStaff.IsEnabled       = false;
                            dpDateDeal.IsEnabled    = false;
                            tbCompanyID.Text        = "0";
                            dpDateDeal.SelectedDate = DateTime.Now;
                        }
                        else
                        {
                            cbCompany.SelectedValue = deal.People.ID_CardClient;

                            if (deal.People.CardClient.NameCompany == "")
                            {
                                tbCompanyID.Text = "0";
                            }
                        }

                        gMain.IsEnabled = true;
                    });
                }
                catch (Exception ex)
                {
                    MessageService.MetroMessageDialogError(ex.Message);
                }
            });
        }