/// <summary> /// 事件触发函数 /// </summary> /// <param name="e"></param> public void OnMyRefreshOwnerRegisterEvent(MyRefeshRegisterEventArgs e) { if (MyRefreshOwnerRegisterEvent != null) { MyRefreshOwnerRegisterEvent(this, e); } }
/// <summary> /// 事件处理函数:刷新注册码控件文本字符串 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void RefreshRegisterCode(object sender, EventArgs e) { MyRefeshRegisterEventArgs myRefeshRegisterEventArgs = e as MyRefeshRegisterEventArgs; if (myRefeshRegisterEventArgs.Res == 0 && myRefeshRegisterEventArgs.RegisterCode.Trim().Length > 0) { this.txt_registerNum.Text = myRefeshRegisterEventArgs.RegisterCode; this.txt_registerNum.Enabled = false; } else { if (myRefeshRegisterEventArgs.Res == 1) { this.lbl_LoginResult.Text = "软件尚未注册!"; this.txt_registerNum.Enabled = false; } else if (myRefeshRegisterEventArgs.Res == 2) { this.lbl_LoginResult.Text = "注册机器与本机不一致!"; this.txt_registerNum.Enabled = false; } else if (myRefeshRegisterEventArgs.Res == 3) { this.lbl_LoginResult.Text = "软件注册已到期!"; this.txt_registerNum.Enabled = false; } else if (myRefeshRegisterEventArgs.Res == 3) { this.lbl_LoginResult.Text = "激活码与注册码不匹配!"; this.txt_registerNum.Enabled = false; } else { this.lbl_LoginResult.Text = "注册码已失效!"; this.txt_registerNum.Enabled = false; } } }
/// <summary> /// 获取注册码 /// </summary> public void GetRegisterCode() { string path = "Software\\IDCardRegisterCode"; int res = RegeditTime.InitRegedit(ref sericalNumber, ref cdKey, path, "registerCode"); MyRefeshRegisterEventArgs myRefeshRegisterEventArgs = new MyRefeshRegisterEventArgs(); myRefeshRegisterEventArgs.RegisterCode = sericalNumber; myRefeshRegisterEventArgs.Res = res; MyRefreshOwnerRegisterEvent += this.userLogin1.RefreshRegisterCode; //校验通过 if (res == 0) { OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs); } else if (res == 1)//软件尚未注册 { RegisterFrm registerFrm = new RegisterFrm(); registerFrm.Owner = this; registerFrm.ShowDialog(); } else if (res == 2)//注册机器与本机不一致 { OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs); } else if (res == 3)//软件试用已到期 { OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs); } else if (res == 4)//激活码与注册码不匹配 { OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs); } else//软件运行已到期 { OnMyRefreshOwnerRegisterEvent(myRefeshRegisterEventArgs); } }