Exemplo n.º 1
0
        /// <summary>
        /// 按属性条件查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripMenuItemQuery_Click(object sender, EventArgs e)
        {
            QueryFilterDlg dlg = new QueryFilterDlg();
            string fc_name = selectNode.Text;
            List<string> fieldNames = controlOperation.GetFieldNamesByFeatureName(fc_name);
            dlg.FieldList_listBox.DataSource = fieldNames;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string whereClause = dlg.QueryFilter_txt.Text.Trim();
                DataTable dt = controlOperation.BuildDataTableByFeatureName(fc_name, whereClause);
                new AttributeForm(dt, fc_name, whereClause).Show();
            }
        }
Exemplo n.º 2
0
        private void toolStripMenuItemQuery_Click(object sender, EventArgs e)
        {
            string          fc_name  = selectNode.Text;
            string          set_name = selectNode.Parent.Text;
            myTreeNode      node     = (myTreeNode)selectNode.Parent.Parent;
            IConnectionInfo ci       = node.con;

            IDataSource     ds      = null;
            IFeatureDataSet dataset = null;
            IFeatureClass   fc      = null;

            try
            {
                ds      = dsFactory.OpenDataSource(ci);
                dataset = ds.OpenFeatureDataset(set_name);
                fc      = dataset.OpenFeatureClass(fc_name);

                QueryFilterDlg pQueryFilterDlg = new QueryFilterDlg();
                for (int index = 0; index < fc.GetFields().Count; index++)
                {
                    pQueryFilterDlg.FieldList_listBox.Items.Add(fc.GetFields().Get(index).Name);
                }
                if (DialogResult.OK == pQueryFilterDlg.ShowDialog())
                {
                    IQueryFilter filter = new QueryFilter();
                    filter.WhereClause = pQueryFilterDlg.QueryFilter_txt.Text;
                    int nCount = fc.GetCount(filter);
                    if (nCount == 0)
                    {
                        return;
                    }

                    // 初始化表格
                    DataTable dt = CreateDataTable(fc);
                    // 查找数据
                    GetResultSet(fc, filter, dt);
                    // 显示表格
                    new AttributeFrm(dt, fc.Name, filter.WhereClause).Show();
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            finally
            {
                if (ds != null)
                {
                    //Marshal.ReleaseComObject(ds);
                    ds = null;
                }
                if (dataset != null)
                {
                    //Marshal.ReleaseComObject(dataset);
                    dataset = null;
                }
                if (fc != null)
                {
                    //Marshal.ReleaseComObject(fc);
                    fc = null;
                }
            }
        }