示例#1
0
 private void MakingObject(object sender, EventArgs e)
 {
     try
     {
         if ((nameBox.Text.Trim()).Length == 0)
         {
             throw new Exception("Please, enter name of drink");
         }
         if ((Convert.ToInt32(percentBox.Text) > 40) || (Convert.ToInt32(percentBox.Text) < 0))
         {
             throw new FormatException();
         }
         if (types.SelectedIndex == -1)
         {
             throw new Exception("Please, choose the type");
         }
         Vine template = new Vine(nameBox.Text.Trim().ToString(), Convert.ToDouble(volume.Value), Convert.ToInt32(percentBox.Text), types.SelectedIndex);
         ChooseAction(template);
     }
     catch (FormatException exept)
     {
         MessageBox.Show("Please enter correct percent of alcohol");
     }
     catch (ArgumentOutOfRangeException exept)
     {
     }
     catch (Exception exept)
     {
         MessageBox.Show(exept.Message);
     }
 }
示例#2
0
        public override bool Equals(Drinks v1)
        {
            Vine other = v1 as Vine;

            if ((other != null) && (this.Name == other.Name) && (this.PercentOfAlcohol == other.PercentOfAlcohol) && (this.Volume == other.Volume) && (this.vineType == other.vineType))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        public override void ChangingElement(Panel panel, Drinks element, DChange del)
        {
            Vine temp = element as Vine;

            nameBox.Text       = element.Name;
            volume.Value       = Convert.ToDecimal(element.Volume);
            percentBox.Text    = temp.PercentOfAlcohol.ToString();
            types.SelectedItem = temp.vineType;

            this.save.Text = "Change Object";

            delToAdd    = null;
            delToChange = del;
        }