public ActionResult SalvaBalancete([Bind(Include = "Balid,DataBal,Descricao,Arquivo,ApeId")] Balancetes bal, HttpPostedFileBase arquivo, string data)
        {
            Sindico usuario = AdminLar.Repositories.Funcoes.GetUsuario();

            if (usuario != null)
            {
                string fileName    = "";
                string contentType = "";
                string path        = "";

                if (arquivo != null && arquivo.ContentLength > 0)
                {
                    fileName    = System.IO.Path.GetFileName(arquivo.FileName);
                    contentType = arquivo.ContentType;

                    path = System.Configuration.ConfigurationManager.AppSettings["PathFiles"] + "\\Atas\\" + fileName;

                    arquivo.SaveAs(path);

                    bal.Arquivo = fileName;
                }

                bal.ApeId   = usuario.ApeId;
                bal.DataBal = Convert.ToDateTime(data);

                db.Balancetes.Add(bal);

                if (db.SaveChanges() > 0)
                {
                    return(RedirectToAction("Index", "Balancetes"));
                }
            }

            return(Json(false));
        }
Example #2
0
        public bool Adicionar(Sindico sindico)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("INSERT INTO ");
            builder.Append(this.TableName + " ");

            builder.Append("( ");

            builder.Append("id, ");
            builder.Append("id_endereco, ");
            builder.Append("id_condominio, ");
            builder.Append("nome, ");
            builder.Append("cpf, ");
            builder.Append("rg ");

            builder.Append(") ");

            builder.Append("VALUES ");

            builder.Append("(");

            builder.Append(sindico.Id + ", ");
            builder.Append(sindico.Id_endereco + ", ");
            builder.Append(sindico.Id_condominio + ", ");
            builder.Append("'" + sindico.Nome + "', ");
            builder.Append("'" + sindico.Cpf + "', ");
            builder.Append("'" + sindico.Rg + "' ");

            builder.Append(");");

            return(this.Update(builder.ToString()));
        }
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            /*
             * Obj
             * */
            Sindico obj = new Sindico();

            obj.Id_endereco   = Convert.ToInt32(dlEndereco.SelectedValue);
            obj.Id_condominio = Convert.ToInt32(dlCondominio.SelectedValue);
            obj.Nome          = Convert.ToString(txNome.Text);
            obj.Cpf           = txCPF.Text;
            obj.Rg            = txRg.Text;

            if (txId.Text.Equals(""))
            {
                obj.Id = obj.NextId();
                obj.Adicionar();
            }
            else
            {
                obj.Id = Convert.ToInt32(txId.Text);
                obj.Editar();
            }

            this.redirecionarMesmaPagina();
        }
Example #4
0
        public bool Editar(Sindico sindico)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("UPDATE ");
            builder.Append(this.TableName + " ");
            builder.Append("SET ");

            builder.Append("id_endereco = ");
            builder.Append(sindico.Id_endereco + ", ");

            builder.Append("id_condominio = ");
            builder.Append(sindico.Id_condominio + ", ");

            builder.Append("nome = ");
            builder.Append("'" + sindico.Nome + "', ");

            builder.Append("cpf = ");
            builder.Append("'" + sindico.Cpf + "', ");

            builder.Append("rg = ");
            builder.Append("'" + sindico.Rg + "' ");

            builder.Append("WHERE ");
            builder.Append("id = " + sindico.Id);
            builder.Append(";");

            return(this.Update(builder.ToString()));
        }
        public Sindico Buscar(int id)
        {
            string strConexao = "SERVER=localhost; DataBase=condominio; UID=root; pwd=";

            using (MySqlConnection conn = new MySqlConnection(strConexao))
            {
                conn.Open();

                using (MySqlCommand cmd = new MySqlCommand())
                {
                    string query = $"SELECT * FROM sindico WHERE IdSindico = {id}";

                    cmd.Connection  = conn;
                    cmd.CommandText = query;

                    MySqlDataReader reader = cmd.ExecuteReader();

                    Sindico retorno = new Sindico();

                    while (reader.Read())
                    {
                        retorno.IdSindico   = (int)reader["IdSindico"];
                        retorno.NomeSindico = (string)reader["NomeSindico"];
                        retorno.Email       = (string)reader["Email"];
                        retorno.Cpf         = (string)reader["Cpf"];
                        retorno.Telefone    = (string)reader["Telefone"];
                    }

                    return(retorno);
                }
            }
        }
