Beispiel #1
0
        //Extensao para facilitar a conversao de int nullable
        public static int toInt(this object value)
        {
            if (value.isEmpty())
            {
                return(0);
            }

            return(UtilNumber.toInt32(value));
        }
        //Calcular percentual
        public static int toCents(decimal?valorTotal)
        {
            if (valorTotal == 0)
            {
                return(0);
            }

            string valorCentavos = UtilString.onlyNumber(valorTotal.ToString());

            return(UtilNumber.toInt32(valorCentavos));
        }
        //
        public static decimal toDecimalMod100(string str)
        {
            decimal result = 0;

            str = str.Replace(",", "").Replace(".", "");

            int intValue = UtilNumber.toInt32(str);

            Decimal.TryParse(decimal.Divide(intValue, 100).ToString(CultureInfo.InvariantCulture), out result);

            return(result);
        }
Beispiel #4
0
        //
        public static string toBase64Decode(string encodedString)
        {
            if (encodedString.LengthNullable() % 4 != 0)
            {
                return(string.Empty);
            }

            byte[] data = Convert.FromBase64String(encodedString);

            string strToDecode = Encoding.Unicode.GetString(data);

            long value = (UtilNumber.toInt32(strToDecode) / UtilCrypt.fatorNumerico);

            return(value.ToString());
        }
Beispiel #5
0
        //
        public static DateTime?getDate(string strDate, string strFormat)
        {
            DateTime?result = null;
            string   day;
            string   month;
            string   year;

            if (strFormat.ToLower() == "ddmmyy")
            {
                if (strDate.Length >= 6)
                {
                    day    = strDate.Substring(0, 2);
                    month  = strDate.Substring(2, 2);
                    year   = String.Concat("20", strDate.Substring(4, 2));
                    result = new DateTime(UtilNumber.toInt32(year), UtilNumber.toInt32(month), UtilNumber.toInt32(day));
                }
            }

            return(result);
        }
 public static int getIdPerfilUsuario()
 {
     return(UtilNumber.toInt32(SessionSistema.getSession("idPerfilUser_logged")));
 }
 public static int getIdUser()
 {
     return(UtilNumber.toInt32(SessionSistema.getSession("idUser_logged")));
 }