private void termoDeResponsabilidadeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var frmLogin = new FormLogin())
         using (var frmConfigurarTermoResponsabilidade = new FormConfigurarTermoResponsabilidade())
         {
             frmLogin.ShowDialog();
             if (frmLogin.Logado)
             {
                 frmConfigurarTermoResponsabilidade.ShowDialog();
             }
         }
 }
        private void importarClientesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var frmLogin = new FormLogin())
            {
                frmLogin.ShowDialog();
                if (!frmLogin.Logado)
                {
                    return;
                }
            }

            using (var frmImportacaoSelecionarArquivo = new frmImportacaoSelecionarArquivo())
            {
                frmImportacaoSelecionarArquivo.ShowDialog();
            }
        }
        private void usuáriosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var frmLogin = new FormLogin())
            {
                frmLogin.ShowDialog();
                if (!frmLogin.Logado)
                {
                    return;
                }
            }

            using (var frmUsuarios = new frmUsuarios())
            {
                frmUsuarios.ShowDialog();
            }
        }
        private void tatuagensToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var frmLogin = new FormLogin())
            {
                frmLogin.ShowDialog();
                if (!frmLogin.Logado)
                {
                    return;
                }
            }

            using (var frmPerguntas = new FormPerguntas(TipoPergunta.Tatuagem))
            {
                frmPerguntas.ShowDialog();
            }
        }
        private void btnVisualizarPesquisa_Click(object sender, EventArgs e)
        {
            if (lsvClientes.SelectedIndices.Count != 1)
            {
                return;
            }

            using (var frmLogin = new FormLogin())
            {
                frmLogin.ShowDialog();
                if (!frmLogin.Logado)
                {
                    return;
                }
            }

            try
            {
                using (var frmPesquisa = new FormPesquisa(TipoPergunta.Cliente, PesquisaControl.TipoFonte.Normal, true, clientes[lsvClientes.SelectedIndices[0]].Id))
                {
                    if (frmPesquisa.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    using (var conn = new Connection())
                        using (var transaction = conn.BeginTransaction())
                        {
                            try
                            {
                                Resposta.SalvarRespostas(TipoPergunta.Cliente, clientes[lsvClientes.SelectedIndices[0]].Id, frmPesquisa.Respostas, conn, transaction);

                                transaction.Commit();
                            }
                            catch (Exception erro)
                            {
                                transaction.Rollback();
                                MessageBox.Show(erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                }
            } catch (PerguntasNotFoundException erro)
            {
                MessageBox.Show(erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnRemover_Click(object sender, EventArgs e)
        {
            if (lsvClientes.SelectedIndices.Count == 0)
            {
                MessageBox.Show("Selecione um cliente para ser removido!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // Verificando se o usuário deseja realmente remover os clientes selecionados
            if (MessageBox.Show($"Deseja realmente remover os {lsvClientes.SelectedIndices.Count} clientes selecionados?\nEssa ação não poderá ser revertida!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            using (var frmLogin = new FormLogin())
            {
                frmLogin.ShowDialog();
                if (!frmLogin.Logado)
                {
                    return;
                }
            }

            using (var conn = new Connection())
                using (SQLiteTransaction transaction = conn.BeginTransaction())
                {
                    try
                    {
                        for (int i = 0; i < lsvClientes.SelectedIndices.Count; i++)
                        {
                            clientes[lsvClientes.SelectedIndices[i]].Remover(conn, transaction);
                        }

                        transaction.Commit();

                        MessageBox.Show($"{lsvClientes.SelectedIndices.Count} cliente(s) foi(ram) removido(s) com sucesso!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        CarregarClientes();
                    }
                    catch (Exception erro)
                    {
                        transaction.Rollback();
                        MessageBox.Show($"Ocorreu um erro ao remover os clientes, a ação foi canacelada!\n{erro.Message}", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
        }