Example #1
0
    public static DataSet PegaDadosContatoDevedores(string xcbproduto,
                                                    string xcbprodutogrupo,
                                                    string xdtprevisao1)
    {
        string script;

        //
        if (xdtprevisao1 == "01/01/1900")
        {
            script = "SELECT * FROM Contato C WHERE 1 = 1 ";
            //
            if (xcbproduto.Trim() != string.Empty)
            {
                script = script + " AND exists(SELECT * FROM VENDAS V WHERE V.CLIENTE = C.ID AND V.PRODUTO = " +
                         Srelib.QStr(xcbproduto) + " ";
                //
                if (xcbprodutogrupo.Trim() != string.Empty)
                {
                    script = script + " AND V.GRUPO = " +
                             Srelib.QStr(xcbprodutogrupo) + " ";
                }
                script = script + " ) ";
            }

            script = script + " ORDER BY nome ";
        }
        else
        {
            script = "SELECT * FROM Contato C WHERE 1 = 1 ";
            //
            if (xcbproduto.Trim() != string.Empty)
            {
                //
                string nomearquivo = "parcelas_" + Srelib.QStr0(xcbproduto.Trim(), 5) + "_" + Srelib.QStr0(xcbprodutogrupo.Trim(), 5);
                //
                script = script + " AND exists(SELECT * FROM " + nomearquivo + " P WHERE 1 = 1 ";
                script = script + " AND P.DATA_VENCIMENTO <= " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao1)) +
                         " AND P.DATA_PAGAMENTO = " + Srelib.QStr(Srelib.DataAmericanasembarra("01/01/1900"));
                script = script + " ) ";
                //
            }

            script = script + " ORDER BY C.nome ";
        }

        return(SreDblib.GetDsScript(script));
    }
Example #2
0
 protected void cbgrupounidades_SelectedIndexChanged(object sender, EventArgs e)
 {
     //
     if (cbproduto.Text != string.Empty)
     {
         if (cbgrupo.Text != string.Empty)
         {
             if (cbgrupounidades.Text != string.Empty)
             {
                 //Cliente
                 string grupounidades = cbgrupounidades.Text;
                 string parte         = grupounidades.Substring(grupounidades.IndexOf("-") + 1).Trim();
                 if (parte != "0")
                 {
                     rbmeiolote.Enabled = true;
                     rbmeiolote.Visible = true;
                 }
                 else
                 {
                     rbmeiolote.Enabled = false;
                     rbmeiolote.Visible = false;
                 }
                 string IDCliente = uUnidade.PegaIDCliente(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte, "1");
                 edcliente.Text    = Srelib.QStr0(IDCliente.Trim(), 5) + " - " + uContato.PegaNomeID(IDCliente);
                 Label8.Visible    = true;
                 edcliente.Visible = true;
                 //
                 Label4.Visible  = true;
                 dtvenda.Visible = true;
                 dtvenda.Value   = uVendas.PegaDataVenda(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), "0");
                 //
                 Label13.Visible           = true;
                 rbparcelasituacao.Visible = true;
                 //
                 rbparcelasituacao_SelectedIndexChanged(sender, e);
                 //
             }
             else
             {
                 rbmeiolote.Visible = false;
                 Label8.Visible     = false;
                 edcliente.Visible  = false;
                 //
             }
         }
     }
 }
Example #3
0
    public static ASPxComboBox MontaComboModulos(ASPxComboBox pCombo, Boolean pExibeValor)
    {
        //Documentação - Chamada da Função
        //
        //uPermissoes.MontaComboModulos(ASPxComboBox1);
        //
        //Fim Documentação - Chamada da Função

        String[] modulos = new String[14] {
            "AJUDA",
            "EMPRESA",
            "CLIENTES",
            "OBRAS",
            "PRODUTOS",
            "PROPOSTAS",
            "VENDAS",
            "A PAGAR",
            "A RECEBER",
            "BANCOS",
            "FLUXO DE CAIXA",
            "CONTÁBIL",
            "JURIDICO",
            "CONFIG"
        };

        ListEditItem le;

        pCombo.Items.Clear();

        for (int i = 0; i <= 13; i++)
        {
            //
            le = new ListEditItem();
            if (pExibeValor)
            {
                le.Text = Srelib.QStr0(i.ToString().Trim(), 2) + " - " + modulos[i];
            }
            else
            {
                le.Text = modulos[i];
            };
            le.Value = i;
            pCombo.Items.Add(le);
        }

        return(pCombo);
    }
 protected void cbgrupounidades2_SelectedIndexChanged(object sender, EventArgs e)
 {
     //
     if (cbproduto2.Text != string.Empty)
     {
         if (cbgrupo2.Text != string.Empty)
         {
             if (cbgrupounidades2.Text != string.Empty)
             {
                 //Cliente
                 string grupounidades2 = cbgrupounidades2.Text;
                 string parte2         = grupounidades2.Substring(grupounidades2.IndexOf("-") + 1).Trim();
                 if (parte2 != "0")
                 {
                     rbmeiolote2.Enabled = true;
                     rbmeiolote2.Visible = true;
                 }
                 else
                 {
                     rbmeiolote2.Enabled = false;
                     rbmeiolote2.Visible = false;
                 }
                 //
                 if (rbtipodestino.SelectedIndex == 1)
                 {
                     string IDCliente2 = uUnidade.PegaIDCliente(cbproduto2.Value.ToString(), cbgrupo2.Value.ToString(), cbgrupounidades2.Value.ToString(), parte2, "1");
                     edcliente2.Text = Srelib.QStr0(IDCliente2.Trim(), 5) + " - " + uContato.PegaNomeID(IDCliente2);
                     //Cliente
                     Label11.Visible    = true;
                     edcliente2.Visible = true;
                 }
                 //
                 //Feedback
                 edfeedback.Text    = "Clique no Botão Processar para efetuar a Permuta!";
                 btprocessa.Enabled = true;
                 //
             }
             else
             {
                 //Feedback
                 edfeedback.Text    = "Selecione a Unidade Destino!";
                 btprocessa.Enabled = false;
                 //
             }
         }
     }
 }
Example #5
0
    public static String Grava(string xmes,
                               string xano,
                               string xscript)
    {
        if ((xmes != String.Empty) && (xano != String.Empty))
        {
            string script = "INSERT INTO TAXAS_MENSAIS VALUES ( " +
                            Srelib.QStr0(xmes, 2) +
                            ", " + Srelib.QStr(Srelib.QStr0(xano, 4)) + xscript +
                            " ) ";

            //" where nome=" + Rgblib.QStr(pParametro);

            SreDblib.ExecScript(script);
        }
        return(" ");
    }
Example #6
0
    public static String ExcluiLancamentos(string xcodigoconta,
                                           string xdtperiodo1,
                                           string xdtperiodo2)
    {
        string nomeconta = "conta_" + Srelib.QStr0(xcodigoconta.Trim(), 5);
        //

        string script = "DELETE " + nomeconta + " where " +
                        " (data between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo1)) +
                        " and " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo2)) + " ) ";



        SreDblib.ExecScript(script);

        return(" ");
    }
