private void EditElectricalComponentTypeProperty(NodeView nodeView)
        {
            AddEditExistingElectricalComponentPropertyDialog dialog = new AddEditExistingElectricalComponentPropertyDialog(nodeView.Id);

            dialog.Closed +=
                (s1, e1) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                        EventHandler<AddUpdateElectricalComponentTypePropertyCompletedEventArgs> addCompleted = null;
                        addCompleted = (s2, eventArgs) =>
                        {
                            ElectricalEquipmentComponentTypeProperty pcpt = eventArgs.Result;

                            if (pcpt != null)
                            {
                                nodeView.Name = dialog.ElectricalEquipmentComponentTypeProperty.ElectricalEquipmentProperty.Name;
                                nodeView.Description  = dialog.ElectricalEquipmentComponentTypeProperty.ElectricalEquipmentProperty.Description;
                                nodeView.SortField = dialog.ElectricalEquipmentComponentTypeProperty.Ordinal.ToString();
                            }

                            cmsWebServiceClient.AddUpdateElectricalComponentTypePropertyCompleted -= addCompleted;
                        };

                        cmsWebServiceClient.AddUpdateElectricalComponentTypePropertyCompleted += addCompleted;

                        ElectricalEquipmentComponentTypeProperty ElectricalEquipmentComponentTypeProperty = new ElectricalEquipmentComponentTypeProperty
                        {
                            ElectricalEquipmentComponentTypeId = dialog.ElectricalEquipmentComponentTypeProperty.ElectricalEquipmentComponentTypeId,
                            ElectricalEquipmentPropertyId = dialog.ElectricalEquipmentComponentTypeProperty.ElectricalEquipmentPropertyId,
                            Ordinal = dialog.ElectricalEquipmentComponentTypeProperty.Ordinal
                        };

                        cmsWebServiceClient.AddUpdateElectricalComponentTypePropertyAsync(ElectricalEquipmentComponentTypeProperty);
                    }

                    nodeView.Parent.Sort();

                };
            dialog.Show();
        }
        private void AddExistingElectricalComponentProperty(NodeView nodeView)
        {
            int electricalEquipmentComponentTypeId = nodeView.Id;
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetElectricalEquipmentComponentTypeCompleted +=
                (s, e) =>
                {
                    AddEditExistingElectricalComponentPropertyDialog dialog = new AddEditExistingElectricalComponentPropertyDialog(e.Result);
                    dialog.Show();

                    dialog.Closed += (s1, e1) =>
                    {

                        if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                        {
                            EventHandler<AddElectricalComponentTypePropertyCompletedEventArgs> addCompleted = null;
                            addCompleted = (s2, eventArgs) =>
                            {
                                ElectricalEquipmentComponentTypeProperty pcpt = eventArgs.Result;

                                if (pcpt != null)
                                {
                                    NodeView child = new NodeView(nodeView)
                                    {
                                        Id = pcpt.Id,
                                        Name = dialog.ElectricalEquipmentComponentTypeProperty.ElectricalEquipmentProperty.Name,
                                        Description = dialog.ElectricalEquipmentComponentTypeProperty.ElectricalEquipmentProperty.Description,
                                        Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                        Type = NodeType.ElectricalComponentTypeProperty,
                                        HasChildren = false,
                                        SortField = dialog.ElectricalEquipmentComponentTypeProperty.Ordinal.ToString()
                                    };
                                    if (nodeView.ChildrenLoaded)
                                    {
                                        nodeView.Children.Add(child);
                                        nodeView.Sort();
                                    }
                                }

                                cmsWebServiceClient.AddElectricalComponentTypePropertyCompleted -= addCompleted;

                            };

                            cmsWebServiceClient.AddElectricalComponentTypePropertyCompleted += addCompleted;

                            ElectricalEquipmentComponentTypeProperty electricalEquipmentComponentTypeProperty = new ElectricalEquipmentComponentTypeProperty
                            {
                                ElectricalEquipmentComponentTypeId = electricalEquipmentComponentTypeId,
                                ElectricalEquipmentPropertyId = dialog.ElectricalEquipmentComponentTypeProperty.ElectricalEquipmentPropertyId,
                                Ordinal = dialog.ElectricalEquipmentComponentTypeProperty.Ordinal
                            };

                            cmsWebServiceClient.AddElectricalComponentTypePropertyAsync(electricalEquipmentComponentTypeProperty);
                        }
                    };
                };

            cmsWebServiceClient.GetElectricalEquipmentComponentTypeAsync(electricalEquipmentComponentTypeId);
        }