Beispiel #1
0
        /// <summary>
        /// Return back to the previous form and close current form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_back_Click(object sender, EventArgs e)
        {
            this.Hide();
            var Sscreen = new Student_Screen(current_user);

            Sscreen.Closed += (s, args) => this.Close();
            Sscreen.Show();
        }
        //Login Student
        private bool Log_In_Student()
        {
            //Check if textboxes are empty
            if (string.IsNullOrEmpty(TB_Username.Text) || string.IsNullOrEmpty(TB_Password.Text))
            {
                MessageBox.Show("The username or password was not filled");
            }

            //If textboxes arent empty
            else
            {
                //New instance of DB Class
                DBRepository DB       = DBRepository.GetInstance();
                var          LoggedIn = DB.FindLoginData(TB_Username.Text, TB_Password.Text, "Student");

                //If logged in = true
                if (LoggedIn == true)
                {
                    //Close current form
                    this.Hide();

                    //Make instance of new form
                    var Student_Screen = new Student_Screen(TB_Username.Text);
                    Student_Screen.Closed += (s, args) => this.Close();

                    //Open new form
                    Student_Screen.Show();

                    //Return true (that means log in was succesful)
                    return(true);
                }
            }

            //If log-in was unsuccessful return false
            return(false);
        }