private void CreateNewArticle() { try { var checkedChar = CheckInputService.CheckAllCharacteristics(AddRefTxtBox, AddNameTxtBox, AddPriceTxtBox, AddQuantTxtBox, AddAnArticleTxtBlockInfo); if (checkedChar == true) { if (MessageBox.Show("Etes-vous sûr de vouloir ajouté cet article au stock?", "DataGridView", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var newProduct = ProductManager.AddANewProductByRefChecking(AddRefTxtBox.Text, AddNameTxtBox.Text, AddExclPriceTxtBox.Text, AddPriceTxtBox.Text, AddQuantTxtBox.Text); if (newProduct == null) { AddAnArticleTxtBlockInfo.FontSize = 12; AddAnArticleTxtBlockInfo.Foreground = new SolidColorBrush(Colors.Yellow); AddAnArticleTxtBlockInfo.Text = "L'article existe déjà"; } else { AddAnArticleTxtBlockInfo.FontSize = 12; AddAnArticleTxtBlockInfo.Text = "Le nouveau produit a été intégré au stock"; } ArticlesListManagementPage.ReloadDataGrid(); } } } catch (Exception except) { AddAnArticleTxtBlockInfo.Foreground = new SolidColorBrush(Colors.Orange); AddAnArticleTxtBlockInfo.Text = $"L'erreur suivante est survenue: {except.Message}"; } }
private void EditAnArticle() { try { if (MessageBox.Show("Etes-vous sûr de vouloir modifié cet article?", "DataGridView", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { var checkedChar = CheckInputService.CheckAllCharacteristics(EditRefTxtBox, EditNameTxtBox, EditPriceTxtBox, EditQuantTxtBox, EditAnArticleTxtBlockInfo); if (checkedChar == false) { MessageBox.Show("Une erreur de saisie est survenue."); SelectAnArticle(); } else { ProductViewManager.CurrentItemSelected.Reference = EditRefTxtBox.Text; ProductViewManager.CurrentItemSelected.Name = EditNameTxtBox.Text; ProductViewManager.CurrentItemSelected.ExclTaxPrice = Convert.ToDouble(EditExclTaxPriceTxtBox.Text); ProductViewManager.CurrentItemSelected.Price = Convert.ToDouble(EditPriceTxtBox.Text); ProductViewManager.CurrentItemSelected.Quantity = Convert.ToDouble(EditQuantTxtBox.Text); EditAnArticleTxtBlockInfo.Foreground = new SolidColorBrush(Colors.GreenYellow); EditAnArticleTxtBlockInfo.Text = "Le produit a été modifié avec succès"; ProductManager.UpdateAProduct(ProductViewManager.CurrentItemSelected); Close(); } } } catch (Exception exception) { MessageBox.Show(exception.Message); } }