Exemplo n.º 1
0
        private void PopulateForm()
        {
            if (Request.QueryString["Driver"] != "")
            {
                m_driver       = Request.QueryString["Driver"];
                chkDriver.Text = m_driver;
            }
            else
            {
                chkDriver.Enabled = false;
            }

            if (Request.QueryString["RegNo"] != "")
            {
                m_vehicle       = Request.QueryString["RegNo"];
                chkVehicle.Text = m_vehicle;
            }
            else
            {
                chkVehicle.Enabled = false;
            }

            if (!string.IsNullOrEmpty(Request.QueryString["IsUpdate"]))
            {
                IsUpdate = bool.Parse(Request.QueryString["IsUpdate"]);
            }

            Entities.Instruction previousInstruction = null;
            using (Facade.IInstruction facInstruction = new Facade.Instruction())
            {
                Entities.Instruction instruction = facInstruction.GetInstruction(m_instructionId);
                Entities.Job         job         = null;

                // Try and get the job from the cache
                job = (Entities.Job)Cache.Get("JobEntityForJobId" + instruction.JobId.ToString());

                DateTime trunkStart = DateTime.Now;
                DateTime trunkEnd   = DateTime.Now;

                if (IsUpdate)
                {
                    lblTrunk.Text = "Update Trunk Leg";
                    btnTrunk.Text = "Update";

                    #region Update Trunk

                    this.ucPoint.SelectedPoint = instruction.Point;

                    rdiStartDate.SelectedDate = instruction.PlannedArrivalDateTime;
                    rdiStartTime.SelectedDate = instruction.PlannedArrivalDateTime;

                    rdiEndDate.SelectedDate   = instruction.PlannedDepartureDateTime;
                    rdiStartTime.SelectedDate = instruction.PlannedDepartureDateTime;

                    trResources.Visible  = false;
                    rdiStartDate.Enabled = rdiStartTime.Enabled = false;
                    rdiEndDate.Enabled   = rdiEndTime.Enabled = false;
                    #endregion
                }
                else
                {
                    #region New Trunk
                    if (job == null)
                    {
                        // Job was not in the cache thus get the instruction collection from the db
                        Entities.InstructionCollection instructions = new Facade.Instruction().GetForJobId(instruction.JobId, true);

                        // Get the previous instruction
                        previousInstruction = instructions.GetPreviousInstruction(instruction.InstructionID);
                    }
                    else
                    {
                        // Job is in the cache, check for instructions

                        if (job.Instructions != null)
                        {
                            // We have instructions

                            // use the instruction collection from the cached job
                            previousInstruction = job.Instructions.GetPreviousInstruction(instruction.InstructionID);
                        }
                        else
                        {
                            // otherwise get a fresh instruction collection
                            Entities.InstructionCollection instructions = new Facade.Instruction().GetForJobId(instruction.JobId, true);

                            // Get the previous instruction
                            previousInstruction = instructions.GetPreviousInstruction(instruction.InstructionID);
                        }
                    }

                    if (previousInstruction == null)
                    {
                        previousInstruction = instruction;
                    }

                    previousInstruction.PlannedDepartureDateTime = previousInstruction.PlannedDepartureDateTime.Subtract(new TimeSpan(0, 0, 0, previousInstruction.PlannedDepartureDateTime.Second, previousInstruction.PlannedDepartureDateTime.Millisecond));
                    instruction.PlannedArrivalDateTime           = instruction.PlannedArrivalDateTime.Subtract(new TimeSpan(0, 0, 0, instruction.PlannedArrivalDateTime.Second, instruction.PlannedDepartureDateTime.Millisecond));

                    if (previousInstruction == instruction)
                    {
                        trunkStart = instruction.PlannedArrivalDateTime.AddHours(2);
                        trunkEnd   = instruction.PlannedDepartureDateTime.Subtract(new TimeSpan(0, 2, 0, 0, 0));
                    }
                    else
                    {
                        trunkStart = previousInstruction.PlannedDepartureDateTime.AddHours(2);
                        trunkEnd   = instruction.PlannedArrivalDateTime.Subtract(new TimeSpan(0, 2, 0, 0, 0));
                    }

                    trunkStart = trunkStart.AddSeconds(-trunkStart.Second);
                    trunkEnd   = trunkEnd.AddSeconds(-trunkEnd.Second);

                    if (trunkStart >= trunkEnd)
                    {
                        if (previousInstruction == instruction)
                        {
                            trunkStart = instruction.PlannedArrivalDateTime.AddMinutes(15);
                            trunkEnd   = instruction.PlannedDepartureDateTime.AddMinutes(-15);
                        }
                        else
                        {
                            trunkStart = previousInstruction.PlannedDepartureDateTime.AddMinutes(15);
                            trunkEnd   = instruction.PlannedArrivalDateTime.AddMinutes(-15);
                        }

                        if (trunkStart >= trunkEnd)
                        {
                            if (previousInstruction == instruction)
                            {
                                trunkStart = instruction.PlannedArrivalDateTime.AddMinutes(1);
                                trunkEnd   = instruction.PlannedDepartureDateTime.AddMinutes(-1);
                            }
                            else
                            {
                                trunkStart = previousInstruction.PlannedDepartureDateTime.AddMinutes(1);
                                trunkEnd   = instruction.PlannedArrivalDateTime.AddMinutes(-1);
                            }
                        }
                    }

                    if (trunkStart == trunkEnd)
                    {
                        if (previousInstruction == instruction)
                        {
                            trunkStart = instruction.PlannedArrivalDateTime.AddMinutes(60);
                            trunkEnd   = instruction.PlannedDepartureDateTime.AddMinutes(-60);
                        }
                        else
                        {
                            trunkStart = previousInstruction.PlannedDepartureDateTime.AddMinutes(60);
                            trunkEnd   = instruction.PlannedArrivalDateTime.AddMinutes(-60);
                        }
                    }
                    #endregion
                }

                rdiStartDate.SelectedDate = trunkStart;
                rdiStartTime.SelectedDate = trunkStart;
                rdiEndDate.SelectedDate   = trunkEnd;
                rdiEndTime.SelectedDate   = trunkEnd;
            }
        }
        void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Entities.FacadeResult success = new Orchestrator.Entities.FacadeResult(false);

                if (rdOrderAction_NotCollected.Checked)
                {
                    #region Get Page details
                    int rReasonId = 0;
                    int.TryParse(cboRedeliveryReason.SelectedValue, out rReasonId);

                    int      nCPointId = 0, nDPointId = 0, dayDifference = 0;
                    bool     nCIsAnytime = false, nDIsAnyTime = false;
                    DateTime nCDateTime = new DateTime(), nCByDateTime = new DateTime(), nDDateTime = new DateTime(), nDFromDateTime = new DateTime(), dateDiff = new DateTime();

                    nCDateTime = dteCollectionFromDate.SelectedDate.Value;
                    nCDateTime = nCDateTime.Add(new TimeSpan(dteCollectionFromTime.SelectedDate.Value.Hour, dteCollectionFromTime.SelectedDate.Value.Minute, 0));

                    nCByDateTime = nCDateTime;

                    if (rdCollectionBookingWindow.Checked)
                    {
                        nCByDateTime = dteCollectionByDate.SelectedDate.Value;
                        nCByDateTime = nCByDateTime.Add(new TimeSpan(dteCollectionByTime.SelectedDate.Value.Hour, dteCollectionByTime.SelectedDate.Value.Minute, 0));
                    }

                    nCIsAnytime = rdCollectionIsAnytime.Checked;

                    if (chkChangeDeliveryDate.Checked)
                    {
                        nDFromDateTime = dteDeliveryFromDate.SelectedDate.Value;
                        nDFromDateTime = nDFromDateTime.Add(new TimeSpan(dteDeliveryFromTime.SelectedDate.Value.Hour, dteDeliveryFromTime.SelectedDate.Value.Minute, 0));

                        nDDateTime = nDFromDateTime;

                        if (rdDeliveryBookingWindow.Checked)
                        {
                            nDDateTime = dteDeliveryByDate.SelectedDate.Value;
                            nDDateTime = nDDateTime.Add(new TimeSpan(dteDeliveryByTime.SelectedDate.Value.Hour, dteDeliveryByTime.SelectedDate.Value.Minute, 0));
                        }

                        nDIsAnyTime = rdDeliveryIsAnytime.Checked;
                    }

                    if (chkCollectGoodsElsewhere.Checked && ucNewCollectionPoint.SelectedPoint != null)
                    {
                        nCPointId = ucNewCollectionPoint.SelectedPoint.PointId;
                    }

                    if (chkDeliverGoodsElsewhere.Checked && ucNewDeliveryPoint.SelectedPoint != null)
                    {
                        nDPointId = ucNewDeliveryPoint.SelectedPoint.PointId;
                    }

                    Entities.Extra extra = null;

                    // If Updates processed sucessfully, log the extra against the highest value order.
                    if (chkCharging.Checked)
                    {
                        // Build an extra to cover the redelivery.
                        extra               = new Entities.Extra();
                        extra.ExtraType     = (eExtraType)int.Parse(cboExtraType.SelectedValue);
                        extra.ForeignAmount = (decimal)txtExtraAmount.Value;

                        extra.ExtraState        = Utilities.SelectedEnumValue <eExtraState>(cboExtraState.SelectedValue);;
                        extra.CustomDescription = txtExtraCustomReason.Text;

                        if (!string.IsNullOrEmpty(txtClientContact.Text))
                        {
                            extra.ClientContact = txtClientContact.Text;
                        }
                    }
                    #endregion

                    Facade.IAttemptedCollection facAC = new Facade.AttemptedCollection();
                    success = facAC.Create(JobId, InstructionId, rdResolutionMethod_AttemptLater.Checked, rReasonId, txtAttemptedCollectionReference.Text, txtAttemptedClientContact.Text, nCDateTime, nCByDateTime, nCIsAnytime, nCPointId, chkChangeDeliveryDate.Checked, nDFromDateTime, nDDateTime, nDIsAnyTime, nDPointId, chkCreateOnwardRun.Checked, extra, Page.User.Identity.Name);
                }

                #region Display Results
                if (success != null && success.Success)
                {
                    if (success.ObjectId > 0)
                    {
                        Facade.IJob  facJob = new Facade.Job();
                        Entities.Job eJob   = facJob.GetJob(JobId);

                        // If the existing run has been cancelled, then re-direct to the new run.
                        if (eJob == null)
                        {
                            JobId         = success.ObjectId;
                            InstructionId = -1;
                        }
                        else
                        {
                            dlgOrder.Open(string.Format("jobId={0}", success.ObjectId));
                        }
                    }

                    btnCancel_Click(null, null);
                }
                else
                {
                    if (success != null)
                    {
                        idErrors.Infringements = success.Infringements;
                    }

                    idErrors.DisplayInfringments();
                    idErrors.Visible = true;
                }
                #endregion
            }
        }
