Пример #1
0
        /// <summary>
        /// Создание новой папки в работе
        /// </summary>
        /// <param name="parentNode">Родитель</param>
        /// <param name="newFolderName">Имя новой папки</param>
        /// <returns>Новая папка</returns>
        public static WorkFolderNode CreateNewFolder(WorkFolderNode parentNode, string newFolderName)
        {
            if (parentNode != null)
            {
                try
                {
                    int result = Environment.FolderData.New(parentNode.ID, newFolderName);
                    if (result != 0)
                    {
                        var newNode = new WorkFolderNode(result, newFolderName, parentNode.Emp);

                        parentNode.Nodes.Add(newNode);
                        newNode.RemoveBold();
                        newNode.EnsureVisible();
                        return(newNode);
                    }
                }
                catch (Exception ex)
                {
                    Lib.Win.Data.Env.WriteToLog(ex);
                }
            }

            return(parentNode);
        }
Пример #2
0
        public WorkFolderNode AddExistingFolder(int nodeID, int empID)
        {
            if (nodeID <= 0)
            {
                return(null);
            }
            try
            {
                DataRow dr = Environment.WorkFolderData(nodeID, empID);
                if (dr == null)
                {
                    Environment.ReloadReadData();
                    dr = Environment.WorkFolderData(nodeID, empID);
                }

                WorkFolderNode newNode = null;

                if (dr != null)
                {
                    int parentID = (int)dr[Environment.FolderData.ParentField];

                    WorkFolderNode parentNode = ContainsByID(parentID, empID)
                                                    ? GetByID(parentID, empID)
                                                    : AddExistingFolder(parentID, empID);

                    if (parentNode != null)
                    {
                        newNode = new WorkFolderNode(nodeID, (string)dr[Environment.FolderData.NameField], parentNode.Emp);

                        parentNode.Nodes.Add(newNode);
                        newNode.RemoveBold();
                    }
                    else
                    {
                        Lib.Win.Data.Env.WriteToLog("parentNode == null");
                    }
                }
                else
                {
                    Lib.Win.Data.Env.WriteToLog("dr == null");
                }

                return(newNode);
            }
            catch (Exception ex)
            {
                Lib.Win.Data.Env.WriteToLog(ex);
            }

            return(null);
        }
Пример #3
0
        private void NewItemDialog_DialogEvent(object source, Kesco.Lib.Win.DialogEventArgs e)
        {
            Kesco.Lib.Win.Document.EnterStringDialog dialog = e.Dialog as Kesco.Lib.Win.Document.EnterStringDialog;
            if (dialog == null || dialog.DialogResult != DialogResult.OK)
            {
                return;
            }

            string folderName = dialog.Input;
            int    result     = Environment.FolderData.New(ID, folderName);

            if (result != 0)
            {
                var newNode = new WorkFolderNode(result, folderName, Emp);

                Nodes.Add(newNode);
                newNode.RemoveBold();
                newNode.EnsureVisible();
                TreeView.SelectedNode = newNode;
            }
        }