ArcGISCompare.frmMaster.SaveAllMappings C# (CSharp) Method

SaveAllMappings() public method

public SaveAllMappings ( ListBox lstMap ) : void
lstMap ListBox
return void
        public void SaveAllMappings(ListBox lstMap)
        {
            if (theInst.isMapped)
            {
                DialogResult theAns = MessageBox.Show(this, "Overwrite Existing Mappings?", "Delete Existing Mappings", MessageBoxButtons.YesNoCancel);

                if (theAns == DialogResult.Cancel) { return; }
                if (theAns == DialogResult.No) { return; }
                if (theAns == DialogResult.Yes)
                {
                    if (theInst.DeleteAllMappings())
                    {
                        for (int i = 0; i < lstMap.Items.Count; i++)
                        {
                            FeatureMappingData theItem = (FeatureMappingData)lstMap.Items[i];
                            theInst.WriteFeatureMapping(theItem);

                            if (theItem.theErrors != null)
                                foreach (LoadErrorData theE in theItem.theErrors)
                                    theInst.WriteLoadErrors(theE);
                            if (theItem.theTransforms != null)
                                foreach (AttributeMappingData theAMap in theItem.theTransforms)
                                {
                                    theInst.WriteAttributeMapping(theAMap);

                                    if (theAMap.theLoss != null)
                                        foreach (DataLossEntries theE in theAMap.theLoss)
                                            theInst.WriteDataLoss(theE);
                                    if (theAMap.theConversions != null)
                                        foreach (ValueMappingData theV in theAMap.theConversions)
                                            theInst.WriteValueMapping(theItem.serialNumber, theV);
                                }
                        }
                    }
                    hasChanged = false;
                }
            }
            else
            {
                theInst.BuildMappingTables();

                for (int i = 0; i < lstMap.Items.Count; i++)
                {
                    FeatureMappingData theItem = (FeatureMappingData)lstMap.Items[i];
                    theInst.WriteFeatureMapping(theItem);

                    if (theItem.theErrors != null)
                        foreach (LoadErrorData theE in theItem.theErrors)
                            theInst.WriteLoadErrors(theE);
                    if (theItem.theTransforms != null)
                        foreach (AttributeMappingData theAMap in theItem.theTransforms)
                        {
                            theInst.WriteAttributeMapping(theAMap);

                            if (theAMap.theLoss != null)
                                foreach (DataLossEntries theE in theAMap.theLoss)
                                    theInst.WriteDataLoss(theE);
                            if (theAMap.theConversions != null)
                                foreach (ValueMappingData theV in theAMap.theConversions)
                                    theInst.WriteValueMapping(theItem.serialNumber, theV);
                        }
                }
                hasChanged = false;
            }
        }