예제 #1
0
        private void btnRegister_Click(object sender, System.EventArgs e)
        {
            string sysKey  = fp.GenKey(txtClientId.Text.Trim());
            string userKey = helper.RemoveWhitespace(txtKey.Text.Trim());

            if (string.Equals(userKey, ""))
            {
                MessageBox.Show("Bạn chưa nhập mã bản quyền. Vui lòng nhập mã bản quyền.", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (userKey.Length != KEY_LENGTH)
            {
                MessageBox.Show("Mã bản quyền không hợp lệ! Kiểm tra lại mã bản quyền của bạn", "Thông báo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                if (string.Equals(sysKey, userKey))
                {
                    MessageBox.Show("Kích hoạt bản quyền thành công! Vui lòng khởi động lại phần mềm", "Thông báo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Properties.Settings.Default.softwareLicense = sysKey;
                    Properties.Settings.Default.Save();
                    Application.Exit();
                }
                else
                {
                    MessageBox.Show("Kích hoạt bản quyền thất bại! Mã bản quyền không chính xác.", "Thông báo",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #2
0
        static void Main()
        {
            const string appName = "QLKB";
            bool         createdNew;

            mutex = new Mutex(true, appName, out createdNew);
            if (!createdNew)
            {
                string message = "Chương trình <" + appName + "> đang chạy ! Vui lòng thoát chương trình đang chạy trước đó.";
                MessageBox.Show(message);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Helper helper = new Helper();

            Splasher.Show(typeof(SplashScreenFrm));
            Splasher.Status = "Đang khởi tạo camera ...";
            initCamera();

            FingerPrint print = new FingerPrint();

            Splasher.Status = "Đang khởi tạo dữ liệu...";
            //Check key license
            string inputString     = print.GenKey(print.cpuId() + print.baseId());
            string keyGen          = print.GenKey(helper.RemoveWhitespace(inputString));
            string softwareLicense = Settings.Default.softwareLicense;

            Session.Instance.ActiveLicense = string.Equals(keyGen, softwareLicense);
            Settings.Default.ClientId      = inputString;
            Settings.Default.Save();

            //check database connection
            if (!DBConnection.Instance.OpenConnection())
            {
                Splasher.Close();
                Application.Run(new ConfigDB());
            }
            else
            {
                int dbVersion = helper.getDbVersion();
                if (dbVersion < DB_VERSION)
                {
                    ConfigDB configDb = new ConfigDB();
                    configDb.upgradeDB(DB_VERSION);
                }
                Application.Run(new Login());
            }
        }