public List <PedidosOrcamentos> Listar() { DbCommand dbc = this.m_db.GetStoredProcCommand("dbo.SPR_PEDORCAMENTO_LISTSAR"); //this.m_db.AddInParameter(dbc, "@USUARIO_ID", DbType.String, usuarioId); List <PedidosOrcamentos> Lista = new List <PedidosOrcamentos>(); using (IDataReader readerUsuario = this.m_db.ExecuteReader(dbc)) { while (readerUsuario.Read()) { PedidosOrcamentos pedidosOrcamentos = new PedidosOrcamentos(); pedidosOrcamentos.Cod_PedidosOrcamentos = Conversion.preencheCampoInt(readerUsuario["COD_PEDIDOSORCAMENTOS"]); pedidosOrcamentos.Item = new ItemData().Seleciona(Conversion.preencheCampoInt(readerUsuario["COD_ITEM"])); pedidosOrcamentos.UnidadeMedida = new UnidadeMedidaData().Obter(Conversion.preencheCampoInt(readerUsuario["COD_UNIDADEMEDIDA"])); pedidosOrcamentos.Projeto = new ProjetosData().Obter(Conversion.preencheCampoInt(readerUsuario["COD_PROJETO"])); pedidosOrcamentos.Quantidade = Conversion.preencheCampoDecimal(readerUsuario["NUM_QUANTIDADE"]); pedidosOrcamentos.DataNecessidade = Conversion.preencheCampoDateTime(readerUsuario["DAT_NECESSIDADE"]); pedidosOrcamentos.UsuarioPedido = new UsuarioData().GetByID(Conversion.preencheCampoInt(readerUsuario["USUARIOID_PEDIDO"])); pedidosOrcamentos.Data_PedidoOrcamento = Conversion.preencheCampoDateTime(readerUsuario["DAT_PEDIDOORCAMENTO"]); pedidosOrcamentos.Status = Conversion.preencheCampoInt(readerUsuario["STATUS"]); pedidosOrcamentos.Area = new GrupoData().Obter(Conversion.preencheCampoInt(readerUsuario["GRUPO_ID"])); pedidosOrcamentos.Outros = Conversion.preencheCampoString(readerUsuario["DSC_OUTROS"]); pedidosOrcamentos.Descricao = Conversion.preencheCampoString(readerUsuario["DSC_DESCRICAO"]); Lista.Add(pedidosOrcamentos); } readerUsuario.Dispose(); } return(Lista); }
/// <summary> /// Incluir um novo grupo /// </summary> /// <param name="grupo">Grupo a ser incluída</param> /// <returns>Resultado</returns> public Resultado Incluir(PedidosOrcamentos pedidoOcarmento) { Resultado resultado = new Resultado(); try { DbCommand dbCommand = this.m_db.GetStoredProcCommand("dbo.SPR_PEDORCAMENTO_INSERE"); this.m_db.AddInParameter(dbCommand, "@COD_ITEM", DbType.Int32, pedidoOcarmento.Item.ItemID); this.m_db.AddInParameter(dbCommand, "@COD_UNIDADEMEDIDA", DbType.Int32, pedidoOcarmento.UnidadeMedida.Id); this.m_db.AddInParameter(dbCommand, "@COD_PROJETO", DbType.Int32, pedidoOcarmento.Projeto.ProjetoID); this.m_db.AddInParameter(dbCommand, "@NUM_QUANTIDADE", DbType.Int32, pedidoOcarmento.Quantidade); this.m_db.AddInParameter(dbCommand, "@DAT_NECESSIDADE", DbType.DateTime, pedidoOcarmento.DataNecessidade); this.m_db.AddInParameter(dbCommand, "@USUARIOID_PEDIDO", DbType.Int32, pedidoOcarmento.UsuarioPedido.UsuarioId); this.m_db.AddInParameter(dbCommand, "@FINALIDADE", DbType.String, pedidoOcarmento.Finalidade); this.m_db.AddInParameter(dbCommand, "@GRUPO_ID", DbType.Int32, pedidoOcarmento.Area.ID); this.m_db.AddInParameter(dbCommand, "@OUTROS", DbType.String, Consts.Funcoes.NullOrString(pedidoOcarmento.Outros)); this.m_db.AddInParameter(dbCommand, "@DESCRICAO", DbType.String, Consts.Funcoes.NullOrString(pedidoOcarmento.Descricao)); resultado.Id = Convert.ToInt32(this.m_db.ExecuteScalar(dbCommand)); resultado.Sucesso = (resultado.Id > 0); } catch (SqlException ex) { resultado.Sucesso = false; Mensagem mensagem = new Mensagem(); mensagem.Campo = "Orcamento"; mensagem.Descricoes.Add(ex.Message); resultado.Mensagens.Add(mensagem); } return resultado; }
public PedidosOrcamentos Obter(int IdPedidosOrcamento) { DbCommand dbc = this.m_db.GetStoredProcCommand("dbo.SPR_ORCAMENTO_OBTER"); this.m_db.AddInParameter(dbc, "@IdPedidosOrcamentos", DbType.Int32, IdPedidosOrcamento); PedidosOrcamentos pedidosOrcamentos = new PedidosOrcamentos(); using (IDataReader Reader = this.m_db.ExecuteReader(dbc)) { if (Reader.Read()) { pedidosOrcamentos.Cod_PedidosOrcamentos = Conversion.preencheCampoInt(Reader["COD_PEDIDOSORCAMENTOS"]); pedidosOrcamentos.Item = new ItemData().Seleciona(Conversion.preencheCampoInt(Reader["COD_ITEM"])); pedidosOrcamentos.UnidadeMedida = new UnidadeMedidaData().Obter(Conversion.preencheCampoInt(Reader["COD_UNIDADEMEDIDA"])); pedidosOrcamentos.Projeto = new ProjetosData().Obter(Conversion.preencheCampoInt(Reader["COD_PROJETO"])); pedidosOrcamentos.Quantidade = Conversion.preencheCampoDecimal(Reader["NUM_QUANTIDADE"]); pedidosOrcamentos.DataNecessidade = Conversion.preencheCampoDateTime(Reader["DAT_NECESSIDADE"]); pedidosOrcamentos.UsuarioPedido = new UsuarioData().GetByID(Conversion.preencheCampoInt(Reader["USUARIOID_PEDIDO"])); pedidosOrcamentos.Data_PedidoOrcamento = Conversion.preencheCampoDateTime(Reader["DAT_PEDIDOORCAMENTO"]); pedidosOrcamentos.Status = Conversion.preencheCampoInt(Reader["STATUS"]); pedidosOrcamentos.Area = new GrupoData().Obter(Conversion.preencheCampoInt(Reader["GRUPO_ID"])); pedidosOrcamentos.Outros = Conversion.preencheCampoString(Reader["DSC_OUTROS"]); pedidosOrcamentos.Descricao = Conversion.preencheCampoString(Reader["DSC_DESCRICAO"]); } Reader.Dispose(); } return(pedidosOrcamentos); }
/// <summary> /// Incluir um novo grupo /// </summary> /// <param name="grupo">Grupo a ser incluída</param> /// <returns>Resultado</returns> public Resultado Incluir(PedidosOrcamentos pedidoOcarmento) { Resultado resultado = new Resultado(); try { DbCommand dbCommand = this.m_db.GetStoredProcCommand("dbo.SPR_PEDORCAMENTO_INSERE"); this.m_db.AddInParameter(dbCommand, "@COD_ITEM", DbType.Int32, pedidoOcarmento.Item.ItemID); this.m_db.AddInParameter(dbCommand, "@COD_UNIDADEMEDIDA", DbType.Int32, pedidoOcarmento.UnidadeMedida.Id); this.m_db.AddInParameter(dbCommand, "@COD_PROJETO", DbType.Int32, pedidoOcarmento.Projeto.ProjetoID); this.m_db.AddInParameter(dbCommand, "@NUM_QUANTIDADE", DbType.Int32, pedidoOcarmento.Quantidade); this.m_db.AddInParameter(dbCommand, "@DAT_NECESSIDADE", DbType.DateTime, pedidoOcarmento.DataNecessidade); this.m_db.AddInParameter(dbCommand, "@USUARIOID_PEDIDO", DbType.Int32, pedidoOcarmento.UsuarioPedido.UsuarioId); this.m_db.AddInParameter(dbCommand, "@FINALIDADE", DbType.String, pedidoOcarmento.Finalidade); this.m_db.AddInParameter(dbCommand, "@GRUPO_ID", DbType.Int32, pedidoOcarmento.Area.ID); this.m_db.AddInParameter(dbCommand, "@OUTROS", DbType.String, Consts.Funcoes.NullOrString(pedidoOcarmento.Outros)); this.m_db.AddInParameter(dbCommand, "@DESCRICAO", DbType.String, Consts.Funcoes.NullOrString(pedidoOcarmento.Descricao)); resultado.Id = Convert.ToInt32(this.m_db.ExecuteScalar(dbCommand)); resultado.Sucesso = (resultado.Id > 0); } catch (SqlException ex) { resultado.Sucesso = false; Mensagem mensagem = new Mensagem(); mensagem.Campo = "Orcamento"; mensagem.Descricoes.Add(ex.Message); resultado.Mensagens.Add(mensagem); } return(resultado); }
protected void PreencheOrcamentos(PedidosOrcamentos pedOrcamento) { txtProjeto.Text = pedOrcamento.Projeto.Nome.ToString(); //lblNomeArea.Text = pedOrcamento.Area.Nome.ToString(); txtCategoria.Text = pedOrcamento.Item.Categoria.Nome.ToString(); txtItem.Text = pedOrcamento.Item.Nome.ToString(); txtQuantidade.Text = pedOrcamento.Quantidade.ToString(); txtFinalidade.Text = pedOrcamento.Finalidade == null ? string.Empty : pedOrcamento.Finalidade.ToString(); }
protected void PreencheOrcamentos(PedidosOrcamentos pedOrcamento) { txtProjeto.Text = pedOrcamento.Projeto.Nome.ToString(); //lblNomeArea.Text = pedOrcamento.Area.Nome.ToString(); txtCategoria.Text = pedOrcamento.Item.Categoria.Nome.ToString(); txtItem.Text = pedOrcamento.Item.Nome.ToString(); txtQuantidade.Text = pedOrcamento.Quantidade.ToString(); txtFinalidade.Text = pedOrcamento.Finalidade == null ? string.Empty : pedOrcamento.Finalidade.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Context.Handler is PedidosOrcamentoLista) { Resultado resultado = new Resultado(); Orcamento = new PedOrcamentoFacade().Obter(ref resultado, ((PedidosOrcamentoLista)Context.Handler).IdPedidoOrcamento); if (resultado.Sucesso) { PreencheOrcamentos(Orcamento); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Resultado", "alert('" + resultado.Mensagens[0].Descricoes[0].ToString() + "'); location.href='PedidosOrcamentoLista.aspx';", true); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Context.Handler is PedidosOrcamentoLista) { Resultado resultado = new Resultado(); Orcamento = new PedOrcamentoFacade().Obter(ref resultado, ((PedidosOrcamentoLista)Context.Handler).IdPedidoOrcamento); if (resultado.Sucesso) { PreencheOrcamentos(Orcamento); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Resultado", "alert('" + resultado.Mensagens[0].Descricoes[0].ToString() + "'); location.href='PedidosOrcamentoLista.aspx';", true); } } } }
public List<PedidosOrcamentos> Listar() { DbCommand dbc = this.m_db.GetStoredProcCommand("dbo.SPR_PEDORCAMENTO_LISTSAR"); //this.m_db.AddInParameter(dbc, "@USUARIO_ID", DbType.String, usuarioId); List<PedidosOrcamentos> Lista = new List<PedidosOrcamentos>(); using (IDataReader readerUsuario = this.m_db.ExecuteReader(dbc)) { while (readerUsuario.Read()) { PedidosOrcamentos pedidosOrcamentos = new PedidosOrcamentos(); pedidosOrcamentos.Cod_PedidosOrcamentos = Conversion.preencheCampoInt(readerUsuario["COD_PEDIDOSORCAMENTOS"]); pedidosOrcamentos.Item = new ItemData().Seleciona(Conversion.preencheCampoInt(readerUsuario["COD_ITEM"])); pedidosOrcamentos.UnidadeMedida = new UnidadeMedidaData().Obter(Conversion.preencheCampoInt(readerUsuario["COD_UNIDADEMEDIDA"])); pedidosOrcamentos.Projeto = new ProjetosData().Obter(Conversion.preencheCampoInt(readerUsuario["COD_PROJETO"])); pedidosOrcamentos.Quantidade = Conversion.preencheCampoDecimal(readerUsuario["NUM_QUANTIDADE"]); pedidosOrcamentos.DataNecessidade = Conversion.preencheCampoDateTime(readerUsuario["DAT_NECESSIDADE"]); pedidosOrcamentos.UsuarioPedido = new UsuarioData().GetByID(Conversion.preencheCampoInt(readerUsuario["USUARIOID_PEDIDO"])); pedidosOrcamentos.Data_PedidoOrcamento = Conversion.preencheCampoDateTime(readerUsuario["DAT_PEDIDOORCAMENTO"]); pedidosOrcamentos.Status = Conversion.preencheCampoInt(readerUsuario["STATUS"]); pedidosOrcamentos.Area = new GrupoData().Obter(Conversion.preencheCampoInt(readerUsuario["GRUPO_ID"])); pedidosOrcamentos.Outros = Conversion.preencheCampoString(readerUsuario["DSC_OUTROS"]); pedidosOrcamentos.Descricao = Conversion.preencheCampoString(readerUsuario["DSC_DESCRICAO"]); Lista.Add(pedidosOrcamentos); } readerUsuario.Dispose(); } return Lista; }
public PedidosOrcamentos Obter(int IdPedidosOrcamento) { DbCommand dbc = this.m_db.GetStoredProcCommand("dbo.SPR_ORCAMENTO_OBTER"); this.m_db.AddInParameter(dbc, "@IdPedidosOrcamentos", DbType.Int32, IdPedidosOrcamento); PedidosOrcamentos pedidosOrcamentos = new PedidosOrcamentos(); using (IDataReader Reader = this.m_db.ExecuteReader(dbc)) { if (Reader.Read()) { pedidosOrcamentos.Cod_PedidosOrcamentos = Conversion.preencheCampoInt(Reader["COD_PEDIDOSORCAMENTOS"]); pedidosOrcamentos.Item = new ItemData().Seleciona(Conversion.preencheCampoInt(Reader["COD_ITEM"])); pedidosOrcamentos.UnidadeMedida = new UnidadeMedidaData().Obter(Conversion.preencheCampoInt(Reader["COD_UNIDADEMEDIDA"])); pedidosOrcamentos.Projeto = new ProjetosData().Obter(Conversion.preencheCampoInt(Reader["COD_PROJETO"])); pedidosOrcamentos.Quantidade = Conversion.preencheCampoDecimal(Reader["NUM_QUANTIDADE"]); pedidosOrcamentos.DataNecessidade = Conversion.preencheCampoDateTime(Reader["DAT_NECESSIDADE"]); pedidosOrcamentos.UsuarioPedido = new UsuarioData().GetByID(Conversion.preencheCampoInt(Reader["USUARIOID_PEDIDO"])); pedidosOrcamentos.Data_PedidoOrcamento = Conversion.preencheCampoDateTime(Reader["DAT_PEDIDOORCAMENTO"]); pedidosOrcamentos.Status = Conversion.preencheCampoInt(Reader["STATUS"]); pedidosOrcamentos.Area = new GrupoData().Obter(Conversion.preencheCampoInt(Reader["GRUPO_ID"])); pedidosOrcamentos.Outros = Conversion.preencheCampoString(Reader["DSC_OUTROS"]); pedidosOrcamentos.Descricao = Conversion.preencheCampoString(Reader["DSC_DESCRICAO"]); } Reader.Dispose(); } return pedidosOrcamentos; }
protected void btnAddItem_Click(object sender, ImageClickEventArgs e) { if (Page.IsValid) { if (ddlItem.SelectedIndex > 0) { Resultado resultado = new Resultado(); List <PedidosOrcamentos> ListaOrcamento = null; PedidosOrcamentos ItemOrcamento = new PedidosOrcamentos(); if (ListaGridPersistida != null) { ListaOrcamento = (List <PedidosOrcamentos>)ListaGridPersistida; } else { ListaOrcamento = new List <PedidosOrcamentos>(); } Projetos oProd = new Projetos(); oProd.ProjetoID = Convert.ToInt32(ddlProjeto.SelectedValue); oProd.Nome = ddlProjeto.SelectedItem.ToString(); Categoria oCat = new Categoria(); oCat.CategoriaID = Convert.ToInt32(ddlCategoria.SelectedValue); oCat.Nome = ddlCategoria.SelectedItem.ToString(); ItemOrcamento.UnidadeMedida = new UnidadeMedida(Convert.ToInt32(ddlUnidadeMedida.SelectedItem.Value), ddlUnidadeMedida.SelectedItem.Text); Grupo oArea = new Grupo(); if (((Usuario)Session["USUARIO"]).Perfil.PerfilId != 3) { oArea.ID = Convert.ToInt32(ddlArea.SelectedValue); oArea.Nome = ddlArea.SelectedItem.ToString(); } else { oArea = ((Usuario)Session["USUARIO"]).Area; } Item oItem = new Item(); oItem.ItemID = Convert.ToInt32(ddlItem.SelectedValue); oItem.Nome = ddlItem.SelectedItem.ToString(); oItem.Categoria = oCat; ItemOrcamento.Cod_PedidosOrcamentos = ListaOrcamento.Count + 1; ItemOrcamento.Item = oItem; ItemOrcamento.Projeto = oProd; ItemOrcamento.Area = oArea; ItemOrcamento.Quantidade = Convert.ToInt32(txtQuantidade.Text); ItemOrcamento.DataNecessidade = Convert.ToDateTime(dtNecessidade.Text); ItemOrcamento.UsuarioPedido.UsuarioId = ((Usuario)Session["USUARIO"]).UsuarioId; if (txtOutros.Text.ToString() != string.Empty) { ItemOrcamento.Outros = txtOutros.Text.ToString(); } if (txtDesc.Text.ToString() != string.Empty) { ItemOrcamento.Descricao = txtDesc.Text.ToString(); } string msgConfirmacao = string.Empty; //resultado = oPedItemFacade.Validar(ItemOrcamento); //if (resultado.Sucesso) //{ ListaGridPersistida = ListaOrcamento; ListaOrcamento.Add(ItemOrcamento); gvPedItens.DataSource = (List <PedidosOrcamentos>)ListaGridPersistida; gvPedItens.DataBind(); btnSalvar.Visible = true; btnCancelar.Visible = true; ddlCategoria.Enabled = false; //} } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ResultadoConfirmação", "alert('Selecione um Item para adicionar a lista!');", true); } ddlCategoria_SelectedIndexChanged(null, null); txtDesc.Text = ""; txtOutros.Text = ""; txtQuantidade.Text = ""; } }
protected void btnAddItem_Click(object sender, ImageClickEventArgs e) { if (Page.IsValid) { if (ddlItem.SelectedIndex > 0) { Resultado resultado = new Resultado(); List<PedidosOrcamentos> ListaOrcamento = null; PedidosOrcamentos ItemOrcamento = new PedidosOrcamentos(); if (ListaGridPersistida != null) { ListaOrcamento = (List<PedidosOrcamentos>)ListaGridPersistida; } else { ListaOrcamento = new List<PedidosOrcamentos>(); } Projetos oProd = new Projetos(); oProd.ProjetoID = Convert.ToInt32(ddlProjeto.SelectedValue); oProd.Nome = ddlProjeto.SelectedItem.ToString(); Categoria oCat = new Categoria(); oCat.CategoriaID = Convert.ToInt32(ddlCategoria.SelectedValue); oCat.Nome = ddlCategoria.SelectedItem.ToString(); ItemOrcamento.UnidadeMedida = new UnidadeMedida(Convert.ToInt32(ddlUnidadeMedida.SelectedItem.Value), ddlUnidadeMedida.SelectedItem.Text); Grupo oArea = new Grupo(); if (((Usuario)Session["USUARIO"]).Perfil.PerfilId != 3) { oArea.ID = Convert.ToInt32(ddlArea.SelectedValue); oArea.Nome = ddlArea.SelectedItem.ToString(); } else { oArea = ((Usuario)Session["USUARIO"]).Area; } Item oItem = new Item(); oItem.ItemID = Convert.ToInt32(ddlItem.SelectedValue); oItem.Nome = ddlItem.SelectedItem.ToString(); oItem.Categoria = oCat; ItemOrcamento.Cod_PedidosOrcamentos = ListaOrcamento.Count + 1; ItemOrcamento.Item = oItem; ItemOrcamento.Projeto = oProd; ItemOrcamento.Area = oArea; ItemOrcamento.Quantidade = Convert.ToInt32(txtQuantidade.Text); ItemOrcamento.DataNecessidade = Convert.ToDateTime(dtNecessidade.Text); ItemOrcamento.UsuarioPedido.UsuarioId = ((Usuario)Session["USUARIO"]).UsuarioId; if (txtOutros.Text.ToString() != string.Empty) { ItemOrcamento.Outros = txtOutros.Text.ToString(); } if (txtDesc.Text.ToString() != string.Empty) { ItemOrcamento.Descricao = txtDesc.Text.ToString(); } string msgConfirmacao = string.Empty; //resultado = oPedItemFacade.Validar(ItemOrcamento); //if (resultado.Sucesso) //{ ListaGridPersistida = ListaOrcamento; ListaOrcamento.Add(ItemOrcamento); gvPedItens.DataSource = (List<PedidosOrcamentos>)ListaGridPersistida; gvPedItens.DataBind(); btnSalvar.Visible = true; btnCancelar.Visible = true; ddlCategoria.Enabled = false; //} } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ResultadoConfirmação", "alert('Selecione um Item para adicionar a lista!');", true); } ddlCategoria_SelectedIndexChanged(null, null); txtDesc.Text = ""; txtOutros.Text = ""; txtQuantidade.Text = ""; } }