Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
0
        private void btnAddNewFault_Click(object sender, EventArgs e)
        {
            // First ensure that we persist any text changes user made to the fault list
            updateFaultListDataSource();
            // Work out what the next order value will be (remember there may not be any (for a new profile), in which case use the increment to start us off)
            int newOrderValue = FAULT_ORDER_NUMBER_INCREMENT;

            if (CurrentProfile != null && CurrentProfileFaultList.Count > 0)
            {
                newOrderValue = CurrentProfileFaultList.Count + FAULT_ORDER_NUMBER_INCREMENT;
            }
            Fleetwood.BlueSphere.BusinessLogic.FaultType newFault = new Fleetwood.BlueSphere.BusinessLogic.FaultType();
            newFault.OrderNumber = newOrderValue;
            CurrentProfileFaultList.Add(newFault);
            populateProfileFaultList();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Ensures the CurrentProfileFaultList reflects the data entered into the fault list table on screen
 /// </summary>
 private void updateFaultListDataSource()
 {
     for (int i = 0; i < CurrentProfileFaultList.Count; i++)
     {
         Fleetwood.BlueSphere.BusinessLogic.FaultType thisFault = CurrentProfileFaultList[i];
         foreach (RepeaterItem item in repeaterFaultList.Items)
         {
             if (item.ItemIndex == i)
             {
                 TextBox txtFaultTitle = (TextBox)item.FindControl("txtFaultTitle");
                 thisFault.Title = txtFaultTitle.Text;
                 TextBox txtFaultCategory = (TextBox)item.FindControl("txtFaultCategory");
                 thisFault.FaultCategory = txtFaultCategory.Text;
                 CheckBox chkIsDiscretionary = (CheckBox)item.FindControl("chkIsDiscretionary");
                 thisFault.IsDiscretionaryQuestion = chkIsDiscretionary.Checked;
                 CheckBox chkHighlight = (CheckBox)item.FindControl("chkHighlight");
                 thisFault.Highlight = chkHighlight.Checked;
                 // We've updated thisFault now - break out of repeater loop and move onto next fault, there can categorically be no more matches
                 break;
             }
         }
     }
 }