コード例 #1
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);
            }
        }
コード例 #2
0
ファイル: KeresesForm.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #3
0
ファイル: MertekegysegForm.cs プロジェクト: gerbicz/MenuMaker
 private void ListBoxRefresh()
 {
     try
     {
         int index = listBox1.SelectedIndex;
         listBox1.DataSource = null;
         listBox1.DataSource = ABKezelo.Kiolvasas().Where(x => x is Mertekegyseg).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);
     }
 }
コード例 #4
0
ファイル: Form1.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #5
0
ファイル: RendezesForm.cs プロジェクト: gerbicz/MenuMaker
        public RendezesForm(bool tipus)
        {
            Logolas.Ment("We are on the sort form");

            InitializeComponent();
            elelmiszerek = new List <Elelmiszer>();

            try
            {
                if (tipus)
                {
                    foreach (Elelmiszer item in ABKezelo.Kiolvasas().Where(x => x is Elelmiszer).ToList())
                    {
                        elelmiszerek.Add(item);
                    }
                }
                else
                {
                    foreach (Elelmiszer item in ABKezelo.Kiolvasas().Where(x => x is Elelmiszer && (x as Elelmiszer).Hasznalhato)
                             .ToList())
                    {
                        elelmiszerek.Add(item);
                    }
                }

                VezerlokLetrehozasa();
                AddButtonClick();
                Rendezes();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
ファイル: ElelmiszerForm.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #7
0
ファイル: ElelmiszerForm.cs プロジェクト: gerbicz/MenuMaker
        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);
                }
            }
        }
コード例 #8
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;
            }
        }
コード例 #9
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;
            }
        }
コード例 #10
0
ファイル: Form1.cs プロジェクト: gerbicz/MenuMaker
 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);
     }
 }
コード例 #11
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;
            }
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #13
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;
            }
        }
コード例 #14
0
ファイル: MertekegysegForm.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #15
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);
            }
        }
コード例 #16
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";
        }
コード例 #17
0
ファイル: PenznemForm.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #18
0
ファイル: KeresesForm.cs プロジェクト: gerbicz/MenuMaker
 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);
         }
     }
 }
コード例 #19
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);
            }
        }
コード例 #20
0
ファイル: Form1.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #21
0
ファイル: MertekegysegForm.cs プロジェクト: gerbicz/MenuMaker
        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);
                }
            }
        }
コード例 #22
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;
            }
        }
