Ejemplo n.º 1
0
        /// <summary>
        /// Exclui o motivo selecionado no data DataGridView
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_excluir_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txt_codigo.Text))
                {
                    throw new Exception("Selecione um motivo para excluí-lo");
                }

                controleMotivo = new MotivoControl();

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

                if (MessageBox.Show($@"Deseja excluir 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.Deletar(id))
                    {
                        MessageBox.Show(@"Excluído com sucesso!", @"SIESC", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    CarregaDataGridView();
                }
                txt_nomemotivo.ResetText();
                txt_codigo.ResetText();
            }
            catch (Exception ex)
            {
                MensagemErro(ex);
            }
        }
        //EVENTO DE LOAD DO FORMULARIO
        private void frmListaCadastrosAdm_Load(object sender, EventArgs e)
        {
            try
            {
                //VERIFICA A OPCAO PARA CARREGAMENTO DOS DADOS
                switch (opcao)
                {
                case 1:
                    UnidadeMedidaControl unidade = new UnidadeMedidaControl();
                    PreencheGrid(unidade.Select());
                    break;

                case 2:
                    TipoProdutoControl tipo = new TipoProdutoControl();
                    PreencheGrid(tipo.Select());
                    break;

                case 3:
                    MotivoControl motivo = new MotivoControl();
                    PreencheGrid(motivo.Select());
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex, "Atenção!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        private void CarregaMotivo()
        {
            try
            {
                MotivoControl control = new MotivoControl();

                cbMotivo.DataSource    = control.Select();
                cbMotivo.DisplayMember = "mot_descricao";
                cbMotivo.ValueMember   = "mot_cod";
                cbMotivo.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro: " + ex, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Salva um novo motiva ou atualiza-o
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_salvar_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txt_nomemotivo.Text))
                {
                    throw new Exception("Impossível salvar!!! Preencha o motivo para cadastrá-lo.");
                }

                motivo = new Motivo()
                {
                    Descricao = txt_nomemotivo.Text,
                };
                controleMotivo = new MotivoControl();

                if (string.IsNullOrEmpty(txt_codigo.Text))
                {
                    if (controleMotivo.Salvar(motivo))
                    {
                        MessageBox.Show(@"Salvo com sucesso!", @"SIESC", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
                else
                {
                    motivo.Codigo = Convert.ToInt16(txt_codigo.Text);
                    if (controleMotivo.Alterar(motivo))
                    {
                        MessageBox.Show(@"Atualizado com sucesso!", @"SIESC", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MensagemErro(ex);
            }
            finally
            {
                txt_nomemotivo.ResetText();
                txt_codigo.ResetText();
                txt_nomemotivo.Enabled = false;
                CarregaDataGridView();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Carrega o DataGridView com os motivos cadastrados no Banco de Dados
        /// </summary>
        private void CarregaDataGridView()
        {
            try
            {
                DataTable dt;

                controleMotivo = new MotivoControl();

                dt = controleMotivo.Listar();
                dgv_motivos.DataSource = dt;

                dgv_motivos.Refresh();
            }
            catch (Exception ex)
            {
                Mensageiro.MensagemErro(ex, this);
            }
        }
Ejemplo n.º 7
0
        private void btnListarMotivo_Click(object sender, EventArgs e)
        {
            MotivoControl        control = new MotivoControl();
            MotivoModel          model   = new MotivoModel();
            frmListaCadastrosAdm lista   = new frmListaCadastrosAdm(3);

            lista.ShowDialog();

            if (lista.codigo != 0)
            {
                model = control.SelectByID(lista.codigo);

                txtCodMotivo.Text  = Convert.ToString(model.mot_cod);
                txtDescMotivo.Text = model.mot_descricao;
            }
            else
            {
                LimpaCampoMotivo();
            }
        }
Ejemplo n.º 8
0
        private void btnExcluirMotivo_Click(object sender, EventArgs e)
        {
            MotivoControl control = new MotivoControl();

            try
            {
                if (control.Excluir(txtCodMotivo.Text))
                {
                    LimpaCampoMotivo();
                    MessageBox.Show("Item excluido com sucesso", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Erro na exclusão do item", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERRO: " + ex, "ATENÇÃO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }