/// <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(); }
/// <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); }
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; } }
/// <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; }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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)); }
/// <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(); }
/// <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); }
protected void CancelEditing(BaseRowViewerViewModel viewModel) => throw new System.NotImplementedException();
protected override void PrintItem(BaseRowViewerViewModel viewModel) => throw new System.NotImplementedException();
protected void CancelEditing(BaseRowViewerViewModel viewModel) { var categoryRowViewerViewModel = viewModel as CategoryRowViewerViewModel; categoryRowViewerViewModel.IsEditable = false; }
/// <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 }