/// <summary> /// Create a new ITEM object. /// </summary> /// <param name="iD_ITEM">Initial value of the ID_ITEM property.</param> /// <param name="iD_PRODUTO">Initial value of the ID_PRODUTO property.</param> /// <param name="iD_ORCAMENTO">Initial value of the ID_ORCAMENTO property.</param> /// <param name="nUM_VALOR_CUSTO">Initial value of the NUM_VALOR_CUSTO property.</param> /// <param name="nUM_QUANTIDADE">Initial value of the NUM_QUANTIDADE property.</param> /// <param name="dATA_ATUALIZACAO">Initial value of the DATA_ATUALIZACAO property.</param> /// <param name="lOGIN_USUARIO">Initial value of the LOGIN_USUARIO property.</param> /// <param name="nUM_VALOR_UNITARIO">Initial value of the NUM_VALOR_UNITARIO property.</param> public static ITEM CreateITEM(global::System.Guid iD_ITEM, global::System.Guid iD_PRODUTO, global::System.Guid iD_ORCAMENTO, global::System.Decimal nUM_VALOR_CUSTO, global::System.Int32 nUM_QUANTIDADE, global::System.DateTime dATA_ATUALIZACAO, global::System.String lOGIN_USUARIO, global::System.Decimal nUM_VALOR_UNITARIO) { ITEM iTEM = new ITEM(); iTEM.ID_ITEM = iD_ITEM; iTEM.ID_PRODUTO = iD_PRODUTO; iTEM.ID_ORCAMENTO = iD_ORCAMENTO; iTEM.NUM_VALOR_CUSTO = nUM_VALOR_CUSTO; iTEM.NUM_QUANTIDADE = nUM_QUANTIDADE; iTEM.DATA_ATUALIZACAO = dATA_ATUALIZACAO; iTEM.LOGIN_USUARIO = lOGIN_USUARIO; iTEM.NUM_VALOR_UNITARIO = nUM_VALOR_UNITARIO; return iTEM; }
/// <summary> /// Deprecated Method for adding a new object to the T_ITEM EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToT_ITEM(ITEM iTEM) { base.AddObject("T_ITEM", iTEM); }
/// <summary> /// Método para salvar os item do orçamento /// </summary> /// <param name="Item">Objeto com os dados do item</param> /// <returns>Contrato.RetornoTaxa</returns> internal static Contrato.RetornoItem SalvarItemOrcamento(Dados.ORCAMENTO Orcamento, string UsuarioLogado, Contrato.Item Item) { // Objeto que recebe o retorno do método Contrato.RetornoItem retItem = new Contrato.RetornoItem(); // Loga no banco de dados Dados.BRASIL_DIDATICOS context = new Dados.BRASIL_DIDATICOS(); // Cria o item Dados.ITEM tItem = new Dados.ITEM() { ID_ITEM = Guid.NewGuid(), DES_ITEM = Item.Descricao, ID_ORCAMENTO = Orcamento.ID_ORCAMENTO, NUM_QUANTIDADE = Item.Quantidade, NUM_VALOR_CUSTO = Item.ValorCusto, NUM_VALOR_UNITARIO = Item.ValorUnitario, NUM_DESCONTO = Item.ValorDesconto, LOGIN_USUARIO = UsuarioLogado, DATA_ATUALIZACAO = DateTime.Now }; if (Item.Produto != null) { tItem.ID_PRODUTO = Item.Produto.Id; if (Item.UnidadeMedida != null) tItem.ID_UNIDADE_MEDIDA = Item.UnidadeMedida.Id; // Verifica se o orçamento foi aprovado if (Orcamento.T_ESTADO_ORCAMENTO != null && Orcamento.T_ESTADO_ORCAMENTO.COD_ESTADO_ORCAMENTO == string.Format("0{0}", (int)Contrato.Enumeradores.EstadoOrcamento.Aprovado)) { // Atualiza a quantidade de produtos if (Item.UnidadeMedida != null && Item.UnidadeMedida.Id != Guid.Empty) { Contrato.UnidadeMedida uMedida = Item.Produto.UnidadeMedidas.Where(um => um.Id == Item.UnidadeMedida.Id).FirstOrDefault(); if (uMedida != null) { uMedida.Quantidade = uMedida.Quantidade - Item.Quantidade; context.T_PRODUTO_UNIDADE_MEDIDA.Where(pum => pum.ID_UNIDADE_MEDIDA == uMedida.Id && pum.ID_PRODUTO == Item.Produto.Id).FirstOrDefault().NUM_QUANTIDADE = uMedida.Quantidade; } } else { Item.Produto.Quantidade = Item.Produto.Quantidade - Item.Quantidade; context.T_PRODUTO.Where(p => p.ID_PRODUTO == Item.Produto.Id).FirstOrDefault().NUM_QUANTIDADE = Item.Produto.Quantidade; } } } Orcamento.T_ITEM.Add(tItem); // Salva as alterações context.SaveChanges(); // Preenche o objeto de retorno retItem.Codigo = Contrato.Constantes.COD_RETORNO_SUCESSO; // retorna dos dados return retItem; }