Example #1
0
        private void repeaterFaultList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string command = e.CommandName.ToUpper();

            if (command == "DELETEFAULT")
            {
                int selectedIndex = e.Item.ItemIndex;
                CurrentProfileFaultList.RemoveAt(selectedIndex);
            }
            else
            {
                int selectedIndex = e.Item.ItemIndex;
                int newIndex      = selectedIndex;
                switch (command)
                {
                case "MOVEDOWN":
                    newIndex++;
                    break;

                case "MOVEUP":
                    newIndex--;
                    break;
                }
                if (selectedIndex != newIndex && newIndex > -1 && newIndex < CurrentProfileFaultList.Count)
                {   // Only continue if the indexes look right/are within bounds
                    // First ensure that we persist any text changes user made to the fault list
                    updateFaultListDataSource();
                    // Just swap the ordernumber values from objects at selectedIndex and newIndex and rebind the grid...
                    int oldOrderNumber = CurrentProfileFaultList[selectedIndex].OrderNumber;
                    CurrentProfileFaultList[selectedIndex].OrderNumber = CurrentProfileFaultList[newIndex].OrderNumber;
                    CurrentProfileFaultList[newIndex].OrderNumber      = oldOrderNumber;
                }
            }
            populateProfileFaultList();
        }
Example #2
0
 /// <summary>
 /// Rebinds the fault list table to the fault list for the current profile
 /// </summary>
 private void populateProfileFaultList()
 {
     // Resort the profile list here so we pick up any reordering the user may have performed.
     CurrentProfileFaultList.Sort("OrderNumber");
     repeaterFaultList.DataSource = CurrentProfileFaultList;
     repeaterFaultList.DataBind();
 }
Example #3
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();
        }