Beispiel #1
0
 private void atualizaEstadoFrentista(Frentista obj)
 {
     if (Int32.Parse(Request.QueryString["ID"]) == 0)
         obj.novo();
     else
         obj.editar();
 }
Beispiel #2
0
 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;
 }
Beispiel #3
0
 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;
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
        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";
        }
Beispiel #6
0
 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;
     }
 }
Beispiel #7
0
 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");
 }
Beispiel #8
0
        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");
            }
        }
Beispiel #9
0
        /******************************************************************************/

        #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");
            }
        }
Beispiel #10
0
        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;
        }
Beispiel #11
0
 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;
 }