Example #1
0
        protected override void f_TreeView_DragDrop(object sender, DragEventArgs e, Ctrl_TreeNodeGroup a_TargetNodeGroup)
        {
            if (a_TargetNodeGroup != null)
            {
                using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction())
                {
                    try
                    {
                        Ctrl_TreeNodeTemplate draggedNodeTemplate = (Ctrl_TreeNodeTemplate)e.Data.GetData(typeof(Ctrl_TreeNodeTemplate));
                        if (e.Effect == DragDropEffects.Move)
                        {
                            Cl_EntityLog eLog = new Cl_EntityLog();
                            eLog.f_SetEntity(draggedNodeTemplate.p_Template);

                            var elsDraggeds = Cl_App.m_DataContext.p_Templates.Where(el => el.p_TemplateID == draggedNodeTemplate.p_Template.p_TemplateID);
                            if (elsDraggeds != null)
                            {
                                bool isChange = false;
                                foreach (Cl_Template el in elsDraggeds)
                                {
                                    el.p_ParentGroupID = a_TargetNodeGroup.p_Group.p_ID;
                                    isChange           = true;
                                }
                                if (isChange)
                                {
                                    Cl_App.m_DataContext.SaveChanges();
                                    eLog.f_SaveEntity(draggedNodeTemplate.p_Template);
                                    transaction.Commit();
                                    draggedNodeTemplate.Remove();
                                    a_TargetNodeGroup.Nodes.Insert(f_GetFirstGroupInNode(a_TargetNodeGroup.Nodes), draggedNodeTemplate);
                                }
                            }
                            else
                            {
                                MonitoringStub.Error("Error_Tree", "Не найден шаблон", new Exception("EX ERROR"), "draggedNodeTemplate.p_Template.p_TemplateID = " + draggedNodeTemplate.p_Template.p_TemplateID, null);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        MonitoringStub.Error("Error_Tree", "При перемещении шаблона произошла ошибка", ex, null, null);
                        return;
                    }
                }
            }
        }
Example #2
0
 protected virtual void f_TreeView_DragDrop(object sender, DragEventArgs e, Ctrl_TreeNodeGroup a_TargetNodeGroup)
 {
 }