/// <summary> /// Adicionar Carro /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { try { int i = int.Parse(textBox1.Text); DateTime d = dateTimePicker1.Value; if (textBox2.Text == "") { throw new Exception("É necessario matricula..."); } var s = (Sector)Enum.Parse(typeof(Sector), comboBox1.SelectedItem.ToString()); Carro c = new Carro(i, textBox2.Text, s, d); bool x = Regras.AddCarroBL(c); Capacidade(); LimparCampos(); CarregarCarros(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }