Exemplo n.º 1
0
        //获取引用字段的显示值
        public object GetRefShowColVal(CColumn col)
        {
            CTable  RefTable   = (CTable)Ctx.TableMgr.Find(col.RefTable);
            CColumn RefCol     = (CColumn)RefTable.ColumnMgr.Find(col.RefCol);
            CColumn RefShowCol = (CColumn)RefTable.ColumnMgr.Find(col.RefShowCol);
            object  localVal   = GetColValue(col);
            //缓存数据优先
            CBaseObjectMgr BaseObjectMgr = Ctx.FindBaseObjectMgrCache(RefTable.Code, Guid.Empty);

            if (BaseObjectMgr == null)
            {
                BaseObjectMgr        = new CBaseObjectMgr();
                BaseObjectMgr.TbCode = RefTable.Code;
                BaseObjectMgr.Ctx    = Ctx;
                string sWhere = string.Format("{0}=", RefCol.Code);
                string sVal   = localVal.ToString();
                if (col.ColType == ColumnType.string_type ||
                    col.ColType == ColumnType.guid_type ||
                    col.ColType == ColumnType.ref_type ||
                    col.ColType == ColumnType.enum_type ||
                    col.ColType == ColumnType.datetime_type ||
                    col.ColType == ColumnType.text_type ||
                    col.ColType == ColumnType.path_type)
                {
                    sVal = string.Format("'{0}'", sVal);
                }
                sWhere += sVal;
                BaseObjectMgr.Load(sWhere);
                List <CBaseObject> lstObjRef = BaseObjectMgr.GetList();
                if (lstObjRef.Count == 0)
                {
                    return(null);
                }
                return(lstObjRef[0].GetColValue(RefShowCol));
            }
            else
            {
                List <CBaseObject> lstObjRef = BaseObjectMgr.GetList();

                var varObj = from objRef in lstObjRef
                             where (localVal.ToString().Equals(objRef.GetColValue(RefCol).ToString(), StringComparison.OrdinalIgnoreCase))
                             select objRef;

                if (varObj.Count() == 0)
                {
                    return(null);
                }
                CBaseObject obj = varObj.ToList().First();
                return(obj.GetColValue(RefShowCol));
            }
        }
Exemplo n.º 2
0
        public CColumn FindByCode(string sCode)
        {
            List <CBaseObject> lstColumn = this.GetList();

            foreach (CBaseObject obj in lstColumn)
            {
                CColumn column = (CColumn)obj;
                if (column.Code.Equals(sCode, StringComparison.OrdinalIgnoreCase))
                {
                    return(column);
                }
            }
            return(null);
        }
Exemplo n.º 3
0
 //通过字段值查找,该字段必须有唯一性, 返回第一个记录
 public CBaseObject FindByValue(CColumn col, object objVal)
 {
     if (col.Code.Equals("id", StringComparison.OrdinalIgnoreCase))
     {
         return(Find((Guid)objVal));
     }
     else
     {
         List <CBaseObject> lstObj = GetList();
         var varObj = from obj in lstObj where obj.GetColValue(col) == objVal select obj;
         if (varObj.Count() > 0)
         {
             return(varObj.First());
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 4
0
        //检验单条记录过滤条件
        public virtual bool FilterByView(CViewFilter vf)
        {
            CColumn col = (CColumn)Table.ColumnMgr.Find(vf.FW_Column_id);

            if (col == null)
            {
                return(false);
            }
            switch (col.ColType)
            {
            case ColumnType.string_type:
            case ColumnType.text_type:
            {
                return(CompareStr(vf.Sign, m_arrOldVal[col.Code.ToLower()].StrVal, vf.Val));

                break;
            }

            case ColumnType.int_type:
            case ColumnType.enum_type:
            {
                return(CompareInt(vf.Sign, m_arrOldVal[col.Code.ToLower()].IntVal, vf.Val));

                break;
            }

            case ColumnType.long_type:
            {
                return(CompareLong(vf.Sign, m_arrOldVal[col.Code.ToLower()].LongVal, vf.Val));

                break;
            }

            case ColumnType.numeric_type:
            {
                return(CompareDouble(vf.Sign, m_arrOldVal[col.Code.ToLower()].DoubleVal, vf.Val));

                break;
            }

            case ColumnType.bool_type:
            {
                return(CompareBool(vf.Sign, m_arrOldVal[col.Code.ToLower()].BoolVal, vf.Val));

                break;
            }

            case ColumnType.datetime_type:
            {
                return(CompareDateTime(vf.Sign, m_arrOldVal[col.Code.ToLower()].DatetimeVal, vf.Val));

                break;
            }

            case ColumnType.guid_type:
            case ColumnType.ref_type:
            {
                object objVal = GetRefShowColVal(col);
                return(CompareStr(vf.Sign, objVal != null?objVal.ToString():"", vf.Val));

                break;
            }

            case ColumnType.object_type:
            {
                return(CompareObject(vf.Sign, m_arrOldVal[col.Code.ToLower()].ObjectVal, vf.Val));

                break;
            }

            case ColumnType.path_type:
            {
                return(ComparePath(vf.Sign, m_arrOldVal[col.Code.ToLower()].StrVal, vf.Val));

                break;
            }

            default:
                break;
            }
            return(false);
        }