Example #1
0
        public void AlterarLocador(Locador locador)
        {
            using (SqlConnection conexao = Conexao.ConexaoDatabase())
            {
                conexao.Open();

                SqlCommand comandoDML = new SqlCommand("SP_AlterarLocadorV1", conexao);
                comandoDML.CommandType = CommandType.StoredProcedure;

                comandoDML.Parameters.Add("@LCIDLOCLOK", SqlDbType.Int);
                comandoDML.Parameters.Add("@LCRZSLOK", SqlDbType.VarChar, 100);
                comandoDML.Parameters.Add("@LCFANTLOK", SqlDbType.VarChar, 100);
                comandoDML.Parameters.Add("@LCNMLOK", SqlDbType.VarChar, 100);
                comandoDML.Parameters.Add("@LCLOGLOK", SqlDbType.VarChar, 100);
                comandoDML.Parameters.Add("@LCBAIRROLOK", SqlDbType.VarChar, 100);
                comandoDML.Parameters.Add("@LCCIDLOK", SqlDbType.VarChar, 100);
                comandoDML.Parameters.Add("@LCUFLOK", SqlDbType.VarChar, 2);
                comandoDML.Parameters.Add("@LCCEPLOK", SqlDbType.VarChar, 10);
                comandoDML.Parameters.Add("@LCSITLOK", SqlDbType.Char, 1);

                comandoDML.Parameters["@LCIDLOCLOK"].Value  = locador.CodigoLocador;
                comandoDML.Parameters["@LCRZSLOK"].Value    = locador.RazaoSocialLocador;
                comandoDML.Parameters["@LCFANTLOK"].Value   = locador.NomeFantasiaLocador;
                comandoDML.Parameters["@LCNMLOK"].Value     = locador.TelefoneLocador;
                comandoDML.Parameters["@LCLOGLOK"].Value    = locador.EnderecoLocador;
                comandoDML.Parameters["@LCBAIRROLOK"].Value = locador.BairroLocador;
                comandoDML.Parameters["@LCCIDLOK"].Value    = locador.CidadeLocador;
                comandoDML.Parameters["@LCUFLOK"].Value     = locador.EstadoLocador;
                comandoDML.Parameters["@LCCEPLOK"].Value    = locador.CepLocador;
                comandoDML.Parameters["@LCSITLOK"].Value    = locador.SituacaoLocador;

                comandoDML.ExecuteNonQuery();
                conexao.Close();
            }
        }
