这是调查的codes:
ActivateForm activationForm = new ActivateForm(); DialogResult result = activationForm.ShowDialog(); if (result != DialogResult.OK) { return; }
下面是ActivateForm codes:
public partial class ActivateForm : Form { ComputerIdGenerator generator = new ComputerIdGenerator(); string postern = "请与软件提供商联系"; public ActivateForm() { try { InitializeComponent(); } catch (Exception ex) { AirMonitorSysEventLog.WriteLog(ex.Message, System.Diagnostics.EventLogEntryType.Error, AirMonitorSysEventLog.GeneralErrorEventId); } } private void btnSave_Click(object sender, EventArgs e) { try { string str = this.richTextBox1.Text.Trim(); if (string.IsNullOrEmpty(str)) { MessageBox.Show(this, "证书码不能为空,请与软件提供商联系", "激活失败", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string certId = generator.GetComputerId(); if (string.IsNullOrEmpty(certId)) { if (string.Compare(str, postern, false) == 0) { AirMonitorSys.Model.KeyValueInfoData computerIdData = new AirMonitorSys.Model.KeyValueInfoData(); computerIdData.Name = AirMonitorSysEventLog.ComputerIdKey; computerIdData.KeyValue = str; var data = BLL.KeyValueInfoBll.GetDataByID(AirMonitorSysEventLog.ComputerIdKey); if (data == null) { BLL.KeyValueInfoBll.Add(computerIdData); } else { BLL.KeyValueInfoBll.Update(computerIdData); } this.DialogResult = DialogResult.OK; } else { MessageBox.Show(this, "激活失败, 电脑验证码不正确! 请与软件提供商联系", "激活失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (string.Compare(str, certId, false) == 0) { AirMonitorSys.Model.KeyValueInfoData computerIdData = new AirMonitorSys.Model.KeyValueInfoData(); computerIdData.Name = AirMonitorSysEventLog.ComputerIdKey; computerIdData.KeyValue = str; var data = BLL.KeyValueInfoBll.GetDataByID(AirMonitorSysEventLog.ComputerIdKey); if (data == null) { BLL.KeyValueInfoBll.Add(computerIdData); } else { BLL.KeyValueInfoBll.Update(computerIdData); } this.DialogResult = DialogResult.OK; } else { MessageBox.Show(this, "激活失败, 电脑验证码不正确!", "激活失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { AirMonitorSysEventLog.WriteLog("激活失败-" + ex.Message, System.Diagnostics.EventLogEntryType.Error, AirMonitorSysEventLog.GeneralErrorEventId); } } private void btnCancel_Click(object sender, EventArgs e) { this.Dispose(); } }