Пример #1
0
        private void Bwreg_DoWork(object sender, DoWorkEventArgs e)
        {
            DbEntityRefresh.Refresh(db);

            LicenseEntity licdb = new LicenseEntity();

            try
            {
                var a = licdb.Licenses.Where(c => c.SoftwareID == txtpublickey.Text).FirstOrDefault();
                if (a != null)
                {
                    var  uid        = db.Randoms.Where(c => c.ID == 18).FirstOrDefault();
                    bool IsPayement = a.IsPayment;
                    if (IsPayement)
                    {
                        if (txtlicense.Text == a.LicenseKey)
                        {
                            var path = Application.StartupPath + @"\bin\";

                            string filename = "License.lic";

                            string[] lines = File.ReadAllLines(path + filename);

                            string ency = a.LicenseStarts + "," + a.LicenseEnds + "," + uid.Text + "," + a.OwnerName + "," + a.SchoolName + "," + "False";

                            lines[7] = "Licensed Hash:" + ClsTripleDES.Encrypt(ency);

                            File.WriteAllLines(path + "/" + filename, lines);

                            a.InProcess = false;

                            licdb.Entry(a).State = System.Data.Entity.EntityState.Modified;
                            licdb.SaveChanges();

                            validate = true;
                        }
                        MessageBox.Show("Student Management System is successfully activated until " + a.LicenseEnds, "Successfully Activated", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }

                    else
                    {
                        validate = false;
                    }
                }
                else
                {
                    MessageBox.Show("Your request doesnot exist at our License server! Please send request then register!", "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured: " + ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                licdb.Dispose();
            }
        }
Пример #2
0
        private void SoftwareIDCheck(string id)
        {
            LicenseEntity licdb = new LicenseEntity();

            try
            {
                var uid = licdb.Licenses.Where(c => c.SoftwareID == id).FirstOrDefault();
                if (uid != null)
                {
                    licdb.Entry(uid).State = System.Data.Entity.EntityState.Deleted;
                    licdb.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured: " + ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                licdb.Dispose();
            }
        }