Example #1
0
        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);
        }
Example #2
0
        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);
        }