private void 查询记录表_Load(object sender, EventArgs e) { this.skinDataGridView1.Columns.Clear(); this.skinDataGridView1.Rows.Clear(); this.Text = recordset.Dataset.Name; for (int i = 0; i < recordset.FieldCount; i++) { String fieldName = recordset.GetFieldInfos()[i].Name; this.skinDataGridView1.Columns.Add(fieldName, fieldName); } DataGridViewRow row = null; while (!recordset.IsEOF) { row = new DataGridViewRow(); for (int i = 0; i < recordset.FieldCount; i++) { Object fieldValue = recordset.GetFieldValue(i); DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (fieldValue != null) { cell.ValueType = fieldValue.GetType(); cell.Value = fieldValue; } row.Cells.Add(cell); } this.skinDataGridView1.Rows.Add(row); recordset.MoveNext(); } this.skinDataGridView1.Update(); }
private void toolStripQueryProperty_Click(object sender, EventArgs e) { //获取选择集 Selection[] selection = mapControl1.Map.FindSelection(true); //判断选择集是否为空 if (selection == null || selection.Length == 0) { MessageBox.Show("请选择要查询属性的空间对象"); return; } //将选择集转换为记录 Recordset recordset = selection[0].ToRecordset(); this.dataGridView1.Columns.Clear(); this.dataGridView1.Rows.Clear(); for (int i = 0; i < recordset.FieldCount; i++) { //定义并获得字段名称 String fieldName = recordset.GetFieldInfos()[i].Name; //将得到的字段名称添加到dataGridView列中 this.dataGridView1.Columns.Add(fieldName, fieldName); } //初始化row DataGridViewRow row = null; //根据选中记录的个数,将选中对象的信息添加到dataGridView中显示 while (!recordset.IsEOF) { row = new DataGridViewRow(); for (int i = 0; i < recordset.FieldCount; i++) { //定义并获得字段值 Object fieldValue = recordset.GetFieldValue(i); //将字段值添加到dataGridView中对应的位置 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (fieldValue != null) { cell.ValueType = fieldValue.GetType(); cell.Value = fieldValue; } row.Cells.Add(cell); } this.dataGridView1.Rows.Add(row); recordset.MoveNext(); } this.dataGridView1.Update(); recordset.Dispose(); }
private void GetData() { Recordset objRt = null; try { dg_Data.Rows.Clear(); dg_Data.Columns.Clear(); if (chkTheme.SelectedItem == null) { m_Application.MessageBox.Show(Message); return; } Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset; objRt = (layer3DDataset.Dataset as DatasetVector).GetRecordset(false, CursorType.Static); for (int i = 0; i < objRt.FieldCount; i++) { FieldInfo fieldInfo = objRt.GetFieldInfos()[i]; if (fieldInfo.Caption.ToLower().Contains("sm")) { continue; } dg_Data.Columns.Add(fieldInfo.Name, fieldInfo.Caption); } objRt.MoveFirst(); while (!objRt.IsEOF) { DataGridViewRow row = new DataGridViewRow(); row.HeaderCell.Value = objRt.GetID().ToString(); for (int j = 0; j < dg_Data.ColumnCount; j++) { DataGridViewTextBoxCell textBoxCell = new DataGridViewTextBoxCell { Value = Convert.ToString(objRt.GetFieldValue(dg_Data.Columns[j].Name)) }; row.Cells.Add(textBoxCell); } dg_Data.Rows.Add(row); objRt.MoveNext(); } } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } }
private void btn_Commit_Click(object sender, EventArgs e) { Recordset objRt = null; try { if (chkTheme.SelectedItem == null) { m_Application.MessageBox.Show(Message); return; } Layer3DDataset layer3DDataset = (chkTheme.SelectedItem as Label).Tag as Layer3DDataset; objRt = (layer3DDataset.Dataset as DatasetVector).GetRecordset(false, CursorType.Dynamic); foreach (DataGridViewRow row in dg_Data.Rows) { int id = Convert.ToInt32(row.HeaderCell.Value); if (objRt.SeekID(id) && objRt.Edit()) { foreach (DataGridViewColumn column in dg_Data.Columns) { switch (objRt.GetFieldInfos()[column.Name].Type) { case FieldType.WText: objRt.SetFieldValue(column.Name, Convert.ToString(row.Cells[column.Name].Value)); break; case FieldType.Double: objRt.SetFieldValue(column.Name, Convert.ToDouble(row.Cells[column.Name].Value)); break; case FieldType.Int32: objRt.SetFieldValue(column.Name, Convert.ToInt32(row.Cells[column.Name].Value)); break; } } objRt.Update(); } } m_SceneControl.Refresh(); } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } }
public void Query() { try { mDataVec = mData as DatasetVector; Recordset rec = mDataVec.GetRecordset(false, CursorType.Dynamic); this.dataGridView1.Columns.Clear(); this.dataGridView1.Rows.Clear(); for (int i = 0; i < rec.FieldCount; i++) { //定义并获得字段名称 String fieldName = rec.GetFieldInfos()[i].Name; //将得到的字段名称添加到dataGridView列中 this.dataGridView1.Columns.Add(fieldName, fieldName); } //初始化row DataGridViewRow row = null; //根据选中记录的个数,将选中对象的信息添加到dataGridView中显示 while (!rec.IsEOF) { row = new DataGridViewRow(); for (int i = 0; i < rec.FieldCount; i++) { //定义并获得字段值 Object fieldValue = rec.GetFieldValue(i); //将字段值添加到dataGridView中对应的位置 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (fieldValue != null) { cell.ValueType = fieldValue.GetType(); cell.Value = fieldValue; } row.Cells.Add(cell); } this.dataGridView1.Rows.Add(row); rec.MoveNext(); } this.dataGridView1.Update(); rec.Dispose(); } catch (System.Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 没有选择对象的时候表格清空 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void m_mapControl_Paint(object sender, PaintEventArgs e) //{ // try // { // if (mapControl1.Map.Layers[0].Selection.Count < 1) // { // dataGridView1.Columns.Clear(); // dataGridView1.Rows.Clear(); // } // } // catch (Exception ex) // { // Trace.WriteLine(ex.Message); // } //} /// <summary> /// 使用记录集填充DataGridView /// </summary> /// <param name="recordset">获取的记录集</param> private void FillDataGridView(Recordset recordset) { try { dataGridView1.Columns.Clear(); dataGridView1.Rows.Clear(); for (int i = 0; i < recordset.FieldCount; i++) { String fieldName = recordset.GetFieldInfos()[i].Name; dataGridView1.Columns.Add(fieldName, fieldName); } DataGridViewRow row = null; //根据选中记录的个数,将选中对象的信息添加到dataGridView中显示 while (!recordset.IsEOF) { row = new DataGridViewRow(); for (int i = 0; i < recordset.FieldCount; i++) { //定义并获得字段值 Object fieldValue = recordset.GetFieldValue(i); //将字段值添加到dataGridView中对应的位置 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (fieldValue != null) { cell.ValueType = fieldValue.GetType(); cell.Value = fieldValue; } row.Cells.Add(cell); } this.dataGridView1.Rows.Add(row); recordset.MoveNext(); } this.dataGridView1.Update(); recordset.Dispose(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void 图查属性_Load(object sender, EventArgs e) { dataGridView1.AllowUserToAddRows = false; dataGridView1.ReadOnly = true; this.dataGridView1.Columns.Clear(); this.dataGridView1.Rows.Clear(); Recordset recordset = Program.re; for (int i = 0; i < recordset.FieldCount; i++) { //定义并获得字段名称 String fieldName = recordset.GetFieldInfos()[i].Name; //将得到的字段名称添加到dataGridView列中 this.dataGridView1.Columns.Add(fieldName, fieldName); } //初始化row DataGridViewRow row = null; //根据选中记录的个数,将选中对象的信息添加到dataGridView中显示 while (!recordset.IsEOF) { row = new DataGridViewRow(); for (int i = 0; i < recordset.FieldCount; i++) { //定义并获得字段值 Object fieldValue = recordset.GetFieldValue(i); //将字段值添加到dataGridView中对应的位置 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (fieldValue != null) { cell.ValueType = fieldValue.GetType(); cell.Value = fieldValue; } row.Cells.Add(cell); } this.dataGridView1.Rows.Add(row); recordset.MoveNext(); } this.dataGridView1.Update(); recordset.Dispose(); }
private void button1_Click(object sender, EventArgs e) { try { if (zdh.Text.Length != 0) { object value = getvalue(recordset.GetFieldInfos()[label_zdh.Text.Remove(label_zdh.Text.Length - 1)].Type, zdh.Text); recordset.SetFieldValue(label_zdh.Text.Remove(label_zdh.Text.Length - 1), value); } if (tdlylb.Text.Length != 0) { object value = getvalue(recordset.GetFieldInfos()[label_tdlylb.Text.Remove(label_tdlylb.Text.Length - 1)].Type, tdlylb.Text); recordset.SetFieldValue(label_tdlylb.Text.Remove(label_tdlylb.Text.Length - 1), value); } if (qlr.Text.Length != 0) { object value = getvalue(recordset.GetFieldInfos()[label_qlr.Text.Remove(label_qlr.Text.Length - 1)].Type, qlr.Text); recordset.SetFieldValue(label_qlr.Text.Remove(label_qlr.Text.Length - 1), value); } if (xzqh.Text.Length != 0) { object value = getvalue(recordset.GetFieldInfos()[label_qh.Text.Remove(label_qh.Text.Length - 1)].Type, xzqh.Text); recordset.SetFieldValue(label_qh.Text.Remove(label_qh.Text.Length - 1), value); } if (frdb.Text.Length != 0) { object value = getvalue(recordset.GetFieldInfos()[label_frdb.Text.Remove(label_frdb.Text.Length - 1)].Type, frdb.Text); recordset.SetFieldValue(label_frdb.Text.Remove(label_frdb.Text.Length - 1), value); } if (sfz1.Text.Length != 0) { object value = getvalue(recordset.GetFieldInfos()[label_sfz.Text.Remove(label_sfz.Text.Length - 1)].Type, sfz1.Text); recordset.SetFieldValue(label_sfz.Text.Remove(label_sfz.Text.Length - 1), value); } if (tel1.Text.Length != 0) { object value = getvalue(recordset.GetFieldInfos()[lable_tel.Text.Remove(lable_tel.Text.Length - 1)].Type, tel1.Text); recordset.SetFieldValue(lable_tel.Text.Remove(lable_tel.Text.Length - 1), value); } MessageBox.Show("修改成功"); recordset.Update(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void mapControl1_DoubleClick(object sender, EventArgs e) { Selection[] selection = mapControl1.Map.FindSelection(true); Recordset recordset = selection[0].ToRecordset(); FieldInfo objFieldinfo = null; if (recordset.RecordCount > 0) { string str = " "; for (int i = 0; i < recordset.FieldCount; i++) { objFieldinfo = recordset.GetFieldInfos()[i]; //String fieldName = recordset.GetFieldInfos()[i].Name; str += objFieldinfo.Name; str += ":" + recordset.GetFieldValue(i).ToString() + "\n"; } MessageBox.Show(str, "属性"); } recordset.Close(); }
//private void mSceneControlQuery5(object sender, ObjectSelectedEventArgs e) //{ // // 无对象被选中 // if (e.Count == 0&& mIndex==6) // { // MessageBox.Show("未选择对象!"); // } // //有对象选中 // else if (e.Count > 0 && mIndex == 6) // { // DiametQuery(); // } //} public void DiametQuery() { mSceneControl.Action = Action3D.Select; Selection3D[] selection = mSceneControl.Scene.FindSelection(true); //判断选择集是否为空 if (selection == null || selection.Length == 0) { MessageBox.Show("请选择要查询管径的空间对象"); return; } //将选择集转换为记录 Recordset recordset = selection[0].ToRecordset(); string str = ""; string str1 = ""; object obj; bool bol = false; for (int i = 0; i < recordset.FieldCount; i++) { str = recordset.GetFieldInfos()[i].Name; if (str == "PipeDiameter") { bol = true; obj = recordset.GetFieldValue(i); str1 = "管径" + ":" + obj.ToString() + "mm" + "\n"; MessageBox.Show(str1, "管径查询结果"); break; } else { continue; } } if (bol == false) { MessageBox.Show("该对象没有管径属性!"); } recordset.Dispose(); }
//规范化数据-BUSINESS_ID private void FormatData() { DatasetVector dtVector = GetSCZT(); if (dtVector != null) { string strBS_ID = m_strBusiness_id; string strFilter = string.Format(" length({0})=5", strBS_ID); Recordset recdst = dtVector.Query(strFilter, CursorType.Dynamic); if (recdst.RecordCount > 0) { int iDex = recdst.GetFieldInfos().IndexOf(strBS_ID); recdst.Batch.Begin(); while (!recdst.IsEOF) { string strValue = string.Format("0{0}", recdst.GetString(iDex)); recdst.SetFieldValue(iDex, strValue); recdst.MoveNext(); } recdst.Batch.Update(); MessageBox.Show("规范数据完毕"); } } }
//复制某记录到另外记录中 private void CopyRecordset(Recordset sour_recdst, Recordset dest_recdst) { try { FieldInfos dest_fis = dest_recdst.GetFieldInfos(); FieldInfos sour_fis = sour_recdst.GetFieldInfos(); dest_recdst.Batch.Begin(); while (!sour_recdst.IsEOF) { if (dest_recdst.AddNew(sour_recdst.GetGeometry())) { Dictionary <string, object> arrValues = new Dictionary <string, object>(); foreach (FieldInfo item in dest_fis) { if (!item.IsSystemField) { int iDex = GetIndexByCaption(sour_fis, item.Name); if (iDex > -1) { object obj = sour_recdst.GetFieldValue(iDex); arrValues.Add(item.Name, obj); } } } //增加主体类型 { arrValues.Add("ZTLX", m_strZTLX); } bool bRes = dest_recdst.SetValues(arrValues); } sour_recdst.MoveNext(); } dest_recdst.Batch.Update(); } catch { } }
/// <summary> /// 给长度柱形图赋值 /// </summary> public void LengBar() { try { Layer3Ds mLayer3D = mSceneControl.Scene.Layers; Layer3DDataset mLayer = null; Recordset mRecord = null; DatasetVector mData = null; String str = ""; String str1 = ""; for (int i = 0; i < mLengthStatis.GetPipeStatist.Count; i++) { mLayer = mLayer3D[mLengthStatis.GetPipeStatist[i].ToString() + "@" + mDataSourceName] as Layer3DDataset; mData = mLayer.Dataset as DatasetVector; mRecord = mData.GetRecordset(false, CursorType.Static); mRecord.MoveFirst(); if (i == 0) { while (!mRecord.IsEOF) { for (int k = 0; k < mRecord.FieldCount; k++) { str = mRecord.GetFieldInfos()[k].Name; if (str == "Length") { str1 = mRecord.GetFieldValue(k).ToString(); if (System.Convert.ToDouble(str1) > 0 && System.Convert.ToDouble(str1) <= 5) { mCount[0]++; break; } else if (System.Convert.ToDouble(str1) > 5 && System.Convert.ToDouble(str1) <= 10) { mCount[1]++; break; } else if (System.Convert.ToDouble(str1) > 10) { mCount[2]++; break; } } } mRecord.MoveNext(); } } else if (i == 1) { while (!mRecord.IsEOF) { for (int k = 0; k < mRecord.FieldCount; k++) { str = mRecord.GetFieldInfos()[k].Name; if (str == "Length") { str1 = mRecord.GetFieldValue(k).ToString(); if (System.Convert.ToDouble(str1) > 0 && System.Convert.ToDouble(str1) <= 5) { mCount1[0]++; break; } else if (System.Convert.ToDouble(str1) > 5 && System.Convert.ToDouble(str1) <= 10) { mCount1[1]++; break; } else if (System.Convert.ToDouble(str1) > 10) { mCount1[2]++; break; } } } mRecord.MoveNext(); } } else if (i == 2) { while (!mRecord.IsEOF) { for (int k = 0; k < mRecord.FieldCount; k++) { str = mRecord.GetFieldInfos()[k].Name; if (str == "Length") { str1 = mRecord.GetFieldValue(k).ToString(); if (System.Convert.ToDouble(str1) > 0 && System.Convert.ToDouble(str1) <= 5) { mCount2[0]++; break; } else if (System.Convert.ToDouble(str1) > 5 && System.Convert.ToDouble(str1) <= 10) { mCount2[1]++; break; } else if (System.Convert.ToDouble(str1) > 10) { mCount2[2]++; break; } } } mRecord.MoveNext(); } } } LengthCreate(); } catch (System.Exception ex) { Trace.WriteLine(ex.Message); } }
public void AttQuery(DataGridView bd_DataGridAttit) { try { DataGridView mDataGridAttit = bd_DataGridAttit; mDataGridAttit.Columns.Clear(); mDataGridAttit.Rows.Clear(); Selection3D[] selection = mSceneControl.Scene.FindSelection(true); // 判断选择集是否为空 if (selection == null || selection.Length == 0) { MessageBox.Show("请选择要查询属性的空间对象"); return; } //将选择集转换为记录 Recordset recordset = selection[0].ToRecordset(); DatasetVector dataset = recordset.Dataset; mDataGridAttit.Columns.Add("", "字段"); mDataGridAttit.Columns.Add("", "字段值"); mDataGridAttit.Columns.Add("", "类型"); mDataGridAttit.Columns.Add("", "长度"); mDataGridAttit.Columns.Add("", "缺省值"); string str = ""; string str_1 = ""; string str1 = ""; string str2 = ""; object obj; string str3 = ""; string str4 = ""; for (int i = 0; i < dataset.FieldCount; i++) { if (!recordset.GetFieldInfos()[i].IsSystemField) { if (recordset.GetFieldInfos()[i].Name == "SmPPoint" || recordset.GetFieldInfos()[i].Name == "SmNPoint") { continue; } str = recordset.GetFieldInfos()[i].Name; str_1 = recordset.GetFieldInfos()[i].Caption; obj = recordset.GetFieldValue(i); if (obj != null) { str1 = obj.ToString(); } else { str1 = null; } str2 = recordset.GetFieldInfos()[i].Type.ToString(); str3 = recordset.GetFieldInfos()[i].MaxLength.ToString(); str4 = recordset.GetFieldInfos()[i].DefaultValue; mDataGridAttit.Rows.Add(new[] { str_1, str1, str2, str3, str4 }); } } mDataGridAttit.Update(); recordset.Dispose(); } catch (System.Exception ex) { Trace.WriteLine(ex.Message); } }
private void btnExportOK_Click(object sender, EventArgs e) { try { SaveFileDialog saveFile = new SaveFileDialog { Filter = "Excel文件|*.xlsx", AddExtension = true, InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), OverwritePrompt = true, }; if (saveFile.ShowDialog() == DialogResult.OK) { DataSet ds = new DataSet(); foreach (var item in chkTypeData.CheckedItems) { ResourceTypeData data = item as ResourceTypeData; DataTable dt = new DataTable(); dt.TableName = data.Caption; Recordset objRt = null; try { objRt = (m_Application.Workspace.Datasources["Resource"].Datasets[data.DatasetName] as DatasetVector).GetRecordset(false, CursorType.Static); foreach (FieldInfo info in objRt.GetFieldInfos()) { if (info.Name.ToLower().Contains("sm")) { continue; } dt.Columns.Add(new DataColumn { ColumnName = info.Name, Caption = info.Caption }); } objRt.MoveFirst(); while (!objRt.IsEOF) { DataRow row = dt.NewRow(); for (int i = 0; i < dt.Columns.Count; i++) { row[i] = objRt.GetFieldValue(dt.Columns[i].ColumnName); } dt.Rows.Add(row); objRt.MoveNext(); } } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } ds.Tables.Add(dt); } ExcelHelper excel = new ExcelHelper(); if (excel.ToFile(ds, saveFile.FileName)) { m_Application.MessageBox.Show("数据导出成功!若提示文件损坏,请尝试修复。"); } else { m_Application.MessageBox.Show("数据导出失败!"); } } } catch (Exception ex) { Log.OutputBox(ex); } }
/// <summary> /// 标注名称 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void NameLabel() { try { Selection3D[] selection = mSceneControl.Scene.FindSelection(true); //判断选择集是否为空 if (selection == null || selection.Length == 0) { MessageBox.Show("请选择要标注名称的空间对象"); return; } //将选择集转换为记录 Recordset recordset = selection[0].ToRecordset(); //获取名称字段的值 string str = ""; string str1 = ""; object obj; bool bol = false; for (int i = 0; i < recordset.FieldCount; i++) { str = recordset.GetFieldInfos()[i].Name; if (str == "Name") { bol = true; obj = recordset.GetFieldValue(i); str1 = "名称: " + obj.ToString() + "\n"; break; } else { continue; } } if (bol == false) { MessageBox.Show("该对象没有名称属性!"); } recordset.Dispose(); TextPart3D mText1 = new TextPart3D(); mText1.Text = str1; mText1.AnchorPoint = mPoint3D; TextStyle mTextStyle1 = new TextStyle(); mTextStyle1.FontName = "微软雅黑"; mTextStyle1.ForeColor = Color.Red; mTextStyle1.FontHeight = 7; mTextStyle1.IsSizeFixed = false; mTextStyle1.Alignment = TextAlignment.MiddleCenter; GeoText3D geoText_1 = new GeoText3D(mText1, mTextStyle1); GeoStyle3D geostyle_1 = new GeoStyle3D(); geostyle_1.AltitudeMode = AltitudeMode.RelativeToGround; geoText_1.Style3D = geostyle_1; TrackingLayer3D trackinglayer = mSceneControl.Scene.TrackingLayer; trackinglayer.IsEditable = true; trackinglayer.IsVisible = true; trackinglayer.Add(geoText_1, "NameLabel"); mSceneControl.Scene.Refresh(); } catch (Exception) { } }
void mSceneControlSelected(object sender, ObjectSelectedEventArgs e) { Recordset recordset = null; Selection3D[] selection3d = null; mGeoLine3D = new GeoLine3D(); //水平及竖直净距 if (mSceneControl.Action == Action3D.Select && mFlag == 1 || mSceneControl.Action == Action3D.Select && mFlag == 2) { if (e.Count > 0) { selection3d = mSceneControl.Scene.FindSelection(true); recordset = selection3d[0].ToRecordset(); if (recordset.GetGeometry().Type != mGeoLine3D.Type) { MessageBox.Show("请选择三维线对象!"); } else { mGeoLine3D = recordset.GetGeometry() as GeoLine3D; if (TempGeoLine.Count > 0 && TempGeoLine[0].Bounds == mGeoLine3D.Bounds) { MessageBox.Show("请不要选择同一条三维线对象!"); } else { mTextPoint3Ds.Add(mGeoLine3D.InnerPoint3D); TempGeoLine.Add(mGeoLine3D); } } if (TempGeoLine.Count == 2) { this.SetPoint(TempGeoLine); } } } //覆土分析 if (mSceneControl.Action == Action3D.Select && mFlag == 3) { string str = ""; object obj; selection3d = mSceneControl.Scene.FindSelection(true); recordset = selection3d[0].ToRecordset(); if (e.Count > 0) { selection3d = mSceneControl.Scene.FindSelection(true); recordset = selection3d[0].ToRecordset(); if (recordset.GetGeometry().Type != mGeoLine3D.Type) { MessageBox.Show("请选择三维线对象!"); } else { mGeoLine3D = recordset.GetGeometry() as GeoLine3D; mTextPoint3Ds.Add(mGeoLine3D.InnerPoint3D); Point3D cPoint3D = new Point3D(mGeoLine3D.InnerPoint3D.X, mGeoLine3D.InnerPoint3D.Y, 0); mTextPoint3Ds.Add(cPoint3D); for (int i = 0; i < recordset.FieldCount; i++) { str = recordset.GetFieldInfos()[i].Name; if (str == "BottomAltitude") { obj = recordset.GetFieldValue(i); mAltitude = Convert.ToDouble(obj); } if (str == "PipeDiameter") { obj = recordset.GetFieldValue(i); mDiameter = new double[] { Convert.ToDouble(obj) }; } } } GetCoverRusult(); } } //碰撞检测 if (mSceneControl.Action == Action3D.Select && mFlag == 4) { if (e.Count > 0) { string str = ""; object obj; selection3d = mSceneControl.Scene.FindSelection(true); recordset = selection3d[0].ToRecordset(); if (recordset.GetGeometry().Type != mGeoLine3D.Type) { MessageBox.Show("请选择三维线对象!"); } else { mGeoLine3D = recordset.GetGeometry() as GeoLine3D; if (TempGeoLine.Count > 0 && TempGeoLine[0].Bounds == mGeoLine3D.Bounds) { MessageBox.Show("请不要选择同一条三维线对象!"); } else if (TempGeoLine.Count > 0 && recordset.Dataset.Name == TempRecordset.Dataset.Name) { MessageBox.Show("请不要选择同一数据集线对象!"); } else { mTextPoint3Ds.Add(mGeoLine3D.InnerPoint3D); TempGeoLine.Add(mGeoLine3D); TempRecordset = recordset; for (int i = 0; i < recordset.FieldCount; i++) { str = recordset.GetFieldInfos()[i].Name; if (str == "PipeDiameter") { obj = recordset.GetFieldValue(i); if (TempGeoLine.Count == 2) { mDiameter[1] = Convert.ToDouble(obj); } else { mDiameter = new double[2]; mDiameter[0] = Convert.ToDouble(obj); } } } } } if (TempGeoLine.Count == 2) { this.SetPoint(TempGeoLine); } } } }
public void ContainQuery() { try { this.mDataGridView.Rows.Clear(); this.mDataGridView.Columns.Clear(); Layer3Ds m_layer = mSceneControl.Scene.Layers; foreach (Layer3D mlayer in m_layer) { if (mlayer.Selection != null) { mlayer.Selection.Clear(); } } QueryParameter para = new QueryParameter(); para.HasGeometry = true; para.SpatialQueryMode = SpatialQueryMode.Contain; para.SpatialQueryObject = m_rec; Recordset recordset = null; Layer3DDataset layer = null; for (int i = 0; i < 3; i++) { if (i == 0) { recordset = mUseData.OutWaterNetWork.Query(para); layer = mUseData.OutWaterLines; } else if (i == 1) { recordset = mUseData.SupplyWaterNetWork.Query(para); layer = mUseData.SupplyWaterLines; } else if (i == 2) { recordset = mUseData.ElectricNetWork.Query(para); layer = mUseData.ElectricLayer; } List <Int32> ids = new List <int>(recordset.RecordCount); while (!recordset.IsEOF) { ids.Add(recordset.GetID()); recordset.MoveNext(); } layer.Selection.AddRange(ids.ToArray()); layer.Selection.UpdateData(); layer.Selection.Style.LineColor = Color.GreenYellow; mSceneControl.Scene.Refresh(); //在DataGrid中显示表 recordset.MoveFirst(); FieldInfos fieldinfos = recordset.GetFieldInfos(); foreach (FieldInfo fieldInfo in fieldinfos) { if (i >= 1) { break; } if (!fieldInfo.IsSystemField) { if (fieldInfo.Name == "SmPPoint" || fieldInfo.Name == "SmNPoint") { continue; } string mCaption = fieldInfo.Caption; this.mDataGridView.Columns.Add(mCaption, mCaption); } } //初始化行 DataGridViewRow dataGridViewRow; recordset.MoveFirst(); //根据选中的个数将对象的信息添加到列表中 while (!recordset.IsEOF) { dataGridViewRow = new DataGridViewRow(); for (int a = 0; a < recordset.FieldCount; a++) { if (!recordset.GetFieldInfos()[a].IsSystemField) { if (recordset.GetFieldInfos()[a].Name == "SmPPoint" || recordset.GetFieldInfos()[a].Name == "SmNPoint") { continue; } //定义并获取字段值 object filevalue = recordset.GetFieldValue(a); //添加到相应的位置 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (filevalue != null) { cell.ValueType = filevalue.GetType(); cell.Value = filevalue; } dataGridViewRow.Cells.Add(cell); } } this.mDataGridView.Rows.Add(dataGridViewRow); recordset.MoveNext(); } this.mDataGridView.Update(); recordset.Dispose(); } mSceneControl.Action = Action3D.Pan2; mSceneControl.Scene.Refresh(); } catch (System.Exception ex) { Trace.WriteLine(ex.Message); } }
void mSceneControlObjectSelectedFlow(object sender, ObjectSelectedEventArgs e) { Recordset recordset = null; Selection3D[] selection3d = null; try { // 无对象被选中 if (e.Count == 0) { MessageBox.Show("未选择对象!"); } //有对象选中 if (e.Count > 0) { mSceneControl.Action = Action3D.Pan2; selection3d = mSceneControl.Scene.FindSelection(true); selection3d[0].Style.LineColor = Color.Blue; recordset = selection3d[0].ToRecordset(); string[] StrName = new string[recordset.FieldCount]; bool PipeFlag = false; string PipeType = null; //判断是否为管线或管点对象 ,若不是 则提示选择管点或管线对象 for (int i = 0; i < recordset.FieldCount; i++) { StrName[i] = recordset.GetFieldInfos()[i].Name; if (StrName[i] == "PipeType") { PipeFlag = true; break; } } if (PipeFlag == true) { PipeType = recordset.GetFieldValue("PipeType").ToString(); switch (PipeType.Trim()) { case "给水": network = mUseData.SupplyWaterNetWork; mLayerName = "给水管网@127.0.0.1_UnderPipeLine"; break; case "排水": network = mUseData.OutWaterNetWork; mLayerName = "排水管网@127.0.0.1_UnderPipeLine"; break; default: MessageBox.Show("请选择其他类型管线对象"); break; } if (network != null) { mPipeId1 = Convert.ToInt32(recordset.GetFieldValue("SmID")); Geometry geo = recordset.GetGeometry(); GeometryType recordsetType = geo.Type; if (recordsetType == GeometryType.GeoLine3D) { MessageBox.Show("当前选择管线ID为" + mPipeId1.ToString().Trim()); mSeachFlag = "Line"; mConnectSeachFlag = "Line"; } else if (recordsetType == GeometryType.GeoPoint3D) { MessageBox.Show("当前选择管点ID为" + mPipeId1.ToString().Trim()); mConnectSeachFlag = "Node"; mSeachFlag = "Node"; } } } else { MessageBox.Show("请选择管点管线对象"); } } } catch (System.Exception ex) { Trace.Write(ex.Message); } finally { if (recordset != null) { recordset.Close(); recordset.Dispose(); } } }
private void Button_Query_Click(object sender, EventArgs e) { try { this.mDataGridView.Rows.Clear(); this.mDataGridView.Columns.Clear(); //每次查询都要先获取图层上的选择集并清除 Selection3D[] selection1 = mScenecontrol.Scene.FindSelection(true); if (selection1 != null) { for (int i = 0; i < selection1.Length; i++) { selection1[i].Clear(); } } //进行分析的数据集 DatasetVector dtvQuery = mData; //设置分析参数 QueryParameter parameter = new QueryParameter(); parameter.HasGeometry = false; parameter.AttributeFilter = txtQueryFilter.Text; string[] resultfields = new string[dtvQuery.GetRecordset(false, CursorType.Static).GetFieldInfos().Count]; if (txtQueryFields.Text == "*") { Recordset recordset = dtvQuery.GetRecordset(false, CursorType.Static); FieldInfos fieldInfos = recordset.GetFieldInfos(); for (int i = 0; i < fieldInfos.Count; i++) { resultfields[i] = fieldInfos[i].Name; } recordset.Dispose(); } else if (txtQueryFields.Text.Length == 0) { MessageBox.Show("查询字段不能为空!"); return; } else { resultfields = txtQueryFields.Text.Split(new char[] { ',' }); } parameter.ResultFields = resultfields; parameter.CursorType = CursorType.Static; parameter.HasGeometry = true; //进行查询显示 mRec = dtvQuery.Query(parameter); if (mRec.RecordCount != 0) { mRec.MoveFirst(); Geometry geo = mRec.GetGeometry(); GeometryType typ = geo.Type; //进行显示,把查询结果放入到选择集中,设置查询结果的风格,在场景中高亮出来 int layerindex = mScenecontrol.Scene.Layers.IndexOf(mLayername); Layer3DDataset layer3d = mScenecontrol.Scene.Layers[layerindex] as Layer3DDataset; List <Int32> ids = new List <int>(mRec.RecordCount); // Selection3D selection = layer3d.Selection; while (!mRec.IsEOF) { ids.Add(mRec.GetID()); mRec.MoveNext(); } layer3d.Selection.AddRange(ids.ToArray()); layer3d.Selection.Style.LineColor = Color.GreenYellow; layer3d.Selection.Style.FillForeColor = Color.GreenYellow; layer3d.Selection.Style.FillMode = FillMode3D.Line; layer3d.Selection.UpdateData(); mScenecontrol.Scene.Refresh(); } else { MessageBox.Show("没有查询结果!"); return; } this.Close(); //在DataGriw显示属性表,以表格的形式显示 mRec.MoveFirst(); FieldInfos fieldinfos = mRec.GetFieldInfos(); foreach (FieldInfo fieldInfo in fieldinfos) { if (!fieldInfo.IsSystemField) { if (fieldInfo.Name == "SmPPoint" || fieldInfo.Name == "SmNPoint") { continue; } // string name = fieldInfo.Name; string mCaption = fieldInfo.Caption; this.mDataGridView.Columns.Add(mCaption, mCaption); } } //初始化行 DataGridViewRow dataGridViewRow; mRec.MoveFirst(); //根据选中的个数将对象的信息添加到列表中 while (!mRec.IsEOF) { dataGridViewRow = new DataGridViewRow(); for (int a = 0; a < mRec.FieldCount; a++) { if (!mRec.GetFieldInfos()[a].IsSystemField) { if (mRec.GetFieldInfos()[a].Name == "SmPPoint" || mRec.GetFieldInfos()[a].Name == "SmNPoint") { continue; } //定义并获取字段值 object filevalue = mRec.GetFieldValue(a); //添加到相应的位置 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (filevalue != null) { cell.ValueType = filevalue.GetType(); cell.Value = filevalue; } dataGridViewRow.Cells.Add(cell); } } this.mDataGridView.Rows.Add(dataGridViewRow); mRec.MoveNext(); } this.mDataGridView.Update(); mScenecontrol.Action = Action3D.Pan2; mScenecontrol.Scene.Refresh(); mRec.Dispose(); } catch (Exception ex) { } }
private void button1_Click(object sender, EventArgs e) { try { if (xzqh.Text.Length > 0) { if (xzqh.Text.Length != 6) { MessageBox.Show("行政区划必须为六位"); return; } object value = getvalue(recordset.GetFieldInfos()[label_xzqh.Text.Remove(label_xzqh.Text.Length - 1)].Type, xzqh.Text); recordset.SetFieldValue(label_xzqh.Text.Remove(label_xzqh.Text.Length - 1), value); } else { MessageBox.Show(label_xzqh.Text.Remove(label_xzqh.Text.Length - 1) + " 不能为空"); return; } if (jd.Text.Length > 0) { if (jd.Text.Length != 3) { MessageBox.Show("街道号必须为3位"); return; } object value = getvalue(recordset.GetFieldInfos()[label_jd.Text.Remove(label_jd.Text.Length - 1)].Type, jd.Text); recordset.SetFieldValue(label_jd.Text.Remove(label_jd.Text.Length - 1), value); } else { MessageBox.Show(label_jd.Text.Remove(label_jd.Text.Length - 1) + "不能为空"); return; } if (jf.Text.Length > 0) { if (jf.Text.Length != 2) { MessageBox.Show("街坊必须为2位"); return; } object value = getvalue(recordset.GetFieldInfos()[label_jf.Text.Remove(label_jf.Text.Length - 1)].Type, jf.Text); recordset.SetFieldValue(label_jf.Text.Remove(label_jf.Text.Length - 1), value); } else { MessageBox.Show(label_jf.Text.Remove(label_jf.Text.Length - 1) + " 不能为空"); return; } if (zdh.Text.Length > 0) { object value = getvalue(recordset.GetFieldInfos()[zdh_l.Text.Remove(zdh_l.Text.Length - 1)].Type, jd.Text + jf.Text + zdh.Text); recordset.SetFieldValue(zdh_l.Text.Remove(zdh_l.Text.Length - 1), value); } else { MessageBox.Show(zdh_l.Text.Remove(zdh_l.Text.Length - 1) + " 不能为空"); return; } if (tdlylb.Text.Length > 0) { object value = getvalue(recordset.GetFieldInfos()[label_tdlylb.Text.Remove(label_tdlylb.Text.Length - 1)].Type, tdlylb.Text); recordset.SetFieldValue(label_tdlylb.Text.Remove(label_tdlylb.Text.Length - 1), value); } else { MessageBox.Show(label_tdlylb.Text.Remove(label_tdlylb.Text.Length - 1) + " 不认为空"); return; } if (qlr.Text.Length > 0) { object value = getvalue(recordset.GetFieldInfos()[label_qlr.Text.Remove(label_qlr.Text.Length - 1)].Type, qlr.Text); recordset.SetFieldValue(label_qlr.Text.Remove(label_qlr.Text.Length - 1), value); } else { MessageBox.Show(qlr.Text.Remove(qlr.Text.Length - 1) + " 不能为空"); return; } if (recordset.Update()) { MessageBox.Show("添加宗地成功"); } tt = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void 属性表_Load(object sender, EventArgs e) { Recordset recordset = dataset; this.skinDataGridView1.Columns.Clear(); this.skinDataGridView1.Rows.Clear(); for (int i = 0; i < recordset.FieldCount; i++) { String fieldName = recordset.GetFieldInfos()[i].Name; this.skinDataGridView1.Columns.Add(fieldName, fieldName); } DataGridViewRow row = null; row = new DataGridViewRow(); bool tt = true; while (!recordset.IsEOF) { tt = true; row = new DataGridViewRow(); if (this.skinDataGridView1.Rows[0].Cells["SmID"].Value != null) { for (int j = 0; j < this.skinDataGridView1.Rows.Count; j++) { if (this.skinDataGridView1.Rows[j].Cells["SmID"].Value != null) { if (this.skinDataGridView1.Rows[j].Cells["SmID"].Value.ToString() == recordset.GetFieldValue("SmID").ToString()) { tt = false; break; } } } } for (int i = 0; i < recordset.FieldCount; i++) { if (tt == false) { break; } Object fieldValue = recordset.GetFieldValue(i); DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (fieldValue != null) { cell.ValueType = fieldValue.GetType(); cell.Value = fieldValue; } row.Cells.Add(cell); } if (tt == true) { this.skinDataGridView1.Rows.Add(row); } recordset.MoveNext(); } this.skinDataGridView1.Update(); recordset.Dispose(); }
public void RefreshDataGridView() { //工矿废弃地临时图层Recordset gkfqdRecordset = importResultShp.GetRecordset(false, CursorType.Dynamic); //工矿废弃地正式图层 if (textBox2.Text == "复垦") { //formatDatasetVector = importDatasource.Datasets["gkfqd"] as DatasetVector; formatDatasetVector = importDatasource.Datasets[gkfqd.Common.DbUse.GetTownCode(textBox3.Text)] as DatasetVector; } //建新图层录入时执行以下处理 if (textBox2.Text == "建新") { //formatDatasetVector = importDatasource.Datasets["JXTC"] as DatasetVector; formatDatasetVector = importDatasource.Datasets["JX" + gkfqd.Common.DbUse.GetTownCode(textBox3.Text)] as DatasetVector; } //建新图层录入时执行以下处理 if (textBox2.Text == "补耕") { //formatDatasetVector = importDatasource.Datasets["JXTC"] as DatasetVector; formatDatasetVector = importDatasource.Datasets["BG" + gkfqd.Common.DbUse.GetTownCode(textBox3.Text)] as DatasetVector; } // 刷新指定区县地块导入状态 formatRecordset = formatDatasetVector.GetRecordset(false, CursorType.Dynamic); this.dataGridView1.Columns.Clear(); this.dataGridView1.Rows.Clear(); //添加dataGridView1 第一列为 地块导入状态,临时图层地块是否在正式图层存在 this.dataGridView1.Columns.Add("录入状态", "录入状态"); //取得字段名 for (int i = 0; i < gkfqdRecordset.FieldCount; i++) { //定义并获得字段名称 String fieldName = gkfqdRecordset.GetFieldInfos()[i].Name; //将得到的字段名称添加到dataGridView列中 this.dataGridView1.Columns.Add(fieldName, fieldName); } //初始化row DataGridViewRow row = null; //根据选中记录的个数,将选中对象的信息添加到dataGridView中显示 while (!gkfqdRecordset.IsEOF) { row = new DataGridViewRow(); //将字段值添加到dataGridView中对应的位置 DataGridViewTextBoxCell cell1 = new DataGridViewTextBoxCell(); if (layerExist(gkfqdRecordset)) { cell1.Value = "已录入"; cell1.Style.BackColor = Color.Green; } else { cell1.Value = "未录入"; } row.Cells.Add(cell1); for (int i = 0; i < gkfqdRecordset.FieldCount; i++) { //定义并获得字段值 Object fieldValue = gkfqdRecordset.GetFieldValue(i); //将字段值添加到dataGridView中对应的位置 DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); if (fieldValue != null) { cell.ValueType = fieldValue.GetType(); cell.Value = fieldValue; } row.Cells.Add(cell); } this.dataGridView1.Rows.Add(row); gkfqdRecordset.MoveNext(); } this.dataGridView1.Update(); gkfqdRecordset.Dispose(); }