Exemplo n.º 1
0
        private void PopulateDockets()
        {
            cboDockets.Items.Clear();
            Facade.IReferenceData facReferenceData = new Facade.ReferenceData();

            string docketNumberText = facReferenceData.GetDocketNumberTextForIdentityId(m_job.IdentityId);

            if (docketNumberText != String.Empty)
            {
                cboDockets.Items.Add(new ListItem("-- Please select a " + docketNumberText + " --"));
            }
            else
            {
                cboDockets.Items.Add(new ListItem("-- Please select a Docket Number --"));
            }

            if (m_isUpdate)
            {
                #region Display the dockets that have not been been assigned to a drop

                foreach (Entities.Instruction instruction in m_job.Instructions)
                {
                    if (instruction.InstructionTypeId == (int)eInstructionType.Load)
                    {
                        foreach (Entities.CollectDrop collectDrop in instruction.CollectDrops)
                        {
                            bool collectDropHasBeenDropped = false;

                            foreach (Entities.Instruction dropInstruction in m_job.Instructions)
                            {
                                if (dropInstruction.InstructionTypeId == (int)eInstructionType.Drop)
                                {
                                    foreach (Entities.CollectDrop dropCollectDrop in dropInstruction.CollectDrops)
                                    {
                                        if (dropCollectDrop.Docket == collectDrop.Docket)
                                        {
                                            collectDropHasBeenDropped = true;
                                        }
                                    }
                                }
                            }

                            if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop)
                            {
                                foreach (Entities.CollectDrop dropCollectDrop in m_instruction.CollectDrops)
                                {
                                    if (dropCollectDrop.Docket == collectDrop.Docket)
                                    {
                                        collectDropHasBeenDropped = true;
                                    }
                                }
                            }

                            if (!collectDropHasBeenDropped)
                            {
                                cboDockets.Items.Add(DocketItem(collectDrop));
                            }
                        }
                    }
                }

                #endregion

                if (m_isAmendment)
                {
                    cboDockets.ClearSelection();

                    cboDockets.Items.Insert(1, DocketItem(m_collectdrop));
                    cboDockets.Items[1].Selected = true;
                }
            }
            else
            {
                #region Display a list of dockets that have not been assigned to a drop

                // Check both within the m_job.Instructions collection, but also the new collection being built-up.
                Entities.InstructionCollection insCollection = new Entities.InstructionCollection();
                foreach (Entities.Instruction instruction in m_job.Instructions)
                {
                    insCollection.Add(instruction);
                }
                insCollection.Add(m_instruction);

                foreach (Entities.Instruction instruction in insCollection)
                {
                    if (instruction.InstructionTypeId == (int)eInstructionType.Load)
                    {
                        foreach (Entities.CollectDrop collectDrop in instruction.CollectDrops)
                        {
                            bool collectDropHasBeenDropped = false;

                            foreach (Entities.Instruction dropInstruction in insCollection)
                            {
                                if (dropInstruction.InstructionTypeId == (int)eInstructionType.Drop)
                                {
                                    foreach (Entities.CollectDrop dropCollectDrop in dropInstruction.CollectDrops)
                                    {
                                        if (collectDrop.Docket == dropCollectDrop.Docket)
                                        {
                                            collectDropHasBeenDropped = true;
                                        }
                                    }
                                }
                            }

                            if (!collectDropHasBeenDropped)
                            {
                                cboDockets.Items.Add(DocketItem(collectDrop));
                            }
                        }
                    }
                }

                #endregion

                if (m_isAmendment)
                {
                    cboDockets.ClearSelection();
                    // Add and select the docket
                    cboDockets.Items.Insert(1, DocketItem(m_collectdrop));
                    cboDockets.Items[1].Selected = true;
                }
            }

            if (m_instruction.InstructionTypeId == (int)eInstructionType.Drop && cboDockets.Items.Count == 2)
            {
                chkAddAnotherDocket.Enabled = false;
            }
        }
Exemplo n.º 2
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();
                }
            }
        }