private void btnBuscaPeca_Click(object sender, EventArgs e)
 {
     this._modelPeca = new mPeca();
     frmBuscaPeca objForm = new frmBuscaPeca(this._modelPeca);
     try
     {
         DialogResult resultado = objForm.ShowDialog();
         if (resultado == DialogResult.Cancel)
         {
             this._modelPeca = null;
             this.txtNomePeca.Text = string.Empty;
         }
         else
         {
             this.txtNomePeca.Text = this._modelPeca.Nom;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         objForm = null;
     }
 }
 public frmPecaFornecedor(mPeca model)
 {
     InitializeComponent();
     this.btnBuscaPeca.Visible = false;
     _modelPeca = model;
     this.txtNomePeca.Text = this._modelPeca.IdPecaReal + " - " + this._modelPeca.Nom;
     this._telaPeca = false;
 }
 public frmBuscaFornecedor(mFornecedor modelFornecedor, mPeca modelPeca)
 {
     InitializeComponent();
     _model = modelFornecedor;
     _alteracao = false;
     this._modelPeca = modelPeca;
     this._filtroBusca = true;
 }
 public frmPecaFornecedor(mPeca model, List<mPecaFornecedor> listaPecaFornecedor)
 {
     InitializeComponent();
     this.btnBuscaPeca.Visible = false;
     _modelPeca = model;
     this.txtNomePeca.Text = this._modelPeca.IdPecaReal + " - " + this._modelPeca.Nom;
     this._listaModelPecaFornecedor = listaPecaFornecedor;
     this._telaPeca = true;
 }
        public frmCadPecaEstoque(mPeca modelPeca, List<mPecaEstoque> listaPecaEstoque)
        {
            InitializeComponent();
            this.btnBuscaPeca.Visible = false;
            this._modelPeca = modelPeca;
            this.txtPeca.Text = modelPeca.IdPecaReal + " - " + modelPeca.Nom;

            this.MarcaPecaEstoque();
            this._listaModelPecaEstoque = listaPecaEstoque;
            this._telaPeca = true;
        }
 /// <summary>
 /// Este metodo busca todos os relacionamento entre peca e estoque por peca selecionada
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public DataTable BuscaPecaEstoquePorPeca(mPeca model)
 {
     SqlParameter param = null;
     try
     {
         param = new SqlParameter("@id_peca", model.IdPeca);
         return base.BuscaDados("sp_busca_pecaestoqueparampeca", param);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         param = null;
     }
 }
 /// <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;
     }
 }
        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;
            }
        }
 public frmBuscaPeca(mPeca modelPeca)
 {
     InitializeComponent();
     this._model = modelPeca;
     this._alteracao = false;
 }
 private void ValidaDados(mPeca model)
 {
     if (this.VerificaExistenciaPeca(model.IdPecaReal) == true)
     {
         throw new Exceptions.Peca.PecaJaExistenteException();
     }
     else if (model.QtdMin <= 0 || model.QtdMin == null)
     {
         throw new Exceptions.Peca.QtdMinimaNuloOuZeroException();
     }
 }
 private void btnLimpa_Click(object sender, EventArgs e)
 {
     base.LimpaDadosTela(this);
     this._listaModelPecaFornecedor = null;
     this._modelPeca = null;
     //base.FechaTela(this);
 }
 public frmBuscaPeca(mPeca modelPeca, bool Alteracao)
 {
     InitializeComponent();
     this._model = modelPeca;
     this._alteracao = Alteracao;
 }
        private void btnLimpa_Click(object sender, EventArgs e)
        {
            base.LimpaDadosTela(this);

            _listaModelPecaEstoque = null;
            _modelPeca = null;

            this.PopulaGrid();
        }
 /// <summary>
 /// Abre a tela para buscar uma Peça
 /// </summary>
 private void AbreTelaBuscaPeca()
 {
     frmBuscaPeca telaPeca = null;
     try
     {
         this._modelPeca = new mPeca();
         telaPeca = new frmBuscaPeca(this._modelPeca);
         DialogResult resultado = telaPeca.ShowDialog();
         if (resultado == DialogResult.Cancel)
         {
             this._modelPeca = null;
         }
         else
         {
             this.txtBuscaFiltro.Text = this._modelPeca.IdPecaReal + " - " + this._modelPeca.Nom;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         telaPeca = null;
     }
 }
 private void btnBuscaPeca_Click(object sender, EventArgs e)
 {
     this.btnLimpa_Click(null, null);
     this._modelPeca = new mPeca();
     frmBuscaPeca objForm = new frmBuscaPeca(this._modelPeca);
     try
     {
         DialogResult resultado = objForm.ShowDialog();
         if (resultado == DialogResult.Cancel)
         {
             this._modelPeca = null;
         }
         else
         {
             this.txtPeca.Text = this._modelPeca.Nom;
             this.MarcaPecaEstoque();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         objForm = null;
     }
 }
 public mPeca BuscaUnicoRegistro(int idPeca)
 {
     DataTable dtRetorno = null;
     SqlParameter param = null;
     mPeca modelPeca = new mPeca();
     try
     {
         param = new SqlParameter("@id_peca", idPeca);
         dtRetorno = base.BuscaDados("sp_select_peca", param);
         modelPeca.Deserialize(dtRetorno);
         return modelPeca;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         param = null;
         if (dtRetorno != null)
         {
             dtRetorno.Dispose();
             dtRetorno = null;
         }
         modelPeca = null;
     }
 }
 private void rdbPeca_CheckedChanged(object sender, EventArgs e)
 {
     if (this.rdbMotor.Checked == true)
     {
         this._modelPeca = null;
     }
     else
     {
         this._modelMotor = null;
     }
 }
 /// <summary>
 /// Limpa a parte da tela de Ordem Compra
 /// </summary>
 private void LimpaGrupoOrdemCompra()
 {
     try
     {
         foreach (Control controle in this.gpbOrdemCompra.Controls)
         {
             Type tipo = controle.GetType();
             if (tipo.Equals(typeof(TextBox)) == true || tipo.Equals(typeof(TCC.Controle.MegaTextBox)) == true)
             {
                 controle.Text = string.Empty;
             }
         }
         this._modelFornecedor = null;
         this._modelMotor = null;
         this._modelPeca = null;
         this.rdbPeca.Checked = true;
         this.rdbMotor.Checked = false;
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 private void btnLimpar_Click(object sender, EventArgs e)
 {
     base.LimpaDadosTela(this);
     this._modelFornecedor = null;
     this._modelMotor = null;
     this._modelPeca = null;
     this._listaOrdemCompra = null;
 }