Exemplo n.º 1
0
 public static void Auth(Label label, string login, string password, Form form)
 {
     if (CheckAgainstInjection.Check(login, password) == true)
     {
         string hashPassword = MD5HashPassword.GetHash(password);
         if (AuthAdminStudentTeacher.Auth(login, hashPassword) == 1)
         {
             Form1 form1 = new Form1();
             form1.Show();
             form.Hide();
         }
         else if (AuthAdminStudentTeacher.Auth(login, hashPassword) == 2)
         {
             StudentForm studentForm = new StudentForm();
             studentForm.Show();
             form.Hide();
         }
         else if (AuthAdminStudentTeacher.Auth(login, hashPassword) == 3)
         {
         }
         else if (AuthAdminStudentTeacher.Auth(login, hashPassword) == 0)
         {
             label.Text = "Неправильный логин или пароль";
         }
     }
     else
     {
         label.Text = "Логин или пароль не может содержать пробелы";
     }
 }
Exemplo n.º 2
0
        public static void Registrate(string name, string lname, string login, string password, string email, string bdate, string phone, int group_id, bool teacherOrStudent, Label label)
        {
            int role;

            //Teacher
            if (teacherOrStudent == true)
            {
                role = 3;
            }
            //Student
            else
            {
                role = 2;
            }
            string cmdstr = "INSERT Users VALUES('" + login + "', '" + MD5HashPassword.GetHash(password) + "', '" + name + "', '" + lname + "', '" + phone + "', '" + bdate + "', " + role + ", " + group_id + ", '" + email + "')";

            using (SqlConnection conn = new SqlConnection(ConnectionString.Connstr))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(cmdstr, conn);
                int        a   = cmd.ExecuteNonQuery();
                if (a != 0)
                {
                    label.ForeColor = Color.FromArgb(118, 166, 46);
                    label.Text      = "Successfully added";
                }
                else
                {
                    label.ForeColor = Color.FromArgb(166, 27, 15);
                    label.Text      = "Wrong data";
                }
            }
        }
Exemplo n.º 3
0
        public static bool Restore(string pass)
        {
            string cmdstr = "UPDATE Users SET password = '******' WHERE email = '" + ConfirmEmailToChangePassword.address + "'";

            using (SqlConnection conn = new SqlConnection(ConnectionString.Connstr))
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(cmdstr, conn);
                int        a   = cmd.ExecuteNonQuery();
                if (a != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }