Пример #1
0
        private void btn_Active_Click(object sender, EventArgs e)
        {
            string license = CreateLicense().Trim();
            string getKey  = txt_key.Text.Trim();

            if (license == getKey)
            {
                Active();
                ProductKeyDB context = new ProductKeyDB();
                MaSP         mSP     = new MaSP()
                {
                    MaKichHoat = getKey,
                };
                MaSP mSPQ = context.MaSP.FirstOrDefault(p => p.MaKichHoat == getKey);
                if (mSPQ == null)
                {
                    context.MaSP.Add(mSP);
                    context.SaveChanges();
                }
            }
            else
            {
                MessageBox.Show("Mã kích hoạt không hợp lệ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void ProductKey_Load(object sender, EventArgs e)
        {
            ProductKeyDB context   = new ProductKeyDB();
            List <MaSP>  ls        = context.MaSP.ToList();
            string       license   = CreateLicense();
            bool         trangthai = false;

            foreach (var item in ls)
            {
                if (license.Trim() == item.MaKichHoat.Trim())
                {
                    trangthai = true;
                    break;
                }
            }
            if (trangthai)
            {
                Active();
            }
            else
            {
                MessageBox.Show("Vui lòng kích hoạt phần mềm", "Kích hoạt", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }