Esempio n. 1
0
        private void menuItemTypeAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (tree.SelectedNode == null)
                {
                    MessageBox.Show("You must select a parent node first");
                    return;
                }

                FormGetName form = new FormGetName();
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (String.IsNullOrEmpty(form.SelectedNorwegianName))
                {
                    MessageBox.Show("Can not use empty names");
                    return;
                }

                TreeNode tnode = tree.SelectedNode;

                foreach (TreeNode tn in tnode.Nodes)
                {
                    string name = tn.Text;
                    if (name.ToLower() == form.SelectedNorwegianName.ToLower())
                    {
                        MessageBox.Show("Name " + name + " already exist at this location");
                        return;
                    }
                }

                XmlNode    xnode = tree.SelectedNode.Tag as XmlNode;
                XmlElement xe    = doc.CreateElement(String.Empty, "sampletype", "");
                xe.SetAttribute("name", form.SelectedNorwegianName);
                xe.SetAttribute("name_english", "");
                xe.SetAttribute("name_latin", "");
                xnode.AppendChild(xe);
                TreeNode tn2 = tnode.Nodes.Add(form.SelectedNorwegianName);
                tn2.ToolTipText = tnode.ToolTipText + "/" + form.SelectedNorwegianName;
                tn2.Tag         = xe;
                modified        = true;

                lblStatus.Text = "Sample type " + form.SelectedNorwegianName + " added";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void menuItemComponentAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (tree.SelectedNode == null)
                {
                    MessageBox.Show("You must select a parent node first");
                    return;
                }

                FormGetName form = new FormGetName();
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                if (String.IsNullOrEmpty(form.SelectedNorwegianName))
                {
                    MessageBox.Show("Can not use empty names");
                    return;
                }

                XmlNode    xnode = tree.SelectedNode.Tag as XmlNode;
                XmlElement xe    = doc.CreateElement(String.Empty, "component", "");
                xe.SetAttribute("name", form.SelectedNorwegianName);
                xe.SetAttribute("name_english", "");
                xe.SetAttribute("name_latin", "");
                xnode.AppendChild(xe);
                modified = true;

                PopulateComponents(tree.SelectedNode);

                lblStatus.Text = "Component " + form.SelectedNorwegianName + " added";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }