protected override E_EditMode DoEdit() { // return the edit mode E_EditMode editmode = E_EditMode.no_edit; // check which controls have text and objects (are in DB) var hasShootingLocationText = !string.IsNullOrEmpty(Window.Location_SubjectLocationControl.GetCurrentText()); var shootingLocationInDB = Window.Location_SubjectLocationControl.GetCurrentObject() != null; var hasParkingLocationText = !string.IsNullOrEmpty(Window.ParkingLocationControl.GetCurrentText()); var parkingLocationInDB = Window.ParkingLocationControl.GetCurrentObject() != null; if (shootingLocationInDB && !parkingLocationInDB) { SwitchEditModeShootingLocation(); editmode = E_EditMode.edit_shootinglocation; } else if (!shootingLocationInDB && parkingLocationInDB) { SwitchEditModeParkingLocation(); editmode = E_EditMode.edit_parkinglocation; } else if (shootingLocationInDB && parkingLocationInDB) { EditChangeSelectionWindow window = new EditChangeSelectionWindow(EditChangeSelectionWindow.EMode.edit); window.ShowDialog(); if (window.DialogResult is true) { if (window.ShootingLocationRadioButton.IsChecked is true) { SwitchEditModeShootingLocation(); editmode = E_EditMode.edit_shootinglocation; } else if (window.ParkingLocationRadioButton.IsChecked is true) { SwitchEditModeParkingLocation(); editmode = E_EditMode.edit_parkinglocation; } } } // editing is not possible - probably user wants to edit values that are not added to DB yet else { ShowMessage("Editing not possible (you might have entered new values)", E_MessageType.info); } return(editmode); }
protected override E_EditMode DoEdit() { // return the edit mode E_EditMode editmode = E_EditMode.no_edit; // check which controls have text and objects (are in DB) var hasCountryText = !string.IsNullOrEmpty(Window.Settings_CountryControl.GetCurrentText()); var countryInDB = Window.Settings_CountryControl.GetCurrentObject() != null; var hasAreaText = !string.IsNullOrEmpty(Window.Settings_AreaControl.GetCurrentText()); var areaInDB = Window.Settings_AreaControl.GetCurrentObject() != null; var hasSubAreaText = !string.IsNullOrEmpty(Window.Settings_SubAreaControl.GetCurrentText()); var subAreaInDB = Window.Settings_SubAreaControl.GetCurrentObject() != null; var hasSubjectLocationText = !string.IsNullOrEmpty(Window.Settings_SubjectLocationControl.GetCurrentText()); var subjectLocationInDB = Window.Settings_SubjectLocationControl.GetCurrentObject() != null; // only country control has text, so edit country if (hasCountryText && !hasAreaText && !hasSubAreaText && !hasSubjectLocationText) { // edit only saved values if (countryInDB) { SwitchEditModeCountry(); editmode = E_EditMode.edit_country; } } // country and area control have text, so edit area else if (hasCountryText && hasAreaText && !hasSubAreaText & !hasSubjectLocationText) { // edit only saved values if (countryInDB && areaInDB) { SwitchEditModeArea(); editmode = E_EditMode.edit_area; } } // country, area and subarea control have text, so edit subarea else if (hasSubAreaText && hasAreaText && hasSubAreaText && !hasSubjectLocationText) { // edit only saved values if (countryInDB && areaInDB && subAreaInDB) { SwitchEditModeSubArea(); editmode = E_EditMode.edit_subarea; } } // all controls have text, so edit subject location else if (hasSubAreaText && hasAreaText && hasSubAreaText && hasSubjectLocationText) { // edit only saved values if (countryInDB && areaInDB && subAreaInDB && subjectLocationInDB) { SwitchEditModeSubjectLocation(); editmode = E_EditMode.edit_subjectlocation; } } // editing is not possible - probably user wants to edit values that are not added to DB yet else { ShowMessage("Editing not possible (you might have entered new values)", E_MessageType.info); } return(editmode); }