Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            admin_form admin = new admin_form(label7.Text);

            this.Close();
            admin.Show();
        }
Пример #2
0
        private void btn_log_Click(object sender, EventArgs e)
        {
            SqlConnection conn = DBUtils.GetDBConnection();

            try
            {
                string str  = "";
                string str1 = "";
                string str2 = "";
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT roleId, id, active FROM [users] WHERE password =\'" + text_parol.Text + "\' AND email=\'" + text_login.Text + "\'";
                SqlDataReader reader = cmd.ExecuteReader();
                foreach (DbDataRecord r in reader)
                {
                    str  = r[0].ToString();
                    str1 = r[1].ToString();
                    str2 = r[2].ToString();
                }

                if (str == "")
                {
                    if (schet >= 3)
                    {
                        label_mess.Text = "Превышен лимит попыток.\n Форма заблокирована на 10 сек.";
                        this.Enabled    = false;
                        timer.Start();
                    }
                    else
                    {
                        label_mess.Text = "Неправильный логин или пароль.";
                        text_parol.Text = "";
                        schet          += 1;
                    }
                }
                else
                {
                    conn.Close();
                    if (str2 == "False")
                    {
                        label_mess.Text = "Вы заблокированы руководством.";
                        text_login.Text = "";
                        text_parol.Text = "";
                    }
                    else
                    {
                        switch (str)
                        {
                        case "2":
                            user_form usForm = new user_form(str1);
                            this.Hide();
                            usForm.Show();
                            break;

                        case "1":
                            admin_form adForm = new admin_form(str1);
                            this.Hide();
                            adForm.Show();
                            break;

                        case "3":
                            manag_form manForm = new manag_form();
                            this.Hide();
                            manForm.Show();
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }