public void CheckBanQuyen() { RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\THCRM", true); if (key != null && key.GetValue("MaKichHoat") != null) { string Key = TMD5.Base64Decode(TMD5.Base64Decode(TMD5.Base64Decode(key.GetValue("MaKichHoat").ToString()))); string[] subs = Key.Split(new char[] { '@' }); DateTime ngayBQ = new DateTime(int.Parse(subs[2].Substring(4)), int.Parse(subs[2].Substring(2, 2)), int.Parse(subs[2].Substring(0, 2))); DateTime ngaySV = DateTime.Now; if (subs.Length != 4 || subs[0] != "ThanhHoangCRM" || subs[1] != "TTTTUNG") { XtraMessageBox.Show("Mã kích hoạt không hợp lệ"); new frmNhapMa().ShowDialog(this); } else if (ngaySV.Date.Subtract(ngayBQ.Date.AddYears(int.Parse(subs[3]))).Days > 0) { XtraMessageBox.Show("Mã kích hoạt hết hạn sử dụng"); new frmNhapMa().ShowDialog(this); } else { XuLyGiaoDien.OpenForm(this); if (key != null) { if (key.GetValue("cmra") != null && key.GetValue("cmrp") != null) { if (key.GetValue("cmra").ToString().Length > 0) { chk.Checked = true; txtUserName.Text = key.GetValue("cmra").ToString(); txtPassword.Text = key.GetValue("cmrp").ToString(); } } if (key.GetValue("TKNC") != null) { key.SetValue("TKNC", "true"); } } } } else { new frmNhapMa().ShowDialog(this); } if (key != null) { key.Close(); } }
void ActiveSoft() { if (btnActive.Text != "Tiếp tục") { try { string Key = TMD5.Base64Decode(TMD5.Base64Decode(TMD5.Base64Decode(txtKey.Text))); string[] subs = Key.Split(new char[] { '@' }); DateTime ngayBQ = new DateTime(int.Parse(subs[2].Substring(4)), int.Parse(subs[2].Substring(2, 2)), int.Parse(subs[2].Substring(0, 2))); DateTime ngaySV = DateTime.Now; if (subs.Length != 4 || subs[0] != "ThanhHoangCRM" || subs[1] != "TTTTUNG") { BaoLoi(false, "Mã kích hoạt không bợp lệ !!", Color.Crimson); return; } else if (ngaySV.Date.Subtract(ngayBQ.Date.AddYears(int.Parse(subs[3]))).Days > 0) { BaoLoi(false, "Key hết hạn", Color.Crimson); return; } else { RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\THCRM", true); if (key == null) { key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\THCRM"); } key.SetValue("MaKichHoat", txtKey.Text); key.Close(); BaoLoi(true, "Kích hoạt thành công", Color.Green); } } catch { BaoLoi(false, "Mã kích hoạt không bợp lệ !!", Color.Crimson); return; } } else { if (Owner is frmDangNhap) { (Owner as frmDangNhap).CheckBanQuyen(); } this.Close(); } }