public AddEditElectricalEquipmentTypeDialog(int id)
        {
            InitializeComponent();

            AddEditElectricalEquipmentTypeModel model = new AddEditElectricalEquipmentTypeModel(id);
            model.View = this;
            model.DataLoaded += (s1) =>
                {
                    DataContext = model;
                    Utils.ResetOriginalValues(this);
                };
        }
        private void AddType(NodeView nodeView)
        {
            AddEditElectricalEquipmentTypeDialog dialog = new AddEditElectricalEquipmentTypeDialog();
            AddEditElectricalEquipmentTypeModel model = new AddEditElectricalEquipmentTypeModel();
            model.View = dialog;
            dialog.DataContext = model;
            dialog.Show();

            dialog.Closed +=
                (s1, e1) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        NodeView child = new NodeView(nodeView)
                        {
                            Id = dialog.ElectricalEquipmentType.Id,
                            Name = dialog.ElectricalEquipmentType.Name,
                            Description = dialog.ElectricalEquipmentType.Description,
                            Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                            Type = NodeType.ElectricalTypeNode,
                            HasChildren = true,
                            SortField = dialog.ElectricalEquipmentType.Ordinal.ToString(),
                            IsActive = dialog.ElectricalEquipmentType.IsActive

                        };
                        if (nodeView.ChildrenLoaded)
                        {
                            nodeView.Children.Add(child);
                            nodeView.Sort(true);
                        }
                    }
                };
        }