Beispiel #1
0
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         Felhasznalo f = new Felhasznalo(Titkositasok.SHAHash(textBox1.Text.Trim() + Konstans.salt), Titkositasok.SHAHash(textBox2.Text + Konstans.salt), "");
         if (!ABKezelo.SikeresBelepes(f))
         {
             throw new WarningException("Unsuccessful login!");
         }
         ABKezelo.setCurrentUser(f);
         Logolas.Ment("Successful login, name: " + textBox1.Text.Trim());
     }
     catch (Exception ex)
     {
         if (ex is WarningException)
         {
             MessageBox.Show(ex.Message, "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         DialogResult = DialogResult.None;
     }
 }
Beispiel #2
0
        void EtrendFeltetelKiolvas()
        {
            try
            {
                var e = ABKezelo.Kiolvasas().Where(x => x is EtrendFeltetel).ToList();
                if (e.Count != 0)
                {
                    EtrendFeltetel et = e.First() as EtrendFeltetel;
                    dateTimePicker1.Value        = et.Datum1;
                    comboBox1.SelectedIndex      = (int)et.Etkezes1;
                    dateTimePicker2.Value        = et.Datum2;
                    comboBox2.SelectedIndex      = (int)et.Etkezes2;
                    comboBox3.SelectedItem       = et.Penz.Megnevezes;
                    numericUpDown1.DecimalPlaces = et.Penz.TizedesekSzama;
                    numericUpDown1.Value         = (decimal)et.Maxpenz;

                    checkBox1.Checked    = et.Koltsegmin;
                    checkBox2.Checked    = et.Orommax;
                    checkBox3.Checked    = et.Solverelrejt;
                    checkBox4.Checked    = et.Folytonosmodell;
                    checkBox5.Checked    = et.NaptarbaMent;
                    numericUpDown2.Value = et.Numvaltozatossag;
                    numericUpDown3.Value = et.Maxfutasiido;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void Button9_Click_general(object sender, EventArgs e, string filename = null, bool save = true, bool check = true, bool msg = true)
        {//xml importálás
            if (filename != null || openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string fnevhash = ABKezelo.GetCurrentUser();
                try
                {
                    if (save)
                    {
                        Button10_Click_general(sender, e, "tempetrend.xml", false);
                    }
                    ABKezelo.TorolMinden();

                    if (filename == null)
                    {
                        filename = openFileDialog1.FileName;
                    }

                    EtrendXML.XMLRead(filename, check, fnevhash, msg);
                    FormRefresh();
                }
                catch (Exception ex)
                {
                    Button9_Click_general(sender, e, "tempetrend.xml", false, false, false);
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #4
0
        private void ListBoxRefresh()
        {
            try
            {
                int index = listBox1.SelectedIndex;

                listBox1.DataSource = null;
                listBox1.DataSource = ABKezelo.Kiolvasas().Where(x => x is Tapanyag).ToList();
                if (index >= 0 && index < listBox1.Items.Count)
                {
                    listBox1.SelectedIndex = index;
                }
                else if (listBox1.Items.Count > 0)
                {
                    listBox1.SelectedIndex = 0;
                }
                else
                {
                    listBox1.SelectedIndex = -1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        private void Button4_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                if (MessageBox.Show("Really want to delete the nutrient?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    try
                    {
                        Tapanyag t = (Tapanyag)listBox1.SelectedItem;

                        //élelmiszerek dictinoray-ből is törölni kell a tápanyagot
                        foreach (Elelmiszer item in ABKezelo.Kiolvasas().Where(x => x is Elelmiszer))
                        {
                            item.TapanyagTartalom.Remove(t);
                            ABKezelo.Modositas(item);
                        }

                        string nev = t.Megnevezes;
                        ABKezelo.Torol(t);
                        Logolas.Ment("Nutrient deleted, name: " + nev);

                        ListBoxRefresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("To delete a nutrient choose one!", "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #6
0
        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                comboBox3.Items.Clear();

                if (comboBox1.SelectedIndex == (int)ENUM.mass)
                {
                    comboBox3.Items.AddRange(ABKezelo.Kiolvasas()
                                             .Where(x => x is Mertekegyseg &&
                                                    (x as Mertekegyseg).Mertek == MertekegysegFajta.weight)
                                             .Select(p => (p as Mertekegyseg).Megnevezes).ToArray());
                    comboBox4.Visible       = false;
                    comboBox2.Left          = comboBox1.Right + 10;
                    numericUpDown1.Left     = comboBox2.Right + 10;
                    comboBox3.Left          = numericUpDown1.Right + 10;
                    comboBox3.Enabled       = true;
                    comboBox3.SelectedIndex = 0;
                }
                else if (comboBox1.SelectedIndex == (int)ENUM.liquidmeasure)
                {
                    comboBox3.Items.AddRange(ABKezelo.Kiolvasas()
                                             .Where(x => x is Mertekegyseg &&
                                                    (x as Mertekegyseg).Mertek == MertekegysegFajta.liquidmeasure)
                                             .Select(p => (p as Mertekegyseg).Megnevezes).ToArray());
                    comboBox4.Visible       = false;
                    comboBox2.Left          = comboBox1.Right + 10;
                    numericUpDown1.Left     = comboBox2.Right + 10;
                    comboBox3.Left          = numericUpDown1.Right + 10;
                    comboBox3.Enabled       = true;
                    comboBox3.SelectedIndex = 0;
                }
                else
                {
                    comboBox4.Items.Clear();
                    comboBox4.Items.AddRange(ABKezelo.Kiolvasas()
                                             .Where(x => x is Tapanyag && (x as Tapanyag).Hasznalhato).Select(p => (p as Tapanyag).Megnevezes).ToArray());
                    comboBox4.Visible = true;
                    comboBox3.Items.Clear();
                    if (comboBox4.Items.Count > 0)
                    {
                        comboBox4.SelectedIndex = 0;
                        Tapanyag t = (Tapanyag)ABKezelo.Kiolvasas()
                                     .Where(x => x is Tapanyag && (x as Tapanyag).Megnevezes == comboBox4.SelectedItem.ToString())
                                     .ToList().First();
                        comboBox3.Items.Add(t.Mertek.Megnevezes);
                        comboBox3.SelectedIndex = 0;
                    }
                    comboBox3.Enabled = false;

                    comboBox2.Left      = comboBox4.Right + 10;
                    numericUpDown1.Left = comboBox2.Right + 10;
                    comboBox3.Left      = numericUpDown1.Right + 10;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        private void listBoxRefresh()
        {
            try
            {
                int index1 = listBox1.SelectedIndex;
                int index2 = listBox2.SelectedIndex;

                List <Elelmiszer> e1 = new List <Elelmiszer>();
                List <Elelmiszer> e2 = new List <Elelmiszer>();

                foreach (Elelmiszer item in ABKezelo.Kiolvasas().Where(x => x is Elelmiszer))
                {
                    if (item is Menu)
                    {
                        (item as Menu).update();
                    }

                    if (item.Hasznalhato)
                    {
                        e2.Add(item);
                    }
                    else
                    {
                        e1.Add(item);
                    }
                }

                listBox1.DataSource = null;
                listBox1.DataSource = e1;

                listBox2.DataSource = null;
                listBox2.DataSource = e2;

                listBox1.SelectedIndex = -1;
                listBox2.SelectedIndex = -1;

                if (index1 >= 0 && index1 < listBox1.Items.Count)
                {
                    listBox1.SelectedIndex = index1;
                }
                else if (index2 >= 0 && index2 < listBox2.Items.Count)
                {
                    listBox2.SelectedIndex = index2;
                }
                else if (listBox1.Items.Count > 0)
                {
                    listBox1.SelectedIndex = 0;
                }
                else if (listBox2.Items.Count > 0)
                {
                    listBox2.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #8
0
        private void Button6_Click(object sender, EventArgs e)
        {
            try
            {
                if (listBox1.SelectedIndex != -1 || listBox2.SelectedIndex != -1)
                {
                    Elelmiszer el;
                    if (listBox1.SelectedIndex != -1)
                    {
                        el = (Elelmiszer)listBox1.SelectedItem;
                    }
                    else
                    {
                        el = (Elelmiszer)listBox2.SelectedItem;
                    }

                    bool torolheto = true;
                    foreach (Menu item in ABKezelo.Kiolvasas().Where(x => x is Menu))
                    {
                        if (item.Osszetevo.ContainsKey(el))
                        {
                            torolheto = false;
                            break;
                        }
                    }

                    if (!torolheto)
                    {
                        throw new WarningException("The food has been used by a menu, so it is not deletable! [delete all menu that is using it or only the food from the menu]");
                    }

                    if (MessageBox.Show("Really want to delete the food?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        string nev = el.Megnevezes;
                        ABKezelo.Torol(el);
                        Logolas.Ment("Deleted food, name: " + nev);

                        listBoxRefresh();
                    }
                }
                else
                {
                    throw new WarningException("For deletion choose a food!");
                }
            }
            catch (Exception ex)
            {
                if (ex is WarningException)
                {
                    MessageBox.Show(ex.Message, "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #9
0
        public static void Init()
        {
            try
            {
                string fnevhash = ABKezelo.GetCurrentUser();

                List <EtrendAdat> e  = ABKezelo.Kiolvasas();
                List <EtrendAdat> e0 = new List <EtrendAdat>()
                {
                    new Mertekegyseg(fnevhash, "gram", MertekegysegFajta.weight, 1, true, false),
                    new Mertekegyseg(fnevhash, "milligram", MertekegysegFajta.weight, 0.001, true, false),
                    new Mertekegyseg(fnevhash, "pound", MertekegysegFajta.weight, Konstans.pondToGramm, true, false),
                    new Mertekegyseg(fnevhash, "calorie", MertekegysegFajta.energy, 1, true, false),
                    new Mertekegyseg(fnevhash, "joule", MertekegysegFajta.energy, Konstans.jouleToCalorie, true,
                                     false),
                    new Mertekegyseg(fnevhash, "deciliter", MertekegysegFajta.liquidmeasure, 0.1, true, false),
                    new Mertekegyseg(fnevhash, "liter", MertekegysegFajta.liquidmeasure, 1, true, false),
                    new Penznem(fnevhash, "Forint", "HUF", 1, 0, true, false),
                    new Penznem(fnevhash, "Dollar", "USD", Konstans.dollarToForint, 2, true, false),
                    new Penznem(fnevhash, "Euro", "EUR", Konstans.euroToForint, 2, true, false),
                    new Penznem(fnevhash, "English pound", "GBP", Konstans.fontToForint, 2, true, false)
                };

                int num = 0;
                foreach (EtrendAdat item in e0)
                {
                    int cnt = 0;
                    if (item is Mertekegyseg)
                    {
                        cnt = e.Where(x =>
                                      x is Mertekegyseg &&
                                      (x as Mertekegyseg).Megnevezes == (item as Mertekegyseg).Megnevezes)
                              .Count();
                    }
                    else if (item is Penznem)
                    {
                        cnt = e.Where(x => x is Penznem && (x as Penznem).Megnevezes == (item as Penznem).Megnevezes)
                              .Count();
                    }

                    if (cnt == 0)
                    {
                        ABKezelo.Beszuras(item);
                        num++;
                    }
                    else if (!(item is Penznem))
                    {
                        ABKezelo.Modositas(item);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (numericUpDown1.Value <= 0)
                {
                    throw new ArgumentException("The exchange rate should be positive!");
                }

                if (penznem == null)
                {
                    string fnevhash = ABKezelo.GetCurrentUser();
                    string nev      = textBox1.Text.Trim();
                    string kod      = textBox2.Text.Trim().ToUpper();

                    if (nev == "" || nev.Length > 30)
                    {
                        throw new ArgumentException("The name should be non-empty and at most 30 characters length!");
                    }

                    if (kod.Length != 3)
                    {
                        throw new ArgumentException("Currency code should have exactly 3 characters!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Penznem && (x as Penznem).Megnevezes == nev).ToList().Count != 0)
                    {
                        throw new ArgumentException("We have already a currency with this name!");
                    }

                    penznem = new Penznem(fnevhash, nev, kod,
                                          (double)numericUpDown1.Value, (byte)numericUpDown2.Value, checkBox1.Checked, checkBox2.Checked);
                    ABKezelo.Beszuras(penznem);
                    Logolas.Ment("New currency added, name: " + penznem.Megnevezes);
                }
                else
                {
                    if (!checkBox1.Checked && ABKezelo.Kiolvasas().Where(x => (x is Elelmiszer) && (x as Elelmiszer).Penz.Megnevezes == penznem.Megnevezes).ToList().Count > 0)
                    {
                        throw new ArgumentException("The currency should be usable, because there is a food that is using it!");
                    }

                    penznem.Arfolyam       = (double)numericUpDown1.Value;
                    penznem.TizedesekSzama = (byte)numericUpDown2.Value;
                    penznem.Hasznalhato    = checkBox1.Checked;
                    ABKezelo.Modositas(penznem);
                    Logolas.Ment("Currency modification, name: " + penznem.Megnevezes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
Beispiel #11
0
 private void Csatlakozas()
 {
     try
     {
         ABKezelo.Csatlakozas(ConfigurationManager.ConnectionStrings["EtrendString"].ConnectionString);
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #12
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (MessageBox.Show("Really want to exit?", "Question", MessageBoxButtons.YesNo,
                         MessageBoxIcon.Question) == DialogResult.No)
     {
         e.Cancel = true;
     }
     else
     {
         ABKezelo.KapcsolatBontas();
         Logolas.Ment("The program has been closed." + Environment.NewLine + "----------------------------");
     }
 }
Beispiel #13
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (numericUpDown1.Value <= 0)
                {
                    throw new WarningException("The rate should be positive!");
                }

                if (mertekegyseg == null)
                {
                    string fnevhash = ABKezelo.GetCurrentUser();
                    string nev      = textBox1.Text.Trim();

                    if (nev == "" || nev.Length > 30)
                    {
                        throw new WarningException("The name should be non-empty and at most 30 characters!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Mertekegyseg &&
                                                   (x as Mertekegyseg).Megnevezes == nev).ToList().Count != 0)
                    {
                        throw new WarningException("We have already a unit with that name!");
                    }

                    mertekegyseg = new Mertekegyseg(fnevhash, nev, (MertekegysegFajta)comboBox1.SelectedIndex, (double)numericUpDown1.Value, checkBox1.Checked,
                                                    checkBox2.Checked);
                    ABKezelo.Beszuras(mertekegyseg);
                    Logolas.Ment("New unit added, name: " + mertekegyseg.Megnevezes);
                }
                else
                {
                    mertekegyseg.Hasznalhato = checkBox1.Checked;
                    ABKezelo.Modositas(mertekegyseg);
                    Logolas.Ment("Unit modification, name: " + mertekegyseg.Megnevezes);
                }
            }
            catch (Exception ex)
            {
                if (ex is WarningException)
                {
                    MessageBox.Show(ex.Message, "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                DialogResult = DialogResult.None;
            }
        }
Beispiel #14
0
 private void ComboBox3_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         Penznem p = (Penznem)ABKezelo.Kiolvasas()
                     .Where(x => x is Penznem && (x as Penznem).Megnevezes == comboBox3.SelectedItem.ToString()).First();
         numericUpDown1.DecimalPlaces = p.TizedesekSzama;
         EtrendFeltetelMentes();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #15
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string       fnevhash = ABKezelo.GetCurrentUser();
                string       mnev     = comboBox1.SelectedItem.ToString();
                Mertekegyseg m        = (Mertekegyseg)ABKezelo.Kiolvasas()
                                        .Where(x => (x is Mertekegyseg) && (x as Mertekegyseg).Megnevezes == mnev).First();

                if (checkBox1.Checked && numericUpDown1.Value > numericUpDown2.Value)
                {
                    throw new ArgumentException("The daily minimum intake should not be less than the maximumu!");
                }

                if (tapanyag == null)
                {
                    string nev = textBox1.Text.Trim();

                    if (nev == "" || nev.Length > 30)
                    {
                        throw new ArgumentException("The name should be non-empty and at most 30 characters length!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Tapanyag && (x as Tapanyag).Megnevezes == nev).ToList().Count > 0)
                    {
                        throw new ArgumentException("We have already a nutrient with this name!");
                    }

                    tapanyag = new Tapanyag(fnevhash, nev, m, (double)numericUpDown1.Value, (double)numericUpDown2.Value, checkBox1.Checked, checkBox2.Checked);
                    ABKezelo.Beszuras(tapanyag);
                    Logolas.Ment("New nutrient added, name: " + tapanyag.Megnevezes);
                    ABKezelo.BeszurTapanyagElelmiszerekbe(tapanyag);
                }
                else
                {
                    tapanyag.NapiMinBevitel = (double)numericUpDown1.Value;
                    tapanyag.NapiMaxBevitel = (double)numericUpDown2.Value;
                    tapanyag.NapiMax        = checkBox1.Checked;
                    tapanyag.Hasznalhato    = checkBox2.Checked;
                    ABKezelo.Modositas(tapanyag);
                    Logolas.Ment("Nutrient modification, name: " + tapanyag.Megnevezes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
        }
Beispiel #16
0
        private void ListBoxRefresh()
        {
            try
            {
                int index = listBox1.SelectedIndex;
                listBox1.DataSource = null;

                if (radioButton1.Checked)
                {
                    listBox1.DataSource = ABKezelo.Kiolvasas().Where(x => x is Elelmiszer).ToList();
                }
                else
                {
                    listBox1.DataSource = ABKezelo.Kiolvasas().Where(x => x is Elelmiszer && (x as Elelmiszer).Hasznalhato).ToList();
                }

                if (index >= 0 && index < listBox1.Items.Count)
                {
                    listBox1.SelectedIndex = index;
                }
                else if (listBox1.Items.Count > 0)
                {
                    listBox1.SelectedIndex = 0;
                }
                else
                {
                    listBox1.SelectedIndex = -1;
                }

                string nev = comboBox3.SelectedItem.ToString();
                comboBox3.Items.Clear();
                comboBox3.Items.AddRange(ABKezelo.Kiolvasas().Where(x => x is Penznem).Select(p => (p as Penznem).Megnevezes)
                                         .ToArray());
                comboBox3.SelectedIndex = 0;
                int cnt = comboBox3.Items.Count;
                for (int i = 0; i < cnt; i++)
                {
                    if (comboBox3.Items[i].ToString() == nev)
                    {
                        comboBox3.SelectedIndex = i;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #17
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string fnev = ABKezelo.GetCurrentUser();
                int    i, j, k;
                int    p = 0, q = 0;
                for (i = 0; i < 2; i++)
                {
                    for (j = 0; j < 4; j++)
                    {
                        for (k = 0; k < 2; k++)
                        {
                            EtkezesFeltetel etk = new EtkezesFeltetel(fnev, (ElelmiszerTipus2)i, (EtkezesTipus2)j,
                                                                      (Szamlalo)k, (double)numericUpDowns[p].Value, checkBoxs[q].Checked,
                                                                      (double)numericUpDowns[p + 1].Value);
                            p += 2;
                            q++;
                            ABKezelo.Torol(etk);
                            ABKezelo.Beszuras(etk);
                        }
                    }
                }

                EtrendIdopont et = new EtrendIdopont(fnev, new List <DateTime>(3));
                for (i = 0; i < 3; i++)
                {
                    et.Datum.Add(new DateTime(2018, 1, 1, (int)numericUpDowns2[2 * i].Value,
                                              (int)numericUpDowns2[2 * i + 1].Value, 0));
                }

                if (ABKezelo.Kiolvasas().Where(x => x is EtrendIdopont).ToList().Count > 0)
                {
                    ABKezelo.Modositas(et);
                }
                else
                {
                    ABKezelo.Beszuras(et);
                }
                Logolas.Ment("Saved diet conditions.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #18
0
        private void Button1_Click(object sender, EventArgs e)
        {
            int l1 = textBox1.Text.Trim().Length;
            int l2 = textBox2.Text.Length;

            if (l1 < 4 || l1 > 24)
            {
                MessageBox.Show("User name's length should be between 4 and 24 !", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
            else if (textBox2.Text != textBox3.Text)
            {
                MessageBox.Show("The two passwords should be the same!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
            else if (l2 < 4 || l2 > 24)
            {
                MessageBox.Show("Password length should be between 4 and 24 !", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
            else if (textBox4.Text.Length > 30)
            {
                MessageBox.Show("Password remainder should be at most 30 !", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                DialogResult = DialogResult.None;
            }
            else
            {
                Titkositasok t = new Titkositasok();
                string       felhasznaloNevHash = Titkositasok.SHAHash(textBox1.Text.Trim() + Konstans.salt);

                if (ABKezelo.CountUsers(felhasznaloNevHash) > 0)
                {
                    MessageBox.Show("This username is already registered, choose another one!", "Error!", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    DialogResult = DialogResult.None;
                }
                else
                {
                    string      jelszoHash = Titkositasok.SHAHash(textBox2.Text + Konstans.salt);
                    Felhasznalo f          = new Felhasznalo(felhasznaloNevHash, jelszoHash,
                                                             t.f0(felhasznaloNevHash, textBox4.Text, KodolasIranya.Kódol));
                    ABKezelo.Beszuras(f);
                    Logolas.Ment("Register a new user, the name: " + textBox1.Text.Trim());
                }
            }
        }
Beispiel #19
0
        private void Button3_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                try
                {
                    string nev = ((Mertekegyseg)listBox1.SelectedItem).Megnevezes;
                    if (nev == "gram" || nev == "milligram" || nev == "liter" || nev == "joule" || nev == "calorie")
                    {
                        throw new WarningException("It is default unit, not deletable, not modifiable!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Tapanyag && (x as Tapanyag).Mertek.Megnevezes == nev).ToList().Count > 0)
                    {
                        throw new WarningException(
                                  "The unit is not modifiable, because there is a nutrient using it!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Etel && (x as Etel).TomegMertek.Megnevezes == nev).ToList().Count > 0)
                    {
                        throw new WarningException(
                                  "The unit is not modifiable, because there is a meal using it!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Ital && (x as Ital).Urmertek.Megnevezes == nev).ToList().Count > 0)
                    {
                        throw new WarningException(
                                  "The unit is not modifiable, because there is a drink using it!");
                    }

                    UjMertekegysegForm dialogus = new UjMertekegysegForm((Mertekegyseg)listBox1.SelectedItem);
                    if (dialogus.ShowDialog() == DialogResult.OK)
                    {
                        ListBoxRefresh();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("To modify a unit choose one!", "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #20
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex != -1)
     {
         try
         {
             Elelmiszer el = (listBox1.SelectedItem as Elelmiszer);
             el.Hasznalhato = true;
             ABKezelo.Modositas(el);
             listBoxRefresh();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #21
0
        public EtrendFeltetel(XElement e) : base(e.Element("EtrendAdat"))
        {
            Datum1     = DateTime.Parse(e.Attribute("Datum1").Value);
            Etkezes1   = (EtkezesTipus)byte.Parse(e.Attribute("Etkezes1").Value);
            Datum2     = DateTime.Parse(e.Attribute("Datum2").Value);
            Etkezes2   = (EtkezesTipus)byte.Parse(e.Attribute("Etkezes2").Value);
            Koltsegmin = e.Attribute("Koltsegmin").Value == "1";
            Orommax    = e.Attribute("Orommax").Value == "1";
            Maxpenz    = double.Parse(e.Attribute("Maxpenz").Value, NumberStyles.Any, new CultureInfo("en-US"));
            string str = e.Attribute("Penz").Value;

            Penz             = (Penznem)ABKezelo.Kiolvasas().Where(x => x is Penznem && (x as Penznem).Megnevezes == str).ToList().First();
            Solverelrejt     = e.Attribute("Solverelrejt").Value == "1";
            Folytonosmodell  = e.Attribute("Folytonosmodell").Value == "1";
            Numvaltozatossag = int.Parse(e.Attribute("Numvaltozatossag").Value);
            Maxfutasiido     = int.Parse(e.Attribute("Maxfutasiido").Value);
            NaptarbaMent     = e.Attribute("NaptarbaMent").Value == "1";
        }
Beispiel #22
0
        private void Button5_Click(object sender, EventArgs e)
        {
            try
            {            // elképzelhető, hogy nincs hálózat
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.Load(Konstans.ekb_bank_xml_link);

                XmlNodeList nodes = xmlDocument.SelectNodes("//*[@currency]");

                Dictionary <string, double> dict = new Dictionary <string, double>();

                dict.Add("EUR", 1);                //triviális árfolyam

                if (nodes != null)
                {
                    foreach (XmlNode node in nodes)
                    {
                        string str      = node.Attributes["currency"].Value.ToUpper();
                        double arfolyam = Convert.ToDouble(Decimal.Parse(node.Attributes["rate"].Value, NumberStyles.Any, new CultureInfo("en-Us")));
                        dict.Add(str, arfolyam);
                    }
                }

                if (!dict.ContainsKey("HUF"))
                {
                    throw new ArgumentException("Synchronization is unsuccessful!");
                }

                foreach (Penznem item in ABKezelo.Kiolvasas().Where(x => x is Penznem).ToList())
                {
                    if (dict.ContainsKey(item.PenzKod))
                    {
                        item.Arfolyam = dict["HUF"] / dict[item.PenzKod];
                        ABKezelo.Modositas(item);
                    }
                }

                ListBoxRefresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #23
0
 private void ComboBox4_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox4.SelectedIndex != -1)
     {
         try
         {
             Tapanyag t = (Tapanyag)ABKezelo.Kiolvasas()
                          .Where(x => x is Tapanyag && (x as Tapanyag).Megnevezes == comboBox4.SelectedItem.ToString())
                          .ToList().First();
             comboBox3.Items.Clear();
             comboBox3.Items.Add(t.Mertek.Megnevezes);
             comboBox3.SelectedIndex = 0;
             comboBox3.Enabled       = false;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #24
0
        public UjElelmiszerForm()
        {
            try
            {
                List <EtrendAdat> e = ABKezelo.Kiolvasas().ToList();
                tapanyagok     = new List <Tapanyag>();
                penznemek      = new List <Penznem>();
                mertekegysegek = new List <Mertekegyseg>();
                elelmiszerek   = new List <Elelmiszer>();
                foreach (EtrendAdat item in e)
                {
                    if ((item is Tapanyag) && (item as Tapanyag).Hasznalhato)
                    {
                        tapanyagok.Add((Tapanyag)item);
                    }
                    else if ((item is Penznem) && (item as Penznem).Hasznalhato)
                    {
                        penznemek.Add((Penznem)item);
                    }
                    else if ((item is Mertekegyseg) && (item as Mertekegyseg).Hasznalhato)
                    {
                        mertekegysegek.Add((Mertekegyseg)item);
                    }
                    else if (item is Elelmiszer)
                    {
                        elelmiszerek.Add((Elelmiszer)item);                                              //menüben minden élelmiszer használható, attól függetlenül, hogy az adott étel/ital használható-e
                    }
                }

                InitializeComponent();
                VezerlokLetrehozasa();
                AddButtonClick();
                ComboBox1_SelectedIndexChanged(new object(), new EventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #25
0
        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                string felhasznaloNevHash = Titkositasok.SHAHash(textBox1.Text.Trim() + Konstans.salt);
                if (ABKezelo.CountUsers(felhasznaloNevHash) != 0)
                {
                    string       jelszoEmlekeztetoOTP = ABKezelo.getJelszoHash(felhasznaloNevHash);
                    Titkositasok t      = new Titkositasok();
                    string       jelszo = t.f0(felhasznaloNevHash, jelszoEmlekeztetoOTP, KodolasIranya.Dekódol);

                    if (jelszo != "" && jelszo[0] != 0)
                    {
                        MessageBox.Show("The password remainder: " + jelszo, "Information", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                    else
                    {
                        throw new WarningException("There is no such username or not set password remainder!");
                    }
                }
                else
                {
                    throw new WarningException("There is no such username or not set password remainder!");
                }
            }
            catch (Exception ex)
            {
                if (ex is WarningException)
                {
                    MessageBox.Show(ex.Message, "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #26
0
        void EtrendFeltetelMentes()
        {
            try
            {
                string fnevhash = ABKezelo.GetCurrentUser();

                Penznem p = (Penznem)ABKezelo.Kiolvasas().Where(x => (x is Penznem) && (x as Penznem).Megnevezes == comboBox3.SelectedItem.ToString()).First();

                EtrendFeltetel e = new EtrendFeltetel(fnevhash, dateTimePicker1.Value, (EtkezesTipus)comboBox1.SelectedIndex, dateTimePicker2.Value, (EtkezesTipus)comboBox2.SelectedIndex, checkBox1.Checked, checkBox2.Checked, (double)numericUpDown1.Value, p, checkBox3.Checked, checkBox4.Checked, (int)numericUpDown2.Value, (int)numericUpDown3.Value, checkBox5.Checked);

                if (ABKezelo.Kiolvasas().Where(x => x is EtrendFeltetel).ToList().Count == 0)
                {
                    ABKezelo.Beszuras(e);
                }
                else
                {
                    ABKezelo.Modositas(e);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #27
0
        void Rendezes()
        {
            try
            {
                if (radioButton1.Checked)
                {
                    if (checkBox1.Checked)
                    {
                        elelmiszerek = elelmiszerek.OrderBy(x => x.Megnevezes).ToList();
                    }
                    else
                    {
                        elelmiszerek = elelmiszerek.OrderByDescending(x => x.Megnevezes).ToList();
                    }
                }
                else if (radioButton2.Checked)
                {
                    if (checkBox1.Checked)
                    {
                        elelmiszerek = elelmiszerek.OrderBy(x => x.Ar * x.Penz.Arfolyam).ToList();
                    }
                    else
                    {
                        elelmiszerek = elelmiszerek.OrderByDescending(x => x.Ar * x.Penz.Arfolyam).ToList();
                    }
                }
                else if (radioButton3.Checked)
                {
                    if (checkBox1.Checked)
                    {
                        elelmiszerek = elelmiszerek.OrderBy(
                            x => (x is Ital)
                                                                ? 0
                                                                : (x is Etel
                                                                        ? (x as Etel).EgysegTomegMennyiseg * (x as Etel).TomegMertek.Valtoszam
                                                                        : (x as Menu).EgysegTomegMennyiseg * (x as Menu).TomegMertek.Valtoszam)).ToList();
                    }
                    else
                    {
                        elelmiszerek = elelmiszerek.OrderByDescending(x =>
                                                                      (x is Ital)
                                                                ? 0
                                                                : (x is Etel
                                                                        ? (x as Etel).EgysegTomegMennyiseg * (x as Etel).TomegMertek.Valtoszam
                                                                        : (x as Menu).EgysegTomegMennyiseg * (x as Menu).TomegMertek.Valtoszam)).ToList();
                    }
                }
                else if (radioButton4.Checked)
                {
                    if (checkBox1.Checked)
                    {
                        elelmiszerek = elelmiszerek.OrderBy(
                            x => (x is Etel)
                                                                ? 0
                                                                : (x is Ital
                                                                        ? (x as Ital).EgysegUrTartalomMennyiseg * (x as Ital).Urmertek.Valtoszam
                                                                        : (x as Menu).EgysegUrTartalomMennyiseg * (x as Menu).Urmertek.Valtoszam)).ToList();
                    }
                    else
                    {
                        elelmiszerek = elelmiszerek.OrderByDescending(x =>
                                                                      (x is Etel)
                                                                ? 0
                                                                : (x is Ital
                                                                        ? (x as Ital).EgysegUrTartalomMennyiseg * (x as Ital).Urmertek.Valtoszam
                                                                        : (x as Menu).EgysegUrTartalomMennyiseg * (x as Menu).Urmertek.Valtoszam)).ToList();
                    }
                }
                else if (comboBox1.SelectedIndex != -1)
                {
                    Tapanyag t = (Tapanyag)ABKezelo.Kiolvasas()
                                 .Where(x => x is Tapanyag && (x as Tapanyag).Megnevezes == comboBox1.SelectedItem.ToString()).ToList().First();
                    if (checkBox1.Checked)
                    {
                        elelmiszerek = elelmiszerek.OrderBy(x => x.TapanyagTartalom[t]).ToList();
                    }
                    else
                    {
                        elelmiszerek = elelmiszerek.OrderByDescending(x => x.TapanyagTartalom[t]).ToList();
                    }
                }

                listBox1.DataSource = null;
                listBox1.DataSource = elelmiszerek;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #28
0
        void VezerlokLetrehozasa()
        {
            Height = 520;
            Width  = 760;
            CenterToScreen();
            Text = "Sort form";

            label1 = new Label()
            {
                Left      = 30,
                Top       = 30,
                Text      = "Sorted list",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            listBox1 = new ListBox()
            {
                Left      = label1.Left,
                Top       = label1.Bottom + 15,
                Height    = 400,
                Width     = 440,
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };

            label2 = new Label()
            {
                Left      = listBox1.Right + 15,
                Top       = listBox1.Top,
                Text      = "Order by:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            radioButton1 = new RadioButton()
            {
                Left      = label2.Left,
                Top       = label2.Bottom + 10,
                Text      = "Name",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Checked   = true,
                Parent    = this
            };

            radioButton2 = new RadioButton()
            {
                Left      = radioButton1.Left,
                Top       = radioButton1.Bottom + 10,
                Text      = "Price",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };

            radioButton3 = new RadioButton()
            {
                Left      = radioButton2.Left,
                Top       = radioButton2.Bottom + 10,
                Text      = "Mass",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };

            radioButton4 = new RadioButton()
            {
                Left      = radioButton3.Left,
                Top       = radioButton3.Bottom + 10,
                Text      = "Liquid measure",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };

            radioButton5 = new RadioButton()
            {
                Left      = radioButton4.Left,
                Top       = radioButton4.Bottom + 10,
                Text      = "Nutrient",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };

            comboBox1 = new ComboBox()
            {
                DataSource    = null,
                DropDownStyle = ComboBoxStyle.DropDownList,
                Left          = radioButton5.Right + 10,
                Top           = radioButton5.Top,
                Font          = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor     = Color.Blue,
                BackColor     = Color.White,
                AutoSize      = true,
                Parent        = this
            };

            label3 = new Label()
            {
                Left      = radioButton5.Left,
                Top       = radioButton5.Bottom + 20,
                Text      = "Order's direction:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            checkBox1 = new CheckBox()
            {
                Left      = label3.Left,
                Top       = label3.Bottom + 10,
                Checked   = true,
                Text      = "Increasing order (in ABC)?",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            radioButton1.Checked = true;

            try
            {
                comboBox1.Items.Clear();
                comboBox1.Items.AddRange(ABKezelo.Kiolvasas().Where(x => x is Tapanyag && (x as Tapanyag).Hasznalhato).Select(x => (x as Tapanyag).Megnevezes).ToArray());
                if (comboBox1.Items.Count > 0)
                {
                    comboBox1.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #29
0
        private void Button4_Click(object sender, EventArgs e)
        {
            try
            {
                if (listBox1.SelectedIndex != -1)
                {
                    string str       = (listBox1.SelectedItem as Mertekegyseg).Megnevezes;
                    bool   torolheto = true;
                    foreach (Elelmiszer item in ABKezelo.Kiolvasas().Where(x => x is Elelmiszer))
                    {
                        if (item is Ital && (item as Ital).Urmertek.Megnevezes == str)
                        {
                            torolheto = false;
                            break;
                        }

                        if (item is Etel && (item as Etel).TomegMertek.Megnevezes == str)
                        {
                            torolheto = false;
                            break;
                        }
                    }

                    if (!torolheto)
                    {
                        throw new WarningException(
                                  "This unit is not deletable, beaucse there is a food using it!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Tapanyag && (x as Tapanyag).Mertek.Megnevezes == str).ToList().Count > 0)
                    {
                        throw new WarningException(
                                  "This unit is not deletable, because there is a nutrient using it!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Etel && (x as Etel).TomegMertek.Megnevezes == str).ToList().Count > 0)
                    {
                        throw new WarningException(
                                  "This unit is not deletable, because there is a meal using it!");
                    }

                    if (ABKezelo.Kiolvasas().Where(x => x is Ital && (x as Ital).Urmertek.Megnevezes == str).ToList().Count > 0)
                    {
                        throw new WarningException(
                                  "This unit is not deletable, because there is a drink using it!");
                    }

                    if (((Mertekegyseg)listBox1.SelectedItem).Torolheto)
                    {
                        if (MessageBox.Show("Really want to delete the unit?", "Question", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            string nev = ((Mertekegyseg)listBox1.SelectedItem).Megnevezes;
                            ABKezelo.Torol((Mertekegyseg)listBox1.SelectedItem);
                            Logolas.Ment("Unit deleted, name: " + nev);
                            ListBoxRefresh();
                        }
                    }
                    else
                    {
                        throw new WarningException("This unit is not deletable!");
                    }
                }
                else
                {
                    throw new WarningException("To delete a unit choose one!");
                }
            }
            catch (Exception ex)
            {
                if (ex is WarningException)
                {
                    MessageBox.Show(ex.Message, "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #30
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string fnevhash = ABKezelo.GetCurrentUser();

                if (comboBox1.SelectedIndex != (int)ElelmiszerTipus.menu && checkBox2.Checked &&
                    numericUpDown5.Value > numericUpDown6.Value)
                {
                    throw new WarningException("The maximal consumption should not be less than the minimal!");
                }

                if (elelmiszer == null)
                {
                    string nev = textBox1.Text.Trim();

                    if (nev == "" || nev.Length > 30)
                    {
                        throw new WarningException("The name should be non-empty and at most 30 characters!");
                    }
                    if (elelmiszerek.Where(x => x.Megnevezes == nev).ToList().Count > 0)
                    {
                        throw new WarningException("You already have a food with this name!");
                    }
                    int         i;
                    List <bool> fogyaszthato = new List <bool> {
                        checkBox3.Checked, checkBox4.Checked, checkBox5.Checked
                    };

                    double ar = (double)numericUpDown2.Value;

                    Penznem penz = penznemek.Where(p => p.Megnevezes == comboBox2.SelectedItem.ToString()).First();

                    Mertekegyseg mertek1    = mertekegysegek.Where(m => m.Megnevezes == comboBox3.SelectedItem.ToString()).First();
                    double       mennyiseg1 = (double)numericUpDown3.Value;

                    Mertekegyseg mertek2    = mertekegysegek.Where(m => m.Megnevezes == comboBox4.SelectedItem.ToString()).First();
                    double       mennyiseg2 = (double)numericUpDown4.Value;

                    //étel
                    Elelmiszer el = null;
                    switch ((ElelmiszerTipus)comboBox1.SelectedIndex)
                    {
                    case ElelmiszerTipus.meal:
                    {
                        el = new Etel(fnevhash, textBox1.Text.Trim(),
                                      (byte)numericUpDown1.Value,
                                      penz,
                                      ar,
                                      checkBox1.Checked,
                                      fogyaszthato,
                                      checkBox6.Checked,
                                      checkBox7.Checked,
                                      new Dictionary <Tapanyag, double>(),
                                      mennyiseg1,
                                      (double)numericUpDown5.Value,
                                      (double)numericUpDown6.Value,
                                      checkBox2.Checked,
                                      mertek1);
                        break;
                    }

                    //ital
                    case ElelmiszerTipus.drink:
                    {
                        el = new Ital(fnevhash, textBox1.Text.Trim(),
                                      (byte)numericUpDown1.Value,
                                      penz,
                                      ar,
                                      checkBox1.Checked,
                                      fogyaszthato,
                                      checkBox6.Checked,
                                      checkBox7.Checked,
                                      new Dictionary <Tapanyag, double>(),
                                      mennyiseg2,
                                      (double)numericUpDown5.Value,
                                      (double)numericUpDown6.Value,
                                      checkBox2.Checked,
                                      mertek2);
                        break;
                    }

                    //menü
                    case ElelmiszerTipus.menu:
                    {
                        el = new Menu(fnevhash, textBox1.Text.Trim(),
                                      (byte)numericUpDown1.Value,
                                      penz,
                                      ar,
                                      checkBox1.Checked,
                                      fogyaszthato,
                                      checkBox6.Checked,
                                      checkBox7.Checked,
                                      new Dictionary <Tapanyag, double>(),
                                      (byte)numericUpDown7.Value,
                                      1,
                                      mertek1,
                                      1,
                                      mertek2,
                                      new Dictionary <Elelmiszer, double>(),
                                      checkBox8.Checked);
                        break;
                    }
                    }

                    foreach (Tapanyag item in ABKezelo.Kiolvasas().Where(x => x is Tapanyag).ToList())
                    {
                        el.TapanyagTartalom.Add(item, 0);
                    }

                    for (i = 0; i < labelek.Count(); i++)
                    {
                        string   str = labelek[i].Text.Remove(labelek[i].Text.Length - 1);
                        double   m   = (double)szamlalok[i].Value;
                        Tapanyag t   = tapanyagok.Where(x => x.Megnevezes == str).First();
                        el.TapanyagTartalom[t] = m;
                    }

                    if (el is Menu)
                    {
                        bool van = false;
                        for (i = 0; i < labelek3.Count; i++)
                        {
                            string str = labelek3[i].Text.Remove(labelek3[i].Text.Length - 1);
                            double m   = (double)szamlalok3[i].Value;
                            if (m > 0)
                            {
                                van = true;
                            }
                            Elelmiszer el2 = elelmiszerek.Where(x => x.Megnevezes == str).First();
                            (el as Menu).Osszetevo.Add(el2, m);
                        }

                        if (!van)
                        {
                            throw new WarningException("There is no meal/drink with positive mass/volume!");
                        }
                    }
                    ABKezelo.Beszuras(el);
                    Logolas.Ment("New food added, name: " + el.Megnevezes);
                }
                else
                {
                    elelmiszer.Orom = (byte)numericUpDown1.Value;
                    elelmiszer.Ar   = (double)numericUpDown2.Value;
                    string pnev = comboBox2.SelectedItem.ToString();
                    elelmiszer.Penz = penznemek.Where(x => x.Megnevezes == pnev).First();
                    elelmiszer.EgysegTobbszorose = checkBox1.Checked;
                    elelmiszer.Fogyaszthato      = new List <bool>()
                    {
                        checkBox3.Checked,
                        checkBox4.Checked,
                        checkBox5.Checked
                    };
                    elelmiszer.Valtozatossag = checkBox6.Checked;
                    elelmiszer.Hasznalhato   = checkBox7.Checked;

                    int i;
                    for (i = 0; i < labelek.Count; i++)
                    {
                        string   tnev = labelek[i].Text.Remove(labelek[i].Text.Length - 1);
                        Tapanyag t    = tapanyagok.Where(x => x.Megnevezes == tnev).First();
                        elelmiszer.TapanyagTartalom[t] = (double)szamlalok[i].Value;
                    }

                    if (elelmiszer is Etel)
                    {
                        (elelmiszer as Etel).TomegMertek.Megnevezes = comboBox3.SelectedItem.ToString();
                        (elelmiszer as Etel).EgysegTomegMennyiseg   = (double)numericUpDown3.Value;
                        (elelmiszer as Etel).MinTomeg  = (double)numericUpDown5.Value;
                        (elelmiszer as Etel).MaxTomeg  = (double)numericUpDown6.Value;
                        (elelmiszer as Etel).MaxTomegE = checkBox2.Checked;
                    }
                    else if (elelmiszer is Ital)
                    {
                        (elelmiszer as Ital).Urmertek.Megnevezes       = comboBox4.SelectedItem.ToString();
                        (elelmiszer as Ital).EgysegUrTartalomMennyiseg = (double)numericUpDown4.Value;
                        (elelmiszer as Ital).MinUrTartalom             = (double)numericUpDown5.Value;
                        (elelmiszer as Ital).MaxUrTartalom             = (double)numericUpDown6.Value;
                        (elelmiszer as Ital).MaxUrTartalomE            = checkBox2.Checked;
                    }
                    else if (elelmiszer is Menu)
                    {
                        (elelmiszer as Menu).TomegMertek.Megnevezes    = comboBox3.SelectedItem.ToString();
                        (elelmiszer as Menu).EgysegTomegMennyiseg      = (double)numericUpDown3.Value;
                        (elelmiszer as Menu).Urmertek.Megnevezes       = comboBox4.SelectedItem.ToString();
                        (elelmiszer as Menu).EgysegUrTartalomMennyiseg = (double)numericUpDown4.Value;
                        (elelmiszer as Menu).MaxDarab = (byte)numericUpDown7.Value;

                        (elelmiszer as Menu).Osszetevo = new Dictionary <Elelmiszer, double>();

                        double total = 0;
                        for (i = 0; i < labelek3.Count; i++)
                        {
                            string     str = labelek3[i].Text.Remove(labelek3[i].Text.Length - 1);
                            Elelmiszer el2 = elelmiszerek.Where(x => x.Megnevezes == str).First();
                            double     m   = (double)szamlalok3[i].Value;
                            if (m > 0)
                            {
                                (elelmiszer as Menu).Osszetevo.Add(el2, m);
                                total += m;
                            }
                        }

                        if (total == 0)
                        {
                            throw new WarningException("The unit should be positive");
                        }
                    }
                    ABKezelo.Modositas(elelmiszer);
                    Logolas.Ment("Food modification, name: " + elelmiszer.Megnevezes);
                }
            }
            catch (Exception ex)
            {
                if (ex is WarningException)
                {
                    MessageBox.Show(ex.Message, "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                DialogResult = DialogResult.None;
            }
        }