Example #6
0
        //Pega os usuarios tipo sindico

        public static Sindico GetUsuario()
        {
            string _login = HttpContext.Current.User.Identity.Name;

            if (HttpContext.Current.Session.Count > 0 || HttpContext.Current.Session["Usuario"] != null)
            {
                _login = HttpContext.Current.Session["Usuario"].ToString();


                //se os logins estiverem com sessões vazias

                if (_login == "")
                {
                    return(null);
                }

                else
                {
                    Context _db      = new Context();
                    Sindico usuarios = (from u in _db.Sindicos
                                        where u.Email == _login
                                        select u).SingleOrDefault();
                    return(usuarios);
                }
            }
            else
            {
                return(null);
            }
        }
        public ActionResult Sindicos(string email, string nome, string cpf, string data, string numeroape, string telefone, string celular, string codigo)
        {
            Sindico sin = new Sindico();

            sin.Email                 = email;
            sin.Sin_Nome              = nome;
            sin.Sin_Cpf               = cpf;
            sin.Tipo                  = "S";
            sin.Sin_DataNascimento    = data;
            sin.Sin_NumeroApartamento = Convert.ToInt32(numeroape);
            sin.Sin_Telefone          = telefone;
            sin.Sin_Celular           = celular;
            sin.ApeId                 = Convert.ToInt32(codigo);

            var callbackUrl = Url.Action("CadastrarSenha", "Landing", new { mandaemail = Funcoes.Base64Codifica(email) }, protocol: Request.Url.Scheme);


            GmailEmailService gmail = new GmailEmailService();
            EmailMessage      msg   = new EmailMessage();

            msg.Body    = "Bem vindo Confirme a sua senha clicando aqui: " + callbackUrl;
            msg.IsHtml  = false;
            msg.Subject = "Bem vindo a AdminLar (Confirmação de Cadastro)";
            msg.ToEmail = email;
            gmail.SendEmailMessage(msg);

            db.Sindicos.Add(sin);

            if (db.SaveChanges() > 0)
            {
                return(Json(true));
            }

            return(Json(false));
        }
Example #8
0
        public void ExclusaoSindico()
        {
            Sindico sindico = new Sindico();

            sindico.Id = 1;

            Assert.IsTrue(sindico.Excluir());
        }
Example #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Sindico sindico = db.Sindicoes.Find(id);

            db.Sindicoes.Remove(sindico);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #10
0
        protected void DeleteRowButton_Click(Object sender, GridViewDeleteEventArgs e)
        {
            TableCell cell    = gridView1.Rows[e.RowIndex].Cells[1];
            int       id      = Convert.ToInt32(cell.Text);
            Sindico   sindico = new Sindico();

            sindico.Id = id;
            sindico.Excluir();
            this.redirecionarMesmaPagina();
        }
Example #11
0
        //Sindico link ativacao

        public ActionResult CadastrarSenha(string mandaemail)
        {
            string email = Funcoes.Base64Decodifica(mandaemail);

            var id = db.Sindicos.Where(x => x.Email == email).Select(x => x.Codigo).FirstOrDefault();

            Sindico usuario = (Sindico)db.Usuarios.Find(id);

            return(View(usuario));
        }
Example #12
0
 public ActionResult Edit([Bind(Include = "SindicoId,NomeSobrenome,Cpf,Telefone,Email,Apartamento,CondominioId")] Sindico sindico)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sindico).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CondominioId = new SelectList(db.Condominios, "CondominioId", "Nome", sindico.CondominioId);
     return(View(sindico));
 }
        public ActionResult InserirSindico(Sindico registro)
        {
            if (!ModelState.IsValid)
            {
                return(View(registro));
            }

            SindicoController controller = new SindicoController();

            controller.Inserir(registro);
            return(RedirectToAction("ListaSindico"));
        }
Example #14
0
        public IActionResult Create([FromBody] Sindico item)
        {
            if (item == null)
            {
                return(BadRequest());
            }

            _context.Sindicos.Add(item);
            _context.SaveChanges();

            return(CreatedAtRoute("GetSindico", new { id = item.Id }, item));
        }
Example #15
0
        public void EditarSindico()
        {
            Sindico sindico = new Sindico();

            sindico.Id            = 1;
            sindico.Id_condominio = 1;
            sindico.Id_endereco   = 1;
            sindico.Nome          = "Fabricio Oliveira";
            sindico.Rg            = "5666";
            sindico.Cpf           = "657657";

            Assert.IsTrue(sindico.Editar());
        }
Example #16
0
        public void AdicaoSindico()
        {
            Sindico sindico = new Sindico();

            sindico.Id            = 1;
            sindico.Id_condominio = 1;
            sindico.Id_endereco   = 1;
            sindico.Nome          = "Marcela Freitas";
            sindico.Rg            = "223344";
            sindico.Cpf           = "3242456";

            Assert.IsTrue(sindico.Adicionar());
        }
Example #17
0
        // GET: Atas
        public ActionResult Index()
        {
            Sindico usuario = AdminLar.Repositories.Funcoes.GetUsuario();

            if (usuario != null)
            {
                return(View(db.Ata.Include(a => a.Apartamento).Where(a => a.ApeId == usuario.ApeId).ToList()));
            }
            else
            {
                return(RedirectToAction("AcessoNegado", "Landing"));
            }
        }
Example #18
0
        // GET: Sindico/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sindico sindico = db.Sindicoes.Find(id);

            if (sindico == null)
            {
                return(HttpNotFound());
            }
            return(View(sindico));
        }
Example #19
0
        private Sindico PreencherObjeto(NpgsqlDataReader dataReader)
        {
            int     i   = 0;
            Sindico obj = new Sindico();

            obj.Id            = dataReader.GetInt32(i++);
            obj.Id_endereco   = dataReader.GetInt32(i++);
            obj.Id_condominio = dataReader.GetInt32(i++);
            obj.Nome          = dataReader.GetString(i++);
            obj.Cpf           = dataReader.GetString(i++);
            obj.Rg            = dataReader.GetString(i++);

            return(obj);
        }
        // GET: Inadimplencia
        public ActionResult Index()
        {
            Sindico usuario = AdminLar.Repositories.Funcoes.GetUsuario();

            if (usuario != null)
            {
                ViewBag.Condominos = db.Condominos.Include(p => p.Apartamento).Where(p => p.ApeId == usuario.ApeId);

                return(View(db.Inadimplecias.Include(e => e.Apartamento).Include(e => e.Condomino).Where(e => e.ApeId == usuario.ApeId).ToList()));
            }
            else
            {
                return(RedirectToAction("AcessoNegado", "Landing"));
            }
        }
Example #21
0
        //verifica se os sindico está logado no sistema

        public static Sindico GetUsuario(string _login)
        {
            if (_login == "")
            {
                return(null);
            }
            else
            {
                Context _db     = new Context();
                Sindico usuario = (from u in _db.Sindicos
                                   where u.Email == _login
                                   select u).SingleOrDefault();
                return(usuario);
            }
        }
Example #22
0
        // GET: Sindico/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Sindico sindico = db.Sindicoes.Find(id);

            if (sindico == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CondominioId = new SelectList(db.Condominios, "CondominioId", "Nome", sindico.CondominioId);
            return(View(sindico));
        }
        public void Inserir(Sindico registro)
        {
            string strConexao = "SERVER=localhost; DataBase=condominio;Allow User Variables=True; UID=root; pwd=";

            using (MySqlConnection conn = new MySqlConnection(strConexao))
            {
                conn.Open();

                using (MySqlCommand cmd = new MySqlCommand())
                {
                    string query = $"INSERT INTO sindico(IdSindico, NomeSindico, Email, Cpf, Telefone) VALUES('{registro.IdSindico}', '{registro.NomeSindico}', '{registro.Email}', '{registro.Cpf}', '{registro.Telefone}');";
                    cmd.Connection  = conn;
                    cmd.CommandText = query;
                    cmd.ExecuteNonQuery();
                }
            }
        }
