Ejemplo n.º 1
0
        //======================================================================================
        //======================================================================================

        //=========== MOTIVOS DE TROCAS ========================================================

        private void btnSalvarMotivo_Click(object sender, EventArgs e)
        {
            try
            {
                MotivoControl control = new MotivoControl();
                MotivoModel   tipo    = new MotivoModel();

                tipo.mot_descricao = txtDescMotivo.Text;

                switch (seletor)
                {
                case 0:
                    if (!control.Inserir(tipo))
                    {
                        MessageBox.Show("Verifique os campos digitados", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    break;

                case 1:

                    if (txtCodTipo.Text != string.Empty)
                    {
                        tipo.mot_cod = Convert.ToInt32(txtCodMotivo.Text);
                    }

                    if (!control.Update(tipo))
                    {
                        MessageBox.Show("Verifique os campos digitados", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    break;

                default:
                    MessageBox.Show("Selecione a opção NOVO CADASTRO ou EDITAR", "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERRO: " + ex, "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                //CHAMA METODO PARA LIMPAR OS CAMPOS
                LimpaCampoMotivo();
            }
        }