Ejemplo n.º 1
0
        /// <summary>
        /// Inativa o motivo
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_inativar_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txt_codigo.Text))
                {
                    throw new Exception("Selecione um motivo para inativá-lo");
                }

                controleMotivo = new MotivoControl();

                int id = Convert.ToInt32(txt_codigo.Text);

                if (MessageBox.Show($@"Deseja inativar o motivo {dgv_motivos[1, dgv_motivos.CurrentCellAddress.X].Value} ? {Environment.NewLine}Clique SIM para Confirmar ou NÂO para cancelar", @"SIESC - Gerenciar Motivo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2).Equals(DialogResult.Yes))
                {
                    if (controleMotivo.Inativar(id))
                    {
                        MessageBox.Show(@"Inativado com sucesso!", @"SIESC", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    CarregaDataGridView();
                }
                txt_nomemotivo.ResetText();
                txt_codigo.ResetText();
            }
            catch (Exception ex)
            {
                MensagemErro(ex);
            }
        }