private void OnAutoRefresh(object sender, DoWorkEventArgs e) { //Event handler for background worker thread DoWork event; runs on worker thread try { ShipScheduleDataset ds = new ShipScheduleDataset(); ds.Merge(ShipScheduleGateway.GetShipSchedule(this.mSortCenterID, this.mScheduleDate)); ds.Merge(ShipScheduleGateway.GetShipScheduleTemplates(this.mSortCenterID, this.mScheduleDate)); e.Result = ds; } catch { } }
public void Update() { //Extract the row versions and update the updated rows. This will keep the selected row in the view //Checks for duplicate load number within the same carrier during the past and future 7 days try { //Determine changes made to the trips in this ship schedule ShipScheduleDataset trips = (ShipScheduleDataset)this.mTrips.GetChanges(DataRowState.Modified); if (trips != null && trips.ShipScheduleViewTable.Rows.Count > 0) { //Update each modified trip foreach (ShipScheduleDataset.ShipScheduleViewTableRow row in trips.ShipScheduleViewTable.Rows) { //Check to see if load# or carrier has changed; if so, then make sure it's unique within the same //carrier (updated once if it's updated along with load#) and during the past one week schedule if (row.LoadNumber.Trim() != row["LoadNumber", DataRowVersion.Original].ToString().Trim() && row.CarrierServiceID.ToString().Trim() == row["CarrierServiceID", DataRowVersion.Original].ToString().Trim()) { string tripID = ShipScheduleGateway.FindShipScheduleTrip(row.ScheduleDate, 0, row.LoadNumber.Trim()); if (tripID.Trim().Length > 0) { throw new DuplicateLoadNumberException("Duplicate load# found in ship schedule for " + tripID + "."); } } //Save trip details ShipScheduleGateway.UpdateShipSchedule(row); try { //Refresh the details of the current trip (instead of a full refresh) ShipScheduleDataset viewItems = ShipScheduleGateway.GetShipSchedule(row.SortCenterID, row.ScheduleDate); if (viewItems.ShipScheduleViewTable.Rows.Count > 0) { ShipScheduleDataset.ShipScheduleViewTableRow viewItem = viewItems.ShipScheduleViewTable.FindByTripID(row.TripID); ShipScheduleDataset.ShipScheduleViewTableRow trip = this.mTrips.ShipScheduleViewTable.FindByTripID(row.TripID); trip.SCDERowVersion = viewItem.SCDERowVersion; trip.S1RowVersion = viewItem.S1RowVersion; if (!row.IsS2StopIDNull()) { trip.S2RowVersion = viewItem.S2RowVersion; } this.mTrips.AcceptChanges(); } } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } } //Refresh(); Doing partial refresh above for performance reasons (i.e. cell editing) } } catch (DuplicateLoadNumberException ex) { throw ex; } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } }
public void Refresh() { //Update a collection (dataset) of all ship schedule trips for the terminal and schedule date try { //Clear and update trips for this schedule this.mTrips.Clear(); this.mTemplates.Clear(); this.mTrips.Merge(ShipScheduleGateway.GetShipSchedule(this.mSortCenterID, this.mScheduleDate)); this.mTemplates.Merge(ShipScheduleGateway.GetShipScheduleTemplates(this.mSortCenterID, this.mScheduleDate)); foreach (ShipScheduleDataset.TemplateViewTableRow row in this.mTemplates.TemplateViewTable.Rows) { row.Selected = (row.IsMandatory == 1); } this.mTemplates.AcceptChanges(); } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } finally { if (this.Changed != null) { this.Changed(this, EventArgs.Empty); } } }