Example #7
0
    public static String GravaLancamento(string xcodigo_conta,
                                         string xlancamento,
                                         string xproduto,
                                         string xclasse,
                                         string xpedido_compra,
                                         string xdata,
                                         string xdescricao,
                                         string xcomplemento,
                                         string xsaldo_i,
                                         string xcredito,
                                         string xdebito,
                                         string xsaldo_f,
                                         string xsaldo_aplicacaoD,
                                         string xsaldo_aplicacaoB,
                                         string xsaldo_total,
                                         string xcheque,
                                         string xcmc7,
                                         string xdtregistro)
    {
        if (xcodigo_conta != String.Empty)
        {
            string script = "INSERT INTO conta_" + Srelib.QStr0(xcodigo_conta.Trim(), 5) + " VALUES ( " +
                            Srelib.QStr(xcodigo_conta) +
                            ", " + Srelib.QStr(xlancamento) +
                            ", " + Srelib.QStr(xproduto) +
                            ", " + Srelib.QStr(xclasse) +
                            ", " + Srelib.QStr(xpedido_compra) +
                            ", " + Srelib.QStr(Srelib.DataAmericanasembarra(xdata)) +
                            ", " + Srelib.QStr(xdescricao) +
                            ", " + Srelib.QStr(xcomplemento) +
                            ", " + Srelib.forcaponto(xsaldo_i) +
                            ", " + Srelib.forcaponto(xcredito) +
                            ", " + Srelib.forcaponto(xdebito) +
                            ", " + Srelib.forcaponto(xsaldo_f) +
                            ", " + Srelib.forcaponto(xsaldo_aplicacaoD) +
                            ", " + Srelib.forcaponto(xsaldo_aplicacaoB) +
                            ", " + Srelib.forcaponto(xsaldo_total) +
                            ", " + Srelib.QStr(xcheque) +
                            ", " + Srelib.QStr(xcmc7) +
                            ", " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtregistro)) +
                            " ) ";

            SreDblib.ExecScript(script);
        }
        return(" ");
    }
Example #8
0
    public static String PegaSaldoInicialsaldo_aplicacaoB(string xcodigoconta)
    {
        string script = "select saldo_aplicacaoB from contas_saldo_inicial " +
                        " with(nolock) " +
                        " where cod_conta = " + Srelib.QStr0(xcodigoconta.Trim(), 5);
        string retorno = "";

        try
        {
            retorno = SreDblib.GetCampoScript(script);
        }
        catch (Exception)
        {
            retorno = "0.00";
        }
        return(retorno);
    }
Example #9
0
    public static String PegaComplemento(string xcodigoconta)
    {
        string script = "select complemento from contas " +
                        " with(nolock) " +
                        " where ID = " + Srelib.QStr0(xcodigoconta.Trim(), 5);
        string retorno = "";

        try
        {
            retorno = SreDblib.GetCampoScript(script);
        }
        catch (Exception)
        {
            retorno = "";
        }
        return(retorno);
    }
Example #10
0
    public static DateTime PegaDataInicial(string xcodigoconta)
    {
        string script = "select data from contas_saldo_inicial " +
                        " with(nolock) " +
                        " where cod_conta = " + Srelib.QStr0(xcodigoconta.Trim(), 5);
        //
        DateTime retorno = Convert.ToDateTime("01/01/1900");

        try
        {
            retorno = Convert.ToDateTime(SreDblib.GetCampoScript(script));
        }
        catch (Exception)
        {
            retorno = Convert.ToDateTime("01/01/1900");
        }
        return(retorno);
    }
Example #11
0
    public static String PegaSaldoInicialDataMigracao(string xcodigo_conta)
    {
        string script = "select top 1 data from conta_" + Srelib.QStr0(xcodigo_conta.Trim(), 5) +
                        " with(nolock) order by data ";
        string retorno = "";

        try
        {
            retorno = SreDblib.GetCampoScript(script);
            if (retorno.Trim() == String.Empty)
            {
                retorno = "01/01/1900";
            }
        }
        catch (Exception)
        {
            retorno = "01/01/1900";
        }
        return(retorno);
    }
Example #12
0
    public static DataSet PegaDadosConta(string xcodigoconta,
                                         string xdataini,
                                         string xdatafim)
    {
        string script      = "";
        string nomearquivo = "conta_" + Srelib.QStr0(xcodigoconta.Trim(), 5);

        script = "SELECT *, (saldo_f+saldo_aplicacaoD+saldo_aplicacaoB) saldo_finalaplicacao FROM " + nomearquivo + " WITH(NOLOCK) ";
        script = script + " WHERE ";
        //Conta
        script = script + " ( cod_conta = " + Srelib.QStr(xcodigoconta) + ") ";
        //Data Prevista
        script = script + " AND ";
        script = script + " (data between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdataini)) + " and " +
                 Srelib.QStr(Srelib.DataAmericanasembarra(xdatafim)) + ") ";
        //script = script + " (data >= " + Srelib.QStr(Srelib.DataAmericanasembarra(xdataini));
        //script = script + " and data <= " + Srelib.QStr(Srelib.DataAmericanasembarra(xdatafim)) + ") ";

        //Data Nota Fiscal
        script = script + " order by data ";


        return(SreDblib.GetDsScript(script));
    }
Example #13
0
    public static DataSet PegaDadosContatoProduto(string xcbproduto,
                                                  string xcbprodutogrupo,
                                                  string xdtprevisao1)
    {
        string script;

        //
        if (xdtprevisao1 == "01/01/1900")
        {
            script = "SELECT * FROM Contato C WITH(NOLOCK) WHERE 1 = 1 ";
            //
            if (xcbproduto != string.Empty)
            {
                script = script + " AND exists(SELECT * FROM VENDAS V WHERE V.CLIENTE = C.ID AND V.PRODUTO = " +
                         Srelib.QStr(xcbproduto) + " ";
                //
                if (xcbprodutogrupo != string.Empty)
                {
                    script = script + " AND V.GRUPO = " +
                             Srelib.QStr(xcbprodutogrupo) + " ";
                }
                script = script + " ) ";
            }

            script = script + " ORDER BY nome ";
        }
        else
        {
            script = "SELECT * FROM Contato C WITH(NOLOCK) WHERE 1 = 1 ";
            //
            if (xcbproduto != string.Empty)
            {
                script = script + " AND exists(SELECT * FROM VENDAS V WHERE V.CLIENTE = C.ID AND V.PRODUTO = " +
                         Srelib.QStr(xcbproduto) + " ";
                //
                if (xcbprodutogrupo != string.Empty)
                {
                    script = script + " AND V.GRUPO = " +
                             Srelib.QStr(xcbprodutogrupo) + " ";
                    //
                    string nomearquivo = "parcelas_" + Srelib.QStr0(xcbproduto.Trim(), 5) + "_" + Srelib.QStr0(xcbprodutogrupo.Trim(), 5);
                    script = script + " AND exists(SELECT * FROM " + nomearquivo + " P WHERE P.PRODUTO = " +
                             Srelib.QStr(xcbproduto) +
                             " AND P.GRUPO = " + Srelib.QStr(xcbprodutogrupo);
                }


                script = script + " ) ";
            }

            script = script + " ORDER BY nome ";
        }

        return(SreDblib.GetDsScript(script));
    }
