public IEnumerable <Imovel> GetAll([FromBody] FiltroViewModel filtro)
        {
            _imovelBLL = new ImovelBLL();
            var imoveis = _imovelBLL.GetAll(filtro);

            return(imoveis.ToArray());
        }
        public async Task <bool> UploadFile([FromForm] IFormFile file, [FromForm] int idImovel)
        {
            _imovelBLL = new ImovelBLL();
            try
            {
                if (file.Length > 0)
                {
                    var    filePath       = Directory.GetCurrentDirectory();
                    string filePathSalvar = "Resources\\img\\idImovel-" + idImovel;
                    filePath += "\\" + filePathSalvar;
                    DirectoryInfo di = Directory.CreateDirectory(filePath);

                    using (var stream = new FileStream(filePath + "\\" + file.FileName, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);

                        ImagensImovel ii = new ImagensImovel();
                        ii.dataInsert     = DateTime.Now;
                        ii.idImovelImagem = idImovel;
                        ii.name           = file.FileName;
                        ii.path           = filePathSalvar + "\\" + ii.name;
                        _imovelBLL.InsertFile(ii);
                    }
                    return(true);
                }
                return(false);
            } catch (Exception ex)
            {
                throw ex;
            }
        }
 public long Insert(ImovelViewModel i)
 {
     _imovelBLL   = new ImovelBLL();
     _enderecoBLL = new EnderecoBLL();
     if (i.idEndereco == 0)
     {
         long e = _enderecoBLL.Insert(RetornarEndereco(i.Endereco));
         i.idEndereco = (int)e;
     }
     return(_imovelBLL.Insert(i));
 }
 public IEnumerable <ImagensImovel> GetFiles(int id)
 {
     try
     {
         _imovelBLL = new ImovelBLL();
         return(_imovelBLL.GetImagens(id).ToArray());
     } catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool Delete(int id)
        {
            _imovelBLL = new ImovelBLL();
            var e     = _imovelBLL.Get(id);
            var files = _imovelBLL.GetImagens(e.idImovel).ToList();

            foreach (var f in files)
            {
                DeleteFIle(f);
            }
            return(_imovelBLL.Delete(e));
        }
 public bool DeleteFile([FromBody] ImagensImovel file)
 {
     _imovelBLL = new ImovelBLL();
     try
     {
         DeleteFIle(file);
         _imovelBLL.DeleteFile(file);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool Update([FromBody] ImovelViewModel i)
        {
            _imovelBLL = new ImovelBLL();
            var imovelAntigo = _imovelBLL.Get(i.idImovel);

            if (imovelAntigo.idEndereco != i.idEndereco)
            {
                _enderecoBLL = new EnderecoBLL();
                if (_enderecoBLL.Get(i.idEndereco) == null)
                {
                    _enderecoBLL.Insert(i.Endereco);
                }
            }

            return(_imovelBLL.Update(i));
        }
 public Imovel Get(int id)
 {
     _imovelBLL = new ImovelBLL();
     return(_imovelBLL.Get(id));
 }
Example #9
0
        protected void btConsultar_Click(object sender, ImageClickEventArgs e)
        {
            bool     isNum          = false;
            Int32    Num            = 0;
            decimal  nSomaPrincipal = 0;
            decimal  nSomaJuros     = 0;
            decimal  nSomaMulta     = 0;
            decimal  nSomaCorrecao  = 0;
            decimal  nSomaTotal     = 0;
            DateTime DataDAM;

            //    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Atenção!", "alert('Sistema em Manutenção!')", true);
            //      return;

            bGerado = false;
            String sTextoImagem = txtimgcode.Text;

            txtimgcode.Text       = "";
            Dados.StringDeConexao = ConfigurationManager.ConnectionStrings["GTIconnection"].ToString();

            lblmsg.Text  = "";
            lblMsg2.Text = "";

            if (optList.Items[0].Selected == true)
            {
                isNum = Int32.TryParse(txtCod.Text, out Num);
                if (!isNum)
                {
                    lblmsg.Text = "Código do imóvel inválido!";
                    return;
                }
                else
                {
                    Imovel reg = new Imovel();
                    reg.Codigo = Num;
                    ImovelBLL     imovel = new ImovelBLL();
                    List <Imovel> lst    = imovel.Listagem(reg, null);
                    if (lst.Count > 0)
                    {
                        lblEndereco.Text = lst[0].LogradouroNome + ", " + lst[0].Numero;
                        lblDoc.Text      = lst[0].BairroNome;
                        List <ProprietarioImovel> lstP = imovel.ListaProprietario(Num, true);
                        lblNome.Text = lstP[0].Nome;
                    }
                    else
                    {
                        lblmsg.Text = "Código do imóvel não cadastrado!";
                        return;
                    }
                }
            }
            else
            {
                if (optList.Items[1].Selected == true)
                {
                    isNum = Int32.TryParse(txtCod.Text, out Num);
                    if (!isNum)
                    {
                        lblmsg.Text = "Código da empresa inválido!";
                        return;
                    }
                    else
                    {
                        Empresa reg = new Empresa();
                        reg.Codigo = Num;
                        EmpresaBLL     empresa = new EmpresaBLL();
                        List <Empresa> lst     = empresa.Listagem(reg, null);
                        if (lst.Count > 0)
                        {
                            lblEndereco.Text = lst[0].RazaoSocial;
                            lblDoc.Text      = lst[0].LogradouroNome + ", " + lst[0].Numero;
                            lblNome.Text     = lst[0].BairroNome + " " + lst[0].CidadeNome + "/" + lst[0].UF;
                        }
                        else
                        {
                            lblmsg.Text = "Inscrição Municipal não cadastrada!";
                            return;
                        }
                    }
                }
                else
                {
                    if (optList.Items[2].Selected == true)
                    {
                        isNum = Int32.TryParse(txtCod.Text, out Num);
                        if (!isNum)
                        {
                            lblmsg.Text = "Código de contribuinte inválido!";
                            return;
                        }
                        else
                        {
                            if (Num < 500000 || Num > 700000)
                            {
                                lblmsg.Text = "Código de contribuinte inválido!";
                                return;
                            }
                            else
                            {
                                Cidadao reg = new Cidadao();
                                reg.Codigo = Num;
                                CidadaoBLL     cidadao = new CidadaoBLL();
                                List <Cidadao> lst     = cidadao.Listagem(reg, null);
                                if (lst.Count > 0)
                                {
                                    lblEndereco.Text = lst[0].LogradouroFora + ", " + lst[0].Numero;
                                    lblDoc.Text      = lst[0].NomeBairro + " - " + lst[0].NomeCidade + "/" + lst[0].NomeUF;
                                    lblNome.Text     = lst[0].Nome;
                                }
                                else
                                {
                                    lblmsg.Text = "Contribuinte não cadastrado!";
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            if (!DateTime.TryParse(txtVencto.Text, out DataDAM))
            {
                lblmsg.Text = "Data de vencimento inválida.";
                ShowResult(false);
                return;
            }
            else
            {
                String sDataVencto = txtVencto.Text;
                String sDataNow    = DateTime.Now.ToString("dd/MM/yyyy");
                if (DateTime.ParseExact(sDataVencto, "dd/MM/yyyy", null) < DateTime.ParseExact(sDataNow, "dd/MM/yyyy", null))
                {
                    lblmsg.Text = "Vencimento menor que a data atual.";
                    ShowResult(false);
                    return;
                }
                else
                {
                    Int32 DifDias = ((TimeSpan)(DataDAM - DateTime.Now)).Days;
                    if (DifDias > 30)
                    {
                        lblmsg.Text = "Vencimento máximo de 30 dias.";
                        ShowResult(false);
                        return;
                    }
                }
            }

            if (sTextoImagem.ToUpper() != this.Session["CaptchaImageText"].ToString().ToUpper())
            {
                lblmsg.Text = "Código da imagem inválido.";
                ShowResult(false);
                return;
            }
            else
            {
                ShowResult(true);
                lblmsg.Text  = "";
                lblMsg2.Text = "";
            }

            this.txtimgcode.Text = "";

            DebitoBLL     obj      = new DebitoBLL();
            String        sDataDAM = DataDAM.ToString("dd/MM/yyyy");
            List <Debito> debitos  = obj.Listagem(Num, DateTime.ParseExact(sDataDAM, "dd/MM/yyyy", null));
            List <Debito> debitos2 = new List <Debito>();

            foreach (var item in debitos)
            {
                //                if (item.Parcela != 0 && item.Situacao == 3) {
                if (item.Situacao == 3)
                {
                    bool bFind = false;
                    int  nPos  = 0;
                    foreach (var item2 in debitos2)
                    {
                        if (item2.Exercicio == item.Exercicio && item2.Lancamento == item.Lancamento && item2.Sequencia == item.Sequencia &&
                            item2.Parcela == item.Parcela && item2.Complemento == item.Complemento)
                        {
                            bFind = true;
                            break;
                        }
                        nPos += 1;
                    }
                    if (bFind)
                    {
                        debitos2[nPos].VlTributo  += item.VlTributo;
                        debitos2[nPos].VlJuros    += item.VlJuros;
                        debitos2[nPos].VlMulta    += item.VlMulta;
                        debitos2[nPos].VlCorrecao += item.VlCorrecao;
                        debitos2[nPos].VlTotal    += item.VlTotal;
                    }
                    else
                    {
                        Debito reg = new Debito();
                        reg.Codigo         = item.Codigo;
                        reg.Exercicio      = item.Exercicio;
                        reg.Lancamento     = item.Lancamento;
                        reg.DescLancamento = item.DescLancamento;
                        reg.Sequencia      = item.Sequencia;
                        reg.Parcela        = item.Parcela;
                        reg.Complemento    = item.Complemento;
                        reg.DtVencimento   = item.DtVencimento;
                        reg.Situacao       = item.Situacao;
                        reg.VlTributo      = item.VlTributo;
                        reg.VlJuros        = item.VlJuros;
                        reg.VlMulta        = item.VlMulta;
                        reg.VlCorrecao     = item.VlCorrecao;
                        reg.VlTotal        = item.VlTotal;
                        reg.DtAjuiza       = item.DtAjuiza;
                        debitos2.Add(reg);
                    }
                }
            }

            if (debitos2.Count == 0)
            {
                lblDoc.Text = "";
                lblmsg.Text = "Não existem débitos.";
                ShowResult(false);
                return;
            }

            DataTable dt = new DataTable();

            dt.Columns.AddRange(new DataColumn[12] {
                new DataColumn("Exercicio"), new DataColumn("Lancamento"), new DataColumn("Sequencia"),
                new DataColumn("Parcela"), new DataColumn("Complemento"), new DataColumn("DtVencimento"), new DataColumn("VlPrincipal"),
                new DataColumn("VlJuros"), new DataColumn("VlMulta"), new DataColumn("VlCorrecao"), new DataColumn("VlTotal"), new DataColumn("DtAjuiza")
            });

            foreach (var item in debitos2)
            {
                dt.Rows.Add(item.Exercicio.ToString(), item.Lancamento.ToString("000") + "-" + item.DescLancamento.ToString(), item.Sequencia.ToString(),
                            item.Parcela.ToString(), item.Complemento.ToString(), item.DtVencimento.ToString("dd/MM/yyyy"),
                            item.VlTributo.ToString("#0.00"), item.VlJuros.ToString("#0.00"), item.VlMulta.ToString("#0.00"),
                            item.VlCorrecao.ToString("#0.00"), item.VlTotal.ToString("#0.00"), item.DtAjuiza == DateTime.MinValue ? "NÃO" : "SIM");
                nSomaPrincipal += (decimal)item.VlTributo;
                nSomaJuros     += (decimal)item.VlJuros;
                nSomaMulta     += (decimal)item.VlMulta;
                nSomaCorrecao  += (decimal)item.VlCorrecao;
                nSomaTotal     += (decimal)item.VlTotal;
            }

            grdMain.DataSource = dt;
            grdMain.DataBind();

            TableTotal.Rows[1].Cells[2].Text = nSomaPrincipal.ToString("#0.00");
            TableTotal.Rows[1].Cells[3].Text = nSomaMulta.ToString("#0.00");
            TableTotal.Rows[1].Cells[4].Text = nSomaJuros.ToString("#0.00");
            TableTotal.Rows[1].Cells[5].Text = nSomaCorrecao.ToString("#0.00");
            TableTotal.Rows[1].Cells[6].Text = nSomaTotal.ToString("#0.00");

            TableTotal.Rows[2].Cells[2].Text  = "0,00";
            TableTotal.Rows[2].Cells[3].Text  = "0,00";
            TableTotal.Rows[2].Cells[4].Text  = "0,00";
            TableTotal.Rows[2].Cells[5].Text  = "0,00";
            TableTotal.Rows[2].Cells[6].Text  = "0,00";
            TableResumo.Rows[0].Cells[1].Text = nValorTaxa.ToString("#0.00");
            TableResumo.Rows[1].Cells[1].Text = "0,00";
            TableResumo.Rows[2].Cells[1].Text = txtVencto.Text;
        }