private void InitialisePage() { // Retrieve the instruction. Facade.IInstruction facInstruction = new Facade.Instruction(); m_instruction = facInstruction.GetInstruction(m_instructionID); ViewState[C_Instruction_VS] = m_instruction; // Populate the control and traffic area dropdowns. Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); cboTrafficArea.DataSource = ((Facade.ITrafficArea)facControlArea).GetAll(); cboTrafficArea.DataBind(); // Select the current control and traffic area assigned to the leg. cboControlArea.Items.FindByValue(m_instruction.ControlAreaId.ToString()).Selected = true; cboTrafficArea.Items.FindByValue(m_instruction.TrafficAreaId.ToString()).Selected = true; // Enable the checkbox if this is not the last leg in the job. Facade.IJob facJob = new Facade.Job(); Entities.InstructionCollection instructions = facInstruction.GetForJobId(m_instruction.JobId); if (instructions.Count == m_instruction.InstructionOrder + 1) { chkApplyToAllFollowingInstructions.Enabled = false; } else { chkApplyToAllFollowingInstructions.Enabled = true; } }
private void LoadJob() { Facade.IJob facJob = new Facade.Job(); m_job = facJob.GetJob(m_jobId); if (m_job != null) { if (m_job.JobState == eJobState.Cancelled) { Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId.ToString() + "&csid=" + this.CookieSessionID); } Facade.IPCV facPCV = new Facade.PCV(); m_job.PCVs = facPCV.GetForJobId(m_jobId); if (m_job.JobState == eJobState.Booked) { Response.Redirect("../jobManagement.aspx?jobId=" + m_jobId + "&csid=" + this.CookieSessionID); } // Load the various parts of the job. Facade.IInstruction facInstruction = new Facade.Instruction(); m_job.Instructions = facInstruction.GetForJobId(m_jobId); PopulateJobInformation(); } ViewState[C_JOB_VS] = m_job; }
void btnConfirm_Click(object sender, EventArgs e) { int newControlAreaId = Convert.ToInt32(cboControlArea.SelectedValue); int newTrafficAreaId = Convert.ToInt32(cboTrafficArea.SelectedValue); bool success = true; if (newControlAreaId != m_instruction.ControlAreaId || newTrafficAreaId != m_instruction.TrafficAreaId) { // Update the control area and traffic area for the leg, and it's following legs if the checkbox is checked. // If the checkbox is checked, the resources on the leg are moved onto the receiving planner's resource list. Facade.IJob facJob = new Facade.Job(); // The end instruction of the leg should always be passed when calling SetControlArea. This is different from // m_instruction, which is the start instruction of the leg. The Start instruction of the leg detertmines the // traffic area responsible for planning the leg. int instructionOrder = m_instruction.InstructionOrder + 1; if (m_instruction.InstructionOrder == 0) { // The instruction is the 1st on the job // Edge case: ensure it is not the only one (ie. collection only job) // If it is then we shouldn't increment the instruction order when calling SetControlArea. Facade.IInstruction facInstruction = new Facade.Instruction(); Entities.InstructionCollection instructions = facInstruction.GetForJobId(m_instruction.JobId); if (instructions.Count == 1) { instructionOrder--; } } Entities.FacadeResult result = facJob.SetControlArea(m_instruction.JobId, newControlAreaId, newTrafficAreaId, instructionOrder, chkApplyToAllFollowingInstructions.Checked, m_lastUpdateDate, ((Entities.CustomPrincipal)Page.User).UserName); success = result.Success; if (!success) { // Display the infringements. idErrors.Infringements = result.Infringements; idErrors.DisplayInfringments(); idErrors.Visible = true; trErrors.Visible = true; } } if (success) { this.ReturnValue = "refresh"; this.Close(); } }
private void btnCancelJob_Click(object sender, EventArgs e) { if (this.btnCancelJob.Text == "Close") { this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CloseWindow", "window.close();", true); } else if (Page.IsValid) { bool result = false; using (Facade.IJob facJob = new Facade.Job()) { Facade.IInstruction facInstruction = new Facade.Instruction(); Entities.InstructionCollection insCol = facInstruction.GetForJobId(m_jobId); if (insCol.Count == 0 || insCol[0].InstructionActuals == null || insCol[0].InstructionActuals.Count == 0) { result = facJob.UpdateState(m_jobId, eJobState.Cancelled, ((Entities.CustomPrincipal)Page.User).UserName); if (result) { lblConfirmation.Text = "The Job " + m_jobId + " has been cancelled successfully."; lblConfirmation.Visible = true; //LoadJob(); //PopulatePage(); this.ButtonBar.Visible = false; this.cancellationTable.Visible = false; this.jobDetailsFieldset.Visible = false; this.btnCancelJob.Text = "Close"; this.jobDetailsTD.Width = "0%"; this.cancellationReasnTD.Width = "100%"; } else { lblConfirmation.Text = "The job could not be cancelled."; lblConfirmation.Visible = true; } } else { lblConfirmation.Visible = true; lblConfirmation.Text = "This job can not be cancelled at this time as it has at least one call-in."; } } } }
private void LoadJob() { using (Facade.IJob facJob = new Facade.Job()) { m_job = facJob.GetJob(m_jobId); if (m_job.JobState == eJobState.Cancelled) { Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId + "&csid=" + this.CookieSessionID); } Facade.IInstruction facInstruction = new Facade.Instruction(); m_job.Instructions = facInstruction.GetForJobId(m_job.JobId); } ViewState[C_JOB_VS] = m_job; }
private void PopulateForm() { Facade.IInstruction facInstruction = new Facade.Instruction(); m_instruction = facInstruction.GetInstruction(m_instructionID); bool canRemoveTrunkPoint = false; if (m_instruction != null) { if (m_instruction.InstructionTypeId == (int)eInstructionType.Trunk && (m_instruction.CollectDrops.Count == 0 || m_instruction.CollectDrops[0].OrderID == 0)) { canRemoveTrunkPoint = true; // This instruction is either a trunk or a trunk that has zero orders. } // Get the previous instruction. Entities.InstructionCollection instructions = facInstruction.GetForJobId(m_instruction.JobId); m_previousInstruction = instructions.GetPreviousInstruction(m_instruction.InstructionID); } pnlConfirmation.Visible = canRemoveTrunkPoint; pnlCannotRemoveTrunk.Visible = !canRemoveTrunkPoint; btnRemoveTrunk.Visible = canRemoveTrunkPoint; }
private void btnBack_Click(object sender, EventArgs e) { if (m_isUpdate) { // Reload the job. Facade.IJob facJob = new Facade.Job(); m_job = facJob.GetJob(m_jobId); Facade.IInstruction facInstruction = new Facade.Instruction(); if (m_job.JobType == eJobType.Normal) { m_job.Charge = ((Facade.IJobCharge)facJob).GetForJobId(m_jobId); m_job.Instructions = facInstruction.GetForJobId(m_job.JobId); m_job.References = ((Facade.IJobReference)facJob).GetJobReferences(m_jobId); Session[wizard.C_JOB] = m_job; } else { switch (m_job.JobType) { case eJobType.PalletReturn: GoToStep("PR"); break; case eJobType.Return: GoToStep("GR"); break; } } } GoToStep("JD"); }
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(); }
private void LoadCommunication() { Facade.IInstruction facInstrucion = new Facade.Instruction(); var jobInstructions = facInstrucion.GetForJobId(_jobId); var instruction = jobInstructions.Single(i => i.InstructionID == _instructionID); // Get the driver. Facade.IDriver facDriver = new Facade.Resource(); Entities.Driver driver = facDriver.GetDriverForResourceId(_driverId); var communicationTypes = Utilities.GetEnumPairs <eDriverCommunicationType>(); // We don't offer the option to communicate by Tough Touch if the driver doesn't have a passcode or the vehicle doesn't have a Tough Touch installed. if (string.IsNullOrWhiteSpace(driver.Passcode) || instruction.Vehicle == null || !instruction.Vehicle.IsTTInstalled) { communicationTypes.Remove((int)eDriverCommunicationType.ToughTouch); } cboCommunicationType.DataSource = communicationTypes; cboCommunicationType.DataBind(); cboCommunicationType.Items.Insert(0, new ListItem("-- Select a communication type --", "")); cboCommunicationType.Attributes.Add("onchange", "cboCommunicationTypeIndex_Changed();"); cboCommunicationStatus.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(eDriverCommunicationStatus))); cboCommunicationStatus.DataBind(); RadioButton rb = null; Entities.ContactCollection contacts = new Entities.ContactCollection(); if (driver != null && driver.Individual.Contacts != null) { contacts = driver.Individual.Contacts; } // Get the vehicle the driver is currently assigned to. Facade.IJourney facJourney = new Facade.Journey(); Entities.Vehicle currentVehicle = facJourney.GetCurrentVehicleForDriver(_driverId); if (currentVehicle != null) { contacts.Add(new Entities.Contact(eContactType.MobilePhone, currentVehicle.CabPhoneNumber)); } Entities.ContactCollection cs = new Orchestrator.Entities.ContactCollection(); rb = new RadioButton(); bool numberSelected = false; foreach (Entities.Contact contact in contacts) { if (contact.ContactDetail.Length > 0) { rb = new RadioButton(); rb.GroupName = "rblNumbers"; rb.Text = contact.ContactDetail; rb.Attributes.Add("onclick", "setNumberUsed('" + contact.ContactDetail + "');"); if (contact.ContactType == eContactType.MobilePhone || contact.ContactType == eContactType.PersonalMobile || contact.ContactType == eContactType.Telephone) { if (!numberSelected) { rb.Checked = true; txtNumber.Text = contact.ContactDetail; numberSelected = true; } } plcNumbers.Controls.Add(rb); plcNumbers.Controls.Add(new LiteralControl("<br/>")); } } rb = new RadioButton(); rb.Text = "Other"; rb.GroupName = "rblNumbers"; rb.Attributes.Add("onclick", "enableOtherTextBox();"); plcNumbers.Controls.Add(rb); bool isInvolvedInLoad = false; foreach (Entities.Instruction i in jobInstructions) { if (i.Driver != null && i.Driver.ResourceId == _driverId) { if ((eInstructionType)i.InstructionTypeId == eInstructionType.Load) { isInvolvedInLoad = true; } } } trLoadOrder.Visible = isInvolvedInLoad; if (isInvolvedInLoad) { var loadComments = BuildLoadComments(_driverId, jobInstructions); lblLoadOrder.Text = loadComments; trLoadOrder.Visible = !string.IsNullOrWhiteSpace(loadComments); } var legPlan = new Facade.Instruction().GetLegPlan(jobInstructions, false); txtComments.Text = GetComments(legPlan, eDriverCommunicationType.Phone); txtSMSText.Text = GetComments(legPlan, eDriverCommunicationType.Text); var defaultCommunicationTypeID = driver.DefaultCommunicationTypeID == 0 ? (int)eDriverCommunicationType.Phone : driver.DefaultCommunicationTypeID; //lookup the communication type in the drop down, dont select if it doesnt exist - this should only happen if the driver whos default method of communitication // is tough touch but has now moved into a vechicial without one being installed if (cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()) != null) { cboCommunicationType.Items.FindByValue(defaultCommunicationTypeID.ToString()).Selected = true; } Facade.IControlArea facControlArea = new Facade.Traffic(); cboControlArea.DataSource = facControlArea.GetAll(); cboControlArea.DataBind(); for (int instructionIndex = jobInstructions.Count - 1; instructionIndex >= 0; instructionIndex--) { if (jobInstructions[instructionIndex].Driver != null && jobInstructions[instructionIndex].Driver.ResourceId == _driverId) { hidLastInstructionInvolvedWith.Value = jobInstructions[instructionIndex].InstructionOrder.ToString(); cboControlArea.ClearSelection(); cboControlArea.Items.FindByValue(jobInstructions[instructionIndex].Point.Address.TrafficArea.ControlAreaId.ToString()).Selected = true; BindTrafficAreas(Convert.ToInt32(cboControlArea.SelectedValue), jobInstructions[instructionIndex].Point.Address.TrafficArea.TrafficAreaId); break; } } ShowPCVS(); }
void dgJobs_ItemCommand(object sender, ComponentArt.Web.UI.GridItemCommandEventArgs e) { Facade.Job facJob = new Orchestrator.Facade.Job(); string userId = ((Entities.CustomPrincipal)Page.User).UserName; int jobId; bool success = false; switch (((Button)e.Control).CommandName.ToLower()) { case "reinstate": jobId = Convert.ToInt32(e.Item["JobId"]); success = facJob.UpdateForCancellation(jobId, false, "", userId); if (success == true) { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "~/images/ico_info.gif"; lblNote.Text = "The Job " + jobId + " has been reinstated successfully."; } else { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "~/images/ico_critical.gif"; lblNote.Text = "The application failed while reinstating the job, please try again."; } break; case "cancel": jobId = Convert.ToInt32(e.Item["JobId"]); Facade.IInstruction facInstruction = new Facade.Instruction(); Entities.InstructionCollection insCol = facInstruction.GetForJobId(jobId); if (insCol.Count == 0 || insCol[0].InstructionActuals == null || insCol[0].InstructionActuals.Count == 0) { success = facJob.UpdateState(jobId, eJobState.Cancelled, ((Entities.CustomPrincipal)Page.User).UserName); if (success) { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "../images/ico_info.gif"; lblNote.Text = "The Job " + jobId + " has been cancelled successfully."; } else { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "../images/ico_critical.gif"; lblNote.Text = "The application failed while cancelling the job, please try again."; } } else { pnlConfirmation.Visible = true; imgIcon.ImageUrl = "../images/ico_critical.gif"; lblNote.Text = "This job can not be cancelled at this time as it has at least one call-in."; } break; } ApplyFilter(); }