コード例 #1
0
        /// <summary>
        /// Edits the specified item in the list
        /// </summary>
        /// <param name="productRowViewerViewmodel">The view model of the item to edit</param>
        protected override void EditItem(BaseRowViewerViewModel viewModel)
        {
            var productRowViewerViewModel = viewModel as ProductRowViewerViewModel;

            Product product = new Product(
                productRowViewerViewModel.ID,
                productRowViewerViewModel.Name,
                productRowViewerViewModel.Description,
                productRowViewerViewModel.StoredQuantity,
                productRowViewerViewModel.Price,
                productRowViewerViewModel.Picture,
                productRowViewerViewModel.Category.ID);

            EditProductWindowViewModel editProductWindowViewModel
                = new EditProductWindowViewModel(product);
            UI_Manager ui_Manager = new UI_Manager();

            ui_Manager.ShowDialog(editProductWindowViewModel);

            productRowViewerViewModel.ID             = editProductWindowViewModel.NewProductData.ID;
            productRowViewerViewModel.Name           = editProductWindowViewModel.NewProductData.Name;
            productRowViewerViewModel.Description    = editProductWindowViewModel.NewProductData.Description;
            productRowViewerViewModel.StoredQuantity = editProductWindowViewModel.NewProductData.QuantityInStock;
            productRowViewerViewModel.Price          = editProductWindowViewModel.NewProductData.Price;
            productRowViewerViewModel.Picture        = editProductWindowViewModel.NewProductData.Image;
            productRowViewerViewModel.Category       = editProductWindowViewModel.NewProductData.Category;
            productRowViewerViewModel.Update();
        }
コード例 #2
0
        /// <summary>
        /// Matches the passed view model with the text in the searchBox depending on
        /// the type of search
        /// </summary>
        /// <param name="viewModel">The view model to match with</param>
        protected override bool IsMatch(BaseRowViewerViewModel viewModel)
        {
            switch (ProductSearchType)
            {
            case ProductSearchType.ID:
                if (((ProductRowViewerViewModel)viewModel).ID.ToString().ToLower().StartsWith(SearchText))
                {
                    return(true);
                }
                break;

            case ProductSearchType.Name:
                if (((ProductRowViewerViewModel)viewModel).Name.ToString().ToLower().StartsWith(SearchText))
                {
                    return(true);
                }
                break;

            case ProductSearchType.Category:
                if (((ProductRowViewerViewModel)viewModel).Category.Name.ToString().ToLower().StartsWith(SearchText))
                {
                    return(true);
                }
                break;

            default:
                break;
            }
            return(false);
        }
コード例 #3
0
        protected override void EditItem(BaseRowViewerViewModel viewModel)
        {
            var categoryRowViewerViewModel = viewModel as CategoryRowViewerViewModel;

            if (categoryRowViewerViewModel.IsEditable)
            {
                // Validate
                if (string.IsNullOrEmpty(categoryRowViewerViewModel.EditedName) ||
                    string.IsNullOrWhiteSpace(categoryRowViewerViewModel.EditedName))
                {
                    MessageBox.Show("Category must have a name", "Invalid data", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                // Edit
                categoryRowViewerViewModel.Name = categoryRowViewerViewModel.EditedName;
                Category category = new Category(categoryRowViewerViewModel.ID, categoryRowViewerViewModel.Name);
                categoryRowViewerViewModel.IsEditable = false;
                category.Edit();

                ApplicationDirector.UpdateCategories();
            }
            else
            {
                categoryRowViewerViewModel.IsEditable = true;
            }
        }
コード例 #4
0
        /// <summary>
        /// Edits the specified item in the list
        /// </summary>
        /// <param name="viewModel">The view model of the item to edit</param>
        protected override void EditItem(BaseRowViewerViewModel viewModel)
        {
            var clientRowViewerViewModel = viewModel as ClientRowViewerViewModel;

            Client client = new Client(
                clientRowViewerViewModel.ID,
                clientRowViewerViewModel.FirstName,
                clientRowViewerViewModel.SecondName,
                clientRowViewerViewModel.Gender,
                clientRowViewerViewModel.Phone,
                clientRowViewerViewModel.Email,
                clientRowViewerViewModel.Image);

            EditClientWindowViewModel editClientWindowViewModel
                = new EditClientWindowViewModel(client);
            UI_Manager ui_Manager = new UI_Manager();

            ui_Manager.ShowDialog(editClientWindowViewModel);

            clientRowViewerViewModel.ID         = editClientWindowViewModel.NewClientData.ID;
            clientRowViewerViewModel.FirstName  = editClientWindowViewModel.NewClientData.FirstName;
            clientRowViewerViewModel.SecondName = editClientWindowViewModel.NewClientData.SecondName;
            clientRowViewerViewModel.Gender     = editClientWindowViewModel.NewClientData.Gender;
            clientRowViewerViewModel.Phone      = editClientWindowViewModel.NewClientData.Phone;
            clientRowViewerViewModel.Email      = editClientWindowViewModel.NewClientData.Email;
            clientRowViewerViewModel.Image      = editClientWindowViewModel.NewClientData.Image;
        }
コード例 #5
0
 /// <summary>
 /// Matches the passed view model with the text in the searchBox depending on
 /// the type of search
 /// </summary>
 /// <param name="viewModel">The view model to match with</param>
 protected override bool IsMatch(BaseRowViewerViewModel viewModel)
 {
     if (((OrderRowViewerViewModel)viewModel).OrderID == long.Parse(SearchText))
     {
         return(true);
     }
     return(false);
 }
コード例 #6
0
        /// <summary>
        /// Prints the specified item from the list
        /// </summary>
        /// <param name="viewModel">The view model of the item to print</param>
        protected override void PrintItem(BaseRowViewerViewModel viewModel)
        {
            var productRowViewerViewmodel = viewModel as ProductRowViewerViewModel;

            ProductReportingWindowViewModel productReportingWindowViewModel
                = new ProductReportingWindowViewModel(productRowViewerViewmodel.ID);
            UI_Manager ui_Manager = new UI_Manager();

            ui_Manager.ShowDialog(productReportingWindowViewModel);
        }
コード例 #7
0
        /// <summary>
        /// Deletes the specified item from the list
        /// </summary>
        /// <param name="viewModel">The view model of the item to delete</param>
        protected override void DeleteItem(BaseRowViewerViewModel viewModel)
        {
            // Delete from the items list
            Items.Remove(viewModel);

            // Delete from the database
            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0]       = new SqlParameter("@Customer_ID", SqlDbType.VarChar);
            sqlParameters[0].Value = ((ClientRowViewerViewModel)viewModel).ID;

            DataConnection.ExcuteCommand("Delete_Client_Procedure", sqlParameters);
        }
コード例 #8
0
        /// <summary>
        /// Deletes the specified item from the list
        /// </summary>
        /// <param name="viewModel">The view model of the item to delete</param>
        protected override void DeleteItem(BaseRowViewerViewModel viewModel)
        {
            // Delete from the items list
            Items.Remove(viewModel);

            // Delete from the database
            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0]       = new SqlParameter("@Product_ID", SqlDbType.VarChar);
            sqlParameters[0].Value = ((ProductRowViewerViewModel)viewModel).ID.ToString();

            DataConnection.ExcuteCommand("DeleteProduct", sqlParameters);

            OrderRowViewerListViewModel.Instance.RemoveFromCart((ProductRowViewerViewModel)viewModel);
        }
