private void butOK_Click(object sender, System.EventArgs e) { if (textKey1.Text != "" && !Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$") && !Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{16}$")) { MsgBox.Show(this, "Invalid registration key format."); return; } string regkey = ""; if (Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$")) { regkey = textKey1.Text.Substring(0, 4) + textKey1.Text.Substring(5, 4) + textKey1.Text.Substring(10, 4) + textKey1.Text.Substring(15, 4); } else if (Regex.IsMatch(textKey1.Text, @"^[A-Z0-9]{16}$")) { regkey = textKey1.Text; } if (!ValidateKey(regkey)) //a blank registration key will only be valid if the CDT.dll is foreign { MsgBox.Show(this, "Invalid registration key."); return; } Prefs.UpdateString(PrefName.RegistrationKey, regkey); FormOpenDental.RegKeyIsForTesting = PrefL.IsRegKeyForTesting(); //prefs refresh automatically in the calling class anyway. DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { if (textRegKey.Text != "" && !Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$") && !Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{16}$")) { MsgBox.Show(this, "Invalid registration key format."); return; } if (textMultiple.Text.Contains(" ")) { MsgBox.Show(this, "No spaces allowed in the database list."); return; } string regkey = ""; if (Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}$")) { regkey = textRegKey.Text.Substring(0, 4) + textRegKey.Text.Substring(5, 4) + textRegKey.Text.Substring(10, 4) + textRegKey.Text.Substring(15, 4); } else if (Regex.IsMatch(textRegKey.Text, @"^[A-Z0-9]{16}$")) { regkey = textRegKey.Text; } bool refreshCache = false; if (Prefs.UpdateString(PrefName.UpdateServerAddress, textUpdateServerAddress.Text) | Prefs.UpdateBool(PrefName.UpdateShowMsiButtons, checkShowMsi.Checked) | Prefs.UpdateString(PrefName.UpdateWebsitePath, textWebsitePath.Text) | Prefs.UpdateString(PrefName.UpdateWebProxyAddress, textWebProxyAddress.Text) | Prefs.UpdateString(PrefName.UpdateWebProxyUserName, textWebProxyUserName.Text) | Prefs.UpdateString(PrefName.UpdateWebProxyPassword, textWebProxyPassword.Text) | Prefs.UpdateString(PrefName.UpdateMultipleDatabases, textMultiple.Text) | Prefs.UpdateDateT(PrefName.UpdateDateTime, _updateTime)) { refreshCache = true; } if (Prefs.UpdateString(PrefName.RegistrationKey, regkey)) { FormOpenDental.RegKeyIsForTesting = PrefL.IsRegKeyForTesting(); refreshCache = true; } if (refreshCache) { Cursor = Cursors.WaitCursor; DataValid.SetInvalid(InvalidType.Prefs); Cursor = Cursors.Default; } DialogResult = DialogResult.OK; }