예제 #1
0
        private void DeletaCadastro()
        {
            rMotor regraMotor = new rMotor();

            try
            {
                regraMotor.ValidarDeleta(this._model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                regraMotor = null;
            }
        }
예제 #2
0
        private void PopulaGrid()
        {
            rMotor    regraMotor = new rMotor();
            DataTable dt         = new DataTable();

            try
            {
                dt = regraMotor.BuscaMotores(this.txtFiltro.Text);
                dgMotor.DataSource = dt;
                this.dgMotor.Columns[0].Visible = false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                regraMotor = null;
                dt         = null;
            }
        }
예제 #3
0
        private mMotor PegaDadosTela()
        {
            mMotor model = new mMotor();
            rMotor regra = new rMotor();

            try
            {
                model.IdMotor  = regra.BuscaMaxId();
                model.DscMotor = this.txtDsMotor.Text;
                model.FlgAtivo = true;

                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                model = null;
            }
        }
예제 #4
0
        private void PopulaModelCompletoAlteracao()
        {
            rMotor    regraMotor      = new rMotor();
            DataTable dtRegistroMotor = null;

            try
            {
                dtRegistroMotor = regraMotor.BuscaUmRegistro(this._model);
                this._model.Deserialize(dtRegistroMotor);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                regraMotor = null;
                if (dtRegistroMotor != null)
                {
                    dtRegistroMotor.Dispose();
                    dtRegistroMotor = null;
                }
            }
        }
예제 #5
0
        private void Inserir()
        {
            mMotor           model;
            rMotor           regra             = new rMotor();
            rMotorFornecedor regraMotorForn    = new rMotorFornecedor();
            rMotorEstoque    regraMotorEstoque = new rMotorEstoque();

            try
            {
                this.ValidaDadosNulos();
                model = this.PegaDadosTela();
                regra.ValidarInsere(model);

                //Verifica se existe itens na lista de motor estoque
                //-------------------------------------------------
                if (this._listaModelMotorEstoque != null)
                {
                    if (this._listaModelMotorEstoque.Count > 0)
                    {
                        this.PopulaListaMotorEstoqueIdMotor(Convert.ToInt32(model.IdMotor));
                        foreach (mMotorEstoque modelMotorEstoque in this._listaModelMotorEstoque)
                        {
                            regraMotorEstoque.ValidarInsere(modelMotorEstoque);
                        }
                    }
                }
                //Verifica se existe itens na lista de motor fornecedor
                //-------------------------------------------------
                if (this._listaModelMotorFornecedor != null)
                {
                    if (this._listaModelMotorFornecedor.Count > 0)
                    {
                        this.PopulaListaMotorFornecedorIdMotor(Convert.ToInt32(model.IdMotor));
                        foreach (mMotorFornecedor modelMotorForn in this._listaModelMotorFornecedor)
                        {
                            regraMotorForn.ValidarInsere(modelMotorForn);
                        }
                    }
                }
                base.LimpaDadosTela(this);
                this.btnAceitar.Enabled = false;
                MessageBox.Show("Registro Salvo com Sucesso!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
            catch (TCC.Regra.Exceptions.Motor.DescMotorExistenteException)
            {
                MessageBox.Show("Nome do Motor já existe!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.txtDsMotor.Focus();
            }
            catch (TCC.Regra.Exceptions.Motor.DescMotorVazioException)
            {
                MessageBox.Show("É Necessário Digitar um Nome para o Motor", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                this.txtDsMotor.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                model = null;
                regra = null;
            }
        }