Exemple #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();
            }
        }
Exemple #2
0
        private void Bwreq_DoWork(object sender, DoWorkEventArgs e)
        {
            LicenseEntity licdb = new LicenseEntity();

            try
            {
                DbEntityRefresh.Refresh(db);

                if (RequestExists())
                {
                    req = false;
                    MessageBox.Show("Please be patience! Your request is under proces!", "Error - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    SoftwareIDCheck(txtpublickey.Text);
                    var     schoolname = db.Randoms.Where(c => c.ID == 1).FirstOrDefault();
                    var     Address    = db.Randoms.Where(c => c.ID == 2).FirstOrDefault();
                    var     Contact    = db.Randoms.Where(c => c.ID == 3).FirstOrDefault();
                    var     Email      = db.Randoms.Where(c => c.ID == 4).FirstOrDefault();
                    var     OwnerName  = db.Randoms.Where(c => c.ID == 5).FirstOrDefault();
                    var     softid     = db.Randoms.Where(c => c.ID == 18).FirstOrDefault();
                    License lic        = new License()
                    {
                        SoftwareID      = softid.Text.ToString().Substring(0, 18),
                        SchoolName      = schoolname.Text,
                        SchoolAddress   = Address.Text,
                        SchoolContact   = Contact.Text,
                        SchoolEmail     = Email.Text,
                        OwnerName       = OwnerName.Text,
                        IstallationDate = InstallationDate().ToString(),
                        InProcess       = true,
                        IsPayment       = false,
                        LicenseKey      = LicenseKey(),
                        LicenseStarts   = LicenseStarts(),
                        LicenseEnds     = LicenseEnds()
                    };

                    licdb.Licenses.Add(lic);
                    licdb.SaveChanges();
                    req = true;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message.ToString(), "Error - Student Management Sytem", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            finally
            {
                licdb.Dispose();
            }
        }
Exemple #3
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();
            }
        }