Пример #1
0
        //login button
        private void button2_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text;
            Int64  password = textBox2.Text.GetHashCode();
            var    userList = loginCredential.AsQueryable().Where(n => n.UserName == username);

            if (userList.Count() != 0)
            {
                var user = userList.First();
                if (user.Password == password)
                {
                    textBox1.Text = textBox2.Text = String.Empty;
                    if (user.Type == "teacher")
                    {
                        TeacherForm t = TeacherForm.GetInstance();
                        MainContainer.LoadForm(t);
                    }
                    else
                    {
                        StudentForm s = StudentForm.GetInstance(user.UserName);
                        MainContainer.LoadForm(s);
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Username or Password!", "Unauthorized acess", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                MessageBox.Show("Invalid Username or Password!", "Unauthorized acess", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainContainer form = MainContainer.GetInstance();

            MainContainer.LoadForm(new LoginForm());
            Application.Run(form);
        }
Пример #3
0
        //logout link
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure?", "Logout", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                LoginForm l = LoginForm.GetInstance();
                MainContainer.LoadForm(l);
            }
        }
Пример #4
0
        //sign up link
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            StudentSignUp s = StudentSignUp.GetInstnce();

            MainContainer.LoadForm(s);
        }
Пример #5
0
        //sign up button
        private void button2_Click(object sender, EventArgs e)
        {
            foreach (Control c in Controls)
            {
                if (c is TextBox)
                {
                    if (c.Text.Length == 0)
                    {
                        MessageBox.Show("All feilds are mandatory");
                        return;
                    }
                }
            }
            foreach (PictureBox c in Controls.OfType <PictureBox>())
            {
                if (c is PictureBox)
                {
                    if (c.ImageLocation == defaultImage)
                    {
                        MessageBox.Show("all images are mandatory");
                        return;
                    }
                }
            }

            student.Name     = textBox2.Text;
            student.Type     = "student";
            student.MobileNo = textBox3.Text;

            if (textBox4.Text != textBox5.Text)
            {
                MessageBox.Show("Password not mathcing!");
                return;
            }
            if (textBox4.Text.Length < 8)
            {
                MessageBox.Show("Password length must be of 8 or more!");
                return;
            }
            if (loginCredential.Find(n => n.UserName == textBox1.Text).CountDocuments() != 0)
            {
                MessageBox.Show("Username already exists!");
                return;
            }
            student.Gender = Controls.OfType <RadioButton>().First().Text;

            picture.UserName = user.UserName = student.UserName = textBox1.Text;
            user.Password    = textBox4.Text.GetHashCode();
            Directory.CreateDirectory(String.Format(@"C:\ProxyKiller\ProxyKiller\ProxyKiller\userPictures\{0}", user.UserName));
            for (int i = 0; i < 4; i++)
            {
                string filename = String.Format(@"C:\ProxyKiller\ProxyKiller\ProxyKiller\userPictures\{0}\{1}{2}.jpg", user.UserName, user.UserName, i);
                File.Copy(picture.ImageLocations[i], filename, true);
                picture.ImageLocations[i] = filename;
            }

            studentInfo.InsertOne(student);
            loginCredential.InsertOne(user);
            studentPicture.InsertOne(picture);

            textBox1.Text             = textBox2.Text = textBox3.Text = textBox4.Text = textBox5.Text = String.Empty;
            pictureBox1.ImageLocation = pictureBox2.ImageLocation = pictureBox3.ImageLocation = pictureBox4.ImageLocation = defaultImage;


            StudentForm s = StudentForm.GetInstance(user.UserName);

            MainContainer.LoadForm(s);
        }
Пример #6
0
        //back to login link
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LoginForm l = LoginForm.GetInstance();

            MainContainer.LoadForm(l);
        }