예제 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            ActiveForm.Hide();
            RunnerMenu rm = new RunnerMenu(runnerId);

            rm.ShowDialog();
            Close();
        }
예제 #2
0
        public void auth(string email, string password, AuthorizForm ar)
        {
            string          connStr = "server=localhost;user=root;database=pafenov;password="******"SELECT Password, Email,RoleId FROM user";

            MySqlCommand    command = new MySqlCommand(sql, conn);
            MySqlDataReader reader  = command.ExecuteReader();
            bool            pass    = false;
            bool            em      = false;
            bool            runner  = false;
            bool            admn    = false;
            bool            coord   = false;

            while (reader.Read())
            {
                if (reader[1].ToString() == email)
                {
                    em = true;
                    if (reader[0].ToString() == password)
                    {
                        pass = true;
                        if (reader[2].ToString() == "R")
                        {
                            runner = true;
                        }
                        else
                        {
                            if (reader[2].ToString() == "A")
                            {
                                admn = true;
                            }
                            else
                            {
                                if (reader[2].ToString() == "C")
                                {
                                }
                            }
                        }
                    }
                }
            }
            reader.Close();
            if (em == true)
            {
                if (pass == true)
                {
                    if (runner == true)
                    {
                        string sql2 = "SELECT RunnerId FROM runner WHERE Email='" + email + "'";


                        command = new MySqlCommand(sql2, conn);

                        int id = Convert.ToInt32(command.ExecuteScalar());
                        ar.Hide();
                        RunnerMenu rm = new RunnerMenu(id);
                        //conn.Close();
                        rm.ShowDialog();

                        conn.Close();

                        ar.Close();
                    }
                    if (admn == true)
                    {
                        ar.Hide();
                        AdminMenuForm amf = new AdminMenuForm();
                        amf.ShowDialog();
                        //reader.Close();
                        conn.Close();
                        ar.Close();
                    }
                    if (coord == true)
                    {
                        ar.Hide();
                        CoordMenuForm cmf = new CoordMenuForm();
                        cmf.ShowDialog();
                        //reader.Close();
                        conn.Close();
                        ar.Close();
                    }
                }
            }
            if (em == false)
            {
                MessageBox.Show("Неверный email!");
            }
            else
            {
                if (pass == false)
                {
                    MessageBox.Show("Неверный пароль!");
                }
            }
            //reader.Close();
            conn.Close();
        }