Example #14
0
    public static ASPxComboBox MontaComboPermissoes(ASPxComboBox pCombo, string pmodulo)
    {
        //Monta Combo de Todas as Permissões Cadastradas
        //return SreDblib.MontaComboPermissoes(pCombo, pmodulo);
        //
        string  pTabela     = "cadpermissoes";
        string  pCampoExibe = "descricao";
        string  pCampoValor = "permissao";
        Boolean pExibeValor = true;
        string  pWhere      = "";

        string script = "";

        script = " select c.Permissao, c.Descricao from cadpermissoes c WITH(NOLOCK) ";
        if (pmodulo != "")
        {
            switch (pmodulo)
            {
            case "PROPOSTAS":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.001") + "  ";
                break;

            case "CLIENTES":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.002") + "  ";
                break;

            case "PRODUTOS":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.003") + "  ";
                break;

            case "VENDAS":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.004") + "  ";
                break;

            case "PAGAMENTOS":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.005") + "  ";
                break;

            case "A PAGAR":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.006") + "  ";
                break;

            case "A RECEBER":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.007") + "  ";
                break;

            case "BANCOS":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.008") + "  ";
                break;

            case "FLUXO DE CAIXA":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.009") + "  ";
                break;

            case "CONTÁBIL":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.010") + "  ";
                break;

            case "CONFIG":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.011") + "  ";
                break;

            case "AJUDA":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.012") + "  ";
                break;

            case "EMPRESA":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.013") + "  ";
                break;

            case "JURIDICO":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.014") + "  ";
                break;

            case "OBRAS":
                script = script +
                         " where substring(c.Permissao,0,8) = " + Srelib.QStr("001.015") + "  ";
                break;
            }
        }
        //
        script = script + " order by c.Permissao ";
        //
        DataSet      ds = SreDblib.GetDsScript(script);
        ListEditItem le;

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            le = new ListEditItem();
            if (pExibeValor)
            {
                le.Text = Srelib.QStr0(dr[pCampoValor].ToString().Trim(), 5) + " - " + dr[pCampoExibe].ToString();
            }
            else
            {
                le.Text = dr[pCampoExibe].ToString();
            };
            le.Value = dr[pCampoValor].ToString();
            pCombo.Items.Add(le);
        }
        return(pCombo);
    }
    protected void btcarrega_Click(object sender, EventArgs e)
    {
        Boolean lOk = true;
        string  tst = "";
        DataSet parcela;
        string  contaproduto   = uProduto.PegaProdutoConta(Convert.ToInt16(cbproduto.Value));
        string  descricaoconta = "";
        Double  totalparcelas  = 0;
        Int32   qtdparcelas    = 0;

        //
        if (lOk)
        {
            //Parcelas
            tst = "";
            List <object> Listagem = GridListagem.GetSelectedFieldValues(new string[] { "ID" });
            if (Listagem.Count > 0)
            {
                foreach (Int32 xval in Listagem)
                {
                    if (tst != "")
                    {
                        tst = tst + ",";
                    }
                    tst = tst + Convert.ToString(xval);
                }
            }
            else
            {
                lOk = false;
                //ScriptManager.RegisterStartupScript(UpdatePanel, GetType(), "msgbox", "alert('Parcelas Não Selecionadas!');", true);
                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), Guid.NewGuid().ToString(),
                                                    "toastr.info('Parcelas Não Selecionadas!', 'Atenção!')", true);
            }
            //
        }

        if (lOk)
        {
            //Cliente
            string grupounidades = cbgrupounidades.Text;
            string parte         = grupounidades.Substring(grupounidades.IndexOf("-") + 1).Trim();
            string meiolote      = "1";
            if (parte != "0")
            {
                if (rbmeiolote.SelectedIndex == 0)
                {
                    meiolote = "1";
                }
                else
                {
                    meiolote = "2";
                }
            }
            //Carregar Dados
            edvlr_parcela.Text  = "0,00";
            eddtpagamento.Value = DateTime.Now;
            edfeedback.Text     = "";
            //
            edvlr_parcela.Enabled = false;
            eddtpagamento.Enabled = true;
            edfeedback.Enabled    = true;
            //
            Label5.Visible            = true;
            edvlr_parcela.Visible     = true;
            Label11.Visible           = true;
            edqtdparcelas.Visible     = true;
            Label6.Visible            = true;
            edvlr_pagamento.Visible   = true;
            edvlr_diferenca.Visible   = true;
            edperc_diferenca.Visible  = true;
            Label10.Visible           = true;
            Label9.Visible            = true;
            eddtpagamento.Visible     = true;
            Label21.Visible           = true;
            cbformapagamento.Visible  = true;
            Label22.Visible           = true;
            cbcontascorrentes.Visible = true;
            Label24.Visible           = true;
            edfeedback.Visible        = true;
            //
            uParcelas.MontaComboFormaPagamento(cbformapagamento, false);
            uContas.MontaComboContas(cbcontascorrentes, "0");
            //
            descricaoconta         = uContas.PegaContaDescricaoSimples(contaproduto);
            cbcontascorrentes.Text = Srelib.QStr0(contaproduto.ToString().Trim(), 5) + " - " + descricaoconta;
            //
            if (parte == "0")
            {
                parcela = uParcelas.PegaDadosParcelaID(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte, tst);
            }
            else
            {
                parcela = uParcelas.PegaDadosParcelaID(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), meiolote, tst);
            }
            //
            totalparcelas = 0;
            qtdparcelas   = 0;
            for (int i = 0; i < parcela.Tables[0].Rows.Count; i++)
            {
                totalparcelas = totalparcelas + Convert.ToDouble(parcela.Tables[0].Rows[0]["vlr_parcela"]);
                qtdparcelas++;
            }
            edvlr_parcela.Text    = totalparcelas.ToString();
            edvlr_pagamento.Text  = totalparcelas.ToString();
            edqtdparcelas.Text    = qtdparcelas.ToString();
            edvlr_diferenca.Text  = "0";
            edperc_diferenca.Text = "0";
            //
            btprocessa.Enabled = true;
            //
            edfeedback.Text = "Parcelas Totalizadas, preencha dos campos e clique no Botão Processar.";
            //
            edvlr_pagamento.Focus();
            //
        }
    }
    protected void rbmeiolote_SelectedIndexChanged(object sender, EventArgs e)
    {
        //
        //Cliente
        string grupounidades = cbgrupounidades.Text;
        string parte         = grupounidades.Substring(grupounidades.IndexOf("-") + 1).Trim();
        string meiolote      = "1";

        if (parte != "0")
        {
            if (rbmeiolote.SelectedIndex == 0)
            {
                meiolote = "1";
            }
            else
            {
                meiolote = "2";
            }
        }
        else
        {
            rbmeiolote.Enabled = false;
            rbmeiolote.Visible = false;
        }
        //
        string IDCliente = uUnidade.PegaIDCliente(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte, meiolote);

        edcliente.Text = Srelib.QStr0(IDCliente.Trim(), 5) + " - " + uContato.PegaNomeID(IDCliente);
        //Feedback
        string quest = parte;

        if (quest != "0")
        {
            quest = meiolote;
        }
        if (!uParcelas.TemParcelaAberto(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), quest))
        {
            edfeedback.Text    = "A Quitação ocorrerá se não existir parcelas em aberto. Clique no Botão Processa para efetuar a Quitação!";
            btprocessa.Enabled = true;
        }
        else
        {
            edfeedback.Text    = "Existem parcelas em aberto neste Financiamento, não é possível efetuar a Quitação!";
            btprocessa.Enabled = false;
        }
        Label8.Visible    = true;
        edcliente.Visible = true;
        //
        Label4.Visible     = true;
        edfeedback.Visible = true;
        //
        //
        if (uVendas.TemQuitacao(cbproduto.Value.ToString(),
                                cbgrupo.Value.ToString(),
                                cbgrupounidades.Value.ToString(),
                                parte))
        {
            Label42.Visible    = true;
            edfeedback.Text    = "Financiamento Quitado no Sistema!";
            btprocessa.Enabled = false;
        }
        else
        {
            Label42.Visible    = false;
            btprocessa.Enabled = true;
        }
        //
    }
