Exemplo n.º 1
0
        /// <summary>
        /// Popula o DataTable com a table de model
        /// </summary>
        private void PopulaDataTableListaModel(DataTable dt)
        {
            DataRow linha;
            rPeca   regraPeca = new rPeca();
            mPeca   modelPeca = new mPeca();

            try
            {
                foreach (mItemPeca model in this._listaModelItemPeca)
                {
                    modelPeca        = regraPeca.BuscaUnicoRegistro(Convert.ToInt32(model.Id_peca));
                    linha            = dt.NewRow();
                    linha["id_peca"] = model.Id_peca;
                    linha["Codigo"]  = modelPeca.IdPecaReal;
                    linha["Peça"]    = modelPeca.Nom;
                    linha["qtd"]     = model.Qtd_peca;
                    dt.Rows.Add(linha);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                linha     = null;
                regraPeca = null;
                modelPeca = null;
            }
        }
Exemplo n.º 2
0
        private mPeca PegaDadosTela()
        {
            mPeca model = new mPeca();
            rPeca regra = new rPeca();

            try
            {
                model.IdPeca     = regra.BuscaIdMaximo();
                model.DatAlt     = DateTime.Now;
                model.DscPeca    = this.txtDsPeca.Text;
                model.FlgAtivo   = true;
                model.IdPecaReal = this.txtCodigoReal.Text;
                model.IdTipoPeca = Convert.ToInt32(this._modelTipoPeca.IdTipoPeca);
                model.Nom        = this.txtNmPeca.Text;
                if (string.IsNullOrEmpty(this.txtPesoPeca.Text) == true)
                {
                    model.Peso = null;
                }
                else
                {
                    model.Peso = Convert.ToDecimal(this.txtPesoPeca.Text);
                }
                if (string.IsNullOrEmpty(this.txtQtdPeca.Text) == true)
                {
                    model.QtdMin = null;
                }
                else
                {
                    model.QtdMin = Convert.ToInt32(this.txtQtdPeca.Text);
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                model = null;
            }
        }
Exemplo n.º 3
0
        private void PopulaGrid()
        {
            rPeca     regraPeca = new rPeca();
            DataTable dt        = new DataTable();

            try
            {
                dt = regraPeca.BuscaPeca(this.txtFiltro.Text);
                dgPeca.DataSource = dt;
                this.dgPeca.Columns[0].Visible = false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                regraPeca = null;
                dt        = null;
            }
        }
Exemplo n.º 4
0
        private void PopulaModelCompletoAlteracao()
        {
            rPeca     regraPeca      = new rPeca();
            DataTable dtRegistroPeca = null;

            try
            {
                dtRegistroPeca = regraPeca.BuscaUmRegistro(this._model);
                this._model.Deserialize(dtRegistroPeca);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                regraPeca = null;
                if (dtRegistroPeca != null)
                {
                    dtRegistroPeca.Dispose();
                    dtRegistroPeca = null;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Busca Peça atravez do filtro escolhido pelo usuario
        /// </summary>
        /// <param name="nomePeca">o filtro passado pelo usuário pode ser Vazio</param>
        /// <returns>DataTable com o resultado da query</returns>
        private DataTable BuscaPeca(string nomePeca)
        {
            rPeca regraPeca = new rPeca();

            try
            {
                if (this.rdbCodigo.Checked == true)
                {
                    return(regraPeca.BuscaPecaCodigo(nomePeca));
                }
                else
                {
                    return(regraPeca.BuscaPecaNome(nomePeca));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                regraPeca = null;
            }
        }
Exemplo n.º 6
0
        private void Insere()
        {
            mPeca           model;
            rPeca           regra               = new rPeca();
            rPecaEstoque    regraPecaEstoque    = new rPecaEstoque();
            rPecaFornecedor regraPecaFornecedor = new rPecaFornecedor();

            try
            {
                this.ValidaDadosNulos();
                model = this.PegaDadosTela();
                regra.ValidarInsere(model);
                //Verifica se existe itens na lista de peça estoque
                //-------------------------------------------------
                if (this._listaPecaEstoque != null)
                {
                    if (this._listaPecaEstoque.Count > 0)
                    {
                        this.PopulaListaPecaEstoqueIdPeca(Convert.ToInt32(model.IdPeca));
                        foreach (mPecaEstoque modelPecaEstoque in this._listaPecaEstoque)
                        {
                            regraPecaEstoque.ValidarInsere(modelPecaEstoque);
                        }
                    }
                }
                //Verifica se existe itens na lista de peça fornecedor
                //-------------------------------------------------
                if (this._listaPecaFornecedor != null)
                {
                    if (this._listaPecaFornecedor.Count > 0)
                    {
                        this.PopulaListaPecaFornecedorIdPeca(Convert.ToInt32(model.IdPeca));
                        foreach (mPecaFornecedor modePecaFornecedor in this._listaPecaFornecedor)
                        {
                            regraPecaFornecedor.ValidarInsere(modePecaFornecedor);
                        }
                    }
                }
                base.LimpaDadosTela(this);
                this.btnConfirma.Enabled = false;
                MessageBox.Show("Registro Salvo com Sucesso!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
            catch (TCC.Regra.Exceptions.Peca.CodigoPecaVazioException)
            {
                MessageBox.Show("O código da Peça não pode ser vazio", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.txtCodigoReal.Focus();
            }
            catch (TCC.Regra.Exceptions.CodigoTipoPecaVazioException)
            {
                MessageBox.Show("O Tipo da Peça não pode ser vazio", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.btnCdTipoPeca.Focus();
            }
            catch (TCC.Regra.Exceptions.Peca.NomePecaVazioException)
            {
                MessageBox.Show("É Necessário Preencher o nome da Peça", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.txtNmPeca.Focus();
            }
            catch (TCC.Regra.Exceptions.Peca.QtdMinimaNuloOuZeroException)
            {
                MessageBox.Show("A quantidade mínima da Peça deve ser maior que zero", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.txtQtdPeca.Focus();
            }
            catch (TCC.Regra.Exceptions.Peca.PecaJaExistenteException)
            {
                MessageBox.Show("Peça já existente! Favor Cadastrar outro Código Real", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.txtCodigoReal.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                model            = null;
                regra            = null;
                regraPecaEstoque = null;
            }
        }