protected void btAcesso_Click(object sender, EventArgs e)
        {
            lblMsg.Text = "";
            ClearTable();
            clsEmpresa empresa_class = new clsEmpresa();

            if (string.IsNullOrWhiteSpace(txtIM.Text) && string.IsNullOrWhiteSpace(txtCNPJ.Text))
            {
                lblMsg.Text = "Erro: Informação necessária.";
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(txtIM.Text) && !string.IsNullOrWhiteSpace(txtCNPJ.Text))
                {
                    lblMsg.Text = "Erro: Digite a inscrição municipal ou o cnpj da empresa.";
                }

                else
                {
                    if (!string.IsNullOrWhiteSpace(txtIM.Text))
                    {
                        if (!empresa_class.ExisteEmpresa(Convert.ToInt32(txtIM.Text)))
                        {
                            lblMsg.Text = "Erro: Cadastro inexistente.";
                        }
                        else
                        {
                            FillTable();
                        }
                    }
                    else
                    {
                        string sCnpj   = txtCNPJ.Text.PadLeft(14, '0');
                        int    nCodigo = empresa_class.ExisteEmpresaCnpj(sCnpj);
                        if (!string.IsNullOrWhiteSpace(sCnpj) && nCodigo == 0)
                        {
                            lblMsg.Text = "Erro: Cadastro inexistente.";
                        }
                        else
                        {
                            txtIM.Text = nCodigo.ToString("000000");
                            FillTable();
                        }
                    }
                }
            }
        }
示例#2
0
        protected void btPrint_Click(object sender, EventArgs e) {
            int Num = 0;
            String sTextoImagem = txtimgcode.Text;
            txtimgcode.Text = "";

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

            clsEmpresa Empresa_class = new clsEmpresa();
            bool isNum = Int32.TryParse(txtCod.Text, out Num);
            if (!isNum) {
                lblmsg.Text = "Inscrição Municipal inválida!";
                return;
            } else {
                bool bExiste = Empresa_class.ExisteEmpresa(Num);
                if (!bExiste) {
                    lblmsg.Text = "Inscrição Municipal inválida!";
                    return;
                }
            }

            SilStructure Sil = Empresa_class.CarregaSil(Num);

            if (Sil.Codigo == 0) {
                lblmsg.Text = "Solicitação inválida!";
                return;}
            else if (Sil.Protocolo == null) {
                lblmsg.Text = "Solicitação inválida!";
                return; } 
            else if (Sil.Data_Validade < DateTime.Now) {
                lblmsg.Text = "Solicitação inválida!";
                return;
            }
           

            lblmsg.Text = "";
            this.txtimgcode.Text = "";
            EmiteAlvara(Num);
        }
