public override bool validarDAO(ClasseBase obj) { DAOFornecedor daoFornecedor = new DAOFornecedor(); Frentista frentista = new Frentista(); frentista.Login = ((Usuario)obj).Login; bool result = false; if ((obj.Estado == Stateobj.stNovo || obj.Estado == Stateobj.stEditar)) { if (((Frentista)obj).Login != "" && !base.buscarLogin(frentista)) { throw new EInvalidObjectDAOBase("Usuário informado não foi encontrado"); } if (((Frentista)obj).Fornecedor.ID != 0 && !daoFornecedor.buscarID(((Frentista)obj).Fornecedor)) { throw new EInvalidObjectDAOBase("Fornecedor/Posto informado não foi encontrado"); } result = true; } else { result = base.validarDAO(obj); } return(result); }
public bool buscarFrentista(Frentista obj) { bool erro = true; try { SqlDataReader reader; command.Connection = MsSQL.getConexao(); command.Connection.Open(); command.CommandText = "SELECT ID,LOGIN,NOME,SENHA,ID_PERFIL,ATIVO,ID_FORNECEDOR FROM USUARIO " + "WHERE LOGIN='******'"; reader = command.ExecuteReader(); if (reader.Read()) { parser(reader, ref obj); } else { erro = false; } } finally { command.Connection.Close(); } return(erro); }
protected void ibtExcluir_Click(object sender, ImageClickEventArgs e) { frentista = (Session["frentista"] as Frentista); frentista.deletar(); daoFrentista = new DAOFrentista(); frentista.aplicar(daoFrentista); Response.Redirect("PesqFrentista.aspx"); }
private void getFornecedor() { frentista = (Session["frentista"] as Frentista); frentista.Fornecedor.ID = Int32.Parse(txbId_fornecedor.Text); if (frentista.Fornecedor.ID != 0) { daoFornecedor = new DAOFornecedor(); daoFornecedor.buscarID(frentista.Fornecedor); } Session["frentista"] = frentista; }
private void atualizaEstadoFrentista(Frentista obj) { if (Int32.Parse(Request.QueryString["ID"]) == 0) { obj.novo(); } else { obj.editar(); } }
private void getUsuario() { frentista = (Session["frentista"] as Frentista); frentista.Login = txbUsuario.Text; if (frentista.Login != "") { daoFrentista = new DAOFrentista(); daoFrentista.buscarLogin(frentista); atualizaEstadoFrentista(frentista); } Session["frentista"] = frentista; }
protected void ibtGravar_Click(object sender, ImageClickEventArgs e) { frentista = (Session["frentista"] as Frentista); setDados(); try { frentista.aplicar(new DAOFrentista()); Session["prox_pagina"] = "PesqFrentista.aspx"; Response.Redirect("OperacaoRealizada.aspx"); } catch (Exception Ex) { lbMsgErro.Visible = true; lbMsgErro.Text = Ex.Message; } }
/******************************************************************************/ #region eventos do webforms ou webcontrols protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { abastecimento = new Abastecimento(); daoCombustivel = new DAOCombustivel(); ddTipoCombustivel.DataSource = daoCombustivel.listar(); ddTipoCombustivel.DataBind(); ddTipoCombustivel.Items[0].Selected = false; /*********************** Item vazio ****************************/ Solucon.WebControls.WebFormat.addItemDefault(ddTipoCombustivel, new ListItem("Selecione", "0", true)); ddTipoCombustivel.Enabled = true; /***************************************************************/ limparCtrl(); Session["abastecimento"] = abastecimento; /// <summary> /// Verificando se o usuário está associado à um fornecedor. /// </summary> frentista = new Frentista(); frentista.ID = ((Usuario)Session["USUARIO_LOGADO"]).ID; daoFrentista = new DAOFrentista(); if (daoFrentista.buscarID(frentista) && frentista.Fornecedor.ID != 0) { txbID_Fornecedor.Text = frentista.Fornecedor.ID.ToString(); getFornecedor(); setFornecedor(); } else { Response.Redirect("usuarioSemFornecedor.aspx"); } /***************************************************************/ txbPlaca.Focus(); } if (Session["buscaFunc"] != null) { txbMatricula.Text = (Session["buscaFunc"] as Funcionario).Matricula; txbMatricula_TextChanged(sender, e); Session.Remove("buscaFunc"); } if (Session["buscaVeiculo"] != null) { txbPlaca.Text = (Session["buscaVeiculo"] as Veiculo).Placa; txbPlaca_TextChanged(sender, e); Session.Remove("buscaVeiculo"); } }
private void parser(SqlDataReader reader, ref Frentista obj) { obj.Login = reader["LOGIN"].ToString(); obj.Nome = reader["NOME"].ToString(); obj.Senha = reader["SENHA"].ToString(); obj.perfil.ID = Convert.ToInt32(reader["ID_PERFIL"]); obj.Ativo = reader["ATIVO"].ToString(); if (reader["ID_FORNECEDOR"].ToString() != "") { obj.Fornecedor.ID = Int32.Parse(reader["ID_FORNECEDOR"].ToString()); } else { obj.Fornecedor.ID = 0; } obj.Estado = Stateobj.stLimpo; }
public void habilitarCtrl(bool ativar) { if (frentista == null) { frentista = (Session["frentista"] as Frentista); } ibtAlterar.Visible = !ativar; ibtGravar.Visible = ativar; ibtExcluir.Visible = !ativar; txbId_fornecedor.Enabled = ativar; btnBuscarFornec.Visible = ativar; if (ativar && frentista.Estado == Solucon.State.Stateobj.stNovo) { txbUsuario.Enabled = ativar; btnBuscarUsuario.Visible = ativar; } else { txbUsuario.Enabled = false; btnBuscarUsuario.Visible = false; } if (txbUsuario.Enabled) { txbUsuario.CssClass = "input_peq"; } else { txbUsuario.CssClass = "textbox_desabilitado"; } if (txbId_fornecedor.Enabled) { txbId_fornecedor.CssClass = "input_peq"; } else { txbId_fornecedor.CssClass = "textbox_desabilitado"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { frentista = new Frentista(); frentista.ID = Int32.Parse(Request.QueryString["ID"]); Session["frentista"] = frentista; if (frentista.ID != 0) { daoFrentista = new DAOFrentista(); daoFrentista.buscarID(frentista); getDados(); habilitarCtrl(false); frentista.editar(); } else { frentista.novo(); habilitarCtrl(true); } } if (Session["buscaFornec"] != null) { txbId_fornecedor.Text = (Session["buscaFornec"] as Fornecedor).ID.ToString(); txbId_fornecedor_TextChanged(sender, e); Session.Remove("buscaFornec"); } if (Session["buscaUsuario"] != null) { txbUsuario.Text = (Session["buscaUsuario"] as Usuario).Login; txbUsuario_TextChanged(sender, e); Session.Remove("buscaUsuario"); } }