Example #17
0
    public static String CriarTabelaContasCorrentes(string xcodigo)
    {
        //Criar Arquivo Contas Correntes individuais

        if (xcodigo != string.Empty)
        {
            //Cria nova tabela no SQL
            string nomeconta   = "conta_" + Srelib.QStr0(xcodigo.Trim(), 5);
            string script      = "";
            string script1     = "";
            string script2     = "";
            string script3     = "";
            string scriptconta = "";

            script1 = "CREATE TABLE [dbo].[";
            script2 = "](" +
                      "	[ID] [int] IDENTITY(1,1) NOT NULL," +
                      "	[cod_conta] [varchar](20) NOT NULL," +
                      "	[lancamento] [int] NOT NULL," +
                      "	[produto] [int] NULL," +
                      "	[classe] [int] NULL," +
                      "	[pedido_compra] [int] NOT NULL," +
                      "	[data] [datetime] NOT NULL," +
                      "	[descricao] [varchar](60) NULL," +
                      "	[complemento] [varchar](60) NULL," +
                      "	[saldo_i] [decimal](18, 2) NULL," +
                      "	[credito] [decimal](18, 2) NULL," +
                      "	[debito] [decimal](18, 2) NULL," +
                      "	[saldo_f] [decimal](18, 2) NULL," +
                      "	[saldo_aplicacaoD] [decimal](18, 2) NULL," +
                      "	[saldo_aplicacaoB] [decimal](18, 2) NULL," +
                      "	[saldo_total] [decimal](18, 2) NULL," +
                      "	[cheque] [varchar](20) NULL," +
                      "	[cmc7] [varchar](30) NULL," +
                      "	[dtregistro] [datetime] NOT NULL," +
                      " CONSTRAINT [PK_";
            script3 = "] PRIMARY KEY NONCLUSTERED " +
                      "(" +
                      "	[ID] ASC" +
                      ")WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR = 90) ON [PRIMARY]" +
                      ") ON [PRIMARY]";   // +
            //"GO";
            //
            scriptconta = scriptconta + nomeconta;

            //Criação da Tabela
            script = script1 + scriptconta + script2 + scriptconta + script3;
            //drop
            try
            {
                SreDblib.ExecScript("drop table dbo." + nomeconta);
            }
            catch (Exception)
            {
                //
            }
            //create
            try
            {
                SreDblib.ExecScript(script);
            }
            catch (Exception)
            {
                //
            }
        }
        //fim Cria nova tabela no SQL

        return(" ");
    }
Example #18
0
    protected void rbmeiolote_SelectedIndexChanged(object sender, EventArgs e)
    {
        //
        //Cliente
        string grupounidades = cbgrupounidades.Text;
        string parte         = grupounidades.Substring(grupounidades.IndexOf("-") + 1).Trim();
        string meiolote      = "1";

        if (parte != "0")
        {
            if (rbmeiolote.SelectedIndex == 0)
            {
                meiolote = "1";
            }
            else
            {
                meiolote = "2";
            }
        }
        else
        {
            rbmeiolote.Enabled = false;
            rbmeiolote.Visible = false;
        }
        //
        //
        if (cbproduto.Text != string.Empty)
        {
            if (cbgrupo.Text != string.Empty)
            {
                if (cbgrupounidades.Text != string.Empty)
                {
                    //Cliente
                    Label8.Visible          = true;
                    edcliente.Visible       = true;
                    Label5.Visible          = true;
                    edindexador.Visible     = true;
                    Label9.Visible          = true;
                    edperiodicidade.Visible = true;
                    Label6.Visible          = true;
                    cbindexador.Visible     = true;
                    Label4.Visible          = true;
                    edfeedback.Visible      = true;
                    //
                    string IndexadorCliente     = "";
                    string PeriodicidadeCliente = "";
                    if (parte != "0")
                    {
                        if (rbmeiolote.SelectedIndex == 0)
                        {
                            meiolote             = "1";
                            IndexadorCliente     = uVendas.PegaIndexador(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), meiolote);
                            PeriodicidadeCliente = uVendas.PegaPeriodicidade(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte, meiolote);
                        }
                        else
                        {
                            meiolote             = "2";
                            IndexadorCliente     = uVendas.PegaIndexador(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), meiolote);
                            PeriodicidadeCliente = uVendas.PegaPeriodicidade(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte, meiolote);
                        }
                    }
                    else
                    {
                        IndexadorCliente     = uVendas.PegaIndexador(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), "0");
                        PeriodicidadeCliente = uVendas.PegaPeriodicidade(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), "0", "1");
                    }
                    edindexador.Text     = IndexadorCliente;
                    edperiodicidade.Text = PeriodicidadeCliente;
                    //
                    //Combo Unidades
                    cbindexador.Items.Clear();
                    uIndexadores.MontaComboIndexadores(cbindexador, true);
                    //
                    cbindexador.Text = IndexadorCliente;
                    //
                    if (parte != "0")
                    {
                        rbmeiolote.Enabled = true;
                        rbmeiolote.Visible = true;
                    }
                    else
                    {
                        rbmeiolote.Enabled = false;
                        rbmeiolote.Visible = false;
                    }
                    string IDCliente = uUnidade.PegaIDCliente(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte, meiolote);
                    edcliente.Text = Srelib.QStr0(IDCliente.Trim(), 5) + " - " + uContato.PegaNomeID(IDCliente);
                    //
                    Label12.Visible         = true;
                    eddatabaseatual.Visible = true;
                    eddatabaseatual.Text    = uVendas.PegaDataBase(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte).ToString().Substring(0, 10);
                    //
                    cbindexador_SelectedIndexChanged(sender, e);
                }
                else
                {
                    //Cliente
                    Label8.Visible          = false;
                    edcliente.Visible       = false;
                    Label5.Visible          = false;
                    edindexador.Visible     = false;
                    Label9.Visible          = false;
                    edperiodicidade.Visible = false;
                    Label6.Visible          = false;
                    cbindexador.Visible     = false;
                    Label12.Visible         = false;
                    eddatabaseatual.Visible = false;

                    //Feedback
                    Label4.Visible     = false;
                    edfeedback.Visible = false;
                }
            }
        }
    }
