Exemple #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            ServiceReference3.WebService1SoapClient soap = new ServiceReference3.WebService1SoapClient();
            //string xml = dataSet.GetXml();

            try
            {
                XDocument Xdoc = new XDocument(new XElement("Users"));
                if (System.IO.File.Exists("D:\\LessonManagerApp.xml"))
                {
                    Xdoc = XDocument.Load("D:\\LessonManagerApp.xml");
                }
                else
                {
                    Xdoc = new XDocument();
                    XElement xmlstart = new XElement("Users");
                    Xdoc.Add(xmlstart);
                }
                XElement xml1 = /*new XElement("Users",*/
                                new XElement("User",
                                             new XElement("StartTime", textBox1.Text),
                                             new XElement("Duration", customControl11.Text),
                                             new XElement("Notes", textBox3.Text),
                                             new XElement("Instructor_ID", comboBox1.Text));

                if (Xdoc.Descendants().Count() > 0)
                {
                    Xdoc.Descendants().First().Add(xml1);
                }
                else
                {
                    Xdoc.Add(xml1);
                }

                Xdoc.Element("Users").Save("D:\\LessonManagerApp.xml");
                soap.UploadNotes("xml1");
                MessageBox.Show("Uploaded Successfully");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }