Exemplo n.º 1
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            try
            {
                Boolean permissaoEditar = funcao.CriarArquivoEmUso(txtNomeProcedimento.Text.ToString(), codigo_usuario.ToString());

                if (permissaoEditar == true)
                {
                    arquivoEmUso            = txtNomeProcedimento.Text.ToString();
                    titulo_antigo           = txtNomeProcedimento.Text.ToString();
                    btnEditar.Visible       = false;
                    btnEsquerda.Visible     = false;
                    btnInterrogacao.Visible = false;

                    btnSalvar.Visible              = true;
                    btnCancelar.Visible            = true;
                    btnMais.Visible                = true;
                    btnCima.Visible                = true;
                    btnBaixo.Visible               = true;
                    btnLixeira.Visible             = true;
                    btnExcluirProcedimento.Visible = true;
                    txtNomeProcedimento.Enabled    = true;
                }

                else
                {
                    if (DialogResult.Yes == MessageBox.Show("Este procedimento está atualmente em uso. Deseja forçar a edição?", "Procedimento em uso", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
                    {
                        if (DialogResult.Yes == MessageBox.Show("Atenção, forçar a edição pode causar perda de dados, sendo recomendado apenas em caso de falta de energia." +
                                                                " Deseja mesmo forçar a edição de " + txtNomeProcedimento.Text.ToString() + "?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
                        {
                            Boolean statusLiberarRecurso = funcao.ExcluirArquivoEmUso(txtNomeProcedimento.Text.ToString(), true);

                            if (statusLiberarRecurso == true)
                            {
                                btnEditar.PerformClick();
                            }
                            else
                            {
                                MessageBox.Show("Não foi possível liberar o recurso");
                            }
                        }
                    }
                }
            }

            catch
            {
            }
        }