示例#1
0
        private void Init()
        {
            _tbName.Text        = "";
            _upDownPrice.Value  = decimal.Zero;
            _upDownAmount.Value = decimal.Zero;

            using (var context = new Context())
            {
                _observableUnit       = new ObservableRangeCollection <UnitOfMeasure>(context.UnitsOfMeasure);
                _cbUnit.ItemsSource   = _observableUnit;
                _cbUnit.SelectedIndex = 0;
                _currency             = context.Currencies.FirstOrDefault(c => c.Code == "PLN");
            }

            Show();
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new Context())
            {
                _consumer                  = context.Consumers.FirstOrDefault(c => c.Id == _consumer.Id) ?? new Consumer();
                _consumer.CompanyName      = _tbCompanyName.Text;
                _consumer.ConsumerName     = _tbName.Text;
                _consumer.ConsumerLastName = _tbLastName.Text;
                _consumer.Street           = _tbAddress.Text;
                _consumer.PostCode         = _tbPostCode.Text;
                _consumer.Nip              = _tbNIP.Text;

                var result = Saver.Save(_consumer, context);
                if (result)
                {
                    Delegates.ChangeInConsumer?.Invoke();
                    var dialog = new MessageBox(Properties.strings.messageBoxStatement, Properties.strings.saveSuccessful);
                    dialog.Show();
                }
            }
        }