private void advPropertyGrid1_PropertyValueChanging(object sender, PropertyValueChangingEventArgs e) { //var item = GetObjAndField(e.PropertyPath); //var obj= item.Item1; //var propertyName = item.Item2; if (e.PropertyName.EqualIgnoreCase("ModularDevices")) { var ModularDeviceID = ModularDevice.FindAllByName(e.NewValue.ToString())[0].ID; selectObj.Item1.SetItem("ModularDeviceID", ModularDeviceID); } else if (e.PropertyName.EqualIgnoreCase("Sensors")) { var SensorId = Sensor.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID; selectObj.Item1.SetItem("SensorId", SensorId); } else if (e.PropertyName.EqualIgnoreCase("ControlJobTypes")) { var ControlJobTypeId = ControlJobType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Id; selectObj.Item1.SetItem("ControlJobTypeId", ControlJobTypeId); } else if (e.PropertyName.EqualIgnoreCase("RelayTypes")) { var RelayTypeId = RelayType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Id; selectObj.Item1.SetItem("RelayTypeId", RelayTypeId); } else if (e.PropertyName.EqualIgnoreCase("DeviceTypes")) { var DeviceTypeSerialnum = DeviceType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Serialnum; selectObj.Item1.SetItem("DeviceTypeSerialnum", DeviceTypeSerialnum); } else if (e.PropertyName.EqualIgnoreCase("ShowDeviceTypes")) { var ShowDeviceTypeID = ShowDeviceType.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID; selectObj.Item1.SetItem("ShowDeviceTypeID", ShowDeviceTypeID); } else if (e.PropertyName.EqualIgnoreCase("CommunicateDevices")) { var CommunicateDeviceID = CommunicateDevice.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID; selectObj.Item1.SetItem("CommunicateDeviceID", CommunicateDeviceID); } else if (e.PropertyName.EqualIgnoreCase("Farms")) { var FarmID = Farm.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID; selectObj.Item1.SetItem("FarmID", FarmID); } else if (e.PropertyName.EqualIgnoreCase("FacilityTypes")) { var FacilityTypeSerialnum = FacilityType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Serialnum; selectObj.Item1.SetItem("FacilityTypeSerialnum", FacilityTypeSerialnum); } else { selectObj.Item1.SetItem(e.PropertyName, e.NewValue); } }