Exemple #1
0
        private void addItem()
        {
            string addValue   = "";       //Value to add to the Combo Box of choice
            string comboValue = "";       //Type that the user wants to add an option too

            comboValue = catComBox.Text;  //Gets Value from combo box of the data type user wants to change
            addValue   = addTextBox.Text; //Sets value of comboValue to the value of the text box

            if (comboValue == "Filament Type")
            {
                XDocument doc  = XDocument.Load(Globals.xmlFilePath);                                                  //Creates new Xdoc
                XElement  edit = doc.Root;                                                                             //New element equal to the root of the XML File
                edit.Element("addMaterialForm").Element("filamentType").Add(new XElement("FilType", addTextBox.Text)); // Add a new <Type> Element with a value taken from a text box
                doc.Save(Globals.xmlFilePath);                                                                         //Save XML file
                var matForm = new addMaterialForm();                                                                   //Creates New "matForm" Type
                this.Hide();                                                                                           //Hides Current Form
                matForm.Show();                                                                                        //Shows matForm Form
            }
            else if (comboValue == "Color")
            {
                XDocument doc  = XDocument.Load(Globals.xmlFilePath);                                             //Creates new Xdoc
                XElement  edit = doc.Root;                                                                        //New element equal to the root of the XML File
                edit.Element("addMaterialForm").Element("Color").Add(new XElement("ColorType", addTextBox.Text)); // Add a new <Type> Element with a value taken from a text box
                doc.Save(Globals.xmlFilePath);                                                                    //Save XML file
                var matForm = new addMaterialForm();                                                              //Creates New "matForm" Type
                this.Hide();                                                                                      //Hides Current Form
                matForm.Show();                                                                                   //Shows matForm Form
            }
            else if (comboValue == "Vendor")
            {
                XDocument doc  = XDocument.Load(Globals.xmlFilePath);                                               //Creates new Xdoc
                XElement  edit = doc.Root;                                                                          //New element equal to the root of the XML File
                edit.Element("addMaterialForm").Element("Vendor").Add(new XElement("VendorType", addTextBox.Text)); // Add a new <Type> Element with a value taken from a text box
                doc.Save(Globals.xmlFilePath);                                                                      //Save XML file
                var matForm = new addMaterialForm();                                                                //Creates New "matForm" Type
                this.Hide();                                                                                        //Hides Current Form
                matForm.Show();                                                                                     //Shows matForm Form
            }
            else
            {
                MessageBox.Show("Sorry something went wrong, please try again!");
            }
        }
Exemple #2
0
        private void addMaterialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            addMaterialForm f2 = new addMaterialForm(); //Creates new "Add Material Type" form

            f2.Show();                                  //Shows "Add Material Type" form
        }