private void chkCategory_Checked(object sender, RoutedEventArgs e) { CheckBox curCheck = (CheckBox)sender; ShopCategory curCategory = (ShopCategory)(curCheck).Tag; for (int i = 0; i < publicData.myProducts.Count; i++) { if (publicData.myProducts[i].Category == curCategory) { selectedCategoryProducts.Add(publicData.myProducts[i]);//Add Checked Category } } searchUpdate(); }
private void chkCategory_Unchecked(object sender, RoutedEventArgs e) { CheckBox curCheck = (CheckBox)sender; ShopCategory curCategory = (ShopCategory)(curCheck).Tag; for (int i = 0; i < selectedCategoryProducts.Count; i++) { if (selectedCategoryProducts[i].Category == curCategory) { selectedCategoryProducts.RemoveAt(i--);//Remove UnChecked Category } } searchUpdate(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { ShopCategory ct = (ShopCategory)cmbCategory.SelectedItem; //Check Data if (Convert.ToDouble(txtPrice.Text) == 0) { MessageBox.Show("Price cannot be Zero"); txtPrice.Focus(); return; } if (txtName.Text == "") { MessageBox.Show("Please enter Name"); txtName.Focus(); return; } if (_editProduct == null)//New Product { _editProduct = new ShopProduct(); _editProduct.Category = ct; _editProduct.Name = txtName.Text; _editProduct.Price = Convert.ToDouble(txtPrice.Text); _editProduct.Tax = Convert.ToDouble(txtTax.Text); _editProduct.Description = txtDesc.Text; publicData.myProducts.Add(_editProduct); } else //Edit Product { _editProduct.Category = ct; _editProduct.Name = txtName.Text; _editProduct.Price = Convert.ToDouble(txtPrice.Text); _editProduct.Tax = Convert.ToDouble(txtTax.Text); _editProduct.Description = txtDesc.Text; } this.NavigationService.GoBack(); }