Exemple #1
0
        public ProductsManagementViewModel(IMessageBoxService messageBoxService, IUIVisualizerService uiVisualizerService,
                                           IProductManager productManager, IProductGroupManager productGroupManager, IUnitManager unitManager) : base(messageBoxService, uiVisualizerService, productManager)
        {
            // do initialization
            try
            {
                if (productGroupManager == null)
                {
                    throw new ArgumentNullException("productGroupManager");
                }
                _productGroupManager = productGroupManager;

                if (unitManager == null)
                {
                    throw new ArgumentNullException("unitManager");
                }
                _unitManager = unitManager;

                this.DisplayName          = "Products Management";
                ProductGroupListViewModel = new ProductGroupListViewModel(this.MessageBoxService, this.UIVisualizerService, _productGroupManager);
                UnitListViewModel         = new UnitListViewModel(this.MessageBoxService, this.UIVisualizerService, _unitManager);

                //MessageBoxService.ShowInformation(SelectedItem.Name);
                (ModelManager as IProductManager).FetchProductRecipes(SelectedItem);
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Exemple #2
0
        //services
        //private IProductGroupManager _manager = null;

        #endregion // Private Data Members

        #region Constructors

        public ProductGroupViewModel(IMessageBoxService messageBoxService, IProductGroupManager manager) : base(messageBoxService, manager)
        {
            // do initialization
            try
            {
                this.DisplayName = "Create Product Group";
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Exemple #3
0
        public OrderViewModel(IMessageBoxService messageBoxService, IOrderManager manager, ITableManager tableManager) : base(messageBoxService, manager)
        {
            // do initialization
            try
            {
                if (tableManager == null)
                {
                    throw new ArgumentNullException("tableManager");
                }
                _tableManager = tableManager;
                // populate the list of tables
                this.FreeTableList = _tableManager.GetFreeTables();

                _productGroupManager  = new ProductGroupManager();
                this.ProductGroupList = _productGroupManager.GetList();
                // add one item, in case user select all group
                this.ProductGroupList.Insert(0, new ProductGroup
                {
                    Id          = -1,
                    Code        = "ALL",
                    Name        = "All",
                    Description = "List of all products"
                });

                _productManager           = new ProductManager();
                this.AvailableProductList = _productManager.GetList();

                // initialize command
                this.AddOrderItemCommand      = new CommandBase <Product>(o => this.ExecuteAddOrderItemCommand(o), o => this.CanExecuteAddOrderItemCommand(o));
                this.CancelOrderItemCommand   = new CommandBase <OrderItem>(o => this.ExecuteCancelOrderItemCommand(o), o => this.CanExecuteCancelOrderItemCommand(o));
                this.UnCancelOrderItemCommand = new CommandBase <OrderItem>(o => this.ExecuteUnCancelOrderItemCommand(o), o => this.CanExecuteUnCancelOrderItemCommand(o));
                this.IncreaseQuantityCommand  = new CommandBase <OrderItem>(o => this.ExecuteIncreaseQuantityCommand(o), o => this.CanExecuteIncreaseQuantityCommand(o));
                this.DecreaseQuantityCommand  = new CommandBase <OrderItem>(o => this.ExecuteDecreaseQuantityCommand(o), o => this.CanExecuteDecreaseQuantityCommand(o));

                this.SelectProductGroupCommand   = new CommandBase <ProductGroup>(o => this.ExecuteSelectProductGroupCommand(o), o => this.CanExecuteSelectProductGroupCommand(o));
                this.ShowCancelledProductCommand = new CommandBase <object>(o => this.ExecuteShowCancelledProductCommand());

                this.DisplayName = "Create Order";

                // temporarily
                Item.CreatorId   = GlobalObjects.SystemUser.Id;
                Item.CreatorUser = GlobalObjects.SystemUser;
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Exemple #4
0
        public ProductViewModel(IMessageBoxService messageBoxService, Product item, IProductManager manager, IProductGroupManager groupManager, IUnitManager unitManager) : base(messageBoxService, item, manager)
        {
            // do initialization
            try
            {
                if (groupManager == null)
                {
                    throw new ArgumentNullException("groupManager");
                }
                _groupManager = groupManager;
                // populate the list of groups
                this.GroupList = _groupManager.GetList();

                if (unitManager == null)
                {
                    throw new ArgumentNullException("unitManager");
                }
                _unitManager = unitManager;
                // populate the list of units
                this.UnitList = _unitManager.GetList();

                _materialGroupManager  = new MaterialGroupManager();
                this.MaterialGroupList = _materialGroupManager.GetList();

                _materialManager           = new MaterialManager();
                this.AvailableMaterialList = _materialManager.GetList();

                // initialize command
                this.SelectMaterialCommand   = new CommandBase <Material>(o => this.ExecuteSelectMaterialCommand(o), o => this.CanExecuteSelectItemCommand(o));
                this.AddRecipeItemCommand    = new CommandBase <Material>(o => this.ExecuteAddRecipeItemCommand(o), o => this.CanExecuteAddRecipeItemCommand(o));
                this.RemoveRecipeItemCommand = new CommandBase <RecipeItem>(o => this.ExecuteRemoveRecipeItemCommand(o), o => this.CanExecuteRemoveRecipeItemCommand(o));

                this.MarkDeletedCommand = new CommandBase <RecipeItem>(o => this.Item.Delete(), o => !this.Item.IsDeleted);

                this.DisplayName = "Edit Product: " + this.Item.Name;
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Exemple #5
0
        public OrderViewModel(IMessageBoxService messageBoxService, Order item, IOrderManager manager, ITableManager tableManager) : base(messageBoxService, item, manager)
        {
            // do initialization
            try
            {
                if (tableManager == null)
                {
                    throw new ArgumentNullException("tableManager");
                }
                _tableManager = tableManager;
                // populate the list of tables
                this.FreeTableList = _tableManager.GetFreeTables();
                // aslo need add current table into top of free table list
                this.FreeTableList.Insert(0, this.Item.Table);

                _productGroupManager  = new ProductGroupManager();
                this.ProductGroupList = _productGroupManager.GetList();
                // add one item, in case user select all group
                this.ProductGroupList.Insert(0, new ProductGroup
                {
                    Id          = -1,
                    Code        = "ALL",
                    Name        = "All",
                    Description = "List of all products"
                });

                _productManager           = new ProductManager();
                this.AvailableProductList = _productManager.GetList();

                // initialize command
                this.AddOrderItemCommand      = new CommandBase <Product>(o => this.ExecuteAddOrderItemCommand(o), o => this.CanExecuteAddOrderItemCommand(o));
                this.CancelOrderItemCommand   = new CommandBase <OrderItem>(o => this.ExecuteCancelOrderItemCommand(o), o => this.CanExecuteCancelOrderItemCommand(o));
                this.UnCancelOrderItemCommand = new CommandBase <OrderItem>(o => this.ExecuteUnCancelOrderItemCommand(o), o => this.CanExecuteUnCancelOrderItemCommand(o));
                this.IncreaseQuantityCommand  = new CommandBase <OrderItem>(o => this.ExecuteIncreaseQuantityCommand(o), o => this.CanExecuteIncreaseQuantityCommand(o));
                this.DecreaseQuantityCommand  = new CommandBase <OrderItem>(o => this.ExecuteDecreaseQuantityCommand(o), o => this.CanExecuteDecreaseQuantityCommand(o));

                this.SelectProductGroupCommand   = new CommandBase <ProductGroup>(o => this.ExecuteSelectProductGroupCommand(o), o => this.CanExecuteSelectProductGroupCommand(o));
                this.ShowCancelledProductCommand = new CommandBase <object>(o => this.ExecuteShowCancelledProductCommand());

                this.DisplayName = "Edit Order: " + this.Item.Table.Name;

                CollectionViewSource.GetDefaultView(Item.OrderItems).Filter = o => IsShowCancelledProduct ||
                                                                              ((OrderItem)o).IsCancelled == false ||
                                                                              (((OrderItem)o).IsCancelled == true && ((OrderItem)o).IsDirty == true);

                //if (GlobalObjects.SystemUser.StartEditOrder(Item))
                //{ }
                if (Item.LockState == false)
                {
                    // lock order, prevent other user editting order.
                    Item.LockKeeperId = GlobalObjects.SystemUser.Id;
                    Item.LockKeeper   = GlobalObjects.SystemUser;

                    // below code will do inside lock function
                    //Item.LockState = true;
                    (ModelManager as IOrderManager).Lock(Item);
                }
            }
            catch (Exception ex)
            {
                this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
            }
        }
Exemple #6
0
 public ProductGroupListViewModel(IMessageBoxService messageBoxService, IUIVisualizerService uiVisualizerService, IProductGroupManager manager) : base(messageBoxService, uiVisualizerService, manager)
 {
     // do initialization
     try
     {
     }
     catch (Exception ex)
     {
         this.MessageBoxService.ShowError(this.GetType().FullName + System.Reflection.MethodBase.GetCurrentMethod().Name + ": " + ex.Message);
     }
 }