public frmGerenciarMilitar(DTOGerenciamento dto)
        {
            InitializeComponent();
            militar       = new Militar();
            gerenciamento = new Gerenciamento();

            idGerenciamento = dto.Id;

            DTOMilitar dtoMilitar = militar.GetDTO(dto.IdMilitar.ToString());

            cmbNomedeGuerra.Items.Add(dtoMilitar.GradNome);
            cmbNomedeGuerra.SelectedIndex = 0;
            cmbNomedeGuerra.Enabled       = false;

            txtMotivo.Text = dto.Motivo;
            dtpSaida.Value = dto.Saida;
            dtpVolta.Value = dto.Retorno;
        }
        private void BSalvar(object sender, EventArgs e)
        {
            if (TelaValida())
            {
                DateTime saida = dtpSaida.Value;
                DateTime volta = dtpVolta.Value;

                int id = militar.GetIdByName(cmbNomedeGuerra.Text);

                bool sucesso;

                if (idGerenciamento > 0) //Edição
                {
                    DTOGerenciamento dto = new DTOGerenciamento
                    {
                        Id      = idGerenciamento,
                        Motivo  = txtMotivo.Text,
                        Saida   = saida,
                        Retorno = volta
                    };

                    sucesso = gerenciamento.Update(dto);
                }
                else //novo gerenciamento
                {
                    sucesso = gerenciamento.Insert(militar: id, motivo: txtMotivo.Text, saida: saida, retorno: volta);
                }

                if (sucesso)
                {
                    MessageBox.Show("Gerenciamento salvo com sucesso!");
                    LimparTela();
                }
                else
                {
                    MessageBox.Show("Houve um erro ao salvar");
                }
            }
            this.Close();
        }