Exemplo n.º 3
0
        private void TrunkLeg()
        {
            Entities.CustomPrincipal user   = (Entities.CustomPrincipal)Page.User;
            Entities.FacadeResult    result = null;

            int pointId = ucPoint.PointID;// int.Parse(cboPoint.SelectedValue);

            if (!IsUpdate)
            {
                #region Create New Trunk
                Entities.Instruction instruction = null;
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    instruction = facInstruction.GetInstruction(m_instructionId);
                }

                // We've trunked the leg.
                DateTime arriveAtTrunkPoint;
                DateTime leaveTrunkPoint;

                // Get the arrival time.
                //arriveAtTrunkPoint = timeStartDate.xDateTime;
                arriveAtTrunkPoint = new DateTime(rdiStartDate.SelectedDate.Value.Year, rdiStartDate.SelectedDate.Value.Month, rdiStartDate.SelectedDate.Value.Day, rdiStartTime.SelectedDate.Value.Hour, rdiStartTime.SelectedDate.Value.Minute, 0);

                // Get the departure time.
                //leaveTrunkPoint = timeEndDate.xDateTime;
                leaveTrunkPoint = new DateTime(rdiEndDate.SelectedDate.Value.Year, rdiEndDate.SelectedDate.Value.Month, rdiEndDate.SelectedDate.Value.Day, rdiEndTime.SelectedDate.Value.Hour, rdiEndTime.SelectedDate.Value.Minute, 0);

                DateTime lastUpdateDate = DateTime.Parse(Request.QueryString["LastUpdateDate"]);

                // Create the new trunk instruction
                Entities.Instruction trunkInstruction = new Orchestrator.Entities.Instruction();
                trunkInstruction.InstructionTypeId        = (int)eInstructionType.Trunk;
                trunkInstruction.JobId                    = instruction.JobId;
                trunkInstruction.PointID                  = pointId;
                trunkInstruction.PlannedDepartureDateTime = leaveTrunkPoint;
                trunkInstruction.PlannedArrivalDateTime   = arriveAtTrunkPoint;
                trunkInstruction.Trailer                  = instruction.Trailer;

                // Set the booked datetime of the trunk to the trunks planned arrival time. This could produce a situation
                // where the booked times do not flow, however, the trunks booked time is irrelevant so if this happens, it shouldn't matter.
                // Failing to set a booked time for the trunk here would cause an error when attempting to save the instruction.
                trunkInstruction.BookedDateTime = arriveAtTrunkPoint;

                // Note: Always get the driver and the vehicle.
                trunkInstruction.Driver  = instruction.Driver;
                trunkInstruction.Vehicle = instruction.Vehicle;

                // Add the trunk to the job.
                using (Facade.IJob facJob = new Facade.Job())
                {
                    Entities.Job job = facJob.GetJob(instruction.JobId);
                    result = facJob.Trunk(trunkInstruction, instruction, job.IdentityId, user.UserName, job.LastUpdateDate, chkDriver.Checked, chkVehicle.Checked);
                }

                #endregion
            }
            else
            {
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                {
                    facInstruction.UpdatePointID(m_instructionId, pointId, user.UserName);
                    result = new Orchestrator.Entities.FacadeResult(true);
                }
            }

            if (result.Success)
            {
                this.ReturnValue = "refresh";
                this.Close();
            }
            else
            {
                infringementDisplay.Infringements = result.Infringements;
                infringementDisplay.DisplayInfringments();
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            // Retrieve the job from the session variable
            m_job         = (Entities.Job)Session[wizard.C_JOB];
            m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];

            // If this is an update to a job, make sure that the rates are valid.
            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }
            else
            {
                HandleNext();
            }

            if (!IsPostBack)
            {
                btnNext.Attributes.Add("onClick", "javascript:HidePage();");
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);

                // This is a new job, so we need to enforce that rates exist.
                List <int> collectionPointIds = new List <int>();
                List <int> deliveryPointIds   = new List <int>();

                #region Build the Instruction Collections

                if (m_isUpdate)
                {
                    // Populate from the legs collection
                    foreach (Entities.Instruction instruction in m_job.Instructions)
                    {
                        // Do not include point for the instruction being altered.
                        if (instruction.InstructionID != m_instruction.InstructionID)
                        {
                            switch ((eInstructionType)instruction.InstructionTypeId)
                            {
                            case eInstructionType.Load:
                                m_collections.Add(instruction);
                                break;

                            case eInstructionType.Drop:
                                m_deliveries.Add(instruction);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    // Populate from the instructions collection
                    foreach (Entities.Instruction instruction in m_job.Instructions)
                    {
                        switch ((eInstructionType)instruction.InstructionTypeId)
                        {
                        case eInstructionType.Load:
                            m_collections.Add(instruction);
                            break;

                        case eInstructionType.Drop:
                            m_deliveries.Add(instruction);
                            break;
                        }
                    }
                }

                // Add the current instruction if it is new.
                if (m_instruction.InstructionID == 0)
                {
                    if (m_instruction.InstructionTypeId == (int)eInstructionType.Load)
                    {
                        m_collections.Add(m_instruction);
                    }
                    else
                    {
                        m_deliveries.Add(m_instruction);
                    }
                }
                else
                {
                    // Add the point.
                    if (m_instruction.InstructionTypeId == (int)eInstructionType.Load)
                    {
                        m_collections.Add(m_instruction);
                    }
                    else
                    {
                        m_deliveries.Add(m_instruction);
                    }
                }

                #endregion

                if (m_deliveries.Count == 0)
                {
                    HandleNext();
                }

                foreach (Entities.Instruction collection in m_collections)
                {
                    collectionPointIds.Add(collection.PointID);
                }
                foreach (Entities.Instruction delivery in m_deliveries)
                {
                    deliveryPointIds.Add(delivery.PointID);
                }

                Facade.IJobRate facJobRate     = new Facade.Job();
                DataSet         dsMissingRates = facJobRate.GetMissingRates(m_job.IdentityId, collectionPointIds, deliveryPointIds);

                imgRatesRequired.Visible = false;
                if (dsMissingRates.Tables[0].Rows.Count > 0)
                {
                    repRates.DataSource = dsMissingRates;
                    repRates.DataBind();
                    lblRateAnalysis.Text       = "There are rates missing, you should correct this before proceeding.";
                    chkManualRateEntry.Checked = false;
                    trRateAnalysis.Visible     = true;
                    // The user can only ignore rates if the client defaults allow that option.
                    Facade.IOrganisation facOrganisation = new Facade.Organisation();
                    DataSet defaults         = facOrganisation.GetDefaultsForIdentityId(m_job.IdentityId);
                    bool    mustSpecifyRates = false;
                    try
                    {
                        mustSpecifyRates = (bool)defaults.Tables[0].Rows[0]["MustCaptureRate"];
                    }
                    catch { }
                    chkManualRateEntry.Visible = !mustSpecifyRates;
                }
                else
                {
                    HandleNext();
                }
            }
        }
Exemplo n.º 5
0
 private void SetJobDetails()
 {
     Facade.IJob  facJob = new Facade.Job();
     Entities.Job job    = facJob.GetJob(m_jobId);
 }
Exemplo n.º 6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }

            // Retrieve the job from the session variable
            m_job = (Entities.Job)Session[wizard.C_JOB];

            if (Session[wizard.C_INSTRUCTION_INDEX] != null)
            {
                m_instructionIndex = (int)Session[wizard.C_INSTRUCTION_INDEX];

                if (!m_isUpdate && m_instructionIndex != m_job.Instructions.Count)
                {
                    m_isAmendment = true;
                }
            }

            if (!IsPostBack)
            {
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);

                if (Session[wizard.C_INSTRUCTION] != null)
                {
                    m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];

                    switch ((eInstructionType)m_instruction.InstructionTypeId)
                    {
                    case eInstructionType.Load:
                        // Allow the user to collect from any location if this is a stock movement job.
                        if (m_job.IsStockMovement)
                        {
                            m_identityId = 0;
                        }
                        else
                        {
                            m_identityId = m_job.IdentityId;
                        }
                        lblCollection.Visible  = true;
                        lblCollectFrom.Visible = true;
                        lblDelivery.Visible    = false;
                        lblDeliverTo.Visible   = false;
                        lblCollectDrop.Text    = "Collection Details";
                        break;

                    case eInstructionType.Drop:
                        m_identityId           = m_instruction.ClientsCustomerIdentityID;
                        lblCollection.Visible  = false;
                        lblCollectFrom.Visible = false;
                        lblDelivery.Visible    = true;
                        lblDeliverTo.Visible   = true;
                        lblCollectDrop.Text    = "Delivery Details";
                        break;
                    }
                }
                else
                {
                    m_instruction       = new Entities.Instruction();
                    m_instruction.JobId = m_jobId;

                    switch ((ePointType)Session[wizard.C_POINT_TYPE])
                    {
                    case ePointType.Collect:
                        // Allow the user to collect from any location if this is a stock movement job.
                        if (m_job.IsStockMovement)
                        {
                            m_identityId = 0;
                        }
                        else
                        {
                            m_identityId = m_job.IdentityId;
                        }
                        m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                        lblCollection.Visible           = true;
                        lblCollectFrom.Visible          = true;
                        lblDelivery.Visible             = false;
                        lblDeliverTo.Visible            = false;
                        lblCollectDrop.Text             = "Collection Details";

                        #region Load the Default Collection Point

                        try
                        {
                            using (Facade.IOrganisation facOrganisation = new Facade.Organisation())
                            {
                                Entities.Organisation client       = facOrganisation.GetForIdentityId(m_job.IdentityId);
                                Facade.IPoint         facPoint     = new Facade.Point();
                                Entities.Point        defaultPoint = facPoint.GetPointForPointId(client.Defaults[0].DefaultCollectionPointId);
                                cboTown.SelectedValue  = defaultPoint.PostTown.TownId.ToString();
                                cboTown.Text           = defaultPoint.PostTown.TownName;
                                cboPoint.SelectedValue = defaultPoint.PointId.ToString();
                                cboPoint.Text          = defaultPoint.Description;

                                m_pointId = defaultPoint.PointId;
                                m_point   = defaultPoint.Description;
                                m_townId  = defaultPoint.PostTown.TownId;
                                m_town    = defaultPoint.PostTown.TownName;
                            }
                        }
                        catch {}

                        #endregion
                        break;
                    }

                    Session[wizard.C_INSTRUCTION] = m_instruction;

                    if (!m_isUpdate)
                    {
                        Session[wizard.C_INSTRUCTION_INDEX] = m_job.Instructions.Count;
                    }
                }

                if (m_instruction != null && m_instruction.Point != null)
                {
                    cboPoint.SelectedValue = m_instruction.PointID.ToString();
                    cboPoint.Text          = m_instruction.Point.Description;
                    cboTown.SelectedValue  = m_instruction.Point.PostTown.TownId.ToString();
                    cboTown.Text           = m_instruction.Point.PostTown.TownName;

                    cboTown.Enabled  = false;
                    cboPoint.Enabled = false;
                }
            }
            else
            {
                m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];
            }

            pnlCreateNewPoint.Visible = false;
        }
