Example #1
0
        private void btnAddPlane_Click(object sender, EventArgs e)//______________________________Add________________________________
        {
            if (isValid.isNumberValid(tbNumber.Text) && isValid.isPlaneTypeValid(cbType.SelectedIndex) && isValid.isSpeedValid(tbSpeed.Text) && isValid.isSpeedTypeValid(cbType.SelectedItem.ToString(), Convert.ToInt32(tbSpeed.Text)))
            {
                if (planesDataLink.Exists(tbNumber.Text))
                {
                    MessageBox.Show("Самолет с таким номер уже существует");
                }
                else
                {
                    Plane plane = new Plane()
                    {
                        Number = tbNumber.Text,
                        Type   = cbType.Text,
                        Speed  = Convert.ToInt32(tbSpeed.Text)
                    };

                    planesDataLink.Add(plane);

                    fillPlaneTable();

                    tbNumber.Text        = "";
                    cbType.SelectedIndex = -1;
                    tbSpeed.Text         = "";
                }
            }
        }