private bool IsModified(CITYCOD record) { //Type-specific routine that takes into account relationships that should also be considered //when deciding if there are unsaved changes. The entity properties also return true if the //record is new or deleted. if (record == null) { return(false); } return(record.IsModified(_context) || record.SupplierCity.IsModified(_context) || record.GeoCode.IsModified(_context)); //Mapping }
void ClearBindings() { _ignoreLeaveRow = true; _ignorePositionChange = true; _selectedRecord = null; BindingSourceSupplierCity.Clear(); SetReadOnly(true); BarButtonItemDelete.Enabled = false; BarButtonItemSave.Enabled = false; BindingSource.DataSource = typeof(CITYCOD); ClearMapData(); //Mapping _ignoreLeaveRow = false; _ignorePositionChange = false; }
private void BarButtonItemNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { _ignoreLeaveRow = true; //so that when the grid row changes it doesn't try to save again if (SaveRecord(true)) { //For some reason when there is no existing record in the binding source the Add method does not //trigger the CurrentChanged event, but AddNew does so use that instead _selectedRecord = (CITYCOD)BindingSource.AddNew(); //With the instant feedback data source, the new row is not immediately added to the grid, so move //the focused row to the filter row just so that no other existing row is visually highlighted GridViewLookup.FocusedRowHandle = DevExpress.Data.BaseListSourceDataController.FilterRow; SetReadOnlyKeyFields(false); TextEditCode.Focus(); SetReadOnly(false); } ErrorProvider.Clear(); _ignoreLeaveRow = false; }
void SetBindings() { if (BindingSource.Current == null) { ClearBindings(); } else { _selectedRecord = ((CITYCOD)BindingSource.Current); LoadAndBindSupplierCities(); SetReadOnly(false); SetReadOnlyKeyFields(true); BarButtonItemDelete.Enabled = true; BarButtonItemSave.Enabled = true; ShowMapData(_selectedRecord); //Mapping } ErrorProvider.Clear(); }
private void ShowMapData(CITYCOD record) { GeoCode geoCode = record?.GeoCode ?? new GeoCode(); AddOrMovePushpin(geoCode); //If a bounding box has been given, then use it if (geoCode.NorthLat != 0) { var topLeft = new GeoPoint(geoCode.NorthLat, geoCode.WestLong); var bottomRight = new GeoPoint(geoCode.SouthLat, geoCode.EastLong); MapControl.ZoomToRegion(topLeft, bottomRight, 0); } else { //If there there is no bounding box, zoom all the way out if this is a new record, otherwise go to the //default zoom level MapControl.ZoomLevel = (geoCode.GeoCodeId == 0) ? 1 : 13; } }
private void GridViewLookup_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { if (!_ignoreLeaveRow) { GridView view = (GridView)sender; object row = view.GetRow(e.FocusedRowHandle); if (row != null && row.GetType() != typeof(DevExpress.Data.NotLoadedObject)) { ReadonlyThreadSafeProxyForObjectFromAnotherThread proxy = (ReadonlyThreadSafeProxyForObjectFromAnotherThread)view.GetRow(e.FocusedRowHandle); CITYCOD record = (CITYCOD)proxy.OriginalRow; BindingSource.DataSource = _context.CITYCOD.Where(c => c.CODE == record.CODE) .Include(c => c.GeoCode); } else { ClearBindings(); } } }