Exemplo n.º 7
0
        internal static DateTime?GetNullableDateTimeStateDataValue(this Entities.Job job, string stateDataKey)
        {
            var sd = job.ToStateData();

            return(JobHelper.DeserializeNullableDateTime(sd.Data[stateDataKey]));
        }
Exemplo n.º 8
0
        private void LoadJob()
        {
            chkIsPriced.Enabled = true;

            Facade.IJob         facJob         = new Facade.Job();
            Facade.IInstruction facInstruction = new Facade.Instruction();

            m_job = facJob.GetJob(m_jobId);

            // The m_job pricing can only be viewed if it is complete.
            if (m_job.JobState == eJobState.Booked || m_job.JobState == eJobState.Planned || m_job.JobState == eJobState.InProgress)
            {
                Response.Redirect("../jobManagement.aspx?jobId=" + m_jobId.ToString() + "&csid=" + this.CookieSessionID);
            }

            if (m_job.JobState == eJobState.Cancelled)
            {
                Response.Redirect("../../Job/job.aspx?jobId=" + m_job.JobId.ToString() + "&csid=" + this.CookieSessionID);
            }

            m_job.Charge       = ((Facade.IJobCharge)facJob).GetForJobId(m_job.JobId);
            m_job.Instructions = facInstruction.GetForJobId(m_job.JobId);
            m_job.Extras       = facJob.GetExtras(m_job.JobId, true);
            Facade.IJobRate facJobRate = new Facade.Job();
            m_job.Rate = facJobRate.GetRateForJobId(m_job.JobId);

            GetChargeableLegs();
            CountChargeableLegs();

            // Store the m_job in the ViewState
            ViewState[C_JOB_VS] = m_job;

            // The job can not be altered if it has been invoiced.
            if (m_job.JobState == eJobState.Invoiced)
            {
                txtRate.Enabled     = false;
                btnUpdate.Enabled   = false;
                chkIsPriced.Checked = true;
                chkIsPriced.Enabled = false;
            }

            #region Populate the Job Information

            lblJobId.Text = m_jobId.ToString();

            // Display the client this m_job is for
            Facade.IOrganisation facOrganisation = new Facade.Organisation();
            lblCustomer.Text = facOrganisation.GetNameForIdentityId(m_job.IdentityId);

            // Select the appropriate m_job type
            lblJobType.Text = Utilities.UnCamelCase(Enum.GetName(typeof(eJobChargeType), m_job.Charge.JobChargeType));

            // Display the m_job rate
            txtRate.Text = m_job.Charge.JobChargeAmount.ToString("C");

            // Set if the m_job is priced or not
            chkIsPriced.Checked = m_job.IsPriced;

            #endregion

            //Get the Extras for the Job
            pnlExtra.Visible    = true;
            dgExtras.DataSource = GetExtras();
            dgExtras.DataBind();
            if (((Entities.ExtraCollection)dgExtras.DataSource).Count > 0)
            {
                dgExtras.Visible    = true;
                lblNoExtras.Visible = false;
            }
            else
            {
                dgExtras.Visible    = false;
                lblNoExtras.Visible = true;
            }
            btnAddExtra.Visible = m_job.JobType != eJobType.Groupage;

            // Display the legs with their associated costs and charges
            gvLegs.DataSource = new Facade.Instruction().GetLegPlan(m_job.Instructions, false).Legs();
            gvLegs.DataBind();

            if (m_job.JobType == eJobType.Return)
            {
                gvRefusals.DataBind();
            }
            else
            {
                fsRefusals.Visible = false;
            }

            checkRoundingIssue();
        }
