Exemplo n.º 1
0
        public static bool UpdateShipScheduleTripStop(ShipScheduleDataset.ShipScheduleStopTableRow stop)
        {
            //
            bool updated = false;
            ShipScheduleServiceClient client = new ShipScheduleServiceClient();

            try {
                //Map datarow to data transfer object
                ShipScheduleStop ssstop = new ShipScheduleStop();
                ssstop.StopID          = stop.StopID;
                ssstop.TripID          = stop.TripID;
                ssstop.StopNumber      = !stop.IsStopNumberNull() ? stop.StopNumber : "";
                ssstop.AgentTerminalID = !stop.IsAgentTerminalIDNull() ? stop.AgentTerminalID : 0;
                ssstop.Tag             = !stop.IsTagNull() ? stop.Tag : "";
                ssstop.Notes           = !stop.IsNotesNull() ? stop.Notes : "";
                if (!stop.IsScheduledArrivalNull())
                {
                    ssstop.ScheduledArrival = stop.ScheduledArrival;
                }
                if (!stop.IsScheduledOFD1Null())
                {
                    ssstop.ScheduledOFD1 = stop.ScheduledOFD1;
                }
                ssstop.LastUpdated = DateTime.Now;
                ssstop.UserID      = Environment.UserName;
                ssstop.RowVersion  = stop.RowVersion;

                updated = client.UpdateShipScheduleTripStop(int.Parse(Program.TerminalCode), ssstop);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <ShipScheduleFault> ssf) { client.Abort(); throw new ApplicationException(ssf.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(updated);
        }
Exemplo n.º 2
0
        public static bool UpdateShipSchedule(ShipScheduleDataset.ShipScheduleViewTableRow viewItem)
        {
            //
            bool updated = false;
            ShipScheduleServiceClient client = new ShipScheduleServiceClient();

            try {
                //Map datarows to data transfer objects
                ShipScheduleTrip sstrip = new ShipScheduleTrip();
                sstrip.TripID           = viewItem.TripID;
                sstrip.ScheduleID       = viewItem.ScheduleID;
                sstrip.TemplateID       = viewItem.TemplateID;
                sstrip.BolNumber        = !viewItem.IsBolNumberNull() ? viewItem.BolNumber : 0;
                sstrip.CarrierServiceID = !viewItem.IsCarrierServiceIDNull() ? viewItem.CarrierServiceID : 0;
                sstrip.LoadNumber       = !viewItem.IsLoadNumberNull() ? viewItem.LoadNumber : "";
                sstrip.TrailerNumber    = !viewItem.IsTrailerNumberNull() ? viewItem.TrailerNumber : "";
                sstrip.TractorNumber    = !viewItem.IsTractorNumberNull() ? viewItem.TractorNumber : "";
                sstrip.DriverName       = !viewItem.IsDriverNameNull() ? viewItem.DriverName : "";
                if (!viewItem.IsScheduledCloseNull())
                {
                    sstrip.ScheduledClose = viewItem.ScheduledClose;
                }
                if (!viewItem.IsScheduledDepartureNull())
                {
                    sstrip.ScheduledDeparture = viewItem.ScheduledDeparture;
                }
                sstrip.IsMandatory = !viewItem.IsIsMandatoryNull() ? viewItem.IsMandatory : (byte)0;
                if (!viewItem.IsFreightAssignedNull())
                {
                    sstrip.FreightAssigned = viewItem.FreightAssigned;
                }
                if (!viewItem.IsTrailerCompleteNull())
                {
                    sstrip.TrailerComplete = viewItem.TrailerComplete;
                }
                if (!viewItem.IsPaperworkCompleteNull())
                {
                    sstrip.PaperworkComplete = viewItem.PaperworkComplete;
                }
                if (!viewItem.IsTrailerDispatchedNull())
                {
                    sstrip.TrailerDispatched = viewItem.TrailerDispatched;
                }
                if (!viewItem.IsCanceledNull())
                {
                    sstrip.Canceled = viewItem.Canceled;
                }
                sstrip.LastUpdated = DateTime.Now;
                sstrip.UserID      = Environment.UserName;
                sstrip.RowVersion  = viewItem.SCDERowVersion;

                ShipScheduleStop ssstop1 = new ShipScheduleStop();
                ssstop1.StopID          = viewItem.StopID;
                ssstop1.TripID          = viewItem.TripID;
                ssstop1.StopNumber      = !viewItem.IsStopNumberNull() ? viewItem.StopNumber : "";
                ssstop1.AgentTerminalID = !viewItem.IsAgentTerminalIDNull() ? viewItem.AgentTerminalID : 0;
                ssstop1.Tag             = !viewItem.IsTagNull() ? viewItem.Tag : "";
                ssstop1.Notes           = !viewItem.IsNotesNull() ? viewItem.Notes : "";
                if (!viewItem.IsScheduledArrivalNull())
                {
                    ssstop1.ScheduledArrival = viewItem.ScheduledArrival;
                }
                if (!viewItem.IsScheduledOFD1Null())
                {
                    ssstop1.ScheduledOFD1 = viewItem.ScheduledOFD1;
                }
                ssstop1.LastUpdated = DateTime.Now;
                ssstop1.UserID      = Environment.UserName;
                ssstop1.RowVersion  = viewItem.S1RowVersion;

                ShipScheduleStop ssstop2 = null;
                if (!viewItem.IsS2MainZoneNull() && viewItem.S2MainZone.Trim().Length > 0)
                {
                    ssstop2                 = new ShipScheduleStop();
                    ssstop2.StopID          = viewItem.S2StopID;
                    ssstop2.TripID          = viewItem.TripID;
                    ssstop2.StopNumber      = !viewItem.IsS2StopNumberNull() ? viewItem.S2StopNumber : "";
                    ssstop2.AgentTerminalID = !viewItem.IsS2AgentTerminalIDNull() ? viewItem.S2AgentTerminalID : 0;
                    ssstop2.Tag             = !viewItem.IsS2TagNull() ? viewItem.S2Tag : "";
                    ssstop2.Notes           = !viewItem.IsS2NotesNull() ? viewItem.S2Notes : "";
                    if (!viewItem.IsS2ScheduledArrivalNull())
                    {
                        ssstop2.ScheduledArrival = viewItem.S2ScheduledArrival;
                    }
                    if (!viewItem.IsS2ScheduledOFD1Null())
                    {
                        ssstop2.ScheduledOFD1 = viewItem.S2ScheduledOFD1;
                    }
                    ssstop2.LastUpdated = DateTime.Now;
                    ssstop2.UserID      = Environment.UserName;
                    ssstop2.RowVersion  = viewItem.S2RowVersion;
                }

                updated = client.UpdateShipSchedule(int.Parse(Program.TerminalCode), sstrip, ssstop1, ssstop2);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <ShipScheduleFault> ssf) { client.Abort(); throw new ApplicationException(ssf.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(updated);
        }