Esempio n. 1
0
        private void btnProjects_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormProjectsAdmin forma = new FormProjectsAdmin(user1);

            forma.ShowDialog();
            this.Show();
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (usersLogic.reaturnAllUsers().Count == 0)
            {
                bool init = true;
                new FormCreateUser(init).ShowDialog();
                this.Hide();
            }
            string username = txtUsername.Text;
            string password = txtPassword.Text;
            User   user     = usersLogic.Login(username, password);


            if (user != null)
            {
                if (user.Role == 0)
                {
                    this.Hide();
                    FormAdmin forma = new FormAdmin(user);
                    forma.Text = "Welcome " + user.Name + " " + user.Surname;
                    forma.ShowDialog();
                    this.Show();
                    this.Refresh();
                }
                if (user.Role == 1)
                {
                    this.Hide();
                    FormProjectsAdmin forma = new FormProjectsAdmin(user);
                    forma.Text = "Welcome " + user.Name + " " + user.Surname;
                    forma.ShowDialog();
                    this.Show();
                    this.Refresh();
                }
                if (user.Role == 2)
                {
                    this.Hide();
                    FormDeveloperTasks forma = new FormDeveloperTasks(user);
                    forma.Text = "Welcome " + user.Name + " " + user.Surname;
                    forma.ShowDialog();
                    this.Show();
                    this.Refresh();
                }
            }
            else
            {
                MessageBox.Show("Wrong username or password");
                return;
            }
            //var studentName = context.Users.SqlQuery(@"select * from Users where Username='******' AND Password='******'").FirstOrDefault<User>();
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;
            User   user     = usersLogic.Login(username, password);


            if (user != null)
            {
                if (user.Role == 0)
                {
                    this.Hide();
                    FormAdmin forma = new FormAdmin(user);
                    forma.Text = "Welcome " + user.Name + " " + user.Surname;
                    forma.ShowDialog();
                    this.Show();
                }
                if (user.Role == 1)
                {
                    this.Hide();
                    FormProjectsAdmin forma = new FormProjectsAdmin(user);
                    forma.Text = "Welcome " + user.Name + " " + user.Surname;
                    forma.ShowDialog();
                    this.Show();
                }
                if (user.Role == 2)
                {
                    this.Hide();
                    FormDeveloperTasks forma = new FormDeveloperTasks(user);
                    forma.Text = "Welcome " + user.Name + " " + user.Surname;
                    forma.ShowDialog();
                    this.Show();
                }
            }
            else
            {
                lblProslo.Text = "Some error with login";
            }
            //var studentName = context.Users.SqlQuery(@"select * from Users where Username='******' AND Password='******'").FirstOrDefault<User>();
        }