예제 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (tbLogin.Text == "" || tbPass.Text == "" || tbPass2.Text == "")
     {
         MessageBox.Show("Пожалуйста, заполните все поля регистрационной формы.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else if (tbPass.Text != tbPass2.Text)
     {
         MessageBox.Show("Введенные вами пароли не совпадают. Проверьте правильность введенных данных.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else if (curr_role != "admin" && StringHelper.TextToRole(cbRole.Text) == "admin")
     {
         MessageBox.Show("Невозможно создать пользователя с ролью администратора, не будучи администратором.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else
     {
         try
         {
             PgSql.ConnectToUsersDB(curr_role, curr_pass);
             PgSql.InsertIntoValues("users", String.Format("'{0}', '{1}', '{2}'", tbLogin.Text, Crypter.Encrypt(tbPass.Text), StringHelper.TextToRole(cbRole.Text)));
             MessageBox.Show("Пользователь создан с правами \" " + cbRole.Text + "\". Теперь он можете войти, используя свой логин и пароль.");
             this.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
             return;
         }
     }
 }
예제 #2
0
 static public NpgsqlDataReader SelectRoleFromUsers(String Login, String Pass)
 {
     return(Execute(String.Format("SELECT role FROM users WHERE login = '******' and password = '******'", Login, StringHelper.DublicateQuotes(Crypter.Encrypt(Pass)))));
 }