private void cmbDeviceType_SelectedIndexChanged(object sender, EventArgs e) { Recordset objRt = null; try { if (cmbDeviceType.SelectedItem == null) { return; } ResourceTypeData data = cmbDeviceType.SelectedItem as ResourceTypeData; if (!m_Application.Workspace.Datasources["Resource"].Datasets.Contains(data.DatasetName)) { return; } dg_Data.Rows.Clear(); objRt = (m_Application.Workspace.Datasources["Resource"].Datasets[data.DatasetName] as DatasetVector).GetRecordset(false, CursorType.Static); objRt.MoveFirst(); while (!objRt.IsEOF) { DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell cell1 = new DataGridViewTextBoxCell { Value = Convert.ToString(objRt.GetFieldValue(data.FieldID)) }; row.Cells.Add(cell1); int isSet = 0; if (objRt.GetFieldValue("Heading") == null && objRt.GetFieldValue("Altitude") == null) { isSet = 0; } else { isSet = 1; } DataGridViewCheckBoxCell cell2 = new DataGridViewCheckBoxCell { Value = isSet }; row.Cells.Add(cell2); row.Tag = objRt.GetID(); dg_Data.Rows.Add(row); objRt.MoveNext(); } } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } }
private void DeviceTypeManagerControl_Load(object sender, EventArgs e) { Recordset objRt = null; try { if (m_Application.MainForm.FormManager.ActiveForm is IFormScene formScene) { m_SceneControl = formScene.SceneControl; } if (m_lstType == null) { m_lstType = new List <ResourceTypeData>(); } if (m_lstTypeData == null) { m_lstTypeData = new List <Label>(); } objRt = (m_Application.Workspace.Datasources["Resource"].Datasets["ResourceTable"] as DatasetVector).GetRecordset(false, CursorType.Static); objRt.MoveFirst(); while (!objRt.IsEOF) { ResourceTypeData data = new ResourceTypeData { Caption = Convert.ToString(objRt.GetFieldValue("SourceName")), Name = Convert.ToString(objRt.GetFieldValue("SourceID")), FieldID = Convert.ToString(objRt.GetFieldValue("TableField"))?.Split(',')[0], FieldName = Convert.ToString(objRt.GetFieldValue("TableField"))?.Split(',')[1], DatasetName = Convert.ToString(objRt.GetFieldValue("TableName")), }; m_lstType.Add(data); objRt.MoveNext(); } GetData(); } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } }
private void btnGetCamera_Click(object sender, EventArgs e) { Recordset objRt = null; try { if (dg_Data.SelectedRows.Count == 0) { m_Application.MessageBox.Show("未选中数据!"); return; } DataGridViewRow row = dg_Data.SelectedRows[0]; ResourceTypeData data = cmbDeviceType.SelectedItem as ResourceTypeData; objRt = (m_Application.Workspace.Datasources["Resource"].Datasets[data.DatasetName] as DatasetVector).GetRecordset(false, CursorType.Dynamic); if (objRt.SeekID(Convert.ToInt32(row.Tag)) && objRt.Edit()) { objRt.SetFieldValue("Longitude", m_SceneControl.Scene.Camera.Longitude); objRt.SetFieldValue("Latitude", m_SceneControl.Scene.Camera.Latitude); objRt.SetFieldValue("Altitude", m_SceneControl.Scene.Camera.Altitude); objRt.SetFieldValue("Heading", m_SceneControl.Scene.Camera.Heading); objRt.SetFieldValue("Tilt", m_SceneControl.Scene.Camera.Tilt); if (objRt.Update()) { m_Application.MessageBox.Show("视角保存成功!"); } else { m_Application.MessageBox.Show("视角保存失败!"); } } } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } }
private void dg_Data_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { Recordset objRt = null; try { DataGridViewRow row = dg_Data.Rows[e.RowIndex]; ResourceTypeData data = cmbDeviceType.SelectedItem as ResourceTypeData; objRt = (m_Application.Workspace.Datasources["Resource"].Datasets[data.DatasetName] as DatasetVector).GetRecordset(false, CursorType.Static); if (objRt.SeekID(Convert.ToInt32(row.Tag))) { double lon = Convert.ToDouble(objRt.GetFieldValue("Longitude")); double lat = Convert.ToDouble(objRt.GetFieldValue("Latitude")); double alt = Convert.ToDouble(objRt.GetFieldValue("Altitude")); double heading = Convert.ToDouble(objRt.GetFieldValue("Heading")); double tilt = Convert.ToDouble(objRt.GetFieldValue("Tilt")); Camera camera = new Camera { Longitude = lon, Latitude = lat, Altitude = alt, Heading = heading, Tilt = tilt, AltitudeMode = AltitudeMode.Absolute }; m_SceneControl.Scene.Fly(camera); } } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRt != null) { objRt.Close(); objRt.Dispose(); } } }
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); } }
private void cmbDeviceType_SelectedIndexChanged(object sender, EventArgs e) { Recordset objRtType = null; Recordset objRtData = null; try { //获取类型信息 dgv_TypeData.Rows.Clear(); m_lstTypeData.Clear(); if (cmbDeviceType.SelectedItem == null) { return; } ResourceTypeData typeData = cmbDeviceType.SelectedItem as ResourceTypeData; string strDatasetTypeName = typeData.DatasetName + "Type"; if (!m_Application.Workspace.Datasources["Resource"].Datasets.Contains(strDatasetTypeName)) { return; } objRtType = (m_Application.Workspace.Datasources["Resource"].Datasets[strDatasetTypeName] as DatasetVector).GetRecordset(false, CursorType.Static); objRtType.MoveFirst(); while (!objRtType.IsEOF) { DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(new DataGridViewTextBoxCell { Value = Convert.ToString(objRtType.GetFieldValue("TypeName")) }); dgv_TypeData.Rows.Add(row); m_lstTypeData.Add(new Label { Text = Convert.ToString(objRtType.GetFieldValue("TypeName")), Tag = Convert.ToString(objRtType.GetFieldValue("TypeID")) }); objRtType.MoveNext(); } cmbSetDeviceType.DataSource = null; cmbSetDeviceType.DataSource = m_lstTypeData; cmbSetDeviceType.DisplayMember = "Text"; if (cmbSetDeviceType.Items.Count > 0) { cmbSetDeviceType.SelectedIndex = 0; } //获取设备信息 dgv_Data.Rows.Clear(); if (m_Application.Workspace.Datasources["Resource"].Datasets[typeData.DatasetName] == null) { return; } objRtData = (m_Application.Workspace.Datasources["Resource"].Datasets[typeData.DatasetName] as DatasetVector).GetRecordset(false, CursorType.Static); objRtData.MoveFirst(); while (!objRtData.IsEOF) { DataGridViewRow row = new DataGridViewRow(); row.Cells.Add(new DataGridViewCheckBoxCell()); row.Cells.Add(new DataGridViewTextBoxCell { Value = Convert.ToString(objRtData.GetFieldValue(typeData.FieldID)) }); row.Cells.Add(new DataGridViewTextBoxCell { Value = Convert.ToString(objRtData.GetFieldValue(typeData.FieldName)) }); //if (objRtData.GetFieldValue("TypeID") != null) //{ // row.Cells.Add(new DataGridViewTextBoxCell { Value = Convert.ToString(objRtData.GetFieldValue("TypeID")) }); //} row.Tag = objRtData.GetID(); dgv_Data.Rows.Add(row); objRtData.MoveNext(); } } catch (Exception ex) { Log.OutputBox(ex); } finally { if (objRtType != null) { objRtType.Close(); objRtType.Dispose(); } if (objRtData != null) { objRtData.Close(); objRtData.Dispose(); } } }