예제 #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 Restore()
        {
            System.Threading.Thread.Sleep(5000);


            DbEntities newdb = new DbEntities();

            DbEntityRefresh.Refresh(newdb);
            try
            {
                sourcepath = txtfilename.Text;
                File.Move(sourcepath, Path.ChangeExtension(sourcepath, ".db"));

                if (File.Exists(destpath + "/Database.db"))
                {
                    File.Delete(destpath + "/Database.db");
                }

                File.Copy(Path.GetDirectoryName(sourcepath) + "/Database.db", destpath + "/Database.db");

                File.Move(Path.GetDirectoryName(sourcepath) + "/Database.db", Path.ChangeExtension(Path.GetDirectoryName(sourcepath) + "/Database.db", ".backupsms"));

                var schoolname    = newdb.Randoms.Where(c => c.ID == 1).FirstOrDefault();
                var schooladdress = newdb.Randoms.Where(c => c.ID == 2).FirstOrDefault();
                var schoolcontact = newdb.Randoms.Where(c => c.ID == 3).FirstOrDefault();
                var schoolemail   = newdb.Randoms.Where(c => c.ID == 4).FirstOrDefault();
                var ownername     = newdb.Randoms.Where(c => c.ID == 5).FirstOrDefault();
                var softid        = newdb.Randoms.Where(c => c.ID == 18).FirstOrDefault();

                string fileName = Application.StartupPath + @"\bin\License.lic";


                // Check if file already exists. If yes, delete it.
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                // Create a new file
                using (StreamWriter sw = File.CreateText(fileName))
                {
                    sw.WriteLine("Owner Name:" + ownername.Text);
                    sw.WriteLine("School Name:" + schoolname.Text);
                    sw.WriteLine("School Address:" + schooladdress.Text);
                    sw.WriteLine("School Contact:" + schoolcontact.Text);
                    sw.WriteLine("School Email:" + schoolemail.Text);
                    sw.WriteLine("Installation Date:" + DateTime.Now.ToString("dd/MM/yyyy"));
                    sw.WriteLine("IsActivated:" + ClsTripleDES.Encrypt("False"));
                    string ency = DateTime.Now.ToString("dd/MM/yyyy") + "," + DateTime.Now.AddDays(5).ToString("dd/MM/yyyy") + "," + softid.Text + "," + ownername.Text + "," + schoolname.Text + "," + "True";
                    sw.WriteLine("Licensed Hash:" + ClsTripleDES.Encrypt(ency));
                }

                string[] lines = File.ReadAllLines(Application.StartupPath + @"\bin\User.Config");
                lines[0] = "Owner Name:" + txtowner.Text;
                lines[1] = "School Name:" + txtschoolname.Text;
                lines[2] = "FirstRun:" + "False";
                lines[3] = "DefaultPrinter:null";

                File.WriteAllLines(Application.StartupPath + @"\bin\User.Config", lines);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error - Student Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                newdb.Dispose();
            }
        }