Exemplo n.º 9
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            int identityId = -1;

            if (cboClient.SelectedValue == "")
            {
                // The user has not selected an organistion, they may want to create a new one.
                pnlCreateNewOrganisation.Visible = true;

//				if (chkCreateClient.Checked)
//				{
//					Facade.IOrganisation facOrganisation = new Facade.Organisation();
//
//					Entities.Organisation organisation = new Entities.Organisation();
//					organisation.OrganisationName = cboClient.Text;
//					organisation.OrganisationType = eOrganisationType.Client;
//					organisation.IdentityStatus = eIdentityStatus.Active;
//
//					string userId = ((Entities.CustomPrincipal) Page.User).UserName;
//
//					Entities.FacadeResult retVal = facOrganisation.Create(organisation, userId);
//					if (!retVal.Success)
//					{
//						infringementDisplay.Infringements = retVal.Infringements;
//						infringementDisplay.DisplayInfringments();
//						infringementDisplay.Visible = true;
//					}
//					else
//						identityId = retVal.ObjectId;
//				}
            }
            else
            {
                identityId = Convert.ToInt32(cboClient.SelectedValue);
            }

            if (identityId > -1)
            {
                if (!m_isUpdate)
                {
                    if (m_job != null)
                    {
                        if (m_job.IdentityId != identityId)
                        {
                            // The identity id has been changed, remove all the instructions and
                            // references from the job.
                            m_job.References   = null;
                            m_job.Instructions = null;

                            // Update the identityId
                            m_job.IdentityId = identityId;
                        }

                        int businessTypeID = 0;
                        int.TryParse(cboBusinessType.SelectedValue, out businessTypeID);
                        m_job.BusinessTypeID = businessTypeID;

                        // Update the session variable
                        Session[wizard.C_JOB] = m_job;
                    }
                    else
                    {
                        m_job            = new Entities.Job();
                        m_job.IdentityId = identityId;
                        m_job.JobState   = eJobState.Booked;
                        int businessTypeID = 0;
                        int.TryParse(cboBusinessType.SelectedValue, out businessTypeID);
                        m_job.BusinessTypeID = businessTypeID;

                        // Update the session variable
                        Session[wizard.C_JOB] = m_job;
                    }
                }

                GoToStep("JT");
            }
        }
Exemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int instructionId = Convert.ToInt32(Request.QueryString["iID"]);

            if (!Page.IsPostBack)
            {
                using (Facade.Instruction facInstruction = new Facade.Instruction())
                {
                    Entities.Instruction affectedInstruction = null;
                    Entities.Job         job = null;
                    int jobId = 0;
                    Entities.InstructionCollection instructions = null;

                    if (int.TryParse(Request.QueryString["jobId"], out jobId))
                    {
                        if (instructionId != 0)
                        {
                            affectedInstruction = facInstruction.GetInstruction(instructionId);

                            // Get the job.
                            job = (Entities.Job)Cache.Get("JobEntityForJobId" + jobId.ToString());

                            // Try and get the job from the cache
                            if (job == null)
                            {
                                Facade.IJob facJob = new Facade.Job();
                                job = facJob.GetJob(jobId);
                            }
                        }
                        else
                        {
                            // We have no instruction id - this means that ascx is being used for adding
                            // multiple destinations. We should use the last instruction on the job.

                            // Get the job.
                            job = (Entities.Job)Cache.Get("JobEntityForJobId" + jobId.ToString());

                            // Try and get the job from the cache
                            if (job == null)
                            {
                                Facade.IJob facJob = new Facade.Job();
                                job = facJob.GetJob(jobId);

                                // Job was not in the cache thus get the instruction collection from the db
                                instructions = new Facade.Instruction().GetForJobId(jobId);

                                // Get the end instruction
                                Entities.Instruction endInstruction = null;
                                endInstruction = instructions.Find(instruc => instruc.InstructionOrder == instructions.Count - 1);

                                if (endInstruction == null)
                                {
                                    throw new ApplicationException("Cannot find last instruction.");
                                }

                                affectedInstruction = endInstruction;
                            }
                            else
                            {
                                // Job is in the cache, check for instructions

                                if (job.Instructions != null)
                                {
                                    // We have instructions
                                    instructions = job.Instructions;
                                }
                                else
                                {
                                    // otherwise get a fresh instruction collection
                                    instructions = new Facade.Instruction().GetForJobId(jobId);
                                }

                                // Get the end instruction
                                Entities.Instruction endInstruction = null;
                                endInstruction = instructions.Find(instruc => instruc.InstructionOrder == instructions.Count - 1);

                                if (endInstruction == null)
                                {
                                    throw new ApplicationException("Cannot find last instruction.");
                                }

                                affectedInstruction = endInstruction;
                            }
                        }
                    }

                    if (job.JobState != eJobState.Invoiced && job.JobState != eJobState.Cancelled)
                    {
                        if (affectedInstruction.Driver != null)
                        {
                            chkDriver.Text = affectedInstruction.Driver.Individual.FullName;
                        }
                        else
                        {
                            chkDriver.Enabled = false;
                        }

                        if (affectedInstruction.Vehicle != null)
                        {
                            chkVehicle.Text = affectedInstruction.Vehicle.RegNo;
                        }
                        else
                        {
                            chkVehicle.Enabled = false;
                        }
                    }
                }
            }
        }
Exemplo n.º 11
0
 public IHttpActionResult AddJob([FromBody] Entities.Job job)
 {
     return(Ok(BL.SelectorJob.AddNewJob(job)));
 }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["JID"]))
            {
                if (int.TryParse(Request.QueryString["JID"], out m_jobID))
                {
                    bool subbedOutWholeJob = false;
                    _job = GetJobEntityFromCache();

                    foreach (Entities.JobSubContractor jsc in _job.SubContractors)
                    {
                        if (jsc.SubContractWholeJob)
                        {
                            _wholeJobSubcontractor = jsc;
                            _culture          = new CultureInfo(jsc.LCID);
                            subbedOutWholeJob = true;
                            break;
                        }
                    }

                    if (!IsPostBack)
                    {
                        if (!subbedOutWholeJob)
                        {
                            // Only show the legs and orders grid if not subbed out whole job
                            repLegSubbyRates.Visible = true;

                            Facade.IJob facJob = new Facade.Job();
                            DataTable   dt     = facJob.GetTrafficSheetForJobId(m_jobID).Tables[1];
                            repLegSubbyRates.DataSource = dt;
                            repLegSubbyRates.DataBind();
                        }
                        else
                        {
                            // ...otherwise, show the whole job rate controls.
                            fldWholeJobSubcontractInformation.Visible = true;
                            repLegSubbyRates.Visible = false;

                            txtWholeJobSubcontractRate.Attributes.Add("jobSubContractID", _wholeJobSubcontractor.JobSubContractID.ToString());
                            txtWholeJobSubcontractRate.Attributes.Add("LCID", _wholeJobSubcontractor.LCID.ToString());

                            txtWholeJobSubcontractRate.Culture = new CultureInfo(_wholeJobSubcontractor.LCID);
                            txtWholeJobSubcontractRate.Text    = _wholeJobSubcontractor.ForeignRate.ToString();
                            chkIsAttended.Checked = _wholeJobSubcontractor.IsAttended;
                            txtReference.Text     = _wholeJobSubcontractor.Reference;

                            if (_wholeJobSubcontractor.InvoiceID > 0)
                            {
                                // don't allow the user to update information as the invoice has already been generated
                                txtWholeJobSubcontractRate.Enabled = false;
                                chkIsAttended.Enabled  = false;
                                txtReference.Enabled   = false;
                                btnUpdateRates.Enabled = false;
                            }
                        }
                    }
                }
            }

            this.Master.WizardTitle = "Update Sub-Contract Rates";
        }
