获得指定图层的指定字段值

2016-01-28 16:32:05  访问(1370) 赞(0) 踩(0)


        /// <summary>
        /// 获得指定图层的指定字段值
        /// </summary>
        /// <param name="layerName"></param>
        /// <param name="dcName"></param>
        /// <returns></returns>
        public string Dev4ShowLayerData
            (
                string layerName,
                string dcName
            )
        {
            StringBuilder theResult 
                = 
                new StringBuilder();

            FeatureLayer lyr = FeatureLayerGetByName
                (
                    layerName
                );

            if (lyr == null)
            {
                throw new Exception
                    (
                        "方法:"
                        + MethodBase.GetCurrentMethod().ReflectedType.FullName
                        + " "
                        + MethodBase.GetCurrentMethod().ToString()
                        + " 发生异常:没有找到" + layerName + "图层"
                    );
            }

            Table tbCar = lyr.Table;

            if (tbCar == null)
            {
                throw new Exception
                    (
                        "方法:"
                        + MethodBase.GetCurrentMethod().ReflectedType.FullName
                        + " "
                        + MethodBase.GetCurrentMethod().ToString()
                        + " 发生异常:没有找到" + layerName + "图层对应的Table"
                    );
            }

            object oValue = null; 

            foreach (Feature fcar in tbCar)
            {
                if (fcar == null)
                    continue;

                oValue = fcar[dcName];

                if (oValue == null)
                    theResult.AppendLine();
                else
                    theResult.AppendLine(oValue.ToString());
            }

            return theResult.ToString();

        }


标签:获得指定图层的指定字段值 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)