Exemplo 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);
        }
Exemplo n.º 2
0
        protected bool checkColumn(ref object value, JObject uiDict, string key, sys_column yoColumn)
        {
            bool result = false;

            while (true)
            {
                if (key == ID)
                {
                    break;
                }

                if (key == UPTIME)
                {
                    break;
                }

                if (yoColumn.datatype == DataType.Calc)
                {
                    break;
                }

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

                value = uiDict[key];
                if (!ui2db(ref value, yoColumn))
                {
                    m_errorDict.Add(key, value);
                    break;
                }

                result = true;
                break;
            }
            return(result);
        }
Exemplo n.º 3
0
        protected string getColumnDisplay(object value, sys_column yoColumn)
        {
            string result = null;

            while (true)
            {
                if (yoColumn.datatype == DataType.Refer)
                {
                    var select = new YoSelect(yoColumn.refer as string);
                    result = select.GetRowTitleDisplay(value);
                    break;
                }

                var obj = db2ui(value, yoColumn);
                if (obj == null)
                {
                    break;
                }

                result = obj.ToString();
                break;
            }
            return(result);
        }
Exemplo n.º 4
0
        object db2ui(object value, sys_column yoColumn)
        {
            object result = value;

            switch (yoColumn.datatype)
            {
            case DataType.Number:
            case DataType.Calc: {
                object format = yoColumn.format;
                if (format != null && YoConvert.ToInt(ref format))
                {
                    result = string.Format("{0:F" + format + "}", value);
                }
            }
            break;

            case DataType.Datetime:
                if (yoColumn.format != null && YoConvert.ToDatetime(ref value))
                {
                    result = ((DateTime)value).ToShortDateString();
                }
                break;

            case DataType.Set:
                if (value != null && yoColumn.setDict != null)
                {
                    var setKey = value.ToString();
                    if (yoColumn.setDict.ContainsKey(setKey))
                    {
                        result = yoColumn.setDict[setKey];
                    }
                }
                break;
            }
            return(result);
        }