コード例 #23
0
ファイル: PenznemForm.cs プロジェクト: gerbicz/MenuMaker
        private void Button4_Click(object sender, EventArgs e)
        {
            try
            {
                if (listBox1.SelectedIndex != -1)
                {
                    Penznem p         = (Penznem)listBox1.SelectedItem;
                    bool    torolheto = true;

                    foreach (Elelmiszer item in ABKezelo.Kiolvasas().Where(x => x is Elelmiszer))
                    {
                        if (item.Penz.Megnevezes == p.Megnevezes)
                        {
                            torolheto = false;
                            break;
                        }
                    }

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

                    EtrendFeltetel et = (EtrendFeltetel)ABKezelo.Kiolvasas().Where(x => x is EtrendFeltetel).ToList().First();

                    if (et.Penz.Megnevezes == p.Megnevezes)
                    {
                        throw new WarningException("This currency is not deletable, bceause Form1 is using it!");
                    }

                    if (((Penznem)listBox1.SelectedItem).Torolheto)
                    {
                        if (MessageBox.Show("Really want to delete the currency?", "Question", MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            string nev = ((Penznem)listBox1.SelectedItem).Megnevezes;
                            ABKezelo.Torol((Penznem)listBox1.SelectedItem);
                            Logolas.Ment("Currency deleted, name: " + nev);
                            ListBoxRefresh();
                        }
                    }
                    else
                    {
                        throw new WarningException("This currency is not deletable!");
                    }
                }
                else
                {
                    throw new WarningException("To delete a currency 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);
                }
            }
        }
コード例 #24
0
ファイル: Form1.cs プロジェクト: gerbicz/MenuMaker
        private void Button6_Click(object sender, EventArgs eventargs)
        {
            try
            {
                if (numericUpDown3.Value <= 0 || numericUpDown3.Value > Konstans.maxValaszthatoFutasiIdo)
                {
                    throw new ArgumentException("Running time is positive and at most " + Konstans.maxValaszthatoFutasiIdo + " !");
                }

                Logolas.Ment("Diet making/running with the Glpk program.");
                EtrendMegold e0 = new EtrendMegold();

                List <object> ans = e0.Megoldas();

                if ((bool)ans[0])
                {
                    EtrendFeltetel e = (EtrendFeltetel)ABKezelo.Kiolvasas().Where(x => x is EtrendFeltetel).First();

                    var l = ABKezelo.Kiolvasas().Where(x => x is EtrendElelmiszer).ToList();

                    DateTime e1 = e.Datum1;
                    DateTime e2 = e.Datum2;
                    e1 = new DateTime(e1.Year, e1.Month, e1.Day, 0, 0, 0);
                    e2 = new DateTime(e2.Year, e2.Month, e2.Day, 0, 0, 0);
                    DateTime d = e1;

                    string str = "";

                    if (checkBox1.Checked)
                    {
                        str += String.Format("Minimum cost: {0} {1}", ans[1], (ans[2] as Penznem).Megnevezes) + Environment.NewLine;
                    }
                    else if (checkBox2.Checked)
                    {
                        str += String.Format("Maximum joy: {0}", ans[1]) + Environment.NewLine;
                    }

                    while (d <= e2)
                    {
                        str += String.Format("{0:yyyy.MM.dd.}", d) + Environment.NewLine;
                        for (int i = 0; i < 3; i++)
                        {
                            if (d == e1 && i < (int)e.Etkezes1)
                            {
                                continue;
                            }
                            if (d == e2 && i > (int)e.Etkezes2)
                            {
                                continue;
                            }

                            var l2 = l.Where(x => (x as EtrendElelmiszer).Datum == d && (int)(x as EtrendElelmiszer).Etkezes == i).ToList();

                            str += "   " + (EtkezesTipus)i + ":" + Environment.NewLine;
                            foreach (EtrendElelmiszer item in l2)
                            {
                                Elelmiszer elelmiszer = item.Elelmiszer;
                                if (elelmiszer is Etel)
                                {
                                    str += String.Format("      {0:0.00} {1} {2}", item.Tomeg, item.Tomegmertekegyseg.Megnevezes, elelmiszer.Megnevezes);
                                }
                                else if (elelmiszer is Ital)
                                {
                                    str += String.Format("      {0:0.00} {1} {2}", item.Urmertek, item.Urmertekegyseg.Megnevezes, elelmiszer.Megnevezes);
                                }
                                else
                                {
                                    str += String.Format("      {0:0.00} {1} [{2:0.00} {3}, {4:0.00} {5}]", item.Val, elelmiszer.Megnevezes, item.Tomeg,
                                                         item.Tomegmertekegyseg.Megnevezes, item.Urmertek, item.Urmertekegyseg.Megnevezes);
                                }
                                str += Environment.NewLine;
                            }
                        }
                        d = d.AddDays(1);
                    }

                    textBox1.Text = str;

                    File.AppendAllText("diets.txt", "Solution:" + Environment.NewLine + str + Environment.NewLine);

                    if (checkBox5.Checked)
                    {
                        Naptar.NaptarbaRak(); // google calendar-ba mentés, ha checkbox be van jelölve
                    }
                }
                else
                {
                    MessageBox.Show("The linear program has no solution!", "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Text = "No solution!";
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            Logolas.Ment("Glpk's run has finished.");
        }
コード例 #25
0
        public static void XMLRead(string filename, bool check = false, string hash = null, bool msg = true)
        {
            try
            {
                if (File.Exists(filename))
                {
                    List <ABHiba> hibak = new List <ABHiba>();
                    XDocument     xml   = XDocument.Load(filename);

                    List <Penznem> penznemek =
                        (from p in xml.Root.Elements("Penznem")
                         select new Penznem(p)).ToList();

                    List <EtrendAdat> e = new List <EtrendAdat>();
                    foreach (Penznem item in penznemek)
                    {
                        if (check && item.FelhasznaloNevHash != hash)
                        {
                            throw new ArgumentException("Other user saved this, you have no right to use it!");
                        }

                        e.Add(item);
                    }
                    hibak.AddRange(ABKezelo.Csoportosbeszuras(Csere(e, hash)));

                    e = new List <EtrendAdat>();
                    List <Mertekegyseg> mertekegysegek =
                        (from m in xml.Root.Elements("Mertekegyseg")
                         select new Mertekegyseg(m)).ToList();
                    foreach (Mertekegyseg item in mertekegysegek)
                    {
                        e.Add(item);
                    }
                    hibak.AddRange(ABKezelo.Csoportosbeszuras(Csere(e, hash)));


                    e = new List <EtrendAdat>();
                    List <Tapanyag> tapanyagok =
                        (from t in xml.Root.Elements("Tapanyag") select new Tapanyag(t, mertekegysegek)).ToList();
                    foreach (Tapanyag item in tapanyagok)
                    {
                        e.Add(item);
                    }
                    hibak.AddRange(ABKezelo.Csoportosbeszuras(Csere(e, hash)));


                    e = new List <EtrendAdat>();
                    List <Etel> etelek = (from etel in xml.Root.Elements("Etel") select new Etel(etel, penznemek, mertekegysegek)).ToList();
                    foreach (Etel item in etelek)
                    {
                        e.Add(item);
                    }
                    hibak.AddRange(ABKezelo.Csoportosbeszuras(Csere(e, hash)));

                    e = new List <EtrendAdat>();
                    List <Ital> italok = (from ital in xml.Root.Elements("Ital") select new Ital(ital, penznemek, mertekegysegek)).ToList();
                    foreach (Ital item in italok)
                    {
                        e.Add(item);
                    }
                    hibak.AddRange(ABKezelo.Csoportosbeszuras(Csere(e, hash)));

                    e = new List <EtrendAdat>();
                    List <Menu> menuk = (from menu in xml.Root.Elements("Menu") select new Menu(menu, penznemek, mertekegysegek)).ToList();
                    foreach (Menu item in menuk)
                    {
                        e.Add(item);
                    }
                    hibak.AddRange(ABKezelo.Csoportosbeszuras(Csere(e, hash)));


                    e = new List <EtrendAdat>();
                    List <ElelmiszerTapanyag> elelmiszertapanyag =
                        (from et in xml.Root.Elements("ElelmiszerTapanyag") select new ElelmiszerTapanyag(et, tapanyagok)).ToList();


                    List <Elelmiszer> elelmiszerek = new List <Elelmiszer>();
                    foreach (Etel item in etelek)
                    {
                        elelmiszerek.Add(item);
                    }
                    foreach (Ital item in italok)
                    {
                        elelmiszerek.Add(item);
                    }
                    foreach (Tapanyag t in tapanyagok)
                    {
                        ABKezelo.BeszurTapanyagElelmiszerekbe((Tapanyag)Csere(t, hash), elelmiszerek);
                    }


                    foreach (Elelmiszer item in ABKezelo.Kiolvasas().Where(x => x is Elelmiszer).ToList())
                    {
                        foreach (ElelmiszerTapanyag item2 in elelmiszertapanyag.Where(x => x.ElelmiszerMegnevezes == item.Megnevezes).ToList())
                        {
                            item.TapanyagTartalom[item2.Tapanyag] = item2.Ertek;
                        }
                        ABKezelo.Modositas(item);
                    }

                    elelmiszerek = new List <Elelmiszer>();
                    foreach (Etel item in etelek)
                    {
                        elelmiszerek.Add(item);
                    }
                    foreach (Ital item in italok)
                    {
                        elelmiszerek.Add(item);
                    }

                    e = new List <EtrendAdat>();
                    List <ElelmiszerElelmiszer> elelmiszerelelmiszer =
                        (from et in xml.Root.Elements("ElelmiszerElelmiszer") select new ElelmiszerElelmiszer(et, elelmiszerek)).ToList();

                    foreach (Menu item in menuk)
                    {
                        ABKezelo.BeszurElelmiszerElelmiszerekbe((Elelmiszer)Csere(item, hash));
                    }

                    foreach (Menu item in ABKezelo.Kiolvasas().Where(x => x is Menu).ToList())
                    {
                        foreach (ElelmiszerElelmiszer item2 in elelmiszerelelmiszer.Where(x => x.ElelmiszerMegnevezes == item.Megnevezes).ToList())
                        {
                            item.Osszetevo[item2.Elelmiszer] = item2.Ertek;
                        }
                        ABKezelo.Modositas(item);
                    }

                    EtrendFeltetel etrendfeltetel = (from x in xml.Root.Elements("EtrendFeltetel") select new EtrendFeltetel(x)).ToList().First();
                    ABKezelo.Beszuras(Csere(etrendfeltetel, hash));

                    e = new List <EtrendAdat>();
                    List <EtkezesFeltetel> etkezesfeltetel = (from x in xml.Root.Elements("EtkezesFeltetel") select new EtkezesFeltetel(x)).ToList();
                    foreach (EtkezesFeltetel item in etkezesfeltetel)
                    {
                        e.Add(item);
                    }
                    hibak.AddRange(ABKezelo.Csoportosbeszuras(Csere(e, hash)));

                    var etrendidopont = (from x in xml.Root.Elements("EtrendIdopont") select new EtrendIdopont(x)).ToList();
                    if (etrendidopont.Count > 0)
                    {
                        ABKezelo.Beszuras(Csere(etrendidopont.First(), hash));
                    }

                    if (hibak.Count > 0)
                    {
                        string szoveg = "";
                        foreach (ABHiba item in hibak)
                        {
                            szoveg += item + " " + item.Hibas + Environment.NewLine;
                        }

                        throw new Exception(szoveg);
                    }

                    if (msg)
                    {
                        MessageBox.Show("Successful import!", "Info!", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        Logolas.Ment("Successful XML import!");
                    }
                }
                else
                {
                    throw new FileNotFoundException("Not existing file!");
                }
            }
            catch (Exception ex)
            {
                if (msg)
                {
                    Logolas.Ment("Unsuccessful XML import!");
                }
                throw ex;
            }
        }
コード例 #26
0
ファイル: Form1.cs プロジェクト: gerbicz/MenuMaker
        void VezerlokLetrehozasa()
        {
            Height = 768;
            Width  = 1366;
            CenterToScreen();// képernyő közepére teszi a formot
            Text = "Diet preparing";

            openFileDialog1 = new OpenFileDialog()
            {
                Filter = "XML fájlok | *.xml"
            };

            saveFileDialog1 = new SaveFileDialog()
            {
                Filter = "XML fájlok | *.xml"
            };

            radioButton1 = new RadioButton()
            {
                Left      = 15,
                Top       = 25,
                Width     = 250,
                Text      = "All foods",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Checked   = true,
                Parent    = this
            };

            radioButton2 = new RadioButton()
            {
                Left      = radioButton1.Left,
                Top       = radioButton1.Bottom + 15,
                Width     = 250,
                Text      = "Foods used for diet",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };

            listBox1 = new ListBox()
            {
                Left      = radioButton1.Left,
                Top       = radioButton2.Bottom + 15,
                Height    = 400,
                Width     = 440,
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };
            button1 = new Button()
            {
                Left      = listBox1.Right + 30,
                Top       = radioButton1.Top,
                Width     = 320,
                Text      = "Units edit",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            button2 = new Button()
            {
                Left      = button1.Left,
                Top       = button1.Bottom + 10,
                Width     = button1.Width,
                Text      = "Currency edit",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            button3 = new Button()
            {
                Left      = button1.Left,
                Top       = button2.Bottom + 10,
                Width     = button1.Width,
                Text      = "Nutrients edit",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            button4 = new Button()
            {
                Left      = button1.Left,
                Top       = button3.Bottom + 10,
                Width     = button1.Width,
                Text      = "Foods edit",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            label2 = new Label()
            {
                Left      = button1.Left,
                Top       = button4.Bottom + 20,
                Text      = "Starting date:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            dateTimePicker1 = new DateTimePicker()
            {
                Left         = label2.Right + 25,
                Top          = label2.Top,
                CustomFormat = "yyyy.MM.dd",
                MinDate      = DateTime.Parse("2001.01.01"),
                AutoSize     = true,
                Parent       = this
            };

            label3 = new Label()
            {
                Left      = label2.Left,
                Top       = label2.Bottom + 10,
                Text      = "Starting meal:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            comboBox1 = new ComboBox()
            {
                Parent        = this,
                DataSource    = Enum.GetValues(typeof(EtkezesTipus)),
                DropDownStyle = ComboBoxStyle.DropDownList,
                Left          = dateTimePicker1.Left,
                Top           = label3.Top,
                Font          = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor     = Color.Blue,
                BackColor     = Color.White,
                AutoSize      = true
            };

            label4 = new Label()
            {
                Left      = label3.Left,
                Top       = label3.Bottom + 20,
                Text      = "End date:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            dateTimePicker2 = new DateTimePicker()
            {
                Left         = dateTimePicker1.Left,
                Top          = label4.Top,
                CustomFormat = "yyyy.MM.dd",
                MinDate      = DateTime.Parse("2001.01.01"),
                AutoSize     = true,
                Parent       = this
            };

            label5 = new Label()
            {
                Left      = label4.Left,
                Top       = label4.Bottom + 10,
                Text      = "End meal:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            comboBox2 = new ComboBox()
            {
                Parent        = this,
                DataSource    = Enum.GetValues(typeof(EtkezesTipus)),
                DropDownStyle = ComboBoxStyle.DropDownList,
                Left          = comboBox1.Left,
                Top           = label5.Top,
                Font          = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor     = Color.Blue,
                BackColor     = Color.White,
                AutoSize      = true,
            };

            checkBox1 = new CheckBox()
            {
                Left      = label5.Left,
                Top       = label5.Bottom + 15,
                Checked   = false,
                Text      = "Minimize cost?",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            checkBox2 = new CheckBox()
            {
                Left      = checkBox1.Left,
                Top       = checkBox1.Bottom + 5,
                Checked   = false,
                Text      = "Maximize joy?",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            label6 = new Label()
            {
                Left      = button1.Left,
                Top       = checkBox2.Bottom + 5,
                Text      = "Maximal money:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            numericUpDown1 = new NumericUpDown()
            {
                Left          = button1.Left + 20,
                Top           = label6.Bottom + 5,
                Maximum       = Konstans.maxElkolthetoPenz,
                DecimalPlaces = 2,
                AutoSize      = true,
                Parent        = this
            };

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

            checkBox3 = new CheckBox()
            {
                Left      = button1.Left,
                Top       = numericUpDown1.Bottom + 5,
                Checked   = true,
                Text      = "Hide solver?",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            checkBox4 = new CheckBox()
            {
                Left      = checkBox3.Left,
                Top       = checkBox3.Bottom + 5,
                Checked   = false,
                Text      = "Continous model?",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            numericUpDown2 = new NumericUpDown()
            {
                Left     = checkBox4.Left,
                Top      = checkBox4.Bottom + 5,
                Minimum  = 1,
                Maximum  = 100,
                Value    = 1,
                AutoSize = true,
                Parent   = this
            };

            label7 = new Label()
            {
                Left      = numericUpDown2.Right + 5,
                Top       = numericUpDown2.Top,
                Text      = "Varied food for how many diets",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            numericUpDown3 = new NumericUpDown()
            {
                Left     = numericUpDown2.Left,
                Top      = numericUpDown2.Bottom + 5,
                Value    = 30,
                Minimum  = 1,
                Maximum  = Konstans.maxValaszthatoFutasiIdo,
                AutoSize = true,
                Parent   = this
            };

            label8 = new Label()
            {
                Left      = numericUpDown3.Right + 5,
                Top       = numericUpDown3.Top,
                Text      = "Max. running time (second)",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };

            checkBox5 = new CheckBox()
            {
                Left      = numericUpDown3.Left,
                Top       = numericUpDown3.Bottom + 5,
                Checked   = false,
                Text      = "Save to calendar?",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.DarkMagenta,
                AutoSize  = true,
                Parent    = this
            };
            button5 = new Button()
            {
                Left      = checkBox5.Left + 50,
                Top       = checkBox5.Bottom + 15,
                Width     = 220,
                Text      = "Diet conditions",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            button6 = new Button()
            {
                Left      = button5.Left,
                Top       = button5.Bottom + 15,
                Width     = 220,
                Text      = "Prepare diet",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            button9 = new Button()
            {
                Left      = button6.Left,
                Top       = button6.Bottom + 15,
                Width     = 220,
                Text      = "XML import",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            button10 = new Button()
            {
                Left      = button9.Left,
                Top       = button9.Bottom + 15,
                Width     = 220,
                Text      = "XML export",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            label9 = new Label()
            {
                Left      = Right - 550,
                Top       = radioButton1.Top,
                Text      = "Solution:",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                AutoSize  = true,
                Parent    = this
            };

            textBox1 = new TextBox()
            {
                Parent    = this,
                Top       = label9.Bottom + 10,
                Left      = label9.Left,
                Height    = 500,
                Width     = 440,
                AutoSize  = true,
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                BackColor = Color.Chartreuse,
                ForeColor = Color.Indigo,
                Multiline = true,
                ReadOnly  = true,
            };

            button8 = new Button()
            {
                Left      = listBox1.Left,
                Top       = listBox1.Bottom + 15,
                Width     = listBox1.Width,
                Text      = "Sort",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            button7 = new Button()
            {
                Left      = listBox1.Left,
                Top       = button8.Bottom + 15,
                Width     = listBox1.Width,
                Text      = "Search",
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.DarkGreen,
                AutoSize  = true,
                Parent    = this
            };

            try
            {
                comboBox3.DataSource = null;
                comboBox3.Items.AddRange(ABKezelo.Kiolvasas().Where(x => x is Penznem && (x as Penznem).Hasznalhato).Select(p => (p as Penznem).Megnevezes)
                                         .ToArray());
                comboBox3.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #27
0
ファイル: RendezesForm.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #28
0
        void VezerlokLetrehozasa()
        {
            Height = 350;
            Width  = 400;
            CenterToScreen();
            Text = "New nutrient form";

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

            textBox1 = new TextBox()
            {
                Left      = label1.Right + 10,
                Top       = label1.Top,
                AutoSize  = true,
                Font      = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor = Color.Indigo,
                Parent    = this
            };

            label2 = new Label()
            {
                Left      = label1.Left,
                Top       = label1.Bottom + 15,
                Text      = "Unit of measurement:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            comboBox1 = new ComboBox()
            {
                Parent        = this,
                Left          = label2.Right + 10,
                Top           = label2.Top,
                DataSource    = null,
                DropDownStyle = ComboBoxStyle.DropDownList,
                AutoSize      = true,
            };

            label3 = new Label()
            {
                Left      = label2.Left,
                Top       = label2.Bottom + 15,
                Text      = "Daily min. intake:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            numericUpDown1 = new NumericUpDown()
            {
                Left          = label3.Right + 10,
                Top           = label3.Top,
                DecimalPlaces = 2,
                Minimum       = 0,
                Maximum       = 1000000,
                AutoSize      = true,
                Parent        = this
            };

            label4 = new Label()
            {
                Left      = label3.Left,
                Top       = label3.Bottom + 15,
                Text      = "Daily max. intake:",
                Font      = new Font(FontFamily.GenericSansSerif, 10),
                ForeColor = Color.Brown,
                AutoSize  = true,
                Parent    = this
            };

            numericUpDown2 = new NumericUpDown()
            {
                Left          = label4.Right + 10,
                Top           = label4.Top,
                DecimalPlaces = 2,
                Minimum       = 0,
                Maximum       = 1000000,
                AutoSize      = true,
                Parent        = this
            };

            checkBox1 = new CheckBox()
            {
                Left     = label4.Left,
                Top      = label4.Bottom + 15,
                Text     = "Consider the daily max?",
                Checked  = false,
                AutoSize = true,
                Parent   = this
            };

            checkBox2 = new CheckBox()
            {
                Left     = label1.Left,
                Top      = checkBox1.Bottom + 15,
                Text     = "Usable?",
                Checked  = true,
                AutoSize = true,
                Parent   = this
            };

            button1 = new Button()
            {
                Left         = label1.Left,
                Top          = checkBox2.Bottom + 20,
                Width        = 220,
                Text         = "OK",
                Font         = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor    = Color.DarkGreen,
                DialogResult = DialogResult.OK,
                AutoSize     = true,
                Parent       = this
            };

            button2 = new Button()
            {
                Left         = button1.Left,
                Top          = button1.Bottom + 10,
                Width        = 220,
                Text         = "Cancel",
                Font         = new Font(FontFamily.GenericSansSerif, 12),
                ForeColor    = Color.DarkGreen,
                DialogResult = DialogResult.Cancel,
                AutoSize     = true,
                Parent       = this
            };

            try
            {
                comboBox1.Items.AddRange(ABKezelo.Kiolvasas().Where(x => x is Mertekegyseg && (x as Mertekegyseg).Hasznalhato).Select(p => (p as Mertekegyseg).Megnevezes).ToArray());
                comboBox1.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #29
0
ファイル: RendezesForm.cs プロジェクト: gerbicz/MenuMaker
        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);
            }
        }
コード例 #30
0
        public static void XMLSave(string filename, bool msg = true)
        {
            try
            {
                XDocument xml = new XDocument(new XElement("Gyoker"));


                foreach (Penznem item in ABKezelo.Kiolvasas().Where(x => x is Penznem).ToList())
                {
                    xml.Root.Add(item.ToXML());
                }

                foreach (Mertekegyseg item in ABKezelo.Kiolvasas().Where(x => x is Mertekegyseg).ToList())
                {
                    xml.Root.Add(item.ToXML());
                }

                foreach (Tapanyag item in ABKezelo.Kiolvasas().Where(x => x is Tapanyag).ToList())
                {
                    xml.Root.Add(item.ToXML());
                }

                foreach (Etel item in ABKezelo.Kiolvasas().Where(x => x is Etel).ToList())
                {
                    xml.Root.Add(item.ToXML());
                    foreach (KeyValuePair <Tapanyag, double> item2 in item.TapanyagTartalom)
                    {
                        ElelmiszerTapanyag item3 = new ElelmiszerTapanyag(item.FelhasznaloNevHash, item.Megnevezes, item2.Key, item2.Value);
                        xml.Root.Add(item3.ToXML());
                    }
                }

                foreach (Ital item in ABKezelo.Kiolvasas().Where(x => x is Ital).ToList())
                {
                    xml.Root.Add(item.ToXML());
                    foreach (KeyValuePair <Tapanyag, double> item2 in item.TapanyagTartalom)
                    {
                        ElelmiszerTapanyag item3 = new ElelmiszerTapanyag(item.FelhasznaloNevHash, item.Megnevezes, item2.Key, item2.Value);
                        xml.Root.Add(item3.ToXML());
                    }
                }

                foreach (Menu item in ABKezelo.Kiolvasas().Where(x => x is Menu).ToList())
                {
                    xml.Root.Add(item.ToXML());
                    foreach (KeyValuePair <Tapanyag, double> item2 in item.TapanyagTartalom)
                    {
                        ElelmiszerTapanyag item3 =
                            new ElelmiszerTapanyag(item.FelhasznaloNevHash, item.Megnevezes, item2.Key, item2.Value);
                        xml.Root.Add(item3.ToXML());
                    }

                    foreach (KeyValuePair <Elelmiszer, double> item4 in item.Osszetevo)
                    {
                        ElelmiszerElelmiszer item5 = new ElelmiszerElelmiszer(item.FelhasznaloNevHash, item.Megnevezes, item4.Key, item4.Value);
                        xml.Root.Add(item5.ToXML());
                    }
                }

                xml.Root.Add(ABKezelo.Kiolvasas().Where(x => x is EtrendFeltetel).ToList().First().ToXML());

                foreach (EtkezesFeltetel item in ABKezelo.Kiolvasas().Where(x => x is EtkezesFeltetel).ToList())
                {
                    xml.Root.Add(item.ToXML());
                }

                var e = ABKezelo.Kiolvasas().Where(x => x is EtrendIdopont).ToList();
                if (e.Count > 0)
                {
                    xml.Root.Add(e.First().ToXML());
                }

                try
                {
                    xml.Save(filename);
                    if (msg)
                    {
                        Logolas.Ment("Successful XML export!");
                    }
                }
                catch (Exception)
                {
                    if (msg)
                    {
                        Logolas.Ment("Unsuccessful XML export!");
                    }
                    throw new FileNotFoundException("Unsuccessful file export!");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }