示例#1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            User.DataBase = "cook";
            User.Username = usernameTB.Text;
            User.Password = passwordTB.Text;
            File.WriteAllLines(User.Path, new string[] { User.DataBase, User.Username, User.Password });

            DDB ddb = new DDB(User.DataBase, User.Username, User.Password);

            //ddb.Command("drop database cook;");
            //ddb.Command($"create database cook;");
            string[] create = File.ReadAllLines("creation.sql");

            foreach (string line in create) //Excute the sql script
            {
                ddb.Command(line);          //creation of the table
            }
            string[] fill = File.ReadAllLines("peuplement.sql");

            foreach (string line in fill)
            {
                ddb.Command(line);                                            //fill the table
            }
            ddb.SelectRecipe().ForEach(x => Stock.UpdateMinMaxQuantities(x)); //a rajouter a moment des commandes
            ddb.SelectRecipe().ForEach(x => Stock.ManageOrder(x));
            Stock.RottenProducts();

            ddb.Close();
            MainWindow mainWindow = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault();

            mainWindow.DataContext = new MainMenu();
        }