예제 #3
0
        private void SavingInformation()
        {
            try
            {
                Random ran1 = new Random()
                {
                    ID   = 1,
                    Key  = "School Name",
                    Text = txtschoolname.Text
                };

                Random ran2 = new Random()
                {
                    ID   = 2,
                    Key  = "Address",
                    Text = txtschooladdress.Text
                };

                Random ran3 = new Random()
                {
                    ID   = 3,
                    Key  = "Contact",
                    Text = txtschoolcontact.Text
                };

                Random ran4 = new Random()
                {
                    ID   = 4,
                    Key  = "Email",
                    Text = txtschoolEmail.Text
                };
                Random ran5 = new Random()
                {
                    ID   = 5,
                    Key  = "Owner Name",
                    Text = txtowner.Text
                };

                Random ran6 = new Random()
                {
                    ID   = 6,
                    Key  = "Classes",
                    Text = Classess().ToString()
                };

                Random ran7 = new Random()
                {
                    ID   = 7,
                    Key  = "Sections",
                    Text = Sections().ToString()
                };

                Random ran8 = new Random()
                {
                    ID   = 8,
                    Key  = "Classes Fee",
                    Text = ClassesFee().ToString()
                };

                Random ran9 = new Random()
                {
                    ID   = 9,
                    Key  = "Others Fee Label",
                    Text = txtothersfeelabel.Text
                };

                Random ran10 = new Random()
                {
                    ID   = 10,
                    Key  = "Others Fee",
                    Text = txtothersfee.Text
                };

                Random ran11 = new Random()
                {
                    ID   = 11,
                    Key  = "Late Fee",
                    Text = txtlatefee.Text
                };

                Random ran12 = new Random()
                {
                    ID   = 12,
                    Key  = "Voucher Charges",
                    Text = txtvouchcharges.Text
                };

                Random ran13 = new Random()
                {
                    ID   = 13,
                    Key  = "Due Date",
                    Text = txtduedate.Text
                };

                Random ran14 = new Random()
                {
                    ID   = 14,
                    Key  = "Total Fee Per Month",
                    Text = "0,0,0,0,0,0,0,0,0,0,0,0"
                };

                Random ran15 = new Random()
                {
                    ID   = 15,
                    Key  = "Every Submission",
                    Text = "0;0;0;0;0;0;0;0;0;0;0;0"
                };

                Random ran16 = new Random()
                {
                    ID   = 16,
                    Key  = "Submission Date",
                    Text = "0;0;0;0;0;0;0;0;0;0;0;0"
                };

                Random ran17 = new Random()
                {
                    ID   = 17,
                    Key  = "Submission Name",
                    Text = "0;0;0;0;0;0;0;0;0;0;0;0"
                };


                var guid = Guid.NewGuid();



                Random ran18 = new Random()
                {
                    ID   = 18,
                    Key  = "Unique ID",
                    Text = guid.ToString().Substring(0, 18).ToString()
                };


                UserLogin user = new UserLogin()
                {
                    UserName = txtuser.Text,
                    Password = txtpass.Text
                };


                db.Randoms.Add(ran1);
                db.Randoms.Add(ran2);
                db.Randoms.Add(ran3);
                db.Randoms.Add(ran4);
                db.Randoms.Add(ran5);
                db.Randoms.Add(ran6);
                db.Randoms.Add(ran7);
                db.Randoms.Add(ran8);
                db.Randoms.Add(ran9);
                db.Randoms.Add(ran10);
                db.Randoms.Add(ran11);
                db.Randoms.Add(ran12);
                db.Randoms.Add(ran13);
                db.Randoms.Add(ran14);
                db.Randoms.Add(ran15);
                db.Randoms.Add(ran16);
                db.Randoms.Add(ran17);
                db.Randoms.Add(ran18);

                db.UserLogins.Add(user);

                db.SaveChanges();

                string fileName = Application.StartupPath + @"\bin\License.lic";


                // Check if file already exists. If yes, delete it.
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                // Create a new file
                using (StreamWriter sw = File.CreateText(fileName))
                {
                    sw.WriteLine("Owner Name:" + txtowner.Text);
                    sw.WriteLine("School Name:" + txtschoolname.Text);
                    sw.WriteLine("School Address:" + txtschooladdress.Text);
                    sw.WriteLine("School Contact:" + txtschoolcontact.Text);
                    sw.WriteLine("School Email:" + txtschoolEmail.Text);
                    sw.WriteLine("Installation Date:" + DateTime.Now.ToString("dd/MM/yyyy"));
                    sw.WriteLine("IsActivated:" + ClsTripleDES.Encrypt("False"));
                    string ency = DateTime.Now.ToString("dd/MM/yyyy") + "," + DateTime.Now.AddDays(5).ToString("dd/MM/yyyy") + "," + guid.ToString().Substring(0, 18).ToString() + "," + txtowner.Text + "," + txtschoolname.Text + "," + "True";
                    sw.WriteLine("Licensed Hash:" + ClsTripleDES.Encrypt(ency));
                }

                string[] lines = File.ReadAllLines(Application.StartupPath + @"\bin\User.Config");
                lines[0] = "Owner Name:" + txtowner.Text;
                lines[1] = "School Name:" + txtschoolname.Text;
                lines[2] = "FirstRun:" + "False";
                lines[3] = "DefaultPrinter:null";

                File.WriteAllLines(Application.StartupPath + @"\bin\User.Config", lines);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString() + " " + ex.InnerException.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     textBox1.Text = ClsTripleDES.Encrypt(textBox2.Text);
 }