Exemplo n.º 13
0
        void btnUpdateRates_Click(object sender, EventArgs e)
        {
            if (_wholeJobSubcontractor == null)
            {
                // the JS will not allow non currency figures.
                Facade.IJobSubContractor facSubby = new Facade.Job();
                Entities.Job             job      = GetJobEntityFromCache();

                int               jobSubContractID        = 0;
                decimal           rate                    = 0M;
                string            userID                  = this.User.Identity.Name;
                RadNumericTextBox txtRate                 = null;
                TextBox           txtSubcontractReference = null;
                CheckBox          chkIsAttended           = null;
                HiddenField       hidJobSubContractID     = null;

                foreach (RepeaterItem legItem in repLegSubbyRates.Items)
                {
                    if (legItem.ItemType == ListItemType.Item || legItem.ItemType == ListItemType.AlternatingItem)
                    {
                        txtRate                 = legItem.FindControl("rntSubContractRate") as RadNumericTextBox;
                        hidJobSubContractID     = legItem.FindControl("hidJobSubContractID") as HiddenField;
                        txtSubcontractReference = legItem.FindControl("txtSubcontractReference") as TextBox;
                        chkIsAttended           = legItem.FindControl("chkIsAttended") as CheckBox;

                        if (!string.IsNullOrEmpty(hidJobSubContractID.Value))
                        {
                            jobSubContractID = int.Parse(hidJobSubContractID.Value);
                            if (decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, System.Threading.Thread.CurrentThread.CurrentCulture, out rate))
                            {
                                Entities.JobSubContractor jobSubContract = facSubby.GetSubContractorForJobSubContractId(jobSubContractID);
                                jobSubContract.ForeignRate = rate;
                                jobSubContract.IsAttended  = chkIsAttended.Checked;
                                jobSubContract.Reference   = txtSubcontractReference.Text;
                                facSubby.Update(m_jobID, jobSubContract, _job.LastUpdateDate, userID);
                            }
                        }
                        else
                        {
                            Repeater repOrderSubbyRates = legItem.FindControl("repOrderSubbyRates") as Repeater;
                            if (repOrderSubbyRates.Visible)
                            {
                                foreach (RepeaterItem orderItem in repOrderSubbyRates.Items)
                                {
                                    if (orderItem.ItemType == ListItemType.Item || orderItem.ItemType == ListItemType.AlternatingItem)
                                    {
                                        txtRate                 = orderItem.FindControl("rntSubContractRate") as RadNumericTextBox;
                                        hidJobSubContractID     = orderItem.FindControl("hidJobSubContractID") as HiddenField;
                                        txtSubcontractReference = orderItem.FindControl("txtSubcontractReference") as TextBox;
                                        chkIsAttended           = orderItem.FindControl("chkIsAttended") as CheckBox;

                                        if (!string.IsNullOrEmpty(hidJobSubContractID.Value))
                                        {
                                            jobSubContractID = int.Parse(hidJobSubContractID.Value);
                                            if (decimal.TryParse(txtRate.Text, System.Globalization.NumberStyles.Currency, System.Threading.Thread.CurrentThread.CurrentCulture, out rate))
                                            {
                                                Entities.JobSubContractor jobSubContract = facSubby.GetSubContractorForJobSubContractId(jobSubContractID);
                                                jobSubContract.ForeignRate = rate;
                                                jobSubContract.IsAttended  = chkIsAttended.Checked;
                                                jobSubContract.Reference   = txtSubcontractReference.Text;
                                                facSubby.Update(m_jobID, jobSubContract, _job.LastUpdateDate, userID);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                Facade.IJobSubContractor facSub = new Facade.Job();
                job.SubContractors = facSub.GetSubContractorForJobId(_job.JobId);
                AddJobEntityToCache(_job);
            }
            else
            {
                // Save and Hide the Edit Facilities
                decimal rate = 0;

                Facade.IJobSubContractor facSub = new Facade.Job();

                if (Decimal.TryParse(txtWholeJobSubcontractRate.Text, System.Globalization.NumberStyles.Currency, CultureInfo.CreateSpecificCulture("en-GB"), out rate))
                {
                    int jobSubContractID = int.Parse(txtWholeJobSubcontractRate.Attributes["jobSubContractID"]);

                    // Set the jobsubcontract information.
                    _wholeJobSubcontractor.ForeignRate = decimal.Parse(txtWholeJobSubcontractRate.Text);
                    _wholeJobSubcontractor.IsAttended  = chkIsAttended.Checked;
                    _wholeJobSubcontractor.Reference   = txtReference.Text;

                    // Save it.
                    facSub.Update(_wholeJobSubcontractor.JobID, _wholeJobSubcontractor, _job.LastUpdateDate, User.Identity.Name);

                    // Update the cached job.
                    _job.SubContractors = facSub.GetSubContractorForJobId(_job.JobId);
                    AddJobEntityToCache(_job);
                }
            }

            // Refresh the job details page.
            lblInjectScript.Text = "<script>RefreshParentPage();</script>";
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }

            // Retrieve the job from the session variable
            m_job = (Entities.Job)Session[wizard.C_JOB];

            if (Session[wizard.C_INSTRUCTION_INDEX] != null)
            {
                m_instructionIndex = (int)Session[wizard.C_INSTRUCTION_INDEX];

                if (!m_isUpdate && m_instructionIndex != m_job.Instructions.Count)
                {
                    m_isAmendment = true;
                }
            }

            if (Session[wizard.C_INSTRUCTION] != null)
            {
                m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];

                if (m_isUpdate && m_isAmendment)
                {
                    // Get the organisation
                    Facade.IOrganisation facOrganisation = new Facade.Organisation();

                    // Configure the DbCombo box
                    cboClient.Text          = facOrganisation.GetForIdentityId(m_instruction.ClientsCustomerIdentityID).OrganisationName;
                    cboClient.SelectedValue = m_instruction.ClientsCustomerIdentityID.ToString();

                    // Can't change the client's customer for a drop once it is created.
                    if (m_isUpdate)
                    {
                        cboClient.Enabled = false;
                    }
                }
            }
            else
            {
                // This must be a new drop
                m_instruction                   = new Entities.Instruction();
                m_instruction.JobId             = m_jobId;
                m_instruction.InstructionTypeId = (int)eInstructionType.Drop;

                Session[wizard.C_INSTRUCTION] = m_instruction;

                // If this is a new job, set the instruction index
                if (!m_isUpdate)
                {
                    Session[wizard.C_INSTRUCTION_INDEX] = m_job.Instructions.Count;
                }
            }

            if (!IsPostBack)
            {
                btnNext.Attributes.Add("onClick", "javascript:HidePage();");
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);
            }

            infringementDisplay.Visible = false;
        }
Exemplo n.º 15
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.GeneralUsage, eSystemPortion.TakeCallIn);
            m_canEdit = Orchestrator.WebUI.Security.Authorise.CanAccess(eSystemPortion.TakeCallIn);
            btnStoreShortage.Enabled = m_canEdit;

            m_jobId         = Convert.ToInt32(Request.QueryString["jobId"]);
            m_instructionId = Convert.ToInt32(Request.QueryString["instructionId"]);
            if (m_instructionId == 0)
            {
                Response.Redirect("tabProgress.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&csid=" + this.CookieSessionID);
            }
            else
            {
                Facade.IInstructionActual facInstructionActual = new Facade.Instruction();
                DataSet dsInstructionActual = facInstructionActual.GetForInstructionId(m_instructionId);

                if (dsInstructionActual.Tables[0].Rows.Count == 0)
                {
                    Response.Redirect("tabProgress.aspx?wiz=true&jobId=" + m_jobId.ToString() + "&csid=" + this.CookieSessionID);
                }
            }

            try
            {
                hidShortageId.Value = Convert.ToInt32(Request.QueryString["refusalId"]).ToString();
            }
            catch { }
            ConfigureReasons();

            // Set please wait button clicks!
            btnStoreShortage.Attributes.Add("onMouseUp", @"javascript:HideTop(true);");

            if (!IsPostBack)
            {
                LoadJob();
                using (Facade.IInstruction facInstruction = new Facade.Instruction())
                    cboShortageDocket.DataSource = facInstruction.GetDocketsForInstructionId(m_instructionId);

                cboShortageDocket.DataTextField  = "DocketNumberDisplay";
                cboShortageDocket.DataValueField = "DocketNumber";
                cboShortageDocket.DataBind();

                Facade.IOrder facOrder = new Facade.Order();
                cboOrder.DataSource = facOrder.GetOrdersForInstructionID(m_instructionId);
                cboOrder.DataBind();

                if (hidShortageId.Value != "0")
                {
                    BindShortage(Convert.ToInt32(hidShortageId.Value));
                }
                else
                {
                    ClearShortages();
                }
            }
            else
            {
                if (m_instructionId == 0)
                {
                    m_instructionId = Convert.ToInt32(hidInstructionId.Value);
                }
                m_job = (Entities.Job)ViewState[C_JOB_VS];
            }

            if (((Entities.CustomPrincipal) this.Page.User).IsInRole(((int)eUserRole.SubConPortal).ToString()))
            {
                this.buttonBar.Visible = false;
            }

            hidInstructionId.Value = m_instructionId.ToString();
        }
Exemplo n.º 16
0
        private void FindOrders()
        {
            int jobId = int.Parse(txtSearch.Text);

            Facade.IJob  facJob = new Facade.Job();
            Entities.Job job    = facJob.GetJob(jobId);
            if (job == null)
            {
                lblRunInformation.Text = "No run can be found for this Run ID please check and re-key.";
                return;
            }

            if (job.JobState >= eJobState.InProgress)
            {
                lblRunInformation.Text = "This run is already in progress and can not be merged.";
                return;
            }

            Facade.IOrder         facOrder = new Facade.Order();
            List <Entities.Order> orders   = facOrder.GetForJobID(this.JobID);
            //string filter = string.Empty;
            //foreach (Entities.Order o in orders)
            //{
            //    if (filter.Length > 0)
            //        filter += ",";
            //    filter += o.OrderID.ToString();
            //}

            var ds = facOrder.GetForJob(jobId);
            List <MergableRunOrder> mergableOrders = new List <MergableRunOrder>();

            for (int index = 0; index < ds.Tables[0].Rows.Count; index++)
            {
                var dr = ds.Tables[0].Rows[index];
                MergableRunOrder mergableOrder = new MergableRunOrder();
                mergableOrder.OrderID             = int.Parse(dr["OrderID"].ToString());
                mergableOrder.BusinessType        = dr["BusinessType"].ToString();
                mergableOrder.Customer            = dr["Customer"].ToString();
                mergableOrder.CustomerOrderNumber = dr["CustomerOrderNumber"].ToString();
                //mergableOrder.DeliveringResource = dr["DeliveryDriver"].ToString();
                mergableOrder.DeliveryOrderNumber = dr["DeliveryOrderNumber"].ToString();
                Entities.Order foundOrder = orders.Find(o => o.OrderID == mergableOrder.OrderID);
                if (foundOrder == null)
                {
                    mergableOrder.CanAddThisOrder = true;
                    mergableOrder.Status          = "";
                }
                else
                {
                    mergableOrder.CanAddThisOrder = false;
                    mergableOrder.Status          = "This Order is already part of the target run";
                }
                mergableOrders.Add(mergableOrder);
            }


            //var dv = ds.Tables[0].DefaultView;
            //if (!string.IsNullOrEmpty(filter))
            //    dv.RowFilter = "OrderID NOT IN (" + filter + ")";

            //if(dv.Count == 0)
            //{
            //    lblRunInformation.Text = "This run contains no order(s) that can be merged to the current run.";
            //    return;
            //}
            grdOrders.DataSource   = mergableOrders;
            grdOrders.Visible      = true;
            btnMerge.Visible       = true;
            lblRunInformation.Text = string.Empty;
        }
Exemplo n.º 17
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }

            // Retrieve the job from the session variable
            m_job         = (Entities.Job)Session[wizard.C_JOB];
            m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];

            if (Session[wizard.C_COLLECT_DROP_INDEX] != null)
            {
                m_collectDropIndex = (int)Session[wizard.C_COLLECT_DROP_INDEX];

                if (m_collectDropIndex != m_instruction.CollectDrops.Count)
                {
                    m_isAmendment = true;

                    // You can only add a docket at the end
                    if (m_collectDropIndex < m_instruction.CollectDrops.Count - 1)
                    {
                        chkAddAnotherDocket.Visible = false;
                    }
                }
            }

            if (!IsPostBack)
            {
                btnNext.Attributes.Add("onClick", "javascript:HidePage();");
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);



                // Do not show the remove docket button for the only docket in each collection/drop - they must delete the instruction to
                // remove all dockets.
                btnRemoveDocket.Visible = m_instruction.CollectDrops.Count > 1 || m_collectDropIndex == m_instruction.CollectDrops.Count;

                ConfigureDocketTerminology();

                // Details of added Dockets
                repDockets.DataSource = m_instruction.CollectDrops;
                repDockets.DataBind();

                dteBookedDate.SelectedDate = m_instruction.BookedDateTime;
                if (m_instruction.IsAnyTime)
                {
                    dteBookedTime.Text = "AnyTime";
                }
                else
                {
                    dteBookedTime.SelectedDate = m_instruction.BookedDateTime;
                }

                if (Session[wizard.C_COLLECT_DROP] != null)
                {
                    m_collectdrop = (Entities.CollectDrop)Session[wizard.C_COLLECT_DROP];
                }
                else
                {
                    m_collectdrop = new Entities.CollectDrop();
                    m_collectdrop.InstructionID = m_instruction.InstructionID;

                    Session[wizard.C_COLLECT_DROP]       = m_collectdrop;
                    Session[wizard.C_COLLECT_DROP_INDEX] = m_instruction.CollectDrops.Count;
                }

                switch ((eInstructionType)m_instruction.InstructionTypeId)
                {
                case eInstructionType.Load:
                    lblCollection.Visible     = true;
                    chkAddAnotherDocket.Text += "collection.";
                    lblDelivery.Visible       = false;
                    trSelectDocket.Visible    = false;
                    lblCollectDrop.Text       = "Collection Details";
                    if (!m_isAmendment && m_collectDropIndex == 0)
                    {
                        dteBookedDate.Text = DateTime.UtcNow.ToString("dd/MM/yy");
                    }
                    break;

                case eInstructionType.Drop:
                    lblCollection.Visible     = false;
                    chkAddAnotherDocket.Text += "delivery.";
                    lblDelivery.Visible       = true;
                    trSelectDocket.Visible    = true;

                    // Stop the user from editing the docket information
                    txtDocket.Enabled        = false;
                    txtQuantityCases.Enabled = false;
                    txtPallets.Enabled       = false;
                    txtWeight.Enabled        = false;
                    lblCollectDrop.Text      = "Delivery Details";
                    cboGoodsType.Enabled     = false;

                    // Populate the dockets
                    PopulateDockets();
                    break;
                }

                if (m_collectdrop != null)
                {
                    if (m_isUpdate)
                    {
                        cboGoodsType.DataSource = Facade.GoodsType.GetGoodsTypesForClientAndCollectDrop(m_job.IdentityId, m_collectdrop.CollectDropId);
                    }
                    else
                    {
                        cboGoodsType.DataSource = Facade.GoodsType.GetGoodsTypesForClient(m_job.IdentityId);
                    }
                    cboGoodsType.DataBind();

                    // Populate the collect drop information onto the form
                    txtDocket.Text        = m_collectdrop.Docket;
                    txtQuantityCases.Text = (m_collectdrop.NoCases == 0 && !m_isAmendment) ? "" : m_collectdrop.NoCases.ToString();
                    txtPallets.Text       = (m_collectdrop.NoPallets == 0 && !m_isAmendment) ? "" : m_collectdrop.NoPallets.ToString();
                    txtWeight.Text        = (m_collectdrop.Weight == 0 && !m_isAmendment) ? "" : m_collectdrop.Weight.ToString();
                    if (m_isAmendment || m_isUpdate)
                    {
                        cboGoodsType.ClearSelection();
                        ListItem item = cboGoodsType.Items.FindByValue(m_collectdrop.GoodsTypeId.ToString());
                        if (item != null)
                        {
                            item.Selected = true;
                        }
                    }
                    txtNotes.Text = m_instruction.Note;
                }
            }
            else
            {
                m_collectdrop = (Entities.CollectDrop)Session[wizard.C_COLLECT_DROP];
            }
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            m_jobId = Convert.ToInt32(Request.QueryString["jobId"]);

            if (m_jobId > 0)
            {
                m_isUpdate = true;
            }

            // Retrieve the job from the session variable
            m_job = (Entities.Job)Session[wizard.C_JOB];

            if (Session[wizard.C_INSTRUCTION_INDEX] != null)
            {
                m_instructionIndex = (int)Session[wizard.C_INSTRUCTION_INDEX];

                if (!m_isUpdate && m_instructionIndex != m_job.Instructions.Count)
                {
                    m_isAmendment = true;
                }
            }
            if ((Entities.Instruction)Session[wizard.C_INSTRUCTION] != null)
            {
                m_instruction = (Entities.Instruction)Session[wizard.C_INSTRUCTION];
            }

            if (!IsPostBack)
            {
                // Configure cancel button confirmation alert.
                btnCancel.Attributes.Add("onClick", wizard.C_CONFIRM_MESSAGE);

                // Can only change the point if a new instruction is being created.
                ucPoint.CanChangePoint = m_instruction == null;
                ucPoint.Visible        = m_instruction == null;
                if (m_instruction != null)
                {
                    // Configure the point user control to focus on the supplied point.
                    ucPoint.SelectedPoint = m_instruction.Point;

                    dteBookedDate.SelectedDate = m_instruction.BookedDateTime;
                    if (!m_instruction.IsAnyTime)
                    {
                        dteBookedTime.SelectedDate = m_instruction.BookedDateTime;
                    }

                    // Configure the instructions orders user controls.
                    ucInstructionOrders.Instruction = m_instruction;

                    // Configure the orders user control.
                    ucOrders.CollectionPoint     = m_instruction.Point;
                    ucOrders.ExcludedOrderIDs    = m_instruction.GetOrderIDList();
                    ucOrders.CollectionDate      = m_instruction.BookedDateTime;
                    ucOrders.CollectionIsAnytime = m_instruction.IsAnyTime;
                    if (m_job.BusinessTypeID > 0)
                    {
                        ucOrders.BusinessTypeIDs = new List <int>(new int[] { m_job.BusinessTypeID });
                    }

                    // Pass selected orders to the controls
                    if (Session[wizard.C_ADDED_ORDERS] != null)
                    {
                        ucOrders.PreSelectedOrderIDs = (List <int>)Session[wizard.C_ADDED_ORDERS];
                    }
                }
                else
                {
                    // The user is adding a new instruction to the current job.
                    m_instruction                   = new Entities.Instruction();
                    m_instruction.JobId             = m_jobId;
                    m_instruction.InstructionTypeId = (int)eInstructionType.Load;
                    Session[wizard.C_INSTRUCTION]   = m_instruction;
                    if (m_job.BusinessTypeID > 0)
                    {
                        ucOrders.BusinessTypeIDs = new List <int>(new int[] { m_job.BusinessTypeID });
                    }
                }

                // Clear out used session variables
                Session[wizard.C_ADDED_ORDERS]   = null;
                Session[wizard.C_REMOVED_ORDERS] = null;
            }
        }
