public override ScheduleEntry Item(int ID) { //Return an existing entry object from the entry log TrailerEntry entry = null; try { //Merge from collection (dataset) if (ID > 0) { DataRow[] rows = this.mSchedule.TrailerLogTable.Select("ID=" + ID); if (rows.Length == 0) { throw new ApplicationException("Entry " + ID + " does not exist in this schedule!\n"); } DispatchDS.TrailerLogTableRow row = (DispatchDS.TrailerLogTableRow)rows[0]; entry = new TrailerEntry(row, this.mMediator); entry.DataFile = base.mDataFile; entry.EntryChanged += new EventHandler(OnEntryChanged); } else { entry = (TrailerEntry)Item(); } } catch (Exception ex) { throw ex; } return(entry); }
public override DataSet ToDataSet() { //Return a dataset containing values for this object DispatchDS ds = null; try { ds = new DispatchDS(); DispatchDS.TrailerLogTableRow trailerEntry = ds.TrailerLogTable.NewTrailerLogTableRow(); trailerEntry.ID = this._id; trailerEntry.Created = this._created; trailerEntry.CreatedBy = this._createdby; trailerEntry.TrailerNumber = this._trailernumber; trailerEntry.IncomingDate = this._incomingdate; trailerEntry.IncomingCarrier = this._incomingcarrier; trailerEntry.IncomingSeal = this._incomingseal; trailerEntry.IncomingDriverName = this._incomingdrivername; trailerEntry.InitialYardLocation = this._initialyardlocation; trailerEntry.LoadSheetReady = this._loadsheetready; trailerEntry.MoveInProgress = this._moveinprogress; trailerEntry.OutgoingDate = this._outgoingdate; trailerEntry.OutgoingCarrier = this._outgoingcarrier; trailerEntry.OutgoingSeal = this._outgoingseal; trailerEntry.OutgoingDriverName = this._outgoingdrivername; trailerEntry.MovedOut = this._movedout; trailerEntry.Comments = this._comments; ds.TrailerLogTable.AddTrailerLogTableRow(trailerEntry); ds.Merge(this.mTrailerMoves); ds.AcceptChanges(); } catch (Exception) { } return(ds); }
public override void RemoveList(DispatchDS list) { //Remove a list of entries from this schedule try { for (int i = 0; i < list.TrailerLogTable.Rows.Count; i++) { DispatchDS.TrailerLogTableRow row = list.TrailerLogTable[i]; TrailerEntry entry = (TrailerEntry)Item(row.ID); entry.Delete(); } } catch (Exception ex) { throw ex; } }
public override bool Delete() { //Delete this object and all child objects bool bRet = false; try { DispatchDS ds = new DispatchDS(); ds.Merge(base.mMediator.FillDataset(base.mDataFile, "", null)); DispatchDS.TrailerLogTableRow row = (DispatchDS.TrailerLogTableRow)ds.TrailerLogTable.Select("ID = " + this._id)[0]; row.Delete(); for (int i = 0; i < this.mTrailerMoves.TrailerMoveTable.Rows.Count; i++) { DispatchDS.TrailerMoveTableRow _row = (DispatchDS.TrailerMoveTableRow)ds.TrailerMoveTable.Select("ID = " + this.mTrailerMoves.TrailerMoveTable[i].ID)[0]; _row.Delete(); } ds.TrailerMoveTable.AcceptChanges(); ds.TrailerLogTable.AcceptChanges(); bRet = base.mMediator.ExecuteNonQuery(base.mDataFile, new object[] { ds }); bRet = true; base.OnEntryChanged(this, new EventArgs()); } catch (Exception ex) { throw ex; } return(bRet); }
public override void AddList(DispatchDS list) { //Add a list of entries to this schedule try { for (int i = 0; i < list.TrailerLogTable.Rows.Count; i++) { DispatchDS.TrailerLogTableRow row = list.TrailerLogTable[i]; TrailerEntry entry = (TrailerEntry)Item(); entry.ID = row.ID; entry.Created = row.Created; entry.CreatedBy = row.CreatedBy; if (!row.IsTrailerNumberNull()) { entry.TrailerNumber = row.TrailerNumber; } if (!row.IsIncomingDateNull()) { entry.IncomingDate = row.IncomingDate; } if (!row.IsIncomingCarrierNull()) { entry.IncomingCarrier = row.IncomingCarrier; } if (!row.IsIncomingSealNull()) { entry.IncomingSeal = row.IncomingSeal; } if (!row.IsIncomingDriverNameNull()) { entry.IncomingDriverName = row.IncomingDriverName; } if (!row.IsInitialYardLocationNull()) { entry.InitialYardLocation = row.InitialYardLocation; } if (!row.IsLoadSheetReadyNull()) { entry.LoadSheetReady = row.LoadSheetReady; } if (!row.IsMoveInProgressNull()) { entry.MoveInProgress = row.MoveInProgress; } if (!row.IsOutgoingDateNull()) { entry.OutgoingDate = row.OutgoingDate; } if (!row.IsOutgoingCarrierNull()) { entry.OutgoingCarrier = row.OutgoingCarrier; } if (!row.IsOutgoingSealNull()) { entry.OutgoingSeal = row.OutgoingSeal; } if (!row.IsOutgoingDriverNameNull()) { entry.OutgoingDriverName = row.OutgoingDriverName; } if (!row.IsMovedOutNull()) { entry.MovedOut = row.MovedOut; } if (!row.IsCommentsNull()) { entry.Comments = row.Comments; } entry.TrailerMoves.TrailerLogTable.ImportRow(row); //Enable constraints for next line entry.TrailerMoves.Merge(row.GetTrailerMoveTableRows()); entry.TrailerMoves.TrailerMoveTable.AcceptChanges(); Add(entry); } } catch (Exception ex) { throw ex; } }
public TrailerEntry(DispatchDS.TrailerLogTableRow trailerEntry, Mediator mediator) : base(mediator) { //Constructor try { if (trailerEntry != null) { this._id = trailerEntry.ID; this._created = trailerEntry.Created; this._createdby = trailerEntry.CreatedBy; if (!trailerEntry.IsTrailerNumberNull()) { this._trailernumber = trailerEntry.TrailerNumber; } if (!trailerEntry.IsIncomingDateNull()) { this._incomingdate = trailerEntry.IncomingDate; } if (!trailerEntry.IsIncomingCarrierNull()) { this._incomingcarrier = trailerEntry.IncomingCarrier; } if (!trailerEntry.IsIncomingSealNull()) { this._incomingseal = trailerEntry.IncomingSeal; } if (!trailerEntry.IsIncomingDriverNameNull()) { this._incomingdrivername = trailerEntry.IncomingDriverName; } if (!trailerEntry.IsInitialYardLocationNull()) { this._initialyardlocation = trailerEntry.InitialYardLocation; } if (!trailerEntry.IsLoadSheetReadyNull()) { this._loadsheetready = trailerEntry.LoadSheetReady; } if (!trailerEntry.IsMoveInProgressNull()) { this._moveinprogress = trailerEntry.MoveInProgress; } if (!trailerEntry.IsOutgoingDateNull()) { this._outgoingdate = trailerEntry.OutgoingDate; } if (!trailerEntry.IsOutgoingCarrierNull()) { this._outgoingcarrier = trailerEntry.OutgoingCarrier; } if (!trailerEntry.IsOutgoingSealNull()) { this._outgoingseal = trailerEntry.OutgoingSeal; } if (!trailerEntry.IsOutgoingDriverNameNull()) { this._outgoingdrivername = trailerEntry.OutgoingDriverName; } if (!trailerEntry.IsMovedOutNull()) { this._movedout = trailerEntry.MovedOut; } if (!trailerEntry.IsCommentsNull()) { this._comments = trailerEntry.Comments; } this.mTrailerMoves = new DispatchDS(); this.mTrailerMoves.TrailerLogTable.ImportRow(trailerEntry); //Enable constraints for next line this.mTrailerMoves.Merge(trailerEntry.GetTrailerMoveTableRows()); this.mTrailerMoves.TrailerMoveTable.AcceptChanges(); } else { this.mTrailerMoves = new DispatchDS(); } } catch (Exception ex) { throw ex; } }
public override bool Update() { //Update this object and all child objects bool bRet = false; try { DispatchDS ds = new DispatchDS(); ds.Merge(base.mMediator.FillDataset(base.mDataFile, "", null)); DispatchDS.TrailerLogTableRow row = (DispatchDS.TrailerLogTableRow)ds.TrailerLogTable.Select("ID = " + this._id)[0]; row.Created = this._created; row.CreatedBy = this._createdby; row.TrailerNumber = this._trailernumber; row.IncomingDate = this._incomingdate; row.IncomingCarrier = this._incomingcarrier; row.IncomingSeal = this._incomingseal; row.IncomingDriverName = this._incomingdrivername; row.InitialYardLocation = this._initialyardlocation; row.LoadSheetReady = this._loadsheetready; row.MoveInProgress = this._moveinprogress; row.OutgoingDate = this._outgoingdate; row.OutgoingCarrier = this._outgoingcarrier; row.OutgoingSeal = this._outgoingseal; row.OutgoingDriverName = this._outgoingdrivername; row.MovedOut = this._movedout; row.Comments = this._comments; for (int i = 0; i < this.mTrailerMoves.TrailerMoveTable.Rows.Count; i++) { DispatchDS.TrailerMoveTableRow _row = (DispatchDS.TrailerMoveTableRow) this.mTrailerMoves.TrailerMoveTable[i]; if (_row.RowState == DataRowState.Added) { DispatchDS.TrailerMoveTableRow __row = (DispatchDS.TrailerMoveTableRow)ds.TrailerMoveTable.NewTrailerMoveTableRow(); __row.ID = _row.ID; __row.Requested = _row.Requested; __row.RequestedBy = _row.RequestedBy; if (!_row.IsMoveFromNull()) { __row.MoveFrom = _row.MoveFrom; } if (!_row.IsMoveToNull()) { __row.MoveTo = _row.MoveTo; } if (!_row.IsSwitcherNull()) { __row.Switcher = _row.Switcher; } if (!_row.IsLoadedWithNull()) { __row.LoadedWith = _row.LoadedWith; } if (!_row.IsScheduledTimeNull()) { __row.ScheduledTime = _row.ScheduledTime; } if (!_row.IsActualTimeNull()) { __row.ActualTime = _row.ActualTime; } __row.TrailerLogTableRow = row; ds.TrailerMoveTable.AddTrailerMoveTableRow(__row); } else if (_row.RowState == DataRowState.Modified) { DispatchDS.TrailerMoveTableRow __row = (DispatchDS.TrailerMoveTableRow)ds.TrailerMoveTable.Select("ID = " + _row.ID)[0]; if (!_row.IsMoveFromNull()) { __row.MoveFrom = _row.MoveFrom; } if (!_row.IsMoveToNull()) { __row.MoveTo = _row.MoveTo; } if (!_row.IsSwitcherNull()) { __row.Switcher = _row.Switcher; } if (!_row.IsLoadedWithNull()) { __row.LoadedWith = _row.LoadedWith; } if (!_row.IsScheduledTimeNull()) { __row.ScheduledTime = _row.ScheduledTime; } if (!_row.IsActualTimeNull()) { __row.ActualTime = _row.ActualTime; } } else if (_row.RowState == DataRowState.Deleted) { DispatchDS.TrailerMoveTableRow __row = (DispatchDS.TrailerMoveTableRow)ds.TrailerMoveTable.Select("ID = " + _row.ID)[0]; __row.Delete(); } } ds.TrailerMoveTable.AcceptChanges(); ds.TrailerLogTable.AcceptChanges(); bRet = base.mMediator.ExecuteNonQuery(base.mDataFile, new object[] { ds }); bRet = true; base.OnEntryChanged(this, new EventArgs()); } catch (Exception ex) { throw ex; } return(bRet); }
public override bool Create() { //Save this object and all child objects bool bRet = false; try { DispatchDS ds = new DispatchDS(); ds.Merge(base.mMediator.FillDataset(base.mDataFile, "", null)); if (this._id <= 0) { //For new entries only; some entries are moved between schedules int ID = 0; for (int i = 0; i < ds.TrailerLogTable.Rows.Count; i++) { if (ds.TrailerLogTable[i].ID > ID) { ID = ds.TrailerLogTable[i].ID; } } this._id = ID + 1; } DispatchDS.TrailerLogTableRow row = ds.TrailerLogTable.AddTrailerLogTableRow(this._id, this._created, this._createdby, this._trailernumber, this._incomingdate, this._incomingcarrier, this._incomingseal, this._incomingdrivername, this._initialyardlocation, this._loadsheetready, this._moveinprogress, this._outgoingdate, this._outgoingcarrier, this._outgoingseal, this._outgoingdrivername, this._movedout, this._comments); for (int i = 0; i < this.mTrailerMoves.TrailerMoveTable.Rows.Count; i++) { DispatchDS.TrailerMoveTableRow _row = (DispatchDS.TrailerMoveTableRow) this.mTrailerMoves.TrailerMoveTable[i]; DispatchDS.TrailerMoveTableRow __row = (DispatchDS.TrailerMoveTableRow)ds.TrailerMoveTable.NewTrailerMoveTableRow(); __row.ID = _row.ID; __row.Requested = _row.Requested; __row.RequestedBy = _row.RequestedBy; if (!_row.IsMoveFromNull()) { __row.MoveFrom = _row.MoveFrom; } if (!_row.IsMoveToNull()) { __row.MoveTo = _row.MoveTo; } if (!_row.IsSwitcherNull()) { __row.Switcher = _row.Switcher; } if (!_row.IsLoadedWithNull()) { __row.LoadedWith = _row.LoadedWith; } if (!_row.IsScheduledTimeNull()) { __row.ScheduledTime = _row.ScheduledTime; } if (!_row.IsActualTimeNull()) { __row.ActualTime = _row.ActualTime; } __row.TrailerLogTableRow = row; ds.TrailerMoveTable.AddTrailerMoveTableRow(__row); } ds.TrailerMoveTable.AcceptChanges(); ds.TrailerLogTable.AcceptChanges(); bRet = base.mMediator.ExecuteNonQuery(base.mDataFile, new object[] { ds }); bRet = true; base.OnEntryChanged(this, new EventArgs()); } catch (Exception ex) { throw ex; } return(bRet); }