Beispiel #1
0
 public static string ObjectToString(object dataPara, string def)
 {
     if (!CcConvert.isNull(dataPara))
     {
         return Convert.ToString(dataPara);
     }
     return def;
 }
Beispiel #2
0
 public static string DatetimeToShortString(DateTime dt)
 {
     if (CcConvert.isDatetime(dt))
     {
         return dt.ToString("yyyy-MM-dd");
     }
     return string.Empty;
 }
Beispiel #3
0
 public static bool isDecimal(object data)
 {
     if (CcConvert.isNull(data))
     {
         return false;
     }
     bool result;
     try
     {
         Convert.ToDecimal(data);
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Beispiel #4
0
 public static bool isDouble(object data)
 {
     if (CcConvert.isNull(data))
     {
         return false;
     }
     bool result;
     try
     {
         Convert.ToDouble(data.ToString());
         result = true;
     }
     catch
     {
         result = false;
     }
     return result;
 }
Beispiel #5
0
        public static string newID(string tablename, string baseid)
        {
            XmlDocument xml = new XmlDocument();
            string      result2;

            try
            {
                xml.Load(TableIDCodingRule.App_DataPath + TableIDCodingRule.xmlfile);
                string  xpath = string.Format("/TableIDCodingRule/Item[@Tablename='{0}']", tablename.ToLower());
                XmlNode xn    = xml.DocumentElement.SelectSingleNode(xpath);
                if (xn == null)
                {
                    throw new Exception("error in loading xmlfile");
                }
                string codepref = xn.Attributes["Codepref"].Value;
                int    i        = CcConvert.StrToInt(xn.Attributes["Timestamp"].Value, 0);
                string mils     = DateTime.Now.Millisecond.ToString("d6").Substring(6 - i, i);
                int    codelen  = CcConvert.StrToInt(xn.Attributes["AutoCodeLength"].Value, 0);
                if (codelen == 0)
                {
                    throw new Exception("定义代码可变长度不能为0");
                }
                if (baseid == "")
                {
                    baseid = codepref + 0.ToString("d" + codelen) + mils;
                }
                int    varid  = Convert.ToInt32(baseid.Substring(codepref.Length, codelen), 10);
                string result = codepref + (varid + 1).ToString("d" + codelen) + mils;
                result2 = result;
            }
            catch (Exception)
            {
                result2 = "";
            }
            return(result2);
        }
Beispiel #6
0
 public static int StrToInt(string para)
 {
     return CcConvert.StrToInt(para, 0);
 }
Beispiel #7
0
 public static double StrToMoney(string para)
 {
     return CcConvert.StrToDouble(para, 0.0);
 }
Beispiel #8
0
 public static bool ObjectToBool(object dataPara)
 {
     string s = CcConvert.ObjectToString(dataPara).ToLower();
     return s == "true" || s == "是" || s == "1" || s == "yes" || s == "真" || s == "男";
 }
Beispiel #9
0
 public static string ObjectToString(object dataPara)
 {
     return CcConvert.ObjectToString(dataPara, "");
 }
Beispiel #10
0
 public static decimal ObjectToMoney(object dataPara)
 {
     return CcConvert.ObjectToDecimal(dataPara, 0m);
 }
Beispiel #11
0
 public static double ObjectToDouble(object dataPara)
 {
     return CcConvert.ObjectToDouble(dataPara, 0.0);
 }
Beispiel #12
0
 public static byte ObjectToByte(object dataPara)
 {
     return CcConvert.ObjectToByte(dataPara, 0);
 }
Beispiel #13
0
 public static long ObjectToBigInt(object dataPara)
 {
     return CcConvert.ObjectToBigInt(dataPara, 0);
 }
Beispiel #14
0
 public static float ObjectToSingle(object dataPara)
 {
     return CcConvert.ObjectToSingle(dataPara, 0f);
 }
Beispiel #15
0
 public static int ObjectToInt(object dataPara)
 {
     return CcConvert.ObjectToInt(dataPara, 0);
 }