Example #19
0
    //public static DataSet PegaUltimoSaldoContas()
    //{
    //    DataSet dsConta;
    //    String script = "";
    //    string nomearquivo = "contas";
    //    string xcodigoconta = "";

    //    script = "SELECT * FROM " + nomearquivo + " WITH(NOLOCK) ";
    //    script = script + " order by ID ";

    //    dsConta = SreDblib.GetDsScript(script);
    //    script = "";

    //    for (int i = 0; i < dsConta.Tables[0].Rows.Count - 1; i++)
    //    {
    //        nomearquivo = "";
    //        xcodigoconta = dsConta.Tables[0].Rows[i]["ID"].ToString().Trim();

    //        nomearquivo = "conta_" + Srelib.QStr0(xcodigoconta.Trim(), 5);
    //        script = "";
    //        script = script + " SELECT data, cod_conta, saldo_i, credito, debito, saldo_f, saldo_aplicacaoD, saldo_aplicacaoB, (saldo_f+saldo_aplicacaoD+saldo_aplicacaoB) saldo_finalaplicacao FROM ";
    //        script = script + nomearquivo + " WITH(NOLOCK) ";
    //        script = script + " WHERE ID = (select TOP 1 ID from " + nomearquivo + " ORDER BY ID DESC) ";

    //        if (i + 1 < (dsConta.Tables[0].Rows.Count - 1))
    //        {
    //            script = script + " UNION ALL ";
    //        }
    //    }

    //    return SreDblib.GetDsScript(script);

    //}

    public static DataSet PegaUltimoSaldoContas()
    {
        DataSet dsConta;
        DataSet dsSaldo;
        String  script       = "";
        string  nomearquivo  = "contas";
        string  xcodigoconta = "";

        script = "";
        //
        script = "SELECT * FROM " + nomearquivo + " WITH(NOLOCK) ";
        script = script + " order by ID ";
        //
        dsConta = SreDblib.GetDsScript(script);
        //
        //string xdata = "01/01/1900";
        //string xcod_conta = "0";
        //string xsaldo_i = "0";
        //string xcredito = "0";
        //string xdebito = "0";
        //string xsaldo_f = "0";
        //string xsaldo_aplicacaoD = "0";
        //string xsaldo_aplicacaoB = "0";
        //string xsaldo_finalaplicacao = "0";

        //
        DataTable table1 = new DataTable("table1");

        table1.Columns.Add("data");
        table1.Columns.Add("cod_conta");
        table1.Columns.Add("saldo_i");
        table1.Columns.Add("credito");
        table1.Columns.Add("debito");
        table1.Columns.Add("saldo_f");
        table1.Columns.Add("saldo_aplicacaoD");
        table1.Columns.Add("saldo_aplicacaoB");
        table1.Columns.Add("saldo_finalaplicacao");
        //
        for (int i = 0; i < dsConta.Tables[0].Rows.Count - 1; i++)
        {
            nomearquivo  = "";
            xcodigoconta = dsConta.Tables[0].Rows[i]["ID"].ToString().Trim();

            nomearquivo = "conta_" + Srelib.QStr0(xcodigoconta.Trim(), 5);
            script      = "";
            script      = script + " SELECT data, cod_conta, saldo_i, credito, debito, saldo_f, saldo_aplicacaoD, saldo_aplicacaoB, (saldo_f+saldo_aplicacaoD+saldo_aplicacaoB) saldo_finalaplicacao FROM ";
            script      = script + nomearquivo + " WITH(NOLOCK) ";
            script      = script + " WHERE ID = (select TOP 1 ID from " + nomearquivo + " ORDER BY ID DESC) ";

            dsSaldo = SreDblib.GetDsScript(script);
            //
            if (dsSaldo.Tables[0].Rows.Count > 0)
            {
                table1.Rows.Add(dsSaldo.Tables[0].Rows[0]["data"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["cod_conta"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["saldo_i"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["credito"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["debito"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["saldo_f"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["saldo_aplicacaoD"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["saldo_aplicacaoB"].ToString().Trim(),
                                dsSaldo.Tables[0].Rows[0]["saldo_finalaplicacao"].ToString().Trim());
            }
        }
        //
        //
        DataSet ds = new DataSet("table");

        ds.Tables.Add(table1);
        //
        return(ds);
        //
    }
Example #20
0
 protected void cbgrupounidades_SelectedIndexChanged(object sender, EventArgs e)
 {
     //
     if (cbproduto.Text != string.Empty)
     {
         if (cbgrupo.Text != string.Empty)
         {
             if (cbgrupounidades.Text != string.Empty)
             {
                 //Cliente
                 string grupounidades = cbgrupounidades.Text;
                 string parte         = grupounidades.Substring(grupounidades.IndexOf("-") + 1).Trim();
                 if (parte != "0")
                 {
                     rbmeiolote.Enabled = true;
                     rbmeiolote.Visible = true;
                 }
                 else
                 {
                     rbmeiolote.Enabled = false;
                     rbmeiolote.Visible = false;
                 }
                 string IDCliente = uUnidade.PegaIDCliente(cbproduto.Value.ToString(), cbgrupo.Value.ToString(), cbgrupounidades.Value.ToString(), parte, "1");
                 edcliente.Text = Srelib.QStr0(IDCliente.Trim(), 5) + " - " + uContato.PegaNomeID(IDCliente);
                 //
                 //Cliente
                 Label8.Visible    = true;
                 edcliente.Visible = true;
                 //Novo Cliente
                 if (SreDblib.GetParametro("FILTRO CONTATO") == "SIM")
                 {
                     Label5.Visible            = true;
                     cbclientes_filtro.Visible = true;
                 }
                 else
                 {
                     cbclientes.Items.Clear();
                     uContato.MontaComboContato(cbclientes, true);
                     Label5.Visible     = true;
                     cbclientes.Visible = true;
                 }
                 //
                 //Feedback
                 Label4.Visible     = true;
                 edfeedback.Visible = true;
             }
             else
             {
                 //Cliente
                 Label8.Visible    = false;
                 edcliente.Visible = false;
                 //Feedback
                 Label4.Visible     = false;
                 edfeedback.Visible = false;
                 //Novo Cliente
                 Label5.Visible     = false;
                 cbclientes.Visible = false;
             }
         }
     }
 }
    protected void btprocessa_Click(object sender, EventArgs e)
    {
        Boolean lOk = true;

        if (lOk)
        {
            if ((ckempresa.Checked == false) ||
                (ckparametros.Checked == false) ||
                (ckusuariopermissoes.Checked == false) ||
                (ckclientes.Checked == false) ||
                (ckproduto.Checked == false) ||
                (ckprodutotipo.Checked == false) ||
                (ckprodutogrupo1.Checked == false) ||
                (ckprodutogrupo2.Checked == false) ||
                (ckindexadores.Checked == false) ||
                (cktaxasdiarias.Checked == false) ||
                (cktaxasmensais.Checked == false) ||
                (ckmensagensboleto.Checked == false) ||
                (ckcorretores.Checked == false) ||
                (ckdespesas.Checked == false) ||
                (ckfornecedores.Checked == false) ||
                (ckcpagarlancamentos.Checked == false) ||
                (ckreceitas.Checked == false) ||
                (ckclientescontaareceber.Checked == false) ||
                (ckcreceberlancamentos.Checked == false) ||
                (ckbancos.Checked == false) ||
                (ckcontascorrentes.Checked == false) ||
                (cksaldoinicial.Checked == false))
            {
                //ScriptManager.RegisterStartupScript(UpdatePanel, GetType(), "msgbox", "alert('Nenhuma Tabela marcada para Análise!');", true);
                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), Guid.NewGuid().ToString(),
                                                    "toastr.error('Nenhuma Tabela marcada para Análise!', 'Atenção!')", true);
                lOk = false;
            }
        }

        if (lOk)
        {
            //Processamento
            //
            //ckempresa
            if (ckempresa.Checked)
            {
                lbempresa.Text = "";
                ds0.Clear();
                ds0            = SreDblib.GetDsScript("Select count(nome) quantidade from empresa with(nolock) ");
                lbempresa.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //
            //ckparametros
            if (ckparametros.Checked)
            {
                lbparametros.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(nome) quantidade from parametros with(nolock)");
                lbparametros.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckusuariopermissoes
            if (ckusuariopermissoes.Checked)
            {
                lbusuariopermissoes.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(permissao) quantidade from cadpermissoes with(nolock)");
                lbusuariopermissoes.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckclientes
            if (ckclientes.Checked)
            {
                lbclientes.Text = "";
                ds0.Clear();
                ds0             = SreDblib.GetDsScript("Select count(nome) quantidade from Contato with(nolock)");
                lbclientes.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckproduto
            if (ckproduto.Checked)
            {
                lbproduto.Text = "";
                ds0.Clear();
                ds0            = SreDblib.GetDsScript("Select count(ID) quantidade from produto with(nolock)");
                lbproduto.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckprodutotipo
            if (ckprodutotipo.Checked)
            {
                lbprodutotipo.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(produto) quantidade from produto_tipo with(nolock)");
                lbprodutotipo.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckprodutogrupo1
            if (ckprodutogrupo1.Checked)
            {
                lbprodutogrupo1.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from produto_grupo with(nolock) where grupo_tipo = 1 ");
                lbprodutogrupo1.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckprodutogrupo2
            if (ckprodutogrupo2.Checked)
            {
                lbprodutogrupo2.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from produto_grupo with(nolock) where grupo_tipo = 2 ");
                lbprodutogrupo2.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckindexadores
            if (ckindexadores.Checked)
            {
                lbindexadores.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(nome) quantidade from indexadores with(nolock) ");
                lbindexadores.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //cktaxasdiarias
            if (cktaxasdiarias.Checked)
            {
                lbtaxasdiarias.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(data) quantidade from taxas_diarias with(nolock) ");
                lbtaxasdiarias.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //cktaxasmensais
            if (cktaxasmensais.Checked)
            {
                lbtaxasmensais.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ano) quantidade from taxas_mensais with(nolock) ");
                lbtaxasmensais.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckmensagensboleto
            if (ckmensagensboleto.Checked)
            {
                lbmensagensboleto.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from boleto_mensagens with(nolock) ");
                lbmensagensboleto.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckcorretores
            if (ckcorretores.Checked)
            {
                lbcorretores.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from corretores with(nolock) ");
                lbcorretores.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckcorretores
            if (ckcorretores.Checked)
            {
                lbcorretores.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from corretores with(nolock) ");
                lbcorretores.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckdespesas
            if (ckdespesas.Checked)
            {
                lbdespesas.Text = "";
                ds0.Clear();
                ds0             = SreDblib.GetDsScript("Select count(ID) quantidade from classe_despesas with(nolock) ");
                lbdespesas.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckfornecedores
            if (ckfornecedores.Checked)
            {
                lbfornecedores.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from fornecedores with(nolock) ");
                lbfornecedores.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckcpagarlancamentos
            if (ckcpagarlancamentos.Checked)
            {
                lbcpagarlancamentos.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from contas_pagar with(nolock) ");
                lbcpagarlancamentos.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckreceitas
            if (ckreceitas.Checked)
            {
                lbreceitas.Text = "";
                ds0.Clear();
                ds0             = SreDblib.GetDsScript("Select count(ID) quantidade from classe_receitas with(nolock) ");
                lbreceitas.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckclientescontaareceber
            if (ckclientescontaareceber.Checked)
            {
                lbclientescontaareceber.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from clientes with(nolock) ");
                lbclientescontaareceber.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckcreceberlancamentos
            if (ckcreceberlancamentos.Checked)
            {
                lbcreceberlancamentos.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from contas_receber with(nolock) ");
                lbcreceberlancamentos.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckbancos
            if (ckbancos.Checked)
            {
                lbbancos.Text = "";
                ds0.Clear();
                ds0           = SreDblib.GetDsScript("Select count(ID) quantidade from bancos with(nolock) ");
                lbbancos.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //ckcontascorrentes
            if (ckcontascorrentes.Checked)
            {
                lbcontascorrentes.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from contas with(nolock) ");
                lbcontascorrentes.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //cksaldoinicial
            if (cksaldoinicial.Checked)
            {
                lbsaldoinicial.Text = "";
                ds0.Clear();
                ds0 = SreDblib.GetDsScript("Select count(ID) quantidade from contas_saldo_inicial with(nolock) ");
                lbsaldoinicial.Text = Srelib.QStr0(String.Format("{0:N}", ds0.Tables[0].Rows[0]["quantidade"].ToString()), 10);
            }
            //
            //
            // CRIA LOG  ===============================================================================================================================================
            SqlParameter[] param_log = { new SqlParameter("@login",    (String)Session["CodUsuario"]),
                                         new SqlParameter("@tabela",   "TODAS"),
                                         new SqlParameter("@operacao", "CONFIG"),
                                         new SqlParameter("@obs",      "ESTATÍSTICAS"),
                                         new SqlParameter("@acao",     "ESTATÍSTICAS QUANTITATIVA") };
            uLog.MakeLog(param_log);
            // FIM CRIA LOG ============================================================================================================================================
            //
            //ScriptManager.RegisterStartupScript(UpdatePanel, GetType(), "msgbox", "alert('Processamento Concluído!');", true);
            //
            ScriptManager.RegisterStartupScript(this.Page, typeof(Page), Guid.NewGuid().ToString(),
                                                "toastr.success('Processamento Concluído!', 'Atenção!')", true);
        }
    }
Example #22
0
    public static String GeraLancamentos(string xcodigoconta,
                                         string xdtperiodo1,
                                         string xdtperiodo2,
                                         Boolean xckchequedeposito,
                                         Boolean xckfornecedor)
    {
        //
        string   nomearquivo = "conta_" + Srelib.QStr0(xcodigoconta.Trim(), 5);
        DateTime data        = Convert.ToDateTime(xdtperiodo1);
        DataSet  dscontasapagar;
        DataSet  dscontasareceber;
        string   saldo_f_corrente = "";
        //
        string   lancamento       = "";
        string   produto          = "";
        string   classe           = "";
        string   pedido_compra    = "";
        string   descricao        = "";
        string   complemento      = "";
        string   saldo_i          = "";
        string   credito          = "";
        string   debito           = "";
        string   saldo_f          = "";
        string   saldo_aplicacaoD = "";
        string   saldo_aplicacaoB = "";
        string   saldo_total      = "";
        string   cheque           = "";
        string   cmc7             = "";
        DateTime dtregistro       = Convert.ToDateTime("01/01/1900");
        //
        //Saldo Inicial do Período
        string inicial_saldo_f          = "";
        string inicial_saldo_aplicacaoD = "";
        string inicial_saldo_aplicacaoB = "";

        //
        uContas.PegaSaldoFinalDataAnterior(xcodigoconta,
                                           data,
                                           ref inicial_saldo_f,
                                           ref inicial_saldo_aplicacaoD,
                                           ref inicial_saldo_aplicacaoB);
        //
        saldo_i          = inicial_saldo_f;
        saldo_aplicacaoD = inicial_saldo_aplicacaoD;
        saldo_aplicacaoB = inicial_saldo_aplicacaoB;
        //
        //Apagar Lançamentos Conta
        uContas.ExcluiLancamentos(xcodigoconta,
                                  xdtperiodo1,
                                  xdtperiodo2);
        //
        //Geração
        while (data <= Convert.ToDateTime(xdtperiodo2))
        {
            //Contas á Receber
            //
            dscontasareceber = uContasReceber.PegaDadosCReceber("",
                                                                "",
                                                                "",
                                                                xcodigoconta,
                                                                "01/01/1900",
                                                                "31/12/2999",
                                                                data.ToString().Substring(0, 10),
                                                                data.ToString().Substring(0, 10),
                                                                "01/01/1900",
                                                                "31/12/2999",
                                                                "",
                                                                "R",
                                                                "DR",
                                                                false,
                                                                false
                                                                );
            //
            for (int row0 = 0; row0 < dscontasareceber.Tables[0].Rows.Count; row0++)
            {
                //
                lancamento = dscontasareceber.Tables[0].Rows[row0]["lancamento"].ToString().Trim();
                produto    = dscontasareceber.Tables[0].Rows[row0]["produto"].ToString().Trim();
                classe     = dscontasareceber.Tables[0].Rows[row0]["classe"].ToString().Trim();
                descricao  = Srelib.tiraacento(dscontasareceber.Tables[0].Rows[row0]["descricao"].ToString().Trim());
                //
                credito = dscontasareceber.Tables[0].Rows[row0]["vlr_realizado"].ToString().Trim();
                debito  = "0";
                //
                saldo_f_corrente = "";
                saldo_f_corrente = Convert.ToString(Convert.ToDecimal(saldo_i) +
                                                    Convert.ToDecimal(credito));
                //
                saldo_f = saldo_f_corrente;
                //
                if (Convert.ToInt64(classe) == -1)
                {
                    saldo_aplicacaoD = Convert.ToString(Convert.ToDecimal(saldo_aplicacaoD) - Convert.ToDecimal(credito));
                }
                //
                if (Convert.ToInt64(classe) == -2)
                {
                    saldo_aplicacaoB = Convert.ToString(Convert.ToDecimal(saldo_aplicacaoB) - Convert.ToDecimal(credito));
                }
                //
                saldo_total = Convert.ToString(Convert.ToDecimal(saldo_f) + Convert.ToDecimal(saldo_aplicacaoD) + Convert.ToDecimal(saldo_aplicacaoB));
                cheque      = dscontasareceber.Tables[0].Rows[row0]["cheque"].ToString().Trim();
                cmc7        = dscontasareceber.Tables[0].Rows[row0]["cheque"].ToString().Trim();
                dtregistro  = DateTime.Now;

                if (xcodigoconta != String.Empty)
                {
                    uContas.GravaLancamento(xcodigoconta,
                                            lancamento,
                                            produto,
                                            classe,
                                            pedido_compra,
                                            Convert.ToString(data),
                                            descricao,
                                            complemento,
                                            saldo_i,
                                            credito,
                                            debito,
                                            saldo_f,
                                            saldo_aplicacaoD,
                                            saldo_aplicacaoB,
                                            saldo_total,
                                            cheque,
                                            cmc7,
                                            Convert.ToString(dtregistro)
                                            );
                }

                lancamento    = "";
                produto       = "";
                classe        = "";
                pedido_compra = "";
                descricao     = "";
                complemento   = "";
                saldo_i       = saldo_f;
                credito       = "";
                debito        = "";
                saldo_f       = "";
                //saldo_aplicacaoD = "";
                //saldo_aplicacaoB = "";
                saldo_total = "";
                cheque      = "";
                cmc7        = "";
                dtregistro  = Convert.ToDateTime("01/01/1900");
                //
            }
            dscontasareceber.Clear();
            //Fim Contas á Receber
            //
            //Contas á Pagar
            //
            dscontasapagar = uContasPagar.PegaDadosCPagar("",
                                                          "",
                                                          "",
                                                          xcodigoconta,
                                                          "01/01/1900",
                                                          "31/12/2999",
                                                          data.ToString().Substring(0, 10),
                                                          data.ToString().Substring(0, 10),
                                                          "01/01/1900",
                                                          "31/12/2999",
                                                          "",
                                                          "R",
                                                          "DR",
                                                          false,
                                                          false
                                                          );
            //
            //
            for (int row0 = 0; row0 < dscontasapagar.Tables[0].Rows.Count; row0++)
            {
                //
                lancamento = dscontasapagar.Tables[0].Rows[row0]["lancamento"].ToString().Trim();
                produto    = dscontasapagar.Tables[0].Rows[row0]["produto"].ToString().Trim();
                classe     = dscontasapagar.Tables[0].Rows[row0]["classe"].ToString().Trim();
                descricao  = Srelib.tiraacento(dscontasapagar.Tables[0].Rows[row0]["descricao"].ToString().Trim());
                //
                credito = "0";
                debito  = dscontasapagar.Tables[0].Rows[row0]["vlr_realizado"].ToString().Trim();
                //
                saldo_f_corrente = "";
                saldo_f_corrente = Convert.ToString(Convert.ToDecimal(saldo_i) -
                                                    Convert.ToDecimal(debito));
                //
                saldo_f = saldo_f_corrente;
                //
                if (Convert.ToInt64(classe) == -1)
                {
                    saldo_aplicacaoD = Convert.ToString(Convert.ToDecimal(saldo_aplicacaoD) + Convert.ToDecimal(debito));
                }
                //
                if (Convert.ToInt64(classe) == -2)
                {
                    saldo_aplicacaoB = Convert.ToString(Convert.ToDecimal(saldo_aplicacaoB) + Convert.ToDecimal(debito));
                }
                //
                saldo_total = Convert.ToString(Convert.ToDecimal(saldo_f) + Convert.ToDecimal(saldo_aplicacaoD) + Convert.ToDecimal(saldo_aplicacaoB));
                cheque      = dscontasapagar.Tables[0].Rows[row0]["cheque"].ToString().Trim();
                cmc7        = dscontasapagar.Tables[0].Rows[row0]["cheque"].ToString().Trim();
                dtregistro  = DateTime.Now;

                if (xcodigoconta != String.Empty)
                {
                    uContas.GravaLancamento(xcodigoconta,
                                            lancamento,
                                            produto,
                                            classe,
                                            pedido_compra,
                                            Convert.ToString(data),
                                            descricao,
                                            complemento,
                                            saldo_i,
                                            credito,
                                            debito,
                                            saldo_f,
                                            saldo_aplicacaoD,
                                            saldo_aplicacaoB,
                                            saldo_total,
                                            cheque,
                                            cmc7,
                                            Convert.ToString(dtregistro)
                                            );
                }

                lancamento    = "";
                produto       = "";
                classe        = "";
                pedido_compra = "";
                descricao     = "";
                complemento   = "";
                saldo_i       = saldo_f;
                credito       = "";
                debito        = "";
                saldo_f       = "";
                //saldo_aplicacaoD = "";
                //saldo_aplicacaoB = "";
                saldo_total = "";
                cheque      = "";
                cmc7        = "";
                dtregistro  = Convert.ToDateTime("01/01/1900");
                //
            }
            dscontasapagar.Clear();
            //Fim Contas á Receber

            //Proxima Data
            data = data.AddDays(1);
        }

        return(" ");
    }
Example #23
0
    public static String GeraLancamentos(string xproduto,
                                         string xdtperiodo1,
                                         string xdtperiodo2,
                                         string xprevisao)
    {
        //
        string   script      = "";
        string   nomearquivo = "";
        DateTime data        = Convert.ToDateTime(xdtperiodo1);

        decimal[] sub_previsto  = new decimal[1000];
        decimal[] sub_realizado = new decimal[1000];
        for (int i = 0; i < 1000; i++)
        {
            sub_previsto[i]  = 0;
            sub_realizado[i] = 0;
        }
        Int16   conta = 0;
        DataSet dsproduto;
        DataSet ds0;
        DataSet ds1;

        //Apagar Lançamentos Conta
        if (xproduto == String.Empty)
        {
            script = "DELETE contas_receber where Cliente = 1 " +
                     " AND (data_prevista between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo1)) +
                     " AND " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo2)) + ") " +
                     " AND (data_realizado between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo1)) +
                     " AND " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo2)) + ") ";

            SreDblib.ExecScript(script);
        }
        else
        {
            script = "DELETE contas_receber where Cliente = 1 " +
                     " AND produto = " + xproduto +
                     " AND (data_prevista between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo1)) +
                     " AND " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo2)) + ") " +
                     " AND (data_realizado between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo1)) +
                     " AND " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtperiodo2)) + ") ";

            SreDblib.ExecScript(script);
        }
        //Fim Apagar Lançamentos Conta
        //
        //Geração Contas a Receber
        if (xproduto == String.Empty)
        {
            //Todos os Produtos
            dsproduto = uProduto.PegaDadosProdutoID(0);
        }
        else
        {
            //Produto Específico
            dsproduto = uProduto.PegaDadosProdutoID(Convert.ToInt16(xproduto));
        }
        //
        //
        //Não Processa produto 0 nem Inativos
        for (int rowproduto = 0; rowproduto < dsproduto.Tables[0].Rows.Count; rowproduto++)
        {
            //Não Processa produto 0
            if (Convert.ToInt32(dsproduto.Tables[0].Rows[rowproduto]["ID"]) != 0)
            {
                //
                ds0 = uProduto.PegaDadosProdutoGrupo(Convert.ToInt32(dsproduto.Tables[0].Rows[rowproduto]["ID"].ToString().Trim()), "1");
                //
                //Datas
                data = Convert.ToDateTime(xdtperiodo1);
                //
                //Loop de Datas
                while (data <= Convert.ToDateTime(xdtperiodo2))
                {
                    string yproduto = "";
                    string ygrupo   = "";
                    //
                    //Loop de Grupos do Produto
                    for (int row0 = 0; row0 < ds0.Tables[0].Rows.Count; row0++)
                    {
                        // Produtos + Grupo
                        yproduto = ds0.Tables[0].Rows[row0]["produto"].ToString().Trim();
                        ygrupo   = ds0.Tables[0].Rows[row0]["grupo"].ToString().Trim();
                        //
                        nomearquivo = "parcelas_" + Srelib.QStr0(yproduto.Trim(), 5) + "_" + Srelib.QStr0(ygrupo.Trim(), 5);
                        //
                        // Parcelas Contas a Receber na Data Corrente
                        script = " " +
                                 " SELECT * FROM " + nomearquivo + " WITH(NOLOCK)  " +
                                 " WHERE (data_vencimento = " + Srelib.QStr(Srelib.DataAmericanasembarra(Convert.ToString(data).Substring(0, 10))) +
                                 " AND vlr_pagamento = 0 ) " +
                                 " OR (data_pagamento = " + Srelib.QStr(Srelib.DataAmericanasembarra(Convert.ToString(data).Substring(0, 10))) +
                                 " AND vlr_pagamento <> 0 ) " +
                                 //" AND ativa = 1  " +
                                 " UNION ALL " +
                                 " SELECT * FROM parcelas_renegociacao WITH(NOLOCK)  " +
                                 " WHERE (data_vencimento = " + Srelib.QStr(Srelib.DataAmericanasembarra(Convert.ToString(data).Substring(0, 10))) +
                                 " AND vlr_pagamento = 0 ) " +
                                 " OR (data_pagamento = " + Srelib.QStr(Srelib.DataAmericanasembarra(Convert.ToString(data).Substring(0, 10))) +
                                 " AND vlr_pagamento <> 0 ) " +
                                 //" AND ativa = 1  " +
                                 " AND produto = " + yproduto +
                                 " AND produto = " + ygrupo +
                                 " ORDER BY data_vencimento ";
                        //
                        ds1 = SreDblib.GetDsScript(script);
                        //
                        //
                        for (int row1 = 0; row1 < ds1.Tables[0].Rows.Count; row1++)
                        {
                            //Carregar dados das parcelas
                            //
                            //Conta
                            if (ds1.Tables[0].Rows[row1]["conta"].ToString().Trim() == string.Empty)
                            {
                                conta = 0;
                            }
                            else
                            {
                                conta = Convert.ToInt16(ds1.Tables[0].Rows[row1]["conta"]);
                            }
                            //
                            //Totaliza as Parcelas
                            if (data == Convert.ToDateTime(ds1.Tables[0].Rows[row1]["data_pagamento"]))
                            {
                                sub_realizado[conta] = sub_realizado[conta] + Convert.ToDecimal(ds1.Tables[0].Rows[row1]["vlr_pagamento"]);
                            }
                            //
                            if (xprevisao == "0")
                            {
                                //Integral
                                if (data == Convert.ToDateTime(ds1.Tables[0].Rows[row1]["data_vencimento"]))
                                {
                                    sub_previsto[conta] = sub_previsto[conta] + Convert.ToDecimal(ds1.Tables[0].Rows[row1]["vlr_parcela"]);
                                }
                            }
                            else
                            {
                                //Realizado
                                if ((data == Convert.ToDateTime(ds1.Tables[0].Rows[row1]["data_pagamento"])) &&
                                    (data == Convert.ToDateTime(ds1.Tables[0].Rows[row1]["data_vencimento"])))
                                {
                                    sub_previsto[conta] = sub_previsto[conta] + Convert.ToDecimal(ds1.Tables[0].Rows[row1]["vlr_parcela"]);
                                }
                            }
                            //
                        }
                        ds1.Clear();
                        //Fim Parcelas
                    }
                    //Fim Geração Contas a Receber
                    //
                    //Gravar Contas a Receber
                    //na Data todas as Contas
                    for (int j = 0; j < 100; j++)
                    {
                        if ((sub_previsto[j] != 0) || (sub_realizado[j] != 0))
                        {
                            uContasReceber.Grava(PegaNovoCodigoCReceber(),
                                                 yproduto,
                                                 "1",
                                                 "1",
                                                 "Parcelas - " + uProduto.PegaProdutoDescricao(Convert.ToInt16(yproduto)),
                                                 Convert.ToString(data).Substring(0, 10),
                                                 sub_previsto[j],
                                                 Convert.ToString(data).Substring(0, 10),
                                                 sub_realizado[j],
                                                 j.ToString().Trim(),
                                                 "Parcelas",
                                                 Convert.ToString(data).Substring(0, 10),
                                                 "",
                                                 "",
                                                 Convert.ToString(data).Substring(0, 10),
                                                 1,
                                                 ""
                                                 );
                        }
                    }
                    //
                    for (int x = 0; x < 1000; x++)
                    {
                        sub_previsto[x]  = 0;
                        sub_realizado[x] = 0;
                    }
                    //
                    data = data.AddDays(1);
                    //
                }
                ds0.Clear();
            }
            //data = Convert.ToDateTime(xdtperiodo1);
        }
        //

        return(" ");
    }