private void mnuExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvSetor.SelectedItems.Count == 0)
                {
                    tsslblMsg.Text = "Nenhum registro foi selecionado";
                    return;
                }

                cFundo cfun = new cFundo();
                cfun.codfundo = lvSetor.SelectedItems[0].Text;
                cfun.fundo    = lvSetor.SelectedItems[0].SubItems[1].Text;

                DialogResult dlr = (MessageBox.Show(string.Concat("Deseja realmente exclui o fundo:\n", lvSetor.SelectedItems[0].SubItems[1].Text, "?"), "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question));
                if (dlr == DialogResult.Yes)
                {
                    if (!cfun.exclui_fundo(cfun))
                    {
                        MessageBox.Show("Registro excluído com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        #region LOG
                        cLog lg = new cLog();
                        lg.log = string.Concat("Exclusão de Registro.", Environment.NewLine,
                                               "Fundo: ", cfun.fundo.ToUpper()
                                               );
                        lg.form        = this.Text;
                        lg.metodo      = sender.ToString();
                        lg.dt          = DateTime.Now;
                        lg.usersistema = cGlobal.userlogado;
                        lg.userRede    = Environment.UserName;
                        lg.terminal    = Environment.MachineName;
                        lg.tp_flag     = true;
                        lg.grava_log(lg);
                        #endregion
                        inicio();
                    }
                    else
                    {
                        MessageBox.Show("O registro não foi excluído.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        inicio();
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                #region LOG ERRO
                cLog lg = new cLog();
                lg.log         = ex.Message.Replace("'", "");
                lg.form        = this.Text;
                lg.metodo      = sender.ToString();
                lg.dt          = DateTime.Now;
                lg.usersistema = cGlobal.userlogado;
                lg.userRede    = Environment.UserName;
                lg.terminal    = Environment.MachineName;
                lg.tp_flag     = false;
                lg.grava_log(lg);
                #endregion
            }
        }
Exemple #2
0
        private void mnuExcluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (lvFundo.SelectedItems.Count == 0)
                {
                    tsslblMsg.Text = "Nenhum registro foi selecionado";
                    return;
                }

                cFundo fd = new cFundo();
                fd.id_Fundo     = Convert.ToInt32(lvFundo.SelectedItems[0].Text);
                fd.razao_social = lvFundo.SelectedItems[0].SubItems[1].Text;

                DialogResult dlr = (MessageBox.Show(string.Concat("Deseja realmente exclui a Razão Social:\n", lvFundo.SelectedItems[0].SubItems[1].Text, "?"), "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question));
                if (dlr == DialogResult.Yes)
                {
                    if (!fd.exclui_fundo(fd))
                    {
                        MessageBox.Show("Registro excluído com sucesso.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        #region LOG
                        cLog lg = new cLog();
                        lg.log = string.Concat("Exclusão de Registro.", Environment.NewLine,
                                               "Razão Social(Fundo): ", fd.razao_social.ToUpper()
                                               );
                        lg.form        = this.Text;
                        lg.metodo      = sender.ToString();
                        lg.dt          = DateTime.Now;
                        lg.usersistema = cGlobal.userlogado;
                        lg.userRede    = Environment.UserName;
                        lg.terminal    = Environment.MachineName;
                        lg.tp_flag     = true;
                        lg.grava_log(lg);
                        #endregion
                        inicio();
                    }
                    else
                    {
                        MessageBox.Show("O registro não pode ser excluído,\npois contém EVENTOS vínculados a ele.", "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        inicio();
                    }
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                #region LOG ERRO
                cLog lg = new cLog();
                lg.log         = ex.Message.Replace("'", "");
                lg.form        = this.Text;
                lg.metodo      = sender.ToString();
                lg.dt          = DateTime.Now;
                lg.usersistema = cGlobal.userlogado;
                lg.userRede    = Environment.UserName;
                lg.terminal    = Environment.MachineName;
                lg.tp_flag     = false;
                lg.grava_log(lg);
                #endregion
            }
        }