Esempio n. 1
0
        bool ui2db(ref object value, sys_column yoColumn)
        {
            var result = true;

            switch (yoColumn.datatype)
            {
            case DataType.ID:
            case DataType.Refer:
                result = YoConvert.ToInt(ref value);
                break;

            case DataType.Number:
            case DataType.Calc:
                result = YoConvert.ToDouble(ref value);
                break;

            case DataType.Text:
            case DataType.Set:
                result = YoConvert.ToString(ref value);
                break;

            case DataType.Datetime:
                result = YoConvert.ToDatetime(ref value);
                break;
            }
            return(result);
        }
Esempio n. 2
0
        string getWhere(string key, JObject obj)
        {
            string result = null;

            while (true)
            {
                if (string.IsNullOrEmpty(key))
                {
                    break;
                }

                if (!m_yoColumnDict.ContainsKey(key))
                {
                    break;
                }

                if (obj == null)
                {
                    break;
                }

                object v1 = obj[k1];
                object v2 = obj[k2];
                switch (m_yoColumnDict[key].datatype)
                {
                case DataType.ID:
                case DataType.Refer:
                case DataType.Number:
                case DataType.Calc: {
                    if (v1 != null && YoConvert.ToDouble(ref v1))
                    {
                        result += string.Format(" `{0}` >= {1} ", key, v1);
                    }

                    if (v2 != null && YoConvert.ToDouble(ref v2))
                    {
                        if (result != null)
                        {
                            result += "AND";
                        }
                        result += string.Format(" `{0}` <= {1} ", key, v2);
                    }
                }
                break;

                default: {
                    if (v1 != null && YoConvert.ToString(ref v1))
                    {
                        result += string.Format(" `{0}` like '%{1}%' ", key, v1);
                    }
                }
                break;
                }

                break;
            }
            return(result);
        }