Ejemplo n.º 1
0
        public Form2(MySqlConnection conn)
        {
            InitializeComponent();

            this.conn               = conn;
            bl                      = new BindingList <string>(Updates.getCatagories());
            comboBox1.DataSource    = bl;
            comboBox1.SelectedIndex = -1;
            comboBox2.DataSource    = Updates.getStores();
            comboBox2.SelectedIndex = -1;
        }
Ejemplo 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");
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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();
        }