Пример #1
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            DDB ddb = new DDB(User.DataBase, User.Username, User.Password);

            if (ddb.SelectRecipeCreator(new string[] { "numero" }, new string[] { $"'{User.ConnectedClient.PhoneNumber}'" }).Count == 0) //if is not a cdr
            {
                ddb.InsertRecipeCreator(User.ConnectedClient.PhoneNumber);
            }
            DoubleContainer <string, RecipeType> recipeType = CategoryComboBox.SelectedItem as DoubleContainer <string, RecipeType>;

            ddb.InsertRecipe(NameTextBox.Text, recipeType.OtherValue, DescTextBox.Text, User.ConnectedClient.PhoneNumber, Convert.ToInt32(PriceCB.SelectedValue),
                             HealthyCB.IsChecked == true ? true : false,
                             BioCB.IsChecked == true ? true : false,
                             VeganCB.IsChecked == true ? true : false,
                             ChimiCB.IsChecked == true ? true : false);                                  //operator ter because it's bool? not bool

            foreach (DoubleContainer <Product, ProductComposition> productComposition in this._products) // if the user change the name after adding the product composition
            {
                productComposition.OtherValue.RecipeName = NameTextBox.Text;
                ddb.Insert <ProductComposition>(productComposition.OtherValue);
            }
            ddb.Close();
            MainWindow mainWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            mainWindow.DataContext = new MainMenu();
        }