Ejemplo n.º 1
0
        private void ButtonUpdateEstate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _updateEstate.EstateID              = counterID;
                _updateEstate.EstateOwnerID         = estateOwnerID;
                _updateEstate.EstateName            = ((ComboBoxItem)ComboBoxChangeEstateName.SelectedItem).Content.ToString();
                _updateEstate.EstateInventoryNumber = TextBoxChangeEstateInventoryNumber.Text;
                _updateEstate.EstateSpace           = double.Parse(TextBoxChangeEstateSpace.Text);
                _updateEstate.EstateAdress          = TextBoxChangeEstateAdress.Text;
                _updateEstate.EstateFunction        = ((ComboBoxItem)ComboBoxChangeEstateFunction.SelectedItem).Content.ToString();
                _updateEstate.EstateYear            = int.Parse(TextBoxChangeEstateYear.Text);
                _updateEstate.EstateWall            = TextBoxChangeEstateWall.Text;
                _updateEstate.EstateState           = "Не продан";
                _updateEstate.EstateOwner           = TextBoxChangeEstateOwner.Text;
                _updateEstate.EstateCostOfSale      = double.Parse(TextBoxChangeEstateCostOfSale.Text);
                _updateEstate.EstateDescription     = TextBoxChangeEstateDescription.Text;

                estateRepository.UpdateEstate(_updateEstate);
                MessageBox.Show("Изменения внесены.");
                this.Close();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка");
            }
        }
Ejemplo n.º 2
0
        private void ButtonAddCOS_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(_newContractOfSale.Error))
                {
                    return;
                }

                bool beBuyer    = true;
                int  _idCounter = 1;
                foreach (ContractOfSale cos in cosRepository.GetAll())
                {
                    _idCounter++;
                }

                _newContractOfSale.ContractOfSaleID     = _idCounter++;
                _newContractOfSale.ContractOfSaleNumber = TextBoxAddCOSNumber.Text;
                _newContractOfSale.ContractOfSaleDate   = DateTime.Parse(DPAddCOSDate.Text);
                _newContractOfSale.ContractOfSaleOwner  = ComboBoxAddCOSOwner.SelectedItem.ToString().Trim();
                _newContractOfSale.ContractOfSaleBuyer  = ComboBoxAddCOSBuyer.Text.Trim();

                _newContractOfSale.ContractOfSaleCost = double.Parse(TextBoxAddCOSCost.Text);
                _newContractOfSale.ContractOfSaleEstateInventoryNumber = ComboBoxAddCOSEstateInventoryNumber.SelectedItem.ToString().Trim();

                foreach (Buyer buyer in new BuyerRepository().GetAll())
                {
                    if (_newContractOfSale.ContractOfSaleBuyer.Trim() == buyer.BuyerName.Trim())
                    {
                        beBuyer = true;
                        _newContractOfSale.ContractOfSaleBuyerID = buyer.BuyerID;
                        break;
                    }
                    else
                    {
                        beBuyer = false;
                    }
                }

                if (beBuyer == false)
                {
                    winAddBuyer.ShowDialog();
                }

                foreach (Estate estate in new EstateRepository().GetAll())
                {
                    if (_newContractOfSale.ContractOfSaleEstateInventoryNumber.Trim() == estate.EstateInventoryNumber.Trim())
                    {
                        _newContractOfSale.ContractOfSaleEstateID = estate.EstateID;
                        estate.EstateState = "Продан";
                        estateRepository.UpdateEstate(estate);
                        break;
                    }
                }

                cosRepository.AddContractOfSale(_newContractOfSale);

                MessageBox.Show("Данные добавлены.");
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка");
            }
        }