Beispiel #1
0
    public static String PegaMensagens(string xID,
                                       ref string msg1,
                                       ref string msg2,
                                       ref string msg3,
                                       ref string msg4,
                                       ref string msg5)
    {
        DataSet ds;

        string script = "select * from boleto_mensagens " +
                        " with(nolock) " +
                        " where codigo = " + xID;
        string retorno = "";

        ds = SreDblib.GetDsScript(script);

        try
        {
            msg1 = ds.Tables[0].Rows[0]["linha1"].ToString().Trim() + Srelib.replicate(" ", 80);
            msg2 = ds.Tables[0].Rows[0]["linha2"].ToString().Trim() + Srelib.replicate(" ", 80);
            msg3 = ds.Tables[0].Rows[0]["linha3"].ToString().Trim() + Srelib.replicate(" ", 80);
            msg4 = ds.Tables[0].Rows[0]["linha4"].ToString().Trim() + Srelib.replicate(" ", 80);
            msg5 = ds.Tables[0].Rows[0]["linha5"].ToString().Trim() + Srelib.replicate(" ", 80);
        }
        catch (Exception)
        {
            retorno = "";
        }


        return(retorno);
    }
Beispiel #2
0
    public String ValExtenso(Double yVal)
    {
        int l;

        if (yVal <= 0)
        {
            yVal = (yVal) * -1;
        }


        String cents,
               cruz,
               mil,
               milhao,
               bilhao,
               singular,
               plural,
               exp,
               xis,
               yps,
               resto0,
               resto1,
               resto2;

        xis      = "";
        yps      = "";
        singular = "REAL";
        plural   = "REAIS";
        exp      = String.Format("{0:################0.00;-################0.00;###.##}", yVal);
        exp      = exp.Trim();
        l        = exp.Length;

        if (l < 20)
        {
            exp = Srelib.replicate("0", 20 - l) + exp;
        }

        l = exp.Length;

        if (singular == "")
        {
            singular = "REAL";
            plural   = "REAIS";
        }

        cents  = exp.Substring(l - 2, 2);
        cruz   = exp.Substring(l - 6, 3);
        mil    = exp.Substring(l - 9, 3);
        milhao = exp.Substring(l - 12, 3);
        bilhao = exp.Substring(l - 15, 3);

        resto0 = bilhao + milhao + mil + cruz + "." + cents;
        resto1 = milhao + mil + cruz + "." + cents;
        resto2 = mil + cruz + "." + cents;

        if (cents != "00")
        {
            xis = dupla(cents) + " CENTAVO";
            if (cents != "01")
            {
                xis = xis + "S";
            }
        }

        if (cruz != "000")
        {
            if (cents != "00")
            {
                xis = " E " + xis;
            }

            if ((cruz == "001") && (resto1 == "000000000.00"))
            {
                xis = tripla(cruz) + " " + singular + xis;
            }
            else
            {
                xis = tripla(cruz) + " " + plural + xis;
            }
        }

        if (mil != "000")
        {
            if ((cruz != "000") || (cents != "00"))
            {
                xis = ", " + xis;
                if (cruz == "000")
                {
                    xis = " " + plural + xis;
                }
            }
            else
            {
                xis = xis + " " + plural;
            }

            xis = tripla(mil) + " MIL" + xis;
        }

        if (milhao != "000")
        {
            if (resto2 != "000000.00")
            {
                if (resto2.Substring(0, 6) != "000000")
                {
                    xis = ", " + xis;
                }
                else
                {
                    xis = " E " + xis;
                }
            }
            else
            {
                xis = xis + " DE " + plural;
            }

            yps = tripla(milhao);

            if (milhao == "001")
            {
                xis = yps + " MILHAO" + xis;
            }
            else
            {
                xis = yps + " MILHOES" + xis;
            }
        }


        if (bilhao != "000")
        {
            if (resto1 != "000000000.00")
            {
                if (resto1.Substring(1, 8) == "00000000")
                {
                    xis = " E " + xis;
                }
                else
                {
                    xis = ", " + xis;
                }
            }
            else
            {
                xis = xis + " DE " + plural;
            }

            yps = tripla(bilhao);

            if (bilhao == "001")
            {
                xis = yps + " BILHAO" + xis;
            }
            else
            {
                xis = yps + " BILHOES" + xis;
            }
        }

        return(xis);
    }
    private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
        //
        string valor = Convert.ToString(GetCurrentColumnValue("vlr_previsto"));

        //
        if (valor.Trim() == "0,00")
        {
            if (rbvalores == "P")
            {
                e.Cancel = true;
            }
        }

        lvalor.Text = "( " + String.Format("{0:N}", Convert.ToDouble(valor)) + " )";
        //
        DateTime emissao = Convert.ToDateTime(GetCurrentColumnValue("data_prevista"));
        //
        ValorExtenso xExt = new ValorExtenso();
        String       xAux;

        xAux = "( " + xExt.ValExtenso(Convert.ToDouble(valor)) + " )";
        //tamanho máximo de extenso = 70 + 100 = 170 chars
        if (xAux.Length > 170)
        {
            lvalorextenso1.Text = "Extenso supera o limite máximo de 180 characteres. Acione Suporte.";
            lvalorextenso2.Text = Srelib.replicate("*", 100);
        }
        else
        {
            if (xAux.Length <= 70)
            {
                lvalorextenso1.Text = xAux + Srelib.replicate("*", (70 - xAux.Length));
                lvalorextenso2.Text = Srelib.replicate("*", 100);
            }
            else
            {
                //> 70
                lvalorextenso1.Text = xAux.Substring(0, 70);
                lvalorextenso2.Text = xAux.Substring(70, (xAux.Length - 70)) + Srelib.replicate("*", (100 - (xAux.Length - 70)));
            }
        }
        //
        Int32 fornecedor = Convert.ToInt32(GetCurrentColumnValue("fornecedor"));

        lnominal.Text = uFornecedores.PegaNomeFornecedor(fornecedor);
        //
        lemissaoextenso.Text = uEmpresa.PegaCidade(uEmpresa.PegaMatriz()) + ",     " + Srelib.DataExtenso(DateTime.Now);
        //
        //Compensação
        if (rbcompensacao == "1")
        {
            //Compensação na Data da emissão do Cheque
            string lancamento = Convert.ToString(GetCurrentColumnValue("lancamento"));
            //
            uContasPagar.GravaCompensacao(lancamento,
                                          DateTime.Now.ToString().Substring(0, 10),
                                          numerocheque);
            numerocheque = (Convert.ToInt16(numerocheque) + 1).ToString();
        }
    }