Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: ctricks/CMS
        private void tmrLoading_Tick(object sender, EventArgs e)
        {
            Thread.Sleep(500);

            if (progressBar1.Value == 10)
            {
                lblProcessStatus.Text = "Checking Database...";
                if (!cf.CheckDatabaseInfo(ci, ref ConnectionString, ref myConnection))
                {
                    lblProcessStatus.ForeColor = Color.Red;
                    lblProcessStatus.Text      = "Error: Please check your database connection settings.";
                    tmrLoading.Stop();
                    return;
                }
            }

            if (progressBar1.Value == 30)
            {
                lblProcessStatus.Text = "Checking License...";
                if (!cf.CheckLicense(ci.Read("LicenseCode", "Licensing")))
                {
                    lblProcessStatus.ForeColor = Color.Red;
                    lblProcessStatus.Text      = "Error: Please check your license settings.";
                    tmrLoading.Stop();
                    DialogResult drQuestion = MessageBox.Show("License is Invalid. Would you like update it today?", "Update License", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (drQuestion == System.Windows.Forms.DialogResult.Yes)
                    {
                        Unregistered uv = new Unregistered();
                        uv.ShowDialog();
                        if (uv.isMatch)
                        {
                            if (!string.IsNullOrEmpty(uv.MatchWord))
                            {
                                lblProcessStatus.ForeColor = Color.White;
                                lblProcessStatus.Text      = "License Valid...";
                                ci.Write("LicenseCode", uv.MatchWord, "Licensing");
                            }
                            else
                            {
                                MessageBox.Show("Application will close. Please check with your vendor \n(unregistered copy)", "Unable to use the Application.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                Environment.Exit(0);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Application will close. Please check with your vendor \n(unregistered copy)", "Unable to use the Application.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            Environment.Exit(0);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Application will close. Please check with your vendor (unregistered copy)", "Unable to use the Application.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }
                else
                {
                    lblProcessStatus.Text = "License is Valid...";
                }
            }

            if (progressBar1.Value >= 100)
            {
                tmrLoading.Stop();
                lblProcessStatus.Text = "System is ready to use...";
                progressBar1.Value    = 100;
                cbRole.DataSource     = cf.GetUserRole();
                cbRole.DisplayMember  = "RoleName";
                cbRole.ValueMember    = "sysID";
                LoginControls(true);
                tbUsername.Focus();
                return;
            }
            progressBar1.Value += 5;
            if (progressBar1.Value % 10 == 0)
            {
                counter++;
                if (counter > PicLogin.Count - 1)
                {
                    counter = 1;
                }
                LoadLoginImage(counter);
            }
        }