Ejemplo n.º 1
0
    public String Converte_Senha(String _x)
    {
        Int64 j, r;
        Byte  m;
        Char  c;

        r = 0;
        for (m = 0; (m <= (_x.Length - 1)); m++)
        {
            c = _x[m];
            j = c;
            r = (r + (j * 3)) * 2;
        }

        String retorno = Srelib.strzero(r, 10);

        return(retorno);
    }
Ejemplo n.º 2
0
    public static DataSet PegaDadosFCaixaMensal(string xproduto,
                                                string xcontascorrentes,
                                                string xmes,
                                                string xano,
                                                string xrblancamentossituacao,
                                                Boolean xckcompensado,
                                                Boolean xcompensado,
                                                Boolean xckaplicacao)
    {
        //
        DataSet dslancamentos;
        //
        string   tipo           = "1";
        string   classe         = "";
        DateTime data           = Convert.ToDateTime("01/01/1900");
        string   descricao      = "";
        string   mes1           = "0,00";
        string   mes2           = "0,00";
        string   mes3           = "0,00";
        string   totaltrimestre = "0,00";
        DateTime xdtprevisao1   = Convert.ToDateTime("01/01/1900");
        DateTime xdtprevisao2   = Convert.ToDateTime("31/12/2999");

        //
        if (xano != string.Empty)
        {
            if (xmes != string.Empty)
            {
                DateTime ultimoDia = new DateTime(Convert.ToInt16(xano),
                                                  Convert.ToInt16(xmes),
                                                  DateTime.DaysInMonth(Convert.ToInt16(xano), Convert.ToInt16(xmes)));

                xdtprevisao1 = Convert.ToDateTime("01/" + xmes + "/" + xano);
                xdtprevisao2 = Convert.ToDateTime(Srelib.strzero(ultimoDia.Day, 2) + "/" + xmes + "/" + xano);
            }
        }
        //
        DataTable table1 = new DataTable("table1");

        table1.Columns.Add("tipo");
        table1.Columns.Add("classe");
        table1.Columns.Add("data");
        table1.Columns.Add("descricao");
        table1.Columns.Add("mes1");
        table1.Columns.Add("mes2");
        table1.Columns.Add("mes3");
        table1.Columns.Add("totaltrimestre");
        //
        //CONTAS A RECEBER
        string script      = "";
        string nomearquivo = "contas_receber";

        script = "SELECT * FROM " + nomearquivo + " WITH(NOLOCK) ";
        script = script + " WHERE 1 = 1 ";
        //Produto
        if (xproduto != string.Empty)
        {
            script = script + " AND ( " + Srelib.QStr(xproduto) + " = " + Srelib.QStr("") + " OR produto IN (" + Srelib.QStr(xproduto) + ") )";
        }
        //Contas Correntes
        if (xcontascorrentes != "0")
        {
            script = script + " AND ";
            if (xcontascorrentes.Contains(","))
            {
                script = script + "( " + Srelib.QStr("1") + " = " + Srelib.QStr("") + " OR conta IN (" + xcontascorrentes + ") )";
            }
            else
            {
                script = script + "( " + Srelib.QStr(xcontascorrentes) + " = " + Srelib.QStr("") + " OR conta IN (" + Srelib.QStr(xcontascorrentes) + ") )";
            }
        }
        //
        if (xrblancamentossituacao == "P")
        {
            //Data Prevista
            script = script + " AND ";
            script = script + " (data_prevista between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao1.ToString().Substring(0, 10)));
            script = script + " and " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao2.ToString().Substring(0, 10))) + ") ";
        }
        else
        {
            //Data Realizado
            script = script + " AND ";
            script = script + " (data_realizado between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao1.ToString().Substring(0, 10)));
            script = script + " and " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao2.ToString().Substring(0, 10))) + ") ";
        }
        //Aplicações
        if (!xckaplicacao)
        {
            script = script + " AND ";
            script = script + " (classe > 0 ) ";
        }
        //
        //Compensado
        if (xckcompensado)
        {
            if (xcompensado)
            {
                //Compensado
                script = script + " AND ";
                script = script + " (dtcompensacao <> " + Srelib.QStr(Srelib.DataAmericanasembarra("01/01/1900")) + ") ";
            }
            else
            {
                //Não Compensado
                script = script + " AND ";
                script = script + " (dtcompensacao = " + Srelib.QStr(Srelib.DataAmericanasembarra("01/01/1900")) + ") ";
            }
        }
        script = script + " order by classe ";
        //
        dslancamentos = SreDblib.GetDsScript(script);
        //
        for (int i = 0; i <= dslancamentos.Tables[0].Rows.Count - 1; i++)
        {
            //
            tipo   = "1";
            classe = dslancamentos.Tables[0].Rows[i]["classe"].ToString().Trim();
            //
            if (xrblancamentossituacao == "P")
            {
                //Previsto
                data = Convert.ToDateTime(dslancamentos.Tables[0].Rows[i]["data_prevista"]);
                //
                mes1 = Convert.ToString(
                    Convert.ToDouble(mes1) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_previsto"]));
                //
                totaltrimestre = Convert.ToString(
                    Convert.ToDouble(totaltrimestre) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_previsto"]));
                //
            }
            else
            {
                //Realizado
                data = Convert.ToDateTime(dslancamentos.Tables[0].Rows[i]["data_realizado"]);
                //
                mes1 = Convert.ToString(
                    Convert.ToDouble(mes1) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_realizado"]));
                //
                totaltrimestre = Convert.ToString(
                    Convert.ToDouble(totaltrimestre) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_realizado"]));
                //
            }
            //
            descricao = uReceitas.PegaReceitaDescricao(Convert.ToInt16(classe));
            //
            try
            {
                if (classe != dslancamentos.Tables[0].Rows[i + 1]["classe"].ToString().Trim())
                {
                    table1.Rows.Add(tipo,
                                    classe,
                                    data,
                                    descricao,
                                    mes1,
                                    mes2,
                                    mes3,
                                    totaltrimestre);
                    //
                    mes1           = "0,00";
                    mes2           = "0,00";
                    mes3           = "0,00";
                    totaltrimestre = "0,00";
                }
                //
            }
            catch (Exception)
            {
                table1.Rows.Add(tipo,
                                classe,
                                data,
                                descricao,
                                mes1,
                                mes2,
                                mes3,
                                totaltrimestre);
                //
                mes1           = "0,00";
                mes2           = "0,00";
                mes3           = "0,00";
                totaltrimestre = "0,00";
            }
            //
        }
        //
        //CONTAS A PAGAR
        script      = "";
        nomearquivo = "contas_pagar";

        script = "SELECT * FROM " + nomearquivo + " WITH(NOLOCK) ";
        script = script + " WHERE 1 = 1 ";
        //Produto
        if (xproduto != string.Empty)
        {
            script = script + " AND ( " + Srelib.QStr(xproduto) + " = " + Srelib.QStr("") + " OR produto IN (" + Srelib.QStr(xproduto) + ") )";
        }
        //Contas Correntes
        if (xcontascorrentes != "0")
        {
            script = script + " AND ";
            if (xcontascorrentes.Contains(","))
            {
                script = script + "( " + Srelib.QStr("1") + " = " + Srelib.QStr("") + " OR conta IN (" + xcontascorrentes + ") )";
            }
            else
            {
                script = script + "( " + Srelib.QStr(xcontascorrentes) + " = " + Srelib.QStr("") + " OR conta IN (" + Srelib.QStr(xcontascorrentes) + ") )";
            }
        }
        //
        if (xrblancamentossituacao == "P")
        {
            //Data Prevista
            script = script + " AND ";
            script = script + " (data_prevista between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao1.ToString().Substring(0, 10)));
            script = script + " and " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao2.ToString().Substring(0, 10))) + ") ";
        }
        else
        {
            //Data Realizado
            script = script + " AND ";
            script = script + " (data_realizado between " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao1.ToString().Substring(0, 10)));
            script = script + " and " + Srelib.QStr(Srelib.DataAmericanasembarra(xdtprevisao2.ToString().Substring(0, 10))) + ") ";
        }
        //Aplicações
        if (!xckaplicacao)
        {
            script = script + " AND ";
            script = script + " (classe > 0 ) ";
        }
        //
        //Compensado
        if (xckcompensado)
        {
            if (xcompensado)
            {
                //Compensado
                script = script + " AND ";
                script = script + " (dtcompensacao <> " + Srelib.QStr(Srelib.DataAmericanasembarra("01/01/1900")) + ") ";
            }
            else
            {
                //Não Compensado
                script = script + " AND ";
                script = script + " (dtcompensacao = " + Srelib.QStr(Srelib.DataAmericanasembarra("01/01/1900")) + ") ";
            }
        }
        script = script + " order by classe ";
        //
        dslancamentos = SreDblib.GetDsScript(script);
        //
        for (int i = 0; i <= dslancamentos.Tables[0].Rows.Count - 1; i++)
        {
            //
            tipo   = "2";
            classe = dslancamentos.Tables[0].Rows[i]["classe"].ToString().Trim();
            //
            if (xrblancamentossituacao == "P")
            {
                //Previsto
                data = Convert.ToDateTime(dslancamentos.Tables[0].Rows[i]["data_prevista"]);
                //
                mes1 = Convert.ToString(
                    Convert.ToDouble(mes1) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_previsto"]));
                //
                totaltrimestre = Convert.ToString(
                    Convert.ToDouble(totaltrimestre) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_previsto"]));
                //
            }
            else
            {
                //Realizado
                data = Convert.ToDateTime(dslancamentos.Tables[0].Rows[i]["data_realizado"]);
                //
                mes1 = Convert.ToString(
                    Convert.ToDouble(mes1) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_realizado"]));
                //
                totaltrimestre = Convert.ToString(
                    Convert.ToDouble(totaltrimestre) +
                    Convert.ToDouble(dslancamentos.Tables[0].Rows[i]["vlr_realizado"]));
                //
            }
            //
            descricao = uDespesas.PegaDespesaDescricao(Convert.ToInt16(classe));
            //
            try
            {
                if ((i < dslancamentos.Tables[0].Rows.Count) &&
                    (classe != dslancamentos.Tables[0].Rows[i + 1]["classe"].ToString().Trim()))
                {
                    table1.Rows.Add(tipo,
                                    classe,
                                    data,
                                    descricao,
                                    mes1,
                                    mes2,
                                    mes3,
                                    totaltrimestre);
                    //
                    mes1           = "0,00";
                    mes2           = "0,00";
                    mes3           = "0,00";
                    totaltrimestre = "0,00";
                }
            }
            catch (Exception)
            {
                //
                table1.Rows.Add(tipo,
                                classe,
                                data,
                                descricao,
                                mes1,
                                mes2,
                                mes3,
                                totaltrimestre);
                //
                mes1           = "0,00";
                mes2           = "0,00";
                mes3           = "0,00";
                totaltrimestre = "0,00";
                //
            }
        }
        //
        DataView dataview = new DataView(table1);

        dataview.Sort = "tipo, descricao ASC";
        DataTable table2 = dataview.ToTable();
        //
        DataSet dsresult = new DataSet("table");

        dsresult.Tables.Add(table2);
        //
        return(dsresult);
    }