private void btnDeletar_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Você realmente deseja deletar?", "Deletar", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                try
                {
                    DAO.Generica banco = new DAO.Generica();
                    banco.deletarFilmes(lblId.Text);
                    MessageBox.Show("O registro foi deletado!");
                    btnAlterar.Enabled   = false;
                    btnDeletar.Enabled   = false;
                    btnNovo.Visible      = false;
                    btnCadastrar.Enabled = true;
                    using (StreamWriter arquivoTexto = new StreamWriter(@"C:\Cinema\Filmes.txt", true))
                    {
                        int id = int.Parse(lblId.Text);
                        arquivoTexto.WriteLine("-- Iniciando Log -- ");
                        arquivoTexto.WriteLine(DateTime.Today.ToShortDateString() + " | " + DateTime.Now.ToShortTimeString());
                        arquivoTexto.WriteLine("Usuário deletou o seguinte registro de Filme:");
                        arquivoTexto.WriteLine("ID: " + lblId.Text);
                        arquivoTexto.WriteLine("-- Término Log --");
                        arquivoTexto.WriteLine(" ");
                    }
                    limparCampos();
                    dgvFilme.DataSource = banco.retornarFilmes();
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Não foi possível deletar!");
                }
            }
        }
 private void cadFilme_Load(object sender, EventArgs e)
 {
     try
     {
         cboCategoria.SelectedItem = "Ação";
         DAO.Generica banco = new DAO.Generica();
         dgvFilme.DataSource = banco.retornarFilmes();
     }
     catch
     {
         MessageBox.Show("Erro na conexão!");
         this.Hide();
     }
 }
 private void btnCadastrar_Click(object sender, EventArgs e)
 {
     if (ValidarCampoString(txtNm.Text, "Nome") == false)
     {
         txtNm.Clear();
         txtNm.Focus();
         return;
     }
     if (ValidarCampoString(txtClass.Text, "Classificação") == false)
     {
         txtClass.Clear();
         txtClass.Focus();
         return;
     }
     if (ValidarCampoNum(txtClass.Text, "Classificação") == false)
     {
         txtClass.Clear();
         txtClass.Focus();
         return;
     }
     if (ValidarCampoString(cboCategoria.Text, "Categoria") == false)
     {
         cboCategoria.SelectedItem = "Ação";
         cboCategoria.Focus();
         return;
     }
     if (ValidarCampoData(mtxtDura.Text, "Duração") == false)
     {
         mtxtDura.Clear();
         mtxtDura.Focus();
         return;
     }
     if (ValidarCampoString(txtAno.Text, "Ano") == false)
     {
         txtAno.Clear();
         txtAno.Focus();
         return;
     }
     if (ValidarCampoNum(txtAno.Text, "Ano") == false)
     {
         txtAno.Clear();
         txtAno.Focus();
         return;
     }
     if (ValidarCampoString(txtDire.Text, "Diretor") == false)
     {
         txtDire.Clear();
         txtDire.Focus();
         return;
     }
     try
     {
         DAO.Generica banco = new DAO.Generica();
         banco.cadastrarFilmes(txtNm.Text, txtClass.Text, cboCategoria.Text, mtxtDura.Text, txtAno.Text, txtDire.Text);
         MessageBox.Show("Cadastro realizado!");
         btnAlterar.Enabled  = false;
         btnDeletar.Enabled  = false;
         dgvFilme.DataSource = banco.retornarFilmes();
         if (Directory.Exists(@"C:\Cinema") == false)
         {
             Directory.CreateDirectory(@"C:\Cinema");
         }
         using (StreamWriter arquivoTexto = new StreamWriter(@"C:\Cinema\Filmes.txt", true))
         {
             arquivoTexto.WriteLine("-- Iniciando Log -- ");
             arquivoTexto.WriteLine(DateTime.Today.ToShortDateString() + " | " + DateTime.Now.ToShortTimeString());
             arquivoTexto.WriteLine("Usuário efetuou um cadastro de Filme:");
             arquivoTexto.WriteLine("Nome: " + txtNm.Text);
             arquivoTexto.WriteLine("Classificação: " + txtClass.Text);
             arquivoTexto.WriteLine("Categoria: " + cboCategoria.Text);
             arquivoTexto.WriteLine("Duração: " + mtxtDura.Text);
             arquivoTexto.WriteLine("Ano: " + txtAno.Text);
             arquivoTexto.WriteLine("Diretor: " + txtDire.Text);
             arquivoTexto.WriteLine("-- Término Log --");
             arquivoTexto.WriteLine(" ");
         }
         limparCampos();
     }
     catch (Exception erro)
     {
         MessageBox.Show("Não foi possível cadastrar!");
     }
 }