Exemple #1
0
        private void listBox1_MouseClick(object sender, MouseEventArgs e)
        {
            int           currId = idAndActualIdPairs[listBox1.SelectedIndex];
            DbHandler     dbh    = new DbHandler();
            SqlDataReader sdr    = dbh.read("select * from PartsOfFood where id=" + currId);

            sdr.Read();
            label6.Text = sdr.GetString(1);
            label3.Text = sdr.GetInt32(2).ToString();
            label5.Text = sdr.GetInt32(3).ToString();
            int measurementUnitId = sdr.GetInt32(4);
            int howPrepareId      = sdr.GetInt32(5);

            sdr = dbh.read("select * from MeasurementUnits where id=" + measurementUnitId);
            sdr.Read();
            label8.Text = sdr.GetString(1);
            sdr         = dbh.read("select * from HowPrepare where id=" + howPrepareId);
            sdr.Read();
            label10.Text = sdr.GetString(1);
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string ingr = "";

            foreach (KeyValuePair <int, int> item in ingredients)
            {
                ingr += item.Key + "x" + item.Value + ";";
            }
            ingr.Remove(ingr.Length - 1);
            DbHandler dbh = new DbHandler();

            dbh.write("insert into Food (measurementUnitsId, nname, howPrepareId, partsOfFood) values ('" + comboBox1.SelectedValue + "','" + textBox1.Text + "','" + comboBox3.SelectedValue + "','" + ingr + "')");
            textBox1.Text = "";
            listBox1.Items.Clear();
            label6.Visible = true;
            timer          = new Timer();
            timer.Interval = 3000;
            timer.Tick    += hideLabel;
            timer.Start();
        }
Exemple #3
0
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            DbHandler     dbh = new DbHandler();
            SqlDataReader sdr = dbh.read("select * from Food");
            Regex         regularExpression = new Regex(textBox2.Text);

            listBox2.Items.Clear();
            searchResults.Clear();
            int i = 0;

            while (sdr.Read())
            {
                string tmp = regularExpression.Match(sdr.GetString(2)).ToString();
                if (tmp != "")
                {
                    searchResults.Add(i, sdr.GetInt32(0));
                    listBox2.Items.Add(sdr.GetString(2));
                    i++;
                }
            }
        }