private void CreateFolder() { bool isChildNode = false; if (selectedNode.Text.ToLower() != "qualitymanagementsystem" || selectedNode == null) { qm_tree current_tree = db.qm_tree.FirstOrDefault(tree => tree.title == selectedNode.Text); if (current_tree.childs == null) { current_tree.childs = txtFolderName.Text; } else { current_tree.childs = current_tree.childs + "," + txtFolderName.Text; } db.SaveChanges(); isChildNode = true; Close(); } TreeNode node = new TreeNode(); tree.title = txtFolderName.Text; tree.created_at = DateTime.Now; tree.creator_id = StartPage._loggedInUser.user_id; tree.isChild = isChildNode; using (emedEntities db = new emedEntities()) { db.qm_tree.Add(tree); db.SaveChanges(); MessageBox.Show("Added Successfully!"); } Close(); }
public Folder(TreeNode selectedNode, qm_tree tree) { InitializeComponent(); fromAddFolder = this; this.selectedNode = selectedNode; this.tree = tree; }
private void deleteFolderToolStripMenuItem_Click(object sender, EventArgs e) { //delete folder button try { qm_tree currentTree = (qm_tree)treeViewQMS.SelectedNode.Tag; if (currentTree.GetType() == typeof(qm_sop)) { return; } else if (currentTree == null) { MessageBox.Show("Oops, something went wrong", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } // treeViewQMS.Nodes.Remove(treeViewQMS.SelectedNode); db.qm_tree.Remove(db.qm_tree.FirstOrDefault(qm_tree => qm_tree.qm_tree_id == currentTree.qm_tree_id)); db.SaveChanges(); MessageBox.Show("Folder is deleted successfully", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Selected item is not a folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { PopulateTree(); } }
private void ReadChild(qm_tree item, List <TreeNode> childNodes, List <qm_tree> items, Tree tree) { emedEntities db = new emedEntities(); if (item != null && item.childs != null) { foreach (string n in item.childs.Split(',')) { qm_tree current_tree = items.FirstOrDefault(t => t.title == n); List <TreeNode> current_childNodes = new List <TreeNode>(); if (current_tree == null) { continue; } List <qm_sop> documentInNode = db.qm_sop.Where(sop => sop.qm_tree_id == current_tree.qm_tree_id && sop.status.Value == 1).ToList(); ReadDocument(documentInNode, current_childNodes); ReadChild(current_tree, current_childNodes, items, null); TreeNode temp = new TreeNode(n, current_childNodes.ToArray()); string parentIcon = @"C:\Users\iME\Documents\MyProj\FinalProject\Icons\folder_open.png"; registerIcon(parentIcon); temp.ImageKey = parentIcon; temp.Tag = current_tree; childNodes.Add(temp); } } }
//that part?? (document is qm_sop and folder is qm_tree) //yup.... ok, so go back private void createFolderToolStripMenuItem_Click(object sender, EventArgs e) { if (isDocument()) { //some message here MessageBox.Show("Oops, a document cannot have a child", "Error Message", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } qm_tree newTree = new qm_tree(); Folder an = new Folder(treeViewQMS.SelectedNode, newTree); an.ShowDialog(); TreeNode underNameNode = new TreeNode(Folder.fromAddFolder.txtFolderName.Text); underNameNode.Tag = newTree; treeViewQMS.SelectedNode.Nodes.Add(underNameNode); }
public Document(qm_tree parentTree, TreeNode parentNode) { InitializeComponent(); this.parentTree = parentTree; this.parentNode = parentNode; }