private bool ApplyFuelSurcharge() { Facade.IOrder facadeOrder = new Facade.Order(); var order = facadeOrder.GetForOrderID(this.OrderID); Facade.Organisation facOrg = new Facade.Organisation(); var defaults = facOrg.GetDefaultsForIdentityId(order.CustomerIdentityID); Facade.ExtraType facExtraType = new Facade.ExtraType(); var extraType = facExtraType.GetForExtraTypeID(int.Parse(cboExtraType.SelectedValue)); m_fuelSurchargePercentage = order.FuelSurchargePercentage; bool fuelSurchargeAppliesToExtras = bool.Parse(defaults.Tables[0].Rows[0]["FuelSurchargeOnExtras"].ToString()); return(fuelSurchargeAppliesToExtras && extraType.FuelSurchargeApplies); }
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(); } } }