Click here to Skip to main content
15,896,464 members
Articles / Programming Languages / XML

An Introduction to LINQ to XML

Rate me:
Please Sign up or sign in to vote.
4.29/5 (4 votes)
14 Sep 2009CPOL1 min read 34.6K   522   30  
An article on LINQ to XML
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ServerInfoStorageTool
{
    public partial class ServerInfoDialog : Form
    {
        public ServerInfoDialog()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ServerInfoDialog_Load(object sender, EventArgs e)
        {
            List<string> serversList = ServerInfoService.GetAllServers();
            serversList.Add("New...");
            cbxServers.DataSource = serversList;
            this.PopulateServerInformation();
        }

        private void PopulateServerInformation()
        {
            ServerInfoService service = new ServerInfoService();
            service.SetServerInformation(cbxServers.SelectedItem.ToString());
            txtServer.Text = service.Address;
            txtUID.Text = service.UserId;
            txtPwd.Text = service.Password;
            txtSmartRmsDB.Text = service.DB1;
            txtMetabaseDB.Text = service.DB2;
            txtName.Text = service.DisplayName;
        }

        private void cbxServers_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.PopulateServerInformation();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            ServerInfoService service = new ServerInfoService();
            if ( !string.IsNullOrEmpty( txtServer.Text ) && !string.IsNullOrEmpty( txtUID.Text ) &&
                !string.IsNullOrEmpty( txtPwd.Text ) && !string.IsNullOrEmpty( txtSmartRmsDB.Text ) &&
                !string.IsNullOrEmpty( txtMetabaseDB.Text ) && !string.IsNullOrEmpty( txtName.Text ) )
            {
                service.Address = txtServer.Text;
                service.UserId = txtUID.Text;
                service.Password = txtPwd.Text;
                service.DB1 = txtSmartRmsDB.Text;
                service.DB2 = txtMetabaseDB.Text;
                service.DisplayName = txtName.Text;
                service.SaveConfig();
            }
        }

        public static void ShowErrorMessage( string message )
        {
            MessageBox.Show( message, "Server Info Storage Tool", MessageBoxButtons.OK, MessageBoxIcon.Error );
        }

        public static void ShowInformation( string message )
        {
            MessageBox.Show(message, "Server Info Storage Tool", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead Wipro Technologies
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions