public override DataSet ToDataSet() { //Return a dataset containing values for this object DispatchDS ds = null; try { ds = new DispatchDS(); DispatchDS.ScheduledOutboundTableRow row = ds.ScheduledOutboundTable.NewScheduledOutboundTableRow(); row.ID = this._id; row.Created = this._created; row.CreatedBy = this._createdby; row.DriverName = this._drivername; row.TrailerNumber = this._trailernumber; row.FromLocation = this._fromlocation; row.ToLocation = this._tolocation; row.ScheduledDeparture = this._scheduleddeparture; row.ActualDeparture = this._actualdeparture; row.ScheduledDelivery = this._scheduleddelivery; row.ActualDelivery = this._actualdelivery; row.Comments = this._comments; row.Confirmed = this._confirmed; ds.ScheduledOutboundTable.AddScheduledOutboundTableRow(row); } catch (Exception) { } return(ds); }
public override ScheduleEntry Item(int ID) { //Return an existing entry object from the entry schedule OutboundFreight entry = null; try { //Merge from collection (dataset) if (ID > 0) { DataRow[] rows = this.mSchedule.ScheduledOutboundTable.Select("ID=" + ID); if (rows.Length == 0) { throw new ApplicationException("Entry " + ID + " does not exist in this schedule!\n"); } DispatchDS.ScheduledOutboundTableRow row = (DispatchDS.ScheduledOutboundTableRow)rows[0]; entry = new OutboundFreight(row, this.mMediator); entry.DataFile = base.mDataFile; entry.EntryChanged += new EventHandler(OnEntryChanged); } else { entry = (OutboundFreight)Item(); } } catch (Exception ex) { throw ex; } return(entry); }
public override bool Create() { //Save this object 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.ScheduledOutboundTable.Rows.Count; i++) { if (ds.ScheduledOutboundTable[i].ID > ID) { ID = ds.ScheduledOutboundTable[i].ID; } } this._id = ID + 1; } DispatchDS.ScheduledOutboundTableRow row = ds.ScheduledOutboundTable.NewScheduledOutboundTableRow(); row.ID = this._id; row.Created = this._created; row.CreatedBy = this._createdby; row.DriverName = this._drivername; row.TrailerNumber = this._trailernumber; row.FromLocation = this._fromlocation; row.ToLocation = this._tolocation; if (this._scheduleddeparture != DateTime.MinValue) { row.ScheduledDeparture = this._scheduleddeparture; } if (this._actualdeparture != DateTime.MinValue) { row.ActualDeparture = this._actualdeparture; } if (this._scheduleddelivery != DateTime.MinValue) { row.ScheduledDelivery = this._scheduleddelivery; } if (this._actualdelivery != DateTime.MinValue) { row.ActualDelivery = this._actualdelivery; } row.Comments = this._comments; row.Confirmed = this._confirmed; ds.ScheduledOutboundTable.AddScheduledOutboundTableRow(row); ds.ScheduledOutboundTable.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) { // try { for (int i = 0; i < list.ScheduledOutboundTable.Rows.Count; i++) { DispatchDS.ScheduledOutboundTableRow row = list.ScheduledOutboundTable[i]; OutboundFreight entry = (OutboundFreight)Item(); entry.ID = row.ID; entry.Created = row.Created; entry.CreatedBy = row.CreatedBy; if (!row.IsDriverNameNull()) { entry.DriverName = row.DriverName; } if (!row.IsTrailerNumberNull()) { entry.TrailerNumber = row.TrailerNumber; } if (!row.IsFromLocationNull()) { entry.FromLocation = row.FromLocation; } if (!row.IsToLocationNull()) { entry.ToLocation = row.ToLocation; } if (!row.IsScheduledDepartureNull()) { entry.ScheduledDeparture = row.ScheduledDeparture; } if (!row.IsActualDepartureNull()) { entry.ActualDeparture = row.ActualDeparture; } if (!row.IsScheduledDeliveryNull()) { entry.ScheduledDelivery = row.ScheduledDelivery; } if (!row.IsActualDeliveryNull()) { entry.ActualDelivery = row.ActualDelivery; } if (!row.IsCommentsNull()) { entry.Comments = row.Comments; } if (!row.IsConfirmedNull()) { entry.Confirmed = row.Confirmed; } Add(entry); } } catch (Exception ex) { throw ex; } }
public OutboundFreight(DispatchDS.ScheduledOutboundTableRow row, Mediator mediator) : base(mediator) { //Constructor try { if (row != null) { this._id = row.ID; this._created = row.Created; this._createdby = row.CreatedBy; if (!row.IsDriverNameNull()) { this._drivername = row.DriverName; } if (!row.IsTrailerNumberNull()) { this._trailernumber = row.TrailerNumber; } if (!row.IsFromLocationNull()) { this._fromlocation = row.FromLocation; } if (!row.IsToLocationNull()) { this._tolocation = row.ToLocation; } if (!row.IsScheduledDepartureNull()) { this._scheduleddeparture = row.ScheduledDeparture; } if (!row.IsActualDepartureNull()) { this._actualdeparture = row.ActualDeparture; } if (!row.IsScheduledDeliveryNull()) { this._scheduleddelivery = row.ScheduledDelivery; } if (!row.IsActualDeliveryNull()) { this._actualdelivery = row.ActualDelivery; } if (!row.IsCommentsNull()) { this._comments = row.Comments; } if (!row.IsConfirmedNull()) { this._confirmed = row.Confirmed; } } } catch (Exception ex) { throw ex; } }
public override void RemoveList(DispatchDS list) { //Remove a list of entries from this schedule try { for (int i = 0; i < list.ScheduledOutboundTable.Rows.Count; i++) { DispatchDS.ScheduledOutboundTableRow row = list.ScheduledOutboundTable[i]; OutboundFreight entry = (OutboundFreight)Item(row.ID); entry.Delete(); } } catch (Exception ex) { throw ex; } }
public override bool Delete() { //Delete this object bool bRet = false; try { DispatchDS ds = new DispatchDS(); ds.Merge(base.mMediator.FillDataset(base.mDataFile, "", null)); DispatchDS.ScheduledOutboundTableRow row = (DispatchDS.ScheduledOutboundTableRow)ds.ScheduledOutboundTable.Select("ID = " + this._id)[0]; row.Delete(); ds.ScheduledOutboundTable.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 Update() { //Update this object bool bRet = false; try { DispatchDS ds = new DispatchDS(); ds.Merge(base.mMediator.FillDataset(base.mDataFile, "", null)); DispatchDS.ScheduledOutboundTableRow row = (DispatchDS.ScheduledOutboundTableRow)ds.ScheduledOutboundTable.Select("ID = " + this._id)[0]; row.DriverName = this._drivername; row.TrailerNumber = this._trailernumber; row.FromLocation = this._fromlocation; row.ToLocation = this._tolocation; if (this._scheduleddeparture != DateTime.MinValue) { row.ScheduledDeparture = this._scheduleddeparture; } if (this._actualdeparture != DateTime.MinValue) { row.ActualDeparture = this._actualdeparture; } if (this._scheduleddelivery != DateTime.MinValue) { row.ScheduledDelivery = this._scheduleddelivery; } if (this._actualdelivery != DateTime.MinValue) { row.ActualDelivery = this._actualdelivery; } row.Comments = this._comments; row.Confirmed = this._confirmed; ds.ScheduledOutboundTable.AcceptChanges(); bRet = base.mMediator.ExecuteNonQuery(base.mDataFile, new object[] { ds }); bRet = true; base.OnEntryChanged(this, new EventArgs()); } catch (Exception ex) { throw ex; } return(bRet); }