private void AddInterlockType(NodeView nodeView) { var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); var dialog = new AddEditInterlockTypeDialog(); dialog.Show(); dialog.Closed += (s1, e1) => { if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { EventHandler<AddInterlockTypeCompletedEventArgs> addCompleted = null; addCompleted = (s2, eventArgs) => { var mect = eventArgs.Result; if (mect != null) { var child = new NodeView(nodeView) { Id = mect.Id, Name = dialog.InterlockType.Name, Description = dialog.InterlockType.Description, Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png", Type = NodeType.InterlockType, HasChildren = true, SortField = dialog.InterlockType.Ordinal.ToString() }; if (nodeView.ChildrenLoaded) { nodeView.Children.Add(child); nodeView.Sort(); } } cmsWebServiceClient.AddInterlockTypeCompleted -= addCompleted; }; cmsWebServiceClient.AddInterlockTypeCompleted += addCompleted; cmsWebServiceClient.AddInterlockTypeAsync(dialog.InterlockType); } }; }
private void EditInterlockType(NodeView nodeView) { var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); EventHandler<GetInterlockTypeCompletedEventArgs> getInterlockCompleted = null; getInterlockCompleted = (s, eventArgs) => { var mc = eventArgs.Result; var dialog = new AddEditInterlockTypeDialog(mc); dialog.Show(); dialog.Closed += (s1, e1) => { if (dialog.DialogResult.HasValue && dialog.DialogResult.Value) { EventHandler<AddInterlockTypeCompletedEventArgs> addCompleted = null; addCompleted = (s2, e2) => { var interlockType = e2.Result; nodeView.Name = interlockType.Name; nodeView.Description = interlockType.Description; nodeView.SortField = interlockType.Ordinal.ToString(); cmsWebServiceClient.AddInterlockTypeCompleted -= addCompleted; nodeView.Parent.Sort(); }; cmsWebServiceClient.AddInterlockTypeCompleted += addCompleted; cmsWebServiceClient.AddInterlockTypeAsync(dialog.InterlockType); } }; cmsWebServiceClient.GetInterlockTypeCompleted -= getInterlockCompleted; }; cmsWebServiceClient.GetInterlockTypeCompleted += getInterlockCompleted; cmsWebServiceClient.GetInterlockTypeAsync(nodeView.Id); }