public override DataSet ToDataSet() { //Return a dataset containing values for this object DispatchDS ds = null; try { ds = new DispatchDS(); DispatchDS.PickupLogTableRow row = ds.PickupLogTable.NewPickupLogTableRow(); row.ID = this._id; row.Created = this._created; row.CreatedBy = this._createdby; row.CallerName = this._callername; row.ClientName = this._clientname; row.ShipperName = this._shippername; row.ShipperAddress = this._shipperaddress; row.DeliveryWindow = this._deliverywindow; row.Terminal = this._terminal; row.DriverName = this._drivername; row.Amount = this._amount; row.AmountType = this._amounttype; row.FreightType = this._freighttype; row.AutoNumber = this._autonumber; row.RequestDate = this._requestdate; row.PickUpDate = this._pickupdate; row.Comments = this._comments; row.Updated = this._updated; row.MustBeReady = this._mustbeready; row.PickedUp = this._pickedup; ds.PickupLogTable.AddPickupLogTableRow(row); } catch (Exception) { } return(ds); }
public override ScheduleEntry Item(int ID) { //Return an existing entry object from the entry log Pickup entry = null; try { //Merge from collection (dataset) if (ID > 0) { DataRow[] rows = this.mSchedule.PickupLogTable.Select("ID=" + ID); if (rows.Length == 0) { throw new ApplicationException("Entry " + ID + " does not exist in this schedule!\n"); } DispatchDS.PickupLogTableRow row = (DispatchDS.PickupLogTableRow)rows[0]; entry = new Pickup(row, this.mMediator); entry.DataFile = base.mDataFile; entry.EntryChanged += new EventHandler(OnEntryChanged); } else { entry = (Pickup)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.PickupLogTable.Rows.Count; i++) { if (ds.PickupLogTable[i].ID > ID) { ID = ds.PickupLogTable[i].ID; } } this._id = ID + 1; } DispatchDS.PickupLogTableRow row = ds.PickupLogTable.NewPickupLogTableRow(); row.ID = this._id; row.Created = this._created; row.CreatedBy = this._createdby; row.CallerName = this._callername; row.ClientName = this._clientname; row.ShipperName = this._shippername; row.ShipperAddress = this._shipperaddress; row.DeliveryWindow = this._deliverywindow; row.Terminal = this._terminal; row.DriverName = this._drivername; row.Amount = this._amount; row.AmountType = this._amounttype; row.FreightType = this._freighttype; row.AutoNumber = this._autonumber; row.RequestDate = this._requestdate; if (this._pickupdate != DateTime.MinValue) { row.PickUpDate = this._pickupdate; } row.Comments = this._comments; row.Updated = this._updated; row.MustBeReady = this._mustbeready; row.PickedUp = this._pickedup; ds.PickupLogTable.AddPickupLogTableRow(this._id, this._created, this._createdby, this._callername, this._clientname, this._shippername, this._shipperaddress, this._deliverywindow, this._terminal, this._drivername, this._amount, this._amounttype, this._freighttype, this._autonumber, this._requestdate, this._pickupdate, this._comments, this._updated, this._mustbeready, this._pickedup); ds.PickupLogTable.AcceptChanges(); bRet = base.mMediator.ExecuteNonQuery(base.mDataFile, new object[] { ds }); base.OnEntryChanged(this, new EventArgs()); } catch (Exception ex) { throw ex; } return(bRet); }
public override void RemoveList(DispatchDS list) { //Remove a list of entries from this schedule try { for (int i = 0; i < list.PickupLogTable.Rows.Count; i++) { DispatchDS.PickupLogTableRow row = list.PickupLogTable[i]; Pickup entry = (Pickup)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.PickupLogTableRow row = (DispatchDS.PickupLogTableRow)ds.PickupLogTable.Select("ID = " + this._id)[0]; row.Delete(); ds.PickupLogTable.AcceptChanges(); bRet = base.mMediator.ExecuteNonQuery(base.mDataFile, new object[] { ds }); 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.PickupLogTableRow row = (DispatchDS.PickupLogTableRow)ds.PickupLogTable.Select("ID = " + this._id)[0]; row.CallerName = this._callername; row.ClientName = this._clientname; row.ShipperName = this._shippername; row.ShipperAddress = this._shipperaddress; row.DeliveryWindow = this._deliverywindow; row.Terminal = this._terminal; row.DriverName = this._drivername; row.Amount = this._amount; row.AmountType = this._amounttype; row.FreightType = this._freighttype; row.AutoNumber = this._autonumber; row.RequestDate = this._requestdate; if (this._pickupdate != DateTime.MinValue) { row.PickUpDate = this._pickupdate; } row.Comments = this._comments; row.Updated = this._updated; row.MustBeReady = this._mustbeready; row.PickedUp = this._pickedup; ds.PickupLogTable.AcceptChanges(); bRet = base.mMediator.ExecuteNonQuery(base.mDataFile, new object[] { ds }); base.OnEntryChanged(this, new EventArgs()); } catch (Exception ex) { throw ex; } return(bRet); }
public Pickup(DispatchDS.PickupLogTableRow row, Mediator mediator) : base(mediator) { //Constructor try { if (row != null) { this._id = row.ID; this._created = row.Created; this._createdby = row.CreatedBy; if (!row.IsCallerNameNull()) { this._callername = row.CallerName; } if (!row.IsClientNameNull()) { this._clientname = row.ClientName; } if (!row.IsShipperNameNull()) { this._shippername = row.ShipperName; } if (!row.IsShipperAddressNull()) { this._shipperaddress = row.ShipperAddress; } if (!row.IsDeliveryWindowNull()) { this._deliverywindow = row.DeliveryWindow; } if (!row.IsTerminalNull()) { this._terminal = row.Terminal; } if (!row.IsDriverNameNull()) { this._drivername = row.DriverName; } if (!row.IsAmountNull()) { this._amount = row.Amount; } if (!row.IsAmountTypeNull()) { this._amounttype = row.AmountType; } if (!row.IsFreightTypeNull()) { this._freighttype = row.FreightType; } if (!row.IsAutoNumberNull()) { this._autonumber = row.AutoNumber; } if (!row.IsRequestDateNull()) { this._requestdate = row.RequestDate; } if (!row.IsPickUpDateNull()) { this._pickupdate = row.PickUpDate; } if (!row.IsCommentsNull()) { this._comments = row.Comments; } if (!row.IsUpdatedNull()) { this._updated = row.Updated; } if (!row.IsMustBeReadyNull()) { this._mustbeready = row.MustBeReady; } if (!row.IsPickedUpNull()) { this._pickedup = row.PickedUp; } } } catch (Exception ex) { throw ex; } }
public override void AddList(DispatchDS list) { //Add a list of entries to this schedule try { for (int i = 0; i < list.PickupLogTable.Rows.Count; i++) { DispatchDS.PickupLogTableRow row = list.PickupLogTable[i]; Pickup entry = (Pickup)Item(); entry.ID = row.ID; entry.Created = row.Created; entry.CreatedBy = row.CreatedBy; if (!row.IsCallerNameNull()) { entry.CallerName = row.CallerName; } if (!row.IsClientNameNull()) { entry.ClientName = row.ClientName; } if (!row.IsShipperNameNull()) { entry.ShipperName = row.ShipperName; } if (!row.IsShipperAddressNull()) { entry.ShipperAddress = row.ShipperAddress; } if (!row.IsDeliveryWindowNull()) { entry.DeliveryWindow = row.DeliveryWindow; } if (!row.IsTerminalNull()) { entry.Terminal = row.Terminal; } if (!row.IsDriverNameNull()) { entry.DriverName = row.DriverName; } if (!row.IsAmountNull()) { entry.Amount = row.Amount; } if (!row.IsAmountTypeNull()) { entry.AmountType = row.AmountType; } if (!row.IsFreightTypeNull()) { entry.FreightType = row.FreightType; } if (!row.IsAutoNumberNull()) { entry.AutoNumber = row.AutoNumber; } if (!row.IsRequestDateNull()) { entry.RequestDate = row.RequestDate; } if (!row.IsPickUpDateNull()) { entry.PickUpDate = row.PickUpDate; } if (!row.IsCommentsNull()) { entry.Comments = row.Comments; } if (!row.IsUpdatedNull()) { entry.Updated = row.Updated; } if (!row.IsMustBeReadyNull()) { entry.MustBeReady = row.MustBeReady; } if (!row.IsPickedUpNull()) { entry.PickedUp = row.PickedUp; } Add(entry); } } catch (Exception ex) { throw ex; } }