Exemplo n.º 1
0
 private void loginClosing(object sender, FormClosingEventArgs e)
 {
     if (flag)
     {
         usrDB.updateDatabase();
         crsDB.updateDatabase();
     }
 }
Exemplo n.º 2
0
        private void loginClick(object sender, EventArgs e)
        {
            uname = username.Text.Trim().ToLower();
            utype = "student";
            string password = this.password.Text.Trim();

            if (usrDB.isValidUser(uname, password, ref utype))
            {
                Hide();
                if (utype == "admin" || utype == "manager")
                {
                    if (!flag)
                    {
                        var form = new admMainpage(usrDB, @"..\..\historyDB.in", utype);
                        form.ShowDialog();
                        usrDB = form.usrDB;
                        crsDB = form.crsDB;
                        usrDB.updateDatabase();
                    }
                    else
                    {
                        var form = new admMainpage(usrDB, crsDB, utype);
                        form.ShowDialog();
                        usrDB = form.usrDB;
                        crsDB = form.crsDB;
                    }
                }
                else
                {
                    if (utype == "faculty")
                    {
                        if (!flag)
                        {
                            var form = new facMainpage(uname, usrDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                        else
                        {
                            var form = new facMainpage(uname, usrDB, crsDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                    }
                    else
                    {
                        if (!flag)
                        {
                            var form = new stdMainpage(uname, usrDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                        else
                        {
                            var form = new stdMainpage(uname, usrDB, crsDB);
                            form.ShowDialog();
                            usrDB = form.usrDB;
                            crsDB = form.crsDB;
                        }
                    }
                }
                username.Text              = "Username";
                username.ForeColor         = Color.Silver;
                this.password.Text         = "Password";
                this.password.PasswordChar = '\0';
                this.password.ForeColor    = Color.Silver;

                flag = true;
                Show();
            }
            else
            {
                MessageBox.Show("Your username or password is incorrect.",
                                "Invalid Credential",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Question);
                this.password.Text         = "";
                this.password.PasswordChar = '*';
                this.password.ForeColor    = Color.White;
            }
        }