示例#3
0
        protected void btConsultar_Click(object sender, ImageClickEventArgs e)
        {
            bool     isNum          = false;
            int      Num            = 0;
            decimal  nSomaPrincipal = 0;
            decimal  nSomaJuros     = 0;
            decimal  nSomaMulta     = 0;
            decimal  nSomaCorrecao  = 0;
            decimal  nSomaTotal     = 0;
            string   num_cpf_cnpj   = "";
            DateTime DataDAM;

            bGerado = false;
            String sTextoImagem = txtimgcode.Text;

            txtimgcode.Text = "";

            lblmsg.Text      = "";
            lblMsg2.Text     = "";
            lblNome.Text     = "";
            lblDoc.Text      = "";
            lblEndereco.Text = "";
            lblValidate.Text = "";


            if (optCPF.Checked && txtCPF.Text.Length < 14)
            {
                lblmsg.Text = "CPF inválido!";
                ShowResult(false);
                return;
            }
            if (optCNPJ.Checked && txtCNPJ.Text.Length < 18)
            {
                lblmsg.Text = "CNPJ inválido!";
                ShowResult(false);
                return;
            }

            if (optCPF.Checked)
            {
                num_cpf_cnpj = gtiCore.RetornaNumero(txtCPF.Text);
                if (!gtiCore.ValidaCpf(num_cpf_cnpj))
                {
                    lblmsg.Text = "CPF inválido!";
                    ShowResult(false);
                    return;
                }
            }
            else
            {
                num_cpf_cnpj = gtiCore.RetornaNumero(txtCNPJ.Text);
                if (!gtiCore.ValidaCNPJ(num_cpf_cnpj))
                {
                    lblmsg.Text = "CNPJ inválido!";
                    ShowResult(false);
                    return;
                }
            }


            if (optList.Items[0].Selected == true)
            {
                isNum = int.TryParse(txtCod.Text, out Num);
                if (!isNum)
                {
                    lblmsg.Text = "Código do imóvel inválido!";
                    ShowResult(false);
                    return;
                }
                else
                {
                    clsImovel imovel_class = new clsImovel();
                    bool      bFind        = imovel_class.ExisteImovel(Num);
                    if (bFind)
                    {
                        ImovelStruct reg = imovel_class.LoadReg(Num);
                        List <ProprietarioStruct> regProp = imovel_class.ListaProprietario(Num, true);

                        lblEndereco.Text = reg.NomeLogradouro + ", " + reg.Numero + " " + reg.Complemento;
                        lblDoc.Text      = reg.NomeBairro;
                        lblNome.Text     = regProp[0].Nome;
                        if (optCPF.Checked)
                        {
                            if (Convert.ToInt64(gtiCore.RetornaNumero(regProp[0].CPF)).ToString("00000000000") != num_cpf_cnpj)
                            {
                                lblmsg.Text = "CPF não pertence ao proprietário deste imóvel!";
                                ShowResult(false);
                                return;
                            }
                        }
                        else
                        {
                            if (Convert.ToInt64(gtiCore.RetornaNumero(regProp[0].CPF)).ToString("00000000000000") != num_cpf_cnpj)
                            {
                                lblmsg.Text = "CNPJ não pertence ao proprietário deste imóvel!";
                                ShowResult(false);
                                return;
                            }
                        }
                    }
                    else
                    {
                        lblmsg.Text = "Código do imóvel não cadastrado!";
                        ShowResult(false);
                        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!";
                        ShowResult(false);
                        return;
                    }
                    else
                    {
                        clsEmpresa empresa_class = new clsEmpresa();
                        bool       bFind         = empresa_class.ExisteEmpresa(Num);
                        if (bFind)
                        {
                            EmpresaStruct reg = empresa_class.LoadReg(Num);
                            lblEndereco.Text = reg.Endereco + ", " + reg.Numero + " " + reg.Complemento;
                            lblDoc.Text      = reg.NomeBairro;
                            lblNome.Text     = reg.RazaoSocial;

                            if (optCPF.Checked)
                            {
                                if (Convert.ToInt64(gtiCore.RetornaNumero(reg.cpf_cnpj)).ToString("00000000000") != num_cpf_cnpj)
                                {
                                    lblmsg.Text = "CPF não pertence ao proprietário deste imóvel!";
                                    ShowResult(false);
                                    return;
                                }
                            }
                            else
                            {
                                if (Convert.ToInt64(gtiCore.RetornaNumero(reg.cpf_cnpj)).ToString("00000000000000") != num_cpf_cnpj)
                                {
                                    lblmsg.Text = "CNPJ não pertence ao proprietário deste imóvel!";
                                    ShowResult(false);
                                    return;
                                }
                            }
                        }
                        else
                        {
                            lblmsg.Text = "Inscrição Municipal não cadastrada!";
                            ShowResult(false);
                            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!";
                            ShowResult(false);
                            return;
                        }
                        else
                        {
                            if (Num < 500000 || Num > 700000)
                            {
                                lblmsg.Text = "Código de contribuinte inválido!";
                                ShowResult(false);
                                return;
                            }
                            else
                            {
                                clsCidadao cidadao_class = new clsCidadao();
                                bool       bFind         = cidadao_class.ExisteCidadao(Num);
                                if (bFind)
                                {
                                    CidadaoStruct reg = cidadao_class.LoadReg(Num);
                                    if (reg.EtiquetaR != null && reg.EtiquetaR == "S")
                                    {
                                        lblEndereco.Text = reg.EnderecoR + ", " + reg.NumeroR + " " + reg.ComplementoR;
                                        lblDoc.Text      = reg.NomeBairroR;
                                    }
                                    else
                                    {
                                        lblEndereco.Text = reg.EnderecoC + ", " + reg.NumeroC + " " + reg.ComplementoC;
                                        lblDoc.Text      = reg.NomeBairroC;
                                    }
                                    lblNome.Text = reg.Nome;

                                    if (optCPF.Checked)
                                    {
                                        if (Convert.ToInt64(gtiCore.RetornaNumero(reg.Cpf)).ToString("00000000000") != num_cpf_cnpj)
                                        {
                                            lblmsg.Text = "CPF não pertence ao proprietário deste imóvel!";
                                            ShowResult(false);
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        if (Convert.ToInt64(gtiCore.RetornaNumero(reg.Cnpj)).ToString("00000000000000") != num_cpf_cnpj)
                                        {
                                            lblmsg.Text = "CNPJ não pertence ao proprietário deste imóvel!";
                                            ShowResult(false);
                                            return;
                                        }
                                    }
                                }
                                else
                                {
                                    lblmsg.Text = "Contribuinte não cadastrado!";
                                    ShowResult(false);
                                    return;
                                }
                            }
                        }
                    }
                }
            }

            if (!DateTime.TryParse(lblVenctoDam.Text, out DataDAM))
            {
                lblmsg.Text = "Data de vencimento inválida.";
                ShowResult(false);
                return;
            }
            else
            {
                String sDataVencto = lblVenctoDam.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 = "";

            String    sDataDAM              = DataDAM.ToString("dd/MM/yyyy");
            clsDebito debito_class          = new clsDebito();
            List <DebitoStructure> debitos  = debito_class.Extrato(Num, 1990, 2050, 0, 99, 0, 99, 0, 999, 0, 99, 0, 99, DateTime.ParseExact(sDataDAM, "dd/MM/yyyy", null), 0);
            List <DebitoStructure> debitos2 = new List <DebitoStructure>();

            foreach (var item in debitos)
            {
                if (item.Codigo_Situacao == 3 || item.Codigo_Situacao == 19 || item.Codigo_Situacao == 38 || item.Codigo_Situacao == 39)
                {
                    DebitoStructure reg = new DebitoStructure();
                    reg.Codigo_Reduzido      = item.Codigo_Reduzido;
                    reg.Ano_Exercicio        = item.Ano_Exercicio;
                    reg.Codigo_Lancamento    = Convert.ToInt16(item.Codigo_Lancamento);
                    reg.Descricao_Lancamento = item.Descricao_Lancamento;
                    reg.Sequencia_Lancamento = Convert.ToInt16(item.Sequencia_Lancamento);
                    reg.Numero_Parcela       = Convert.ToInt16(item.Numero_Parcela);
                    reg.Complemento          = item.Complemento;
                    reg.Data_Vencimento      = Convert.ToDateTime(item.Data_Vencimento);
                    reg.Codigo_Situacao      = Convert.ToInt16(item.Codigo_Situacao);
                    reg.Soma_Principal       = item.Soma_Principal;
                    reg.Soma_Juros           = item.Soma_Juros;
                    reg.Soma_Multa           = item.Soma_Multa;
                    reg.Soma_Correcao        = item.Soma_Correcao;
                    reg.Soma_Total           = item.Soma_Total;
                    reg.Data_Ajuizamento     = item.Data_Ajuizamento;

                    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[13] {
                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"), new DataColumn("Protesto")
            });

            foreach (var item in debitos2)
            {
                dt.Rows.Add(item.Ano_Exercicio.ToString(), item.Codigo_Lancamento.ToString("000") + "-" + item.Descricao_Lancamento.ToString(), item.Sequencia_Lancamento.ToString(),
                            item.Numero_Parcela.ToString(), item.Complemento.ToString(), Convert.ToDateTime(item.Data_Vencimento).ToString("dd/MM/yyyy"),
                            item.Soma_Principal.ToString("#0.00"), item.Soma_Juros.ToString("#0.00"), item.Soma_Multa.ToString("#0.00"),
                            item.Soma_Correcao.ToString("#0.00"), item.Soma_Total.ToString("#0.00"), item.Data_Ajuizamento == DateTime.MinValue ? "NÃO" : "SIM", item.Codigo_Situacao == 38 | item.Codigo_Situacao == 39 ? "SIM" : "NÃO");
                nSomaPrincipal += (decimal)item.Soma_Principal;
                nSomaJuros     += (decimal)item.Soma_Juros;
                nSomaMulta     += (decimal)item.Soma_Multa;
                nSomaCorrecao  += (decimal)item.Soma_Correcao;
                nSomaTotal     += (decimal)item.Soma_Total;
            }

            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 = "0,00";
            TableResumo.Rows[1].Cells[1].Text = lblVenctoDam.Text;
        }