Beispiel #1
0
        private bool GetExist(string tableName, string condition)
        {
            //List<string> newList = new List<string>();
            //if (m_pWorkspace == null) return newList;
            //DropTable("tempTable");
            //m_pWorkspace.ExecuteSQL("create table tempTable as select " + Key + " from " + tableName + " where " + condition );
            //IFeatureWorkspace pWs = m_pWorkspace as IFeatureWorkspace;
            //ITable pTable = pWs.OpenTable("tempTable");
            //ICursor pCursor = pTable.Search(null ,false);
            //try
            //{
            //    if (pCursor != null)
            //    {
            //        IRow row = pCursor.NextRow();
            //        while (row != null)
            //        {
            //            newList.Add(row.get_Value(0).ToString());
            //            row = pCursor.NextRow();
            //        }

            //    }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //}
            //finally
            //{
            //    DropTable("tempTable");
            //    if (pCursor != null)
            //    {
            //        System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
            //    }
            //}
            //return newList;
            bool bExist = false;

            SysCommon.Gis.SysGisTable pTable = new SysCommon.Gis.SysGisTable(m_pWorkspace);
            try
            {
                if (pTable.ExistData(tableName, condition))
                {
                    bExist = true;
                }
            }
            catch (System.Exception ex)
            {
                bExist = false;
            }

            pTable = null;
            return(bExist);
        }
        /// <summary>
        /// 从系统表中删除该条记录
        /// </summary>
        /// <param name="strTableName">表名</param>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public bool DeleteTableRow(string strTableName, string condition)
        {
            Exception exError = null;
            bool      Bdelete = true;

            SysCommon.Gis.SysGisTable sysTable = new SysCommon.Gis.SysGisTable(m_Workspace);
            if (sysTable.ExistData(strTableName, condition))
            {
                if (!sysTable.DeleteRows(strTableName, condition, out exError))
                {
                    return(Bdelete = false);
                }
            }
            sysTable = null;
            return(Bdelete);
        }
        /// <summary>
        /// 更新系统表的数据记录
        /// </summary>
        /// <param name="tablename"></param>
        /// <param name="condition"></param>
        /// <param name="dicValues"></param>
        /// <returns></returns>
        public bool UpTableRow(string tablename, string condition, Dictionary <string, object> dicValues)
        {
            Exception exError = null;
            bool      Bdelete = true;

            SysCommon.Gis.SysGisTable sysTable = new SysCommon.Gis.SysGisTable(m_Workspace);
            if (sysTable.ExistData(tablename, condition))
            {
                return(Bdelete = sysTable.UpdateRow(tablename, condition, dicValues, out exError));
            }
            else
            {
                Bdelete = false;
            }
            sysTable = null;
            return(Bdelete);
        }