Esempio n. 1
0
 private void save_button_Click(object sender, EventArgs e)
 {
     if (user_box.Text != null || pass_box.Text != null)
     {
         // Open App.Config of executable
         System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
         // Add an Application Setting.
         config.AppSettings.Settings.Remove("user");
         config.AppSettings.Settings.Add("user", user_box.Text);
         config.AppSettings.Settings.Remove("pass");
         config.AppSettings.Settings.Add("pass", pass_box.Text);
         config.AppSettings.Settings.Remove("code");
         config.AppSettings.Settings.Add("code", code_box.Text);
         // Save the configuration file.
         config.Save(ConfigurationSaveMode.Modified);
         ConfigurationManager.RefreshSection("appSettings");
         if (login != user_box.Text || pass != pass_box.Text)
         {
             mf.login(user_box.Text, pass_box.Text, code_box.Text);
         }
         this.Close();
     }
     else
     {
         MessageBox.Show("Put all data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }