Esempio n. 1
0
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         UjMertekegysegForm dialogus = new UjMertekegysegForm();
         if (dialogus.ShowDialog() == DialogResult.OK)
         {
             ListBoxRefresh();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
        private void Button3_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                try
                {
                    string nev = ((Mertekegyseg)listBox1.SelectedItem).Megnevezes;
                    if (nev == "gram" || nev == "milligram" || nev == "liter" || nev == "joule" || nev == "calorie")
                    {
                        throw new WarningException("It is default unit, not deletable, not modifiable!");
                    }

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

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

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

                    UjMertekegysegForm dialogus = new UjMertekegysegForm((Mertekegyseg)listBox1.SelectedItem);
                    if (dialogus.ShowDialog() == DialogResult.OK)
                    {
                        ListBoxRefresh();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("To modify a unit choose one!", "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 3
0
 private void Button2_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex != -1)
     {
         try
         {
             UjMertekegysegForm dialogus = new UjMertekegysegForm((Mertekegyseg)listBox1.SelectedItem, true);
             dialogus.ShowDialog();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("To display a unit choose one!", "Attention!", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }