Esempio n. 1
0
        //logout user
        //public void Logout()
        //{
        //    isLoggedIn = false;
        //    if(ActiveMdiChild != null)
        //    {
        //        ActiveMdiChild.Close();
        //    }
        //}


        private void btnViewComments_Click(object sender, EventArgs e)
        {
            if (isLoggedIn)
            {
                if (Application.OpenForms["viewCommentsForm"] == null)
                {
                    viewCommentsForm view = new viewCommentsForm();
                    view.MdiParent = this;
                    view.Show();
                }
                else
                {
                    Application.OpenForms["viewCommentsForm"].Focus();
                }
            }
            else
            {
                showLoginForm();
            }
        }
Esempio n. 2
0
        private void btnlogin_Click(object sender, EventArgs e)
        {
            var regnumber = txtregnumber.Text;
            var password  = txtpassword.Text;

            // declare object of DB model
            var contx = new zosoEntities();

            //check if true value was returned fron the user check and grant access
            //If false, then continue to restrict access
            var user = contx.users.SingleOrDefault(q => q.regNumber == regnumber && q.password == password);

            if (user != null)
            {
                var parent = (safejaMain)MdiParent;
                parent.isLoggedIn = true;
                this.Close();

                if (Application.OpenForms["viewCommentsForm"] == null)
                {
                    viewCommentsForm view = new viewCommentsForm();
                    view.Show();
                }
                else
                {
                    Application.OpenForms["viewCommentsForm"].Focus();
                }
            }
            else
            {
                MessageBox.Show("Invalid Credentials. Please try again.");
                txtregnumber.Text = "";
                txtpassword.Text  = "";
                txtregnumber.Focus();
            }
        }