using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;
namespace Stone.Class
{
   
    class InforManagment
    {
        public string XmlDataFileName = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\ParsZSDB" + "\\Information.xml";
        public string XmlSchemaFileName = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\ParsZSDB" + "\\Information.xsd";

       public DataTable Information = new DataTable("Information");

       public InforManagment()
       {
           #region Create_Information

           DataColumn Name = new DataColumn("Name", System.Type.GetType("System.String"));
           DataColumn Mobile = new DataColumn("Mobile", System.Type.GetType("System.String"));
           DataColumn Tel = new DataColumn("Tel", System.Type.GetType("System.String"));
           DataColumn Address = new DataColumn("Address", System.Type.GetType("System.String"));
           Information.Columns.Add(Name);
           Information.Columns.Add(Mobile); 
           Information.Columns.Add(Tel);
           Information.Columns.Add(Address);

           #endregion

           #region Create_XMLfile

           if (!File.Exists(XmlDataFileName) || !File.Exists(XmlSchemaFileName))
           {
               Make_DTInformation();
               Information.ReadXmlSchema(XmlSchemaFileName);
               Information.ReadXml(XmlDataFileName);
           }

           else
           {
               Information.ReadXmlSchema(XmlSchemaFileName);
               Information.ReadXml(XmlDataFileName);
           }
           #endregion
       }

       private void Make_DTInformation()
       {

           if (!File.Exists(XmlDataFileName))
           {
               Information.WriteXml(XmlDataFileName);
           }
           if (!File.Exists(XmlSchemaFileName))
           {
               Information.WriteXml(XmlSchemaFileName);
           }

           Information.WriteXmlSchema(XmlSchemaFileName);

       }
    }
}
