Esempio n. 1
0
        public Ingredient(string name, string category, string source, bool staple, int isle)
        {
            if (Updates.getIngredients().Count > 0)
            {
                setName(name);
            }
            else
            {
                this.name = name;
            }

            setCategory(category);
            setSource(source);
            this.staple = staple;
            this.isle   = isle;
        }
Esempio n. 2
0
        // Add store button
        private void button4_Click(object sender, EventArgs e)
        {
            foreach (string store in Updates.getStores())
            {
                if (store == comboBox2.Text)
                {
                    MessageBox.Show("This store is already in the list");
                    return;
                }
            }
            string theCmd = "INSERT INTO Source (name) VALUES (\'" + comboBox2.Text + "\');";

            cmd = new MySqlCommand(theCmd, conn);
            cmd.ExecuteNonQuery();
            Updates.updateSource(conn);
            MessageBox.Show("This store is added to the list");
        }
Esempio n. 3
0
        // Add category button
        private void button3_Click(object sender, EventArgs e)
        {
            foreach (string cat in Updates.getCatagories())
            {
                if (cat == comboBox1.Text)
                {
                    MessageBox.Show("This ingredient category is already in the list");
                    return;
                }
            }
            string theCmd = "INSERT INTO Category (name) VALUES (\'" + comboBox1.Text + "\');";

            cmd = new MySqlCommand(theCmd, conn);
            cmd.ExecuteNonQuery();
            Updates.updateCategory(conn);
            MessageBox.Show("This category is added to the list");
        }
Esempio n. 4
0
        public Form7(MySqlConnection conn)
        {
            InitializeComponent();
            this.conn = conn;
            checkedListBox1.CheckOnClick = true;
            listBox1.DataSource          = Updates.getCuisines();
            listBox2.DataSource          = Updates.getSeasons();
            numericUpDown1.Value         = 1;
            listBox3.DataSource          = Updates.getIngredientsList();
            listBox4.DataSource          = Updates.getUnits();
            listView1.View = View.Details;
            listView1.Columns.Add("Name");
            listView1.Columns.Add("Amount");
            listView1.Columns.Add("Measurement");

            //make most controls invisible
            makeVisible(false);
        }
Esempio n. 5
0
        public void setSource(string source)
        {
            bool check = false;

            foreach (string store in Updates.getStores())
            {
                if (source == store)
                {
                    check = true;
                }
            }
            if (check)
            {
                this.source = source;
            }
            else
            {
                this.source = null;
            }
        }
Esempio n. 6
0
        public void setName(string name)
        {
            bool check = true;

            foreach (Ingredient ing in Updates.getIngredients())
            {
                if (name == ing.name)
                {
                    check = false;
                }
            }
            if (check)
            {
                this.name = name;
            }
            else
            {
                this.name = null;
            }
        }
Esempio n. 7
0
        public void setCategory(string category)
        {
            bool check = false;

            foreach (string cat in Updates.getCatagories())
            {
                if (category == cat)
                {
                    check = true;
                }
            }
            if (check)
            {
                this.category = category;
            }
            else
            {
                this.category = null;
            }
        }
Esempio n. 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (string cuisine in Updates.getCuisines())
            {
                if (cuisine == textBox1.Text)
                {
                    MessageBox.Show("This cuisine is already in the list");
                    button1.Enabled = false;
                    textBox1.Text   = null;
                    textBox1.Select();
                    return;
                }
            }
            string theCmd = "INSERT INTO Cuisine (name) VALUES (\'" + textBox1.Text + "\');";

            cmd = new MySqlCommand(theCmd, conn);
            cmd.ExecuteNonQuery();
            Updates.updateCuisine(conn);
            MessageBox.Show("This cuisine is added to the list");
            textBox1.Text   = null;
            button1.Enabled = false;
            textBox1.Select();
        }
Esempio n. 9
0
        // Adds ingredient
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (Ingredient ing in Updates.getIngredients())
            {
                if (ing.name == textBox1.Text)
                {
                    MessageBox.Show("This ingredient is already in the list");
                    textBox1.Text        = null;
                    radioButton1.Checked = false;
                    button1.Enabled      = false;
                    numericUpDown1.Value = 0;
                    comboBox1.Text       = "";
                    comboBox2.Text       = "";
                    textBox1.Select();
                    return;
                }
            }

            if (comboBox1.Text != String.Empty)
            {
                bool inList = false;

                foreach (string s in Updates.getCatagories())
                {
                    if (s == comboBox1.Text)
                    {
                        inList = true;
                        break;
                    }
                }

                if (!inList)
                {
                    category = null;
                    MessageBox.Show("You must select a category from the list or add it.");
                    comboBox1.Select();
                    return;
                }
                if (inList)
                {
                    category = comboBox1.Text;
                }
            }
            else
            {
                category = null;
            }

            if (comboBox2.Text != String.Empty)
            {
                bool inList = false;

                foreach (string s in Updates.getStores())
                {
                    if (s == comboBox2.Text)
                    {
                        inList = true;
                        break;
                    }
                }

                if (!inList)
                {
                    source = null;
                    MessageBox.Show("You must select a store from the list or add it.");
                    comboBox2.Select();
                    return;
                }

                if (inList)
                {
                    source = comboBox2.Text;
                }
            }
            else
            {
                source = null;
            }


            if (radioButton1.Checked)
            {
                staple = "true";
            }
            else
            {
                staple = "false";
            }

            string cmdText = "SET TRANSACTION READ WRITE;";

            cmd = new MySqlCommand(cmdText, conn);
            cmd.ExecuteNonQuery();
            cmdText = "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;";
            cmd     = new MySqlCommand(cmdText, conn);
            cmd.ExecuteNonQuery();
            cmdText = "START TRANSACTION;";
            cmd     = new MySqlCommand(cmdText, conn);
            cmd.ExecuteNonQuery();
            string theCmd = "CALL addIngredient(\'" + textBox1.Text + "\', \'" + category + "\', \'" + source + "\', " + staple + ", " + numericUpDown1.Value.ToString() + ");";

            cmd = new MySqlCommand(theCmd, conn);
            cmd.ExecuteNonQuery();
            cmdText = "COMMIT;";
            cmd     = new MySqlCommand(cmdText, conn);
            cmd.ExecuteNonQuery();

            Updates.updateIngredients(conn);
            MessageBox.Show("This ingredient is added to the list");
            textBox1.Text        = null;
            button1.Enabled      = false;
            numericUpDown1.Value = 0;
            comboBox1.Text       = "";
            comboBox2.Text       = "";
            radioButton1.Checked = false;
            textBox1.Select();
        }