Example #2
0
        public Locador NovoLocador(Locador L)
        {
            try
            {
                if (L.NomeLocador == null)
                {
                    throw new Exception("Informe o nome do Locador");
                }
                L.Ativo         = true;
                L.DataInclusao  = DateTime.Now;
                L.DataAlteracao = null;
                L.Padrao        = true;

                LocadorRepositorio lr = new LocadorRepositorio();
                lr.Insert(L);
                return(L);


                ImovelLocadorRepositorio ir = new ImovelLocadorRepositorio();

                foreach (ImovelLocador il in L.ImovelLocador)
                {
                    il.IdLocador = L.IdLocador;
                    ir.Insert(il);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public ActionResult AlterarLocadorAR(string txtCodigoLocador, string txtRzScLocador, string txtNmFsLocador, string txtEmailLocador, string txtTelefoneLocador, string selSituacaoLocador, string txtEnderecoLocador, string txtBairroLocador, string txtCidadeLocador, string selEstadoLocador, string txtCepLocador)
        {
            if (ValidarAdmin.UsuarioValido())
            {
                LocadorDAL locadorDAL = new LocadorDAL();
                Locador    locador    = locadorDAL.SelecionarLocadorId(Convert.ToInt32(txtCodigoLocador));

                if (locador.CodigoLocador == 0)
                {
                    TempData[Constantes.MensagemAlerta] = "Não existe Locador para o código digitado.";
                    LocadorControllerModel locadorViewModel = ConvertToModel(locadorDAL.ListarLocador());
                    return(View("AlterarLocadorUI", locadorViewModel));
                }
                else
                {
                    locador = new Locador(Convert.ToInt32(txtCodigoLocador), txtRzScLocador, txtNmFsLocador, txtTelefoneLocador, txtEnderecoLocador, txtBairroLocador, txtCidadeLocador, selEstadoLocador, txtCepLocador, Convert.ToChar(selSituacaoLocador));
                    locadorDAL.AlterarLocador(locador);
                    TempData[Constantes.MensagemAlerta] = "Locador alterado com sucesso!";
                    return(RedirectToAction("Index", "Inicio"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "AreaRestrita"));
            }
        }
Example #4
0
        public static Locador GetLocador()
        {
            string _login = HttpContext.Current.User.Identity.Name;

            //if (HttpContext.Current.Request.Cookies.Count > 0 || HttpContext.Current.Request.Cookies["Usuario"] != null)
            if (HttpContext.Current.Session.Count > 0 || HttpContext.Current.Session["Usuario"] != null)
            {
                _login = HttpContext.Current.Session["Usuario"].ToString();
                //_login = HttpContext.Current.Request.Cookies["Usuario"].Value.ToString();
                if (_login == "")
                {
                    return(null);
                }
                else
                {
                    Context _db     = new Context();
                    Locador locador = (from u in _db.Locadores
                                       where u.EmailLocador == _login
                                       select u).SingleOrDefault();
                    return(locador);
                }
            }
            else
            {
                return(null);
            }
        }
        public ActionResult ExcluirLocadorAR(string txtCodigoLocador)
        {
            if (ValidarAdmin.UsuarioValido())
            {
                LocadorDAL locadorDAL = new LocadorDAL();
                Locador    locador    = locadorDAL.SelecionarLocadorId(Convert.ToInt32(txtCodigoLocador));

                if (locador.CodigoLocador == 0)
                {
                    TempData[Constantes.MensagemAlerta] = "Não existe Locador para o código digitado.";
                    LocadorControllerModel locadorViewModel = ConvertToModel(locadorDAL.ListarLocador());
                    return(View("ExcluirLocadorUI", locadorViewModel));
                }
                else
                {
                    locador = new Locador(Convert.ToInt32(txtCodigoLocador));
                    locadorDAL.ExcluirLocador(locador);
                    TempData[Constantes.MensagemAlerta] = "Locador excluído com sucesso!";
                    return(RedirectToAction("Index", "Inicio"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "AreaRestrita"));
            }
        }
Example #6
0
 public ActionResult Login(Locador usuario)
 {
     if (ModelState.IsValid)
     {
         var v = db.Locadors.Where(a => a.usuario.Equals(usuario.usuario) &&
                                   a.senha.Equals(usuario.senha)).FirstOrDefault();
         if (v != null)
         {
             if (v.Tipo.Equals("A"))
             {
                 Session["nomeUsuarioLogado"] = v.Nome_Dono.ToString();
                 Session["login"]             = v.usuario.ToString();
                 return(RedirectToAction("Index", "Locadors"));
             }
             if (v.Tipo.Equals("U"))
             {
                 Session["nomeUsuarioLogado"] = v.Nome_Dono.ToString();
                 return(RedirectToAction("Edit", "Locadors"));
             }
         }
         else
         {
             ViewBag.msg = "<script>" +
                           "alert('Usuário ou Senha inválidos');" +
                           "</script>";
         }
     }
     else
     {
         return(RedirectToAction("Login", "Home"));
     }
     return(View(usuario));
 }
Example #7
0
        public ActionResult CreateVM([Bind(Include = "NombreContrato,DireccionPropiedad,FechaInicio,FechaFinal,NombreLocador,ApellidoLocador,TelefonoLocador,NombreLocatario,ApellidoLocatario,TelefonoLocatario,NombreGarante,ApellidoGarante,TelefonoGarante")] ContratoVM contrato)
        {
            Propiedad newPropiedad = new Propiedad();

            newPropiedad.Address = contrato.DireccionPropiedad;
            Locador newLocador = new Locador();

            newLocador.Name        = contrato.NombreLocador;
            newLocador.LastName    = contrato.ApellidoLocador;
            newLocador.PhoneNumber = contrato.TelefonoLocador;
            Locatario newLocatario = new Locatario();

            newLocatario.Name        = contrato.NombreLocatario;
            newLocatario.LastName    = contrato.ApellidoLocatario;
            newLocatario.PhoneNumber = contrato.TelefonoLocatario;
            Garante newGarante = new Garante();

            newGarante.Name        = contrato.NombreGarante;
            newGarante.LastName    = contrato.ApellidoGarante;
            newGarante.PhoneNumber = contrato.TelefonoGarante;
            Contrato newContrato = new Contrato();

            newContrato.NombreContrato = contrato.NombreContrato;
            newContrato.Propiedades    = newPropiedad;
            newContrato.FechaInicio    = contrato.FechaInicio;
            newContrato.FechaFinal     = contrato.FechaFinal;
            newContrato.Locador        = newLocador;
            newContrato.Locatario      = newLocatario;
            newContrato.Garante        = newGarante;

            db.Contratos.Add(newContrato);
            db.SaveChanges();

            return(RedirectToAction("Index", "Contratos"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Documento,Nome,Id,Endereco,Contato")] Locador locador)
        {
            if (id != locador.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    locadorRepo.UpdateLocador(locador);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!locadorRepo.LocadorExists(locador.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(locador));
        }
Example #9
0
        public async Task <IActionResult> Edit(int id, [Bind("LocadorId,Status,Nome,SobreNome,Cpf,Rg,OrgaoEmissor,Profissao,EstadoCivil,Email,Tel,TelTestemunha")] Locador locador)
        {
            if (id != locador.LocadorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(locador);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LocadorExists(locador.LocadorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(locador));
        }
Example #10
0
        public ActionResult Create([Bind(Include = "ID_Dono,Nome_Dono,CPF,email,usuario,senha,Tipo")] Locador locador)
        {
            if (ModelState.IsValid)
            {
                db.Locador.Add(locador);
                try
                {
                    db.SaveChanges();
                } catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
                return(RedirectToAction("Index"));
            }

            return(View(locador));
        }
Example #11
0
        // PUT: api/Locadores/5
        public Locador Put(int id, [FromBody] Locador locador
                           )
        {
            Locador _locador = new Locador();

            return(_locador.Update(id, locador));
        }
Example #12
0
        public ActionResult DeleteConfirmed(decimal id)
        {
            Locador locador = db.Locadors.Find(id);

            db.Locadors.Remove(locador);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #13
0
        // POST: api/Locadores
        public List <Locador> Post([FromBody] Locador locador)
        {
            Locador _locador = new Locador();

            _locador.Create(locador);

            return(_locador.ListarLocador());
        }
 public async Task <IActionResult> Create([Bind("Documento,Nome,Id,Endereco,Contato")] Locador locador)
 {
     //locador.Endereco = endereco;
     if (ModelState.IsValid)
     {
         locadorRepo.GravaLocador(locador);
         return(RedirectToAction(nameof(Index)));
     }
     return(View(locador));
 }
 public ActionResult Edit([Bind(Include = "LocadorID,NomeLocador,DataNascimentoLocador,CpfLocador,EmailLocador,SenhaLocador")] Locador locador)
 {
     if (ModelState.IsValid)
     {
         db.Entry(locador).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(locador));
 }
Example #16
0
 public ActionResult Edit([Bind(Include = "ID_Dono,Nome_Dono,Conta_Corrente,CPF,email,usuario,senha,Tipo")] Locador locador)
 {
     if (ModelState.IsValid)
     {
         db.Entry(locador).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(locador));
 }
Example #17
0
 public ActionResult Edit([Bind(Include = "ID,Nombre,Apellido,Email,Telefono,Celular,Direccion,Observaciones,FechaDeAlta")] Locador locador)
 {
     if (ModelState.IsValid)
     {
         db.Entry(locador).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(locador));
 }
Example #18
0
        public IActionResult Delete(long Id)
        {
            Locador v_locador = _context.Locador.Where(x => x.Id == Id).ToList().FirstOrDefault();

            _context.Locador.Remove(v_locador);
            _context.SaveChanges();
            List <Locador> v_locadorList = _context.Locador.ToList();

            return(RedirectToAction("Index"));
        }
Example #19
0
        public ActionResult Create([Bind(Include = "ID_Dono,Nome_Dono,Conta_Corrente,CPF,email,usuario,senha")] Locador locador)
        {
            if (ModelState.IsValid)
            {
                db.Locadors.Add(locador);
                db.SaveChanges();
                return(RedirectToAction("Login", "Home"));
            }

            return(View(locador));
        }
Example #20
0
        public async Task <IActionResult> Create([Bind("LocadorId,Status,Nome,SobreNome,Cpf,Rg,OrgaoEmissor,Profissao,EstadoCivil,Email,Tel,TelTestemunha")] Locador locador)
        {
            if (ModelState.IsValid)
            {
                _context.Add(locador);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(locador));
        }
        public ActionResult Create([Bind(Include = "LocadorID,NomeLocador,DataNascimentoLocador,CpfLocador,EmailLocador,SenhaLocador")] Locador locador)
        {
            if (ModelState.IsValid)
            {
                db.Locadores.Add(locador);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(locador));
        }
Example #22
0
 public IActionResult Edit(Locador locador)
 {
     if (locador.Id == 0)
     {
         _context.Locador.Add(locador);
     }
     else
     {
         _context.Locador.Update(locador);
     }
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public JsonResult SelecionarLocadorJR(int codigoLocador)
 {
     if (ValidarAdmin.UsuarioValido())
     {
         LocadorDAL locadorDAL = new LocadorDAL();
         Locador    locador    = locadorDAL.SelecionarLocadorId(codigoLocador);
         return(Json(locador, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json("Esta informação não pode ser solicitada. Por favor, contate o administrador do sistema.", JsonRequestBehavior.AllowGet));
     }
 }
Example #24
0
        public ActionResult CadastrarVeiculoAR(string txtCodigoLocador, string selTipoVeiculo, string txtMarcaVeiculo, string txtModeloVeiculo, string txtCorVeiculo, string selCombustivelVeiculo, string txtAnoVeiculo, string selSituacaoVeiculo, string txtPlacaVeiculo, string txtRenavamVeiculo, string txtValorDiariaVeiculo)
        {
            if (ValidarAdmin.UsuarioValido())
            {
                LocadorDAL locadorDAL = new LocadorDAL();
                VeiculoDAL veiculoDAL = new VeiculoDAL();

                Locador locador = new Locador();
                Veiculo veiculo = new Veiculo();

                if (txtCodigoLocador == "" || txtCodigoLocador == null)
                {
                    TempData[Constantes.MensagemAlerta] = "Não é possível incluir um veículo sem o código do locador.";
                    return(RedirectToAction("CadastrarVeiculoUI", "Veiculo"));
                }
                else
                {
                    Locador codigoLocador  = locadorDAL.SelecionarLocadorId(Convert.ToInt32(txtCodigoLocador));
                    Veiculo placaVeiculo   = veiculoDAL.SelecionarVeiculoPlaca(txtPlacaVeiculo);
                    Veiculo renavamVeiculo = veiculoDAL.SelecionarVeiculoRenavam(txtRenavamVeiculo);

                    if (codigoLocador.CodigoLocador == 0)
                    {
                        TempData[Constantes.MensagemAlerta] = "Código do Locador inválido! Tente novamente... ";
                        return(RedirectToAction("CadastrarVeiculoUI", "Veiculo"));
                    }
                    else if (placaVeiculo.PlacaVeiculo != null)
                    {
                        TempData[Constantes.MensagemAlerta] = "Esta placa de veículo já existe no sistema! Tente novamente... ";
                        return(RedirectToAction("CadastrarVeiculoUI", "Veiculo"));
                    }
                    else if (renavamVeiculo.RenavamVeiculo != null)
                    {
                        TempData[Constantes.MensagemAlerta] = "Este RENAVAM já existe no sistema! Tente novamente... ";
                        return(RedirectToAction("CadastrarVeiculoUI", "Veiculo"));
                    }
                    else
                    {
                        veiculo = new Veiculo(Convert.ToInt32(txtCodigoLocador), selTipoVeiculo, txtMarcaVeiculo, txtModeloVeiculo, txtPlacaVeiculo, txtRenavamVeiculo, selCombustivelVeiculo, txtCorVeiculo, txtAnoVeiculo, Convert.ToDecimal(txtValorDiariaVeiculo), Convert.ToChar(selSituacaoVeiculo));
                        veiculoDAL.CadastrarVeiculo(veiculo);

                        TempData[Constantes.MensagemAlerta] = "Veiculo cadastrado com sucesso!";
                        return(RedirectToAction("Index", "Inicio"));
                    }
                }
            }
            else
            {
                return(RedirectToAction("Login", "AreaRestrita"));
            }
        }
Example #25
0
        // GET: Locadors/Delete/5
        public ActionResult Delete(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Locador locador = db.Locadors.Find(id);

            if (locador == null)
            {
                return(HttpNotFound());
            }
            return(View(locador));
        }
Example #26
0
        // GET: Locadores/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Locador locador = db.Locadores.Find(id);

            if (locador == null)
            {
                return(HttpNotFound());
            }
            return(View(locador));
        }
Example #27
0
        public Locador SelecionarLocadorId(int codigoLocador)
        {
            using (SqlConnection conexao = Conexao.ConexaoDatabase())
            {
                conexao.Open();

                Locador locador = new Locador();
                locador.CodigoLocador = codigoLocador;

                SqlCommand comandoDML = new SqlCommand("SP_SelecionarLocadorIdV1", conexao);
                comandoDML.CommandType = CommandType.StoredProcedure;

                comandoDML.Parameters.Add("@LCIDLOCLOK", SqlDbType.Int);
                comandoDML.Parameters["@LCIDLOCLOK"].Value = locador.CodigoLocador;

                SqlDataReader dr = comandoDML.ExecuteReader();

                bool consultarIdLocador = dr.HasRows;

                if (consultarIdLocador == false)
                {
                    locador.CodigoLocador = 0;
                }
                else
                {
                    while (dr.Read())
                    {
                        int    idLocador              = Convert.ToInt32(dr["LCIDLOCLOK"]);
                        string mlLocador              = Convert.ToString(dr["LCEMAILLOK"]);
                        string razaoScLocador         = Convert.ToString(dr["LCRZSLOK"]);
                        string fantasiaLocador        = Convert.ToString(dr["LCFANTLOK"]);
                        string documentoLocador       = Convert.ToString(dr["LCPFPJLOK"]);
                        string telefoneLocador        = Convert.ToString(dr["LCNMLOK"]);
                        string enderecoLocador        = Convert.ToString(dr["LCLOGLOK"]);
                        string bairroLocador          = Convert.ToString(dr["LCBAIRROLOK"]);
                        string cidadeLocador          = Convert.ToString(dr["LCCIDLOK"]);
                        string estadoLocador          = Convert.ToString(dr["LCUFLOK"]);
                        string cepLocador             = Convert.ToString(dr["LCCEPLOK"]);
                        string situacaoLocador        = Convert.ToString(dr["LCSITLOK"]);
                        string ultimaAtualizaoLocador = Convert.ToString(dr["LCUHRREG"]);

                        locador = new Locador(idLocador, mlLocador, razaoScLocador, fantasiaLocador, documentoLocador, telefoneLocador, enderecoLocador, bairroLocador, cidadeLocador, estadoLocador, cepLocador, Convert.ToChar(situacaoLocador), ultimaAtualizaoLocador);
                    }
                }

                conexao.Close();
                return(locador);
            }
        }
Example #28
0
 public static Locador GetLocador(string _login)
 {
     if (_login == "")
     {
         return(null);
     }
     else
     {
         Context _db     = new Context();
         Locador locador = (from u in _db.Locadores
                            where u.EmailLocador == _login
                            select u).SingleOrDefault();
         return(locador);
     }
 }
Example #29
0
        public void ExcluirLocador(Locador locador)
        {
            using (SqlConnection conexao = Conexao.ConexaoDatabase())
            {
                conexao.Open();

                SqlCommand comandoDML = new SqlCommand("SP_ExcluirLocadorV1", conexao);
                comandoDML.CommandType = CommandType.StoredProcedure;

                comandoDML.Parameters.Add("@LCIDLOCLOK", SqlDbType.Int);
                comandoDML.Parameters["@LCIDLOCLOK"].Value = locador.CodigoLocador;

                comandoDML.ExecuteNonQuery();
                conexao.Close();
            }
        }
Example #30
0
        public ActionResult ReportarProblemas(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Anuncio anuncio = db.Anuncios.Find(id);
            Locador locador = db.Locadores.Find(anuncio.LocadorID);

            if (anuncio == null)
            {
                return(HttpNotFound());
            }
            ViewBag.LocadorID = new SelectList(db.Locadores, "LocadorID", "NomeLocador", anuncio.LocadorID);
            return(View(anuncio));
        }