Exemplo n.º 1
0
        private void populateAssignProfileFields()
        {
            Dictionary <string, string> assignedVehicleList = new Dictionary <string, string>();

            Fleetwood.BlueSphere.BusinessLogic.VehicleList assignedVehicleListWithUnavailable = CurrentProfile.VehicleList;

            foreach (Fleetwood.BlueSphere.BusinessLogic.Vehicle v in assignedVehicleListWithUnavailable)
            {
                if (v.IsRetired || v.IsDeleted)
                {
                    continue;
                }

                assignedVehicleList.Add(v.DisplayRegistration, v.ID.ToString());
            }

            refreshRadListBoxContents(
                assignedVehiclesListBox
                , false
                , assignedVehicleList
                );

            Dictionary <string, string> unassignedVehicleList = new Dictionary <string, string>();

            foreach (Fleetwood.BlueSphere.BusinessLogic.Vehicle v in BSCustomer.VehicleList)
            {
                if (v.IsRetired || v.IsDeleted || v.SafetyCheckProfileID == CurrentProfileID)
                {
                    continue;
                }

                if (v.SafetyCheckProfileID == Guid.Empty)
                {
                    unassignedVehicleList.Add(v.DisplayRegistration, v.ID.ToString());
                }
                else
                {
                    if (chkShowAllVehicles.Checked)
                    {
                        unassignedVehicleList.Add(v.DisplayRegistration + " (*)", v.ID.ToString());
                    }
                }
            }

            refreshRadListBoxContents(
                unassignedVehiclesListBox
                , false
                , unassignedVehicleList
                );

            lblAssignedCount.Text   = assignedVehicleList.Count.ToString();
            lblUnassignedCount.Text = unassignedVehicleList.Count.ToString();
        }
Exemplo n.º 2
0
        /// <summary>
        /// On save click - beware some funky logic included here if user is trying to UPDATE an existing profile...
        /// </summary>
        private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            updateProfileDataSource();
            updateFaultListDataSource();

            Page.Validate("MinimumProfileDetails");
            if (Page.IsValid)
            {
                try
                {
                    // get the currently Assigned vehicles (if any)
                    Fleetwood.BlueSphere.BusinessLogic.VehicleList assignedVehicles = CurrentProfile.VehicleList;

                    //when profiels are updated this actually creates a new one
                    Guid newProfileID = CurrentProfile.Update();
                    CurrentProfile = new Fleetwood.BlueSphere.BusinessLogic.SafetyCheckProfile(newProfileID);
                    foreach (Fleetwood.BlueSphere.BusinessLogic.FaultType item in CurrentProfileFaultList)
                    {
                        if (item.SafetyCheckProfileID != new Guid("00000000-0000-0000-0000-000000000000"))
                        {
                            Fleetwood.BlueSphere.BusinessLogic.FaultType clonedFault = item.Clone();
                            clonedFault.SafetyCheckProfileID = CurrentProfile.ID;
                            clonedFault.IsDeleted            = false;
                            clonedFault.Update();
                        }
                        else
                        {
                            item.SafetyCheckProfileID = CurrentProfile.ID;
                            item.Update();
                        }
                    }

                    // Now we need to re-ssign any vehicles that had the old Id to the new one.
                    ArrayList assignments = new ArrayList();
                    foreach (Fleetwood.BlueSphere.BusinessLogic.Vehicle v in assignedVehicles)
                    {
                        assignments.Add(v.ID);
                    }

                    CurrentProfile.AssignVehicles(assignments);

                    saveProfileError.Visible = false;
                    Response.Redirect(Request.RawUrl);
                }
                catch (Exception ex)
                {
                    saveProfileError.Visible   = true;
                    saveProfileError.InnerText = ex.Message;
                }
            }
        }