/// <summary> /// Sends a service request to delete additional information of a /// certain category /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolStripButtonDeleteCategoryInfo_Click(object sender, EventArgs e) { Safir.Dob.Typesystem.EntityId entityId = new Safir.Dob.Typesystem.EntityId(); if (m_vehicleEntityListHandler.GetSelectedEntityId(out entityId)) { Capabilities.Vehicles.Vehicle vehicle = new Capabilities.Vehicles.Vehicle(); try { // Get data from Dob and fill dialog using (Safir.Dob.EntityProxy entityProxy = m_secDobConnection.Read(entityId)) { vehicle = (Capabilities.Vehicles.Vehicle)entityProxy.Entity; } } catch { // The specified instance of the entity does not exist statusStrip.Items["toolStripStatus"].Text = "Data was not found in database"; } if (!vehicle.VehicleCategory.IsNull()) { Capabilities.Vehicles.DeleteVehicleCategoryService req = new Capabilities.Vehicles.DeleteVehicleCategoryService(); req.VehicleCategory.Val = vehicle.VehicleCategory.Val; m_secDobConnection.ServiceRequest(req, new Safir.Dob.Typesystem.HandlerId(), this); statusStrip.Items["toolStripStatus"].Text = "OK"; } } else { statusStrip.Items["toolStripStatus"].Text = "No vehicle selected."; } }
/// <summary> /// Open dialog to update a vehicle /// </summary> public bool UpdateVehicle(Safir.Dob.Typesystem.EntityId entityId) { this.Text = "Update vehicle"; ClearAllControls(); textBoxIdentification.ReadOnly = true; // Not allowed to change identification comboBoxCategory.Focus(); m_create = false; try { using (Safir.Dob.EntityProxy entityProxy = m_secDobConnection.Read(entityId)) { m_vehicle = (Capabilities.Vehicles.Vehicle)entityProxy.Entity; } } catch (Safir.Dob.NotFoundException) { // The specified instance of the entity does not exist return(false); } if (!m_vehicle.Identification.IsNull()) { textBoxIdentification.Text = m_vehicle.Identification.Val.ToString(); } if (!m_vehicle.VehicleCategory.IsNull()) { comboBoxCategory.SelectedItem = m_vehicle.VehicleCategory.Val.ToString(); } if (!m_vehicle.Speed.IsNull()) { textBoxSpeed.Text = m_vehicle.Speed.Val.ToString(); } else { textBoxSpeed.Text = ""; } if (!m_vehicle.Position.IsNull()) { // Position (latitude) if (!m_vehicle.Position.Obj.Latitude.IsNull()) { textBoxPosLat.Text = m_vehicle.Position.Obj.Latitude.Val.ToString(); } // Position (longitude) if (!m_vehicle.Position.Obj.Longitude.IsNull()) { textBoxPosLong.Text = m_vehicle.Position.Obj.Longitude.Val.ToString(); } } this.Show(); return(true); }
/// <summary> /// Opens dialog for category information /// </summary> public bool Open(Safir.Dob.Typesystem.EntityId entityId) { ClearAllControls(); try { // Get data from Dob and fill dialog using (Safir.Dob.EntityProxy entityProxy = m_secDobConnection.Read(entityId)) { m_vehicle = (Capabilities.Vehicles.Vehicle)entityProxy.Entity; } } catch { // The specified instance of the entity does not exist return(false); } if (!m_vehicle.VehicleCategory.IsNull()) { textBoxCategoryCode.Text = m_vehicle.VehicleCategory.Val.ToString(); Capabilities.Vehicles.GetVehicleCategoryService req = new Capabilities.Vehicles.GetVehicleCategoryService(); req.VehicleCategory.Val = m_vehicle.VehicleCategory.Val; try { // Send service request m_secDobConnection.ServiceRequest(req, new Safir.Dob.Typesystem.HandlerId(), this); statusStrip.Items["toolStripStatus"].Text = "OK"; } catch (Safir.Dob.OverflowException) { statusStrip.Items["toolStripStatus"].Text = "Overflow when sending, please wait!"; } this.Show(); return(true); } return(false); }
/// <summary> /// Opens dialog to calculate speed difference /// </summary> public bool Open(Safir.Dob.Typesystem.EntityId entityId) { textBoxIdentification.Text = ""; textBoxCurrentSpeed.Text = ""; textboxNewSpeed.Text = ""; textboxSpeedDiff.Text = ""; statusStrip.Items["toolStripStatus"].Text = "OK"; // Get data from Dob and fill dialog try { using (Safir.Dob.EntityProxy entityProxy = m_secDobConnection.Read(entityId)) { m_vehicle = (Capabilities.Vehicles.Vehicle)entityProxy.Entity; } } catch { // The specified instance of the entity does not exist return(false); } if (!m_vehicle.Identification.IsNull()) { textBoxIdentification.Text = m_vehicle.Identification.Val.ToString(); } if (!m_vehicle.Speed.IsNull()) { textBoxCurrentSpeed.Text = m_vehicle.Speed.Val.ToString(); } else { statusStrip.Items["toolStripStatus"].Text = "Current speed must exist."; } this.Show(); return(true); }