private void bLoc_Click(object sender, RibbonControlEventArgs e) { Cursor.Current = Cursors.WaitCursor; Location loc = new Location(); Guid origId = Guid.Empty; string origAddress = ""; if (_appt != null) { if (_touch.Locations.Count == 0) { loc = new Location() { UserType_Id = Guids.Loc_Business, Address = _appt.Location, changeType = ChangeType.Update, Collection_Id = _touch.Collection_Id, OwnedByGroup_Id = _touch.OwnedByGroup_Id, OwnedBy_Id = _touch.OwnedBy_Id }; } else { loc = _touch.Locations[0]; origId = loc.Id; origAddress = loc.Address; } locationForm frm = new locationForm(loc); DialogResult result = frm.ShowDialog(); if (result == DialogResult.OK) { loc = frm.TheLocation; if (origAddress == "" || origAddress != loc.Address) { //ReplaceLocation(origId, loc); foreach (Location l in _touch.Locations) { l.changeType = ChangeType.Remove; DataAPI.DeleteLocation(l.Id); } loc.changeType = ChangeType.Update; loc.Id = DataAPI.PostLocation(loc); DataAPI.PostRelationship(new RelationshipPost() { entityType1 = EntityTypes.Touch, entityId1 = _touch.Id, entityType2 = EntityTypes.Location, entityId2 = loc.Id }); _touch.Locations.Add(loc); _touch.changeType = ChangeType.Update; _appt.Location = loc.Address; } //SyncApptDetails(); } } }
private void pbMap_Click(object sender, EventArgs e) { Location loc = new Location(); Guid origId = Guid.Empty; string origAddress = ""; if (_touch.Locations.Count > 0) { loc = _touch.Locations[0]; origId = loc.Id; origAddress = loc.Address; } locationForm frm = new locationForm(loc); DialogResult result = frm.ShowDialog(); if (result == DialogResult.OK) { loc = frm.TheLocation; lblLocation.Text = loc.Address; if (origAddress == "" || origAddress != loc.Address) { loc.changeType = ChangeType.Update; foreach (Location l in _touch.Locations) { l.changeType = ChangeType.Remove; DataAPI.DeleteLocation(l.Id); } loc.changeType = ChangeType.Update; loc.Id = DataAPI.PostLocation(loc); DataAPI.PostRelationship(new RelationshipPost() { entityType1 = EntityTypes.Touch, entityId1 = _touch.Id, entityType2 = EntityTypes.Location, entityId2 = loc.Id }); _touch.Locations.Add(loc); _touch.changeType = ChangeType.Update; } MakeDirty(); } }