Exemplo n.º 19
0
        //-----------------------------------------------------------------------------------------------------------

        private void AddNewDropInstruction(Entities.Order currentOrder, Entities.Job run, List <Entities.Instruction> amendedInstructions)
        {
            Facade.IPoint facPoint = new Facade.Point();

            // Load the job's current state.
            Facade.IJob facJob = new Facade.Job();

            #region Configure the end instruction.
            Entities.Instruction endInstruction = null;
            if (amendedInstructions.Count > 0)
            {
                endInstruction = amendedInstructions[0];
            }
            else
            {
                endInstruction = run.Instructions.Find(i => i.InstructionTypeId == (int)eInstructionType.Drop && i.PointID == this.cboNewDeliveryPoint.PointID);
            }

            // Can a matching instruction be found on the job after the start instruction?
            //endInstruction = job.Instructions.Find(i => i.InstructionOrder > startInstruction.InstructionOrder && i.InstructionTypeId == (int)untetheredLocations.EndInstructionType.Value && i.PointID == untetheredLocations.EndPointID.Value && !i.HasActual);
            if (endInstruction == null)
            {
                // A new instruction is required.
                endInstruction                   = new Orchestrator.Entities.Instruction();
                endInstruction.PointID           = this.cboNewDeliveryPoint.PointID;
                endInstruction.Point             = facPoint.GetPointForPointId(this.cboNewDeliveryPoint.PointID);
                endInstruction.InstructionTypeId = (int)eInstructionType.Drop;

                if (this.dteDeliveryByDate.SelectedDate.HasValue)
                {
                    endInstruction.BookedDateTime           = this.dteDeliveryByDate.SelectedDate.Value;
                    endInstruction.PlannedArrivalDateTime   = this.dteDeliveryByDate.SelectedDate.Value;
                    endInstruction.PlannedDepartureDateTime = this.dteDeliveryByDate.SelectedDate.Value;
                }
                else
                {
                    endInstruction.BookedDateTime           = currentOrder.DeliveryDateTime;
                    endInstruction.PlannedArrivalDateTime   = currentOrder.DeliveryDateTime;
                    endInstruction.PlannedDepartureDateTime = currentOrder.DeliveryDateTime;
                }

                if (this.rdDeliveryIsAnytime.Checked)
                {
                    endInstruction.IsAnyTime = true;
                }
                else
                {
                    endInstruction.IsAnyTime = false;
                }

                endInstruction.JobId = run.JobId;
                endInstruction.ClientsCustomerIdentityID = currentOrder.CustomerIdentityID;

                // Record that this instruction has been amended.
                amendedInstructions.Add(endInstruction);
            }
            else
            if (amendedInstructions.Count == 0)
            {
                amendedInstructions.Add(endInstruction);
            }

            // Add the collect drop for this order to the instruction.
            Entities.CollectDrop endCollectDrop = new Entities.CollectDrop();
            endCollectDrop.Order     = currentOrder;
            endCollectDrop.OrderID   = currentOrder.OrderID;
            endCollectDrop.NoPallets = currentOrder.NoPallets;
            endCollectDrop.ClientsCustomerReference = currentOrder.CustomerOrderNumber;
            endCollectDrop.GoodsTypeId = currentOrder.GoodsTypeID;
            endCollectDrop.NoCases     = currentOrder.Cases;
            endCollectDrop.Weight      = currentOrder.Weight;
            endCollectDrop.Docket      = currentOrder.OrderID.ToString();

            endCollectDrop.OrderAction = eOrderAction.Default;
            endInstruction.CollectDrops.Add(endCollectDrop);

            this.UpdateOrder(currentOrder);
            #endregion
        }
Exemplo n.º 20
0
 internal static bool IsInState(this Entities.Job job, string stateName)
 {
     return(job.StateName == stateName);
 }