public void Submit()
        {
            ProductToEdit.ProductName = Form.ProductName;
            ProductToEdit.CategoryId  = Form.SelectedCategory.Id;
            ProductToEdit.IsVisible   = Form.IsVisible;
            ProductToEdit.ImportPrice = Form.ImportPrice;
            ProductToEdit.SellPrice   = Form.SellPrice;
            ProductToEdit.Quantity    = Form.Quantity;

            try
            {
                ProductSection.EditProductAction(ProductToEdit);
                ProductSection.UpdateProducts();
                Cancel();
            }
            catch (ArgumentException e)
            {
                StateManager.Push(new ErrorPresenter(StateManager, e.Message, true));
            }
        }
        public void Submit()
        {
            var product = new Product
            {
                ProductName = Form.ProductName,
                CategoryId  = Form.SelectedCategory.Id,
                IsVisible   = Form.IsVisible,
                ImportPrice = Form.ImportPrice,
                SellPrice   = Form.SellPrice,
                Quantity    = Form.Quantity
            };

            try
            {
                ProductSection.AddNewProductAction(product);
                ProductSection.UpdateProducts();
                Cancel();
            }
            catch (ArgumentException e)
            {
                StateManager.Push(new ErrorPresenter(StateManager, e.Message, true));
            }
        }
Esempio n. 3
0
        public override void Update()
        {
            if (!IsFormShown)
            {
                Form.Show();
                IsFormShown = true;
            }

            if (!IsProductsDisplayed && StateManager.UserSession.SessionEntity != null)
            {
                ProductSection.UpdateProducts();
                IsProductsDisplayed = true;
                if (Roles.IsStandard(StateManager.UserSession.SessionEntity.Roles))
                {
                    Form.EnableOrDisableMaterialBtn("RevenueBtn", true);
                    Form.EnableOrDisableMaterialBtn("InvoicesBtn", true);
                    Form.EnableOrDisableMaterialBtn("ExpensesBtn", true);
                }

                Form.Text =
                    $"Simple Warehouse, Потребител: {StateManager.UserSession.SessionEntity.Username} ({string.Join(",", StateManager.UserSession.SessionEntity.Roles.Select(r => r.RoleType.ToString()))})";
                InitializeUserRequiredSections();
            }
        }