示例#1
0
        private void btDeletar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult resposta = MessageBox.Show("Excluir o Grupo Muscular '" + dataGridViewGrupoMuscular.CurrentRow.Cells[1].Value.ToString() + "' ?", "Atenção", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (resposta == DialogResult.Yes)
                {
                    try
                    {
                        GrupoMuscular grupo = new GrupoMuscular();
                        grupo.Id = Convert.ToInt16(dataGridViewGrupoMuscular.CurrentRow.Cells[0].Value);
                        grupo.delete();

                        //Geracao de log
                        Logs   logs = new Logs();
                        string linha;

                        using (StreamReader reader = new StreamReader("user.txt"))
                        {
                            linha = reader.ReadLine();
                        }

                        logs.IdUsuario = Convert.ToInt16(linha.ToString());
                        logs.IdAcao    = 28;
                        logs.Data      = DateTime.Today.ToString("dd/MM/yyyy");
                        logs.Hora      = DateTime.Now.ToString("HH:mm");
                        logs.insert();

                        FrmTabGrupoMuscular_Activated(sender, e);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Não há Grupos Musculares cadastrados.", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }