예제 #1
0
파일: LogIn.cs 프로젝트: tvdlans/NoSQL
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Login   login   = new Login();
            ConUser conUser = new ConUser();

            email = txtEmail.Text;
            string       password   = txtPassword.Text;
            string       hashedpswd = conUser.HashPassword(password);
            BsonDocument user       = login.CheckUser(email, password);

            if (user != null)
            {
                if (user.GetElement("Password").Value.ToString() == hashedpswd)
                {
                    // makes the remember me function work
                    if (chkremember.Checked == true)
                    {
                        Properties.Settings.Default.Name     = txtEmail.Text;
                        Properties.Settings.Default.Password = password;
                        Properties.Settings.Default.Save();
                    }
                    if (chkremember.Checked == false)
                    {
                        Properties.Settings.Default.Name     = "";
                        Properties.Settings.Default.Password = "";
                        Properties.Settings.Default.Save();
                    }

                    // add a "session" of the user that is logged in, that way you can access his or her information in the main program
                    ConSession session = new ConSession();
                    session.AddSession(user.GetElement("FirstName").Value.ToString(), user.GetElement("Email").Value.ToString(), ObjectId.Parse(user.GetElement("_id").Value.ToString()));

                    this.Hide();

                    // checks if the user is a service desk employee or a employee
                    if (int.Parse(user.GetElement("Role").Value.ToString()) == 0)
                    {
                        Employee employee = new Employee();
                        employee.Show();
                    }
                    else
                    {
                        Form1 form1 = new Form1();
                        form1.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Email and Password combination is not valid");
                }
            }
            else
            {
                MessageBox.Show("This user doesn't exist");
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: tvdlans/NoSQL
        private void Form1_Load(object sender, EventArgs e)
        {
            panelDash.BringToFront();
            ConSession session = new ConSession();
            string     name    = session.GetUsername();

            lblUser.Text = name;

            ConDashboard conDashboard = new ConDashboard();

            UnresolvedIncidents(conDashboard);
            IncidentsPastDeadline(conDashboard);
            TypeOfIncidents(conDashboard);
            MostCommonWords(conDashboard);
            IncidentsSolvedByYou(conDashboard);
        }