Example #24
0
        protected void EditRowButton_Click(Object sender, GridViewEditEventArgs e)
        {
            TableCell cell = gridView1.Rows[e.NewEditIndex].Cells[1];
            int       id   = Convert.ToInt32(cell.Text);

            Sindico e1 = new Sindico();

            e1.Id = id;
            Sindico sindico = e1.GetPorId(e1.Id);

            txId.Text           = Convert.ToString(sindico.Id);
            txIdEndereco.Text   = Convert.ToString(sindico.Id_endereco);
            txIdCondominio.Text = Convert.ToString(sindico.Id_condominio);
            txNome.Text         = sindico.Nome;
            txCPF.Text          = sindico.Cpf;
            txRg.Text           = sindico.Rg;
        }
Example #25
0
        public Sindico GetPorId(int id)
        {
            NpgsqlDataReader dataReader = base.GetPorId(id);
            Sindico          sindico    = new Sindico();

            if (dataReader.HasRows && dataReader.Read())
            {
                sindico.Id            = (int)dataReader[0];
                sindico.Id_endereco   = (int)dataReader[1];
                sindico.Id_condominio = (int)dataReader[2];
                sindico.Nome          = (String)dataReader[3];
                sindico.Cpf           = (String)dataReader[4];
                sindico.Rg            = (String)dataReader[5];
            }

            return(sindico);
        }
Example #26
0
        protected void EditRowButton_Click(Object sender, GridViewEditEventArgs e)
        {
            TableCell cell = gridView1.Rows[e.NewEditIndex].Cells[1];
            int       id   = Convert.ToInt32(cell.Text);

            /*
             * Obj
             * */
            Sindico obj = new Sindico().GetPorId(id);

            txId.Text = Convert.ToString(obj.Id);
            dlEndereco.DataValueField = Convert.ToString(obj.Id_endereco);
            txNome.Text = Convert.ToString(obj.Nome);
            txNome.Text = obj.Nome;
            txCPF.Text  = obj.Cpf;
            txRg.Text   = obj.Rg;
        }
Example #27
0
        // GET: Avisos
        public ActionResult Index()
        {
            Sindico usuario = AdminLar.Repositories.Funcoes.GetUsuario();

            if (usuario != null)
            {
                ViewBag.Data = DateTime.Now;

                DateTime expiro = DateTime.Now.AddDays(-1);

                return(View(db.Avisos.Include(p => p.Apartamento).Where(p => p.ApeId == usuario.ApeId && expiro < p.DataAviso).OrderBy(t => t.DataAviso)));
            }
            else
            {
                return(RedirectToAction("AcessoNegado", "Landing"));
            }
        }
Example #28
0
        public Sindico GetPorId(int id)
        {
            NpgsqlDataReader dataReader = base.GetPorId(id);
            Sindico          obj        = new Sindico();

            if (dataReader.HasRows && dataReader.Read())
            {
                obj = this.PreencherObjeto(dataReader);
            }

            /*
             * Fechando
             * */
            dataReader.Close();
            this.CloseCon();

            return(obj);
        }
Example #29
0
        public IActionResult Update(int id, [FromBody] Sindico item)
        {
            if (item == null || item.Id != id)
            {
                return(BadRequest());
            }

            var sindico = _context.Sindicos.FirstOrDefault(t => t.Id == id);

            if (sindico == null)
            {
                return(NotFound());
            }

            sindico.Nome = item.Nome;

            _context.Sindicos.Update(sindico);
            _context.SaveChanges();
            return(new NoContentResult());
        }
Example #30
0
        public ActionResult SalvaAviso(string dataaviso, string descricao)
        {
            Sindico usuario = AdminLar.Repositories.Funcoes.GetUsuario();

            if (usuario != null)
            {
                Aviso aviso = new Aviso();

                aviso.DataAviso = DateTime.Parse(dataaviso);
                aviso.Descricao = descricao;
                aviso.ApeId     = usuario.ApeId;

                db.Avisos.Add(aviso);

                if (db.SaveChanges() > 0)
                {
                    return(Json(true));
                }
            }

            return(Json(false));
        }