Пример #1
0
        private void btnEnter_Click(object sender, EventArgs e)
        {
            LoginText.Focus();
            if (EnterTry == 1)
            {
                btnEnter.Enabled         = false;
                label_timer_expl.Visible = true;
                label_timer.Visible      = true;
                timer1.Start();
                this.timer1.Tick += new System.EventHandler(this.timer_Tick);
            }
            QueryLogin = LoginText.Text;
            QueryPass  = PassText.Text;
            string MyQuery = $"select [role] from [user] where [name_user] = '" + QueryLogin + "'and [password] = '" + QueryPass + "'";

            using (SqlConnection conn = new SqlConnection(MyConn))
            {
                using (SqlCommand command = new SqlCommand(MyQuery, conn))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (System.Data.SqlClient.SqlException)
                    {
                        MessageBox.Show("Проблемы с соединением с сервером БД\nПроверьте подключение", "Авторизация");
                        return;
                    }
                    SqlDataReader reader = command.ExecuteReader();
                    if (reader.HasRows)
                    {
                        reader.Read();
                        role = reader[0].ToString();
                        BodyProgram form2 = new BodyProgram(this);
                        form2.Show();
                        LoginText.Clear();
                        PassText.Clear();
                        this.Hide();
                    }
                    else
                    {
                        LoginText.Clear();
                        PassText.Clear();
                        EnterTry--;
                        MessageBox.Show($"Проверьте правильность ввода логина/пароля\nРазрешено попыток: {EnterTry}");
                    }
                    conn.Close();
                }
            }
        }
Пример #2
0
 public AddTrack_Moderator(BodyProgram BodyPO, string MyConn)
 {
     this.BodyPO = BodyPO;
     this.MyConn = MyConn;
     InitializeComponent();
     AddAlbomGroupBox.Visible             = false;
     AuthorComboBox.DropDownStyle         = System.Windows.Forms.ComboBoxStyle.DropDownList;
     AlbomComboBox.DropDownStyle          = System.Windows.Forms.ComboBoxStyle.DropDownList;
     GenreComboBox.DropDownStyle          = System.Windows.Forms.ComboBoxStyle.DropDownList;
     AuthorComboBox.Enter                += new EventHandler(Select_InfoAuthor);
     AuthorComboBox.SelectedIndexChanged += new EventHandler(Select_InfoAlbom);
     AlbomComboBox.SelectedValueChanged  += new EventHandler(Open_btnSelectFile_OR_formAddNewAlbom);
     GenreComboBox.Enter                   += new EventHandler(Select_InfoGenre);
     CountTrackTextBox.KeyPress            += new KeyPressEventHandler(TextBoxEnterOnlyNumber_KeyPress);
     YearIssueTextBox.KeyPress             += new KeyPressEventHandler(TextBoxEnterOnlyNumber_KeyPress);
     Country_TextBox_AddPerformer.KeyPress += new KeyPressEventHandler(TextBoxEnterOnlySymbol_KeyPress);
 }