Exemplo n.º 1
0
 void ModifyXml(UserData ud)
 {
     XmlDocument doc = new XmlDocument();
     doc.Load(XMLFILENAME);
     XmlNode root = doc.DocumentElement[ud.ElementName];
     List<NameValuePair> udList = ud.ValueList;
     if (udList != null)
     {
         for (int i = 0; i <= udList.Count - 1; i++)
             root.SelectSingleNode(udList[i].Name).InnerText = udList[i].Value;
     }
     doc.Save(XMLFILENAME);
 }
Exemplo n.º 2
0
        private void DbSetting_Click(object sender, EventArgs e)
        {
            DbSettingForm form = new DbSettingForm();
            DialogResult dr = form.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                UserData ud = new UserData();
                ud.ElementName = "SqlServer";
                List<NameValuePair> list = new List<NameValuePair>();
                NameValuePair np = new NameValuePair();
                np.Name = "Server";
                np.Value = RC4.Encrypt("1", form.getIP());
                list.Add(np);

                np = new NameValuePair();
                np.Name = "User";
                np.Value = RC4.Encrypt("1", form.getUser());
                list.Add(np);

                np = new NameValuePair();
                np.Name = "Password";
                np.Value = RC4.Encrypt("1", form.getPassword());
                list.Add(np);

                np = new NameValuePair();
                np.Name = "DataBase";
                np.Value = RC4.Encrypt("1", form.getDatabasename());
                list.Add(np);

                ud.ValueList = list;
                ModifyXml(ud);
                InitDatabaseSetting();
            }
        }