public AddEditInstrumentTypeDialog(int id)
        {
            InitializeComponent();

            AddEditInstrumentTypeModel model = new AddEditInstrumentTypeModel(id);
            model.View = this;

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

            dialog.Closed +=
                (s1, e1) =>
                {
                    NodeView parentNode = nodeView;
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        NodeView child = new NodeView(parentNode)
                        {
                            Id = dialog.InstrumentType.Id,
                            Name = string.Format("{0} ({1})", dialog.InstrumentType.Name, dialog.InstrumentType.Description),
                            Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                            Type = NodeType.InstrumentTypeNode,
                            Description = dialog.InstrumentType.Description,
                            HasChildren = false,
                            SortField = dialog.InstrumentType.Ordinal.ToString(),
                            IsActive = dialog.InstrumentType.IsActive

                        };
                        parentNode.Children.Add(child);
                        nodeView.Parent.Sort(true);
                    }
                };
        }