Exemplo n.º 1
0
        private void Button_Click_DeleteFromDB(object sender, RoutedEventArgs e)
        {
            var obj = ((Button)sender).DataContext;

            Database.TryAction(DatabaseActions.DELETE, obj);
            LoadInfoFromDb();
        }
Exemplo n.º 2
0
        private void Button_Click_SaveAll(object sender, RoutedEventArgs ev)
        {
            if (!_model.IsValid())
            {
                MessageBox.Show("ОШИБКА"); return;
            }
            Credentials person;

            if (_isEditMode)
            {
                int id = _model.CredentialsID;

                person = _db.Credentials.GetByID(id);
                person.PersonalData = _model.PersonalData;
                person.AccountType  = _model.AccountType;
                person.FullName     = _model.FullName;
                person.Login        = _model.Login;
                person.Password     = _model.Password;

                _db.TryAction(DatabaseActions.UPDATE, person);
            }
            else
            {
                person = new Credentials()
                {
                    PersonalData = _model.PersonalData,
                    AccountType  = _model.AccountType,
                    FullName     = _model.FullName,
                    Login        = _model.Login,
                    Password     = _model.Password
                };
                _db.TryAction(DatabaseActions.ADD, person);
            }
            _db.SaveChanges();
            _w.LoadInfoFromDb();
        }
Exemplo n.º 3
0
        private void Button_Click_SaveAll(object sender, RoutedEventArgs ev)
        {
            if (!_model.IsValid())
            {
                MessageBox.Show("ОШИБКА"); return;
            }
            Purchase purchase;

            if (_isEditMode)
            {
                int id = _model.PurchaseID;

                purchase             = _db.Purchases.Where(p => p.PurchaseID == id).FirstOrDefault();
                purchase.Quantity    = _model.Quantity;
                purchase.Timestamp   = _model.Timestamp;
                purchase.TotalPrice  = _model.TotalPrice;
                purchase.Credentials = _model.Credentials;
                purchase.StoreItem   = _model.StoreItem;

                _db.TryAction(DatabaseActions.UPDATE, purchase);
            }
            else
            {
                purchase = new Purchase()
                {
                    Quantity    = _model.Quantity,
                    Timestamp   = DateTime.Now,
                    TotalPrice  = _model.TotalPrice,
                    Credentials = _model.Credentials,
                    StoreItem   = _model.StoreItem
                };
                _db.TryAction(DatabaseActions.ADD, purchase);
            };
            _db.SaveChanges();
            _w.LoadInfoFromDb();
        }
        private void Button_Click_SaveAll(object sender, RoutedEventArgs ev)
        {
            if (!_model.IsValid())
            {
                MessageBox.Show("ОШИБКА"); return;
            }
            StoreItem item;

            if (_isEditMode)
            {
                int id = _model.StoreItemID;

                item                       = _db.StoreItems.GetByID(id);
                item.Description           = _model.Description;
                item.AttributeProductPairs = _model.AttributeProductPairs;
                item.Price                 = _model.Price;
                item.StoreItemType         = _model.StoreItemType;
                item.Title                 = Title;

                _db.TryAction(DatabaseActions.UPDATE, item);
            }
            else
            {
                item = new StoreItem()
                {
                    Description           = _model.Description,
                    AttributeProductPairs = _model.AttributeProductPairs,
                    Price         = _model.Price,
                    StoreItemType = _model.StoreItemType,
                    Title         = _model.Title
                };
                _db.TryAction(DatabaseActions.ADD, item);
            }
            _db.SaveChanges();
            _w.LoadInfoFromDb();
        }