コード例 #9
0
        /// <summary>
        /// Deletes the specified item from the list
        /// </summary>
        /// <param name="viewModel">The view model of the item to delete</param>
        protected override void DeleteItem(BaseRowViewerViewModel viewModel)
        {
            OrderRowViewerViewModel vm = viewModel as OrderRowViewerViewModel;

            // Delete from the items list
            Items.Remove(viewModel);
            CurrentCart.Remove(viewModel);
            vm.ProductViewModel.IsOutFromCart = true;
            for (int i = ((OrderRowViewerViewModel)viewModel).RowNumber - 1; i < Items.Count; i++)
            {
                ((OrderRowViewerViewModel)Items[i]).RowNumber--;
            }
            OnPropertyChanged(nameof(TotalPrice));
        }
コード例 #10
0
        /// <summary>
        /// Deletes the specified item from the list
        /// </summary>
        /// <param name="viewModel">The view model of the item to delete</param>
        protected override void DeleteItem(BaseRowViewerViewModel viewModel)
        {
            // Delete from the items list
            Items.Remove(viewModel);

            // Delete from the database
            SqlParameter[] sqlParameters = new SqlParameter[1];
            sqlParameters[0]       = new SqlParameter("@Category_ID", SqlDbType.Int);
            sqlParameters[0].Value = ((CategoryRowViewerViewModel)viewModel).ID;

            DataConnection.ExcuteCommand("Delete_Category_Procedure", sqlParameters);

            ApplicationDirector.UpdateCategories();
        }
コード例 #11
0
        /// <summary>
        /// Matches the passed view model with the text in the searchBox depending on
        /// the type of search
        /// </summary>
        /// <param name="viewModel">The view model to match with</param>
        protected override bool IsMatch(BaseRowViewerViewModel viewModel)
        {
            switch (ClientSearchType)
            {
            case ClientSearchType.Name:
                if (((ClientRowViewerViewModel)viewModel).FullName.ToString().ToLower().StartsWith(SearchText.ToLower()))
                {
                    return(true);
                }
                break;

            case ClientSearchType.gender:
                if (((ClientRowViewerViewModel)viewModel).Gender.ToString().ToLower().StartsWith(SearchText.ToLower()))
                {
                    return(true);
                }
                break;

            case ClientSearchType.Phone:
                if (((ClientRowViewerViewModel)viewModel).Phone.ToString().ToLower().StartsWith(SearchText.ToLower()))
                {
                    return(true);
                }
                break;

            case ClientSearchType.Email:
                if (((ClientRowViewerViewModel)viewModel).Email.ToString().ToLower().StartsWith(SearchText.ToLower()))
                {
                    return(true);
                }
                break;

            default:
                break;
            }
            return(false);
        }
コード例 #12
0
 protected void CancelEditing(BaseRowViewerViewModel viewModel) => throw new System.NotImplementedException();
コード例 #13
0
 protected override void PrintItem(BaseRowViewerViewModel viewModel) => throw new System.NotImplementedException();
コード例 #14
0
        protected void CancelEditing(BaseRowViewerViewModel viewModel)
        {
            var categoryRowViewerViewModel = viewModel as CategoryRowViewerViewModel;

            categoryRowViewerViewModel.IsEditable = false;
        }
コード例 #15
0
 /// <summary>
 /// Prints the specified item from the list
 /// </summary>
 /// <param name="viewModel">The view model of the item to print</param>
 protected override void PrintItem(BaseRowViewerViewModel viewModel)
 {
     // TODO: Implement print client method
 }