Beispiel #1
0
        public bool addLevel(string newLevel, int atIndex, bool isExisting)// add level
        {
            bool             successfullyAdded = false;
            ValLabelMarixRow row = null;//create ref. for new row

            if (isExisting)
            {
                row = new ValLabelMarixRow(newLevel, atIndex, newLevel, "");// create new row
                vldMatrix.Add(row);
                successfullyAdded = true;
            }
            else// its a new level
            {
                DuplicateInfo dupResult = getDuplicateCatagory(newLevel);
                switch (dupResult.duplicateType)
                {
                case 1:     //duplicate found in original list. check if Change prop is blank or contains value
                    // if blank(removed earlier), then simply add newLevel in Change prop.
                    // else create new entry in Change with current prop name and overwrite current Change value
                    ValLabelMarixRow curr = vldMatrix.ElementAt(dupResult.rowindex);
                    if (curr.ChangeDeleteLevel.Trim().Length == 0)     // empty change value. That means user earlier dropped this level.
                    {
                        curr.ChangeDeleteLevel = newLevel;
                        successfullyAdded      = true;
                    }
                    else if (curr.ChangeDeleteLevel.Trim() != newLevel)                   // user changed the name of this level earlier. We need to create new level with changed name and reset old level
                    {
                        string oldLevel = newLevel;                                       // newLevel is old level actully in this case
                        newLevel = curr.ChangeDeleteLevel;
                        row      = new ValLabelMarixRow(newLevel, atIndex, "", newLevel); // create new row
                        curr.ChangeDeleteLevel = oldLevel;
                        vldMatrix.Add(row);
                        successfullyAdded = true;
                    }
                    else
                    {
                        //its a duplicate
                        successfullyAdded = false;
                    }
                    break;

                case 2:
                    //its a duplicate
                    successfullyAdded = false;
                    break;

                case 3:
                    //its a duplicate
                    successfullyAdded = false;
                    break;

                default:
                    row = new ValLabelMarixRow(newLevel, atIndex, "", newLevel);    // create new row
                    vldMatrix.Add(row);
                    successfullyAdded = true;
                    break;
                }
            }
            return(successfullyAdded);
        }
        public bool addLevel(string newLevel, int atIndex, bool isExisting)// add level
        {
            bool successfullyAdded = false;
            ValLabelMarixRow row = null;//create ref. for new row 
            if (isExisting)
            {
                row = new ValLabelMarixRow(newLevel, atIndex, newLevel, "");// create new row
                vldMatrix.Add(row);
                successfullyAdded = true;
            }
            else// its a new level
            {

                DuplicateInfo dupResult = getDuplicateCatagory(newLevel);
                switch (dupResult.duplicateType)
                {
                    case 1: //duplicate found in original list. check if Change prop is blank or contains value
                        // if blank(removed earlier), then simply add newLevel in Change prop.
                        // else create new entry in Change with current prop name and overwrite current Change value
                        ValLabelMarixRow curr = vldMatrix.ElementAt(dupResult.rowindex);
                        if (curr.ChangeDeleteLevel.Trim().Length == 0) // empty change value. That means user earlier dropped this level.
                        {
                            curr.ChangeDeleteLevel = newLevel;
                            successfullyAdded = true;
                        }
                        else if (curr.ChangeDeleteLevel.Trim() != newLevel) // user changed the name of this level earlier. We need to create new level with changed name and reset old level
                        {
                            string oldLevel = newLevel;// newLevel is old level actully in this case
                            newLevel = curr.ChangeDeleteLevel;
                            row = new ValLabelMarixRow(newLevel, atIndex, "", newLevel);// create new row
                            curr.ChangeDeleteLevel = oldLevel;
                            vldMatrix.Add(row);
                            successfullyAdded = true;
                        }
                        else
                        {
                            //its a duplicate 
                            successfullyAdded = false;
                        }
                        break;
                    case 2:
                        //its a duplicate
                        successfullyAdded = false;
                        break;
                    case 3:
                        //its a duplicate
                        successfullyAdded = false;
                        break;
                    default:
                        row = new ValLabelMarixRow(newLevel, atIndex, "", newLevel);// create new row
                        vldMatrix.Add(row);
                        successfullyAdded = true;
                        break;
                }
            }
            return successfullyAdded;
        }