WinForm:如何从一个WinForm去获得一个值通过DialogResult
来源:互联网 发布:bestbuy 知乎 编辑:程序博客网 时间:2024/05/16 11:32
这是调查的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(); } }
- WinForm:如何从一个WinForm去获得一个值通过DialogResult
- WinForm 通过线程互斥仅启动一个实例
- 在winForm窗体上加上DialogResult作为返回值
- 在winForm窗体上加上DialogResult作为返回值
- C# WinForm中如何打开一个超链接
- C# WinForm中如何打开一个超链接
- C# winform一个窗口去触发另一个窗口的方法
- 收藏一个winform例子
- 一个WinForm记事本程序
- 一个WinForm记事本程序
- Winform中怎样在一个窗体中获得另一个窗体中的控件的值?
- 【winform】使用winform开发一个登录界面
- [原创]一个通过BackgroundWorker实现WinForm异步操作的例子
- 一个通过BackgroundWorker实现WinForm异步操作的例子
- WinForm窗体传值的一个方法
- Winform开发--数据从一个DataGridView转移到另一个DataGridView
- Winform编程总结1—从网上找到一个winform控件,实现打开word的功能
- <WinForm系列> 1 . 我们如何创建一个WinForm的界面程序?
- 积分图像
- 最短路-1010
- NFS系统read调用过程(六)
- iOS多线程总结
- 坚持学css(2013-01-22)
- WinForm:如何从一个WinForm去获得一个值通过DialogResult
- 数据文件及其管理
- centos6 安装 wink录像软件
- Ubuntu装Win7双系统
- [MFC] 动态按钮释放 [大三TJB_708]
- 最短路-1011
- 杭电OJ——2046 骨牌铺方格(简单的推断题)
- 我的网络编程路
- android andengine游戏引擎中图片资源的加密