Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
курсовая / отчет курсовая бд.docx
Скачиваний:
0
Добавлен:
11.02.2026
Размер:
6.38 Mб
Скачать
  1. Список литературы

  1. Форум программистов и сисадминов Киберфорум www.cyberforum.ru

  2. Официальный сайт Microsoft https://learn.microsoft.com/ru-ru/

  3. Stack Overflow — система вопросов и ответов о программировании https://stackoverflow.com/

  4. YouTube – Денвер правильная установка и настройка https://www.youtube.com/watch?v=l3K7fQ9H6ok&ysclid=m4u9l4nlkn472376464

  5. Документация по C# — управляемый язык .NET https://learn.microsoft.com/ru-ru/dotnet/csharp/

  6. MySQL Documentation https://dev.mysql.com/doc/

  7. Интерактивный тренажер по SQL https://stepik.org/course/63054/syllabus?auth=login

  8. SQL Academy – SQL Simulator Tasks Interactive SQL Simulator — SQL Academy

  9. Документация по библиотеке iTextSharp iText pdf library API documentation for Java and .Net

  10. Документация по библиотеке MySql.Data MySql.Data/README.md at master · CsharpDatabase/MySql.Data · GitHub

  11. Документация по библиотеке System.Drawing.Common System.Drawing Пространство имен | Microsoft Learn

ПРИЛОЖЕНИЕ 1.

Листинг программ. Интерфейс для пользователя hikingtrips. Файл Form2.Cs

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace hikingtrips

{

public partial class Form2 : Form

{

public Form2()

{

InitializeComponent();

}

private void Form2_Load(object sender, EventArgs e)

{

}

private void label1_Click(object sender, EventArgs e)

{

}

private void button1_Click(object sender, EventArgs e)

{

Form1 frm2 = new Form1();

frm2.Show();

this.Hide();

}

private void button2_Click(object sender, EventArgs e)

{

Form4 frm3 = new Form4();

frm3.Show();

this.Hide();

}

}

}

Файл Form1.Cs

using MySql.Data.MySqlClient;

using System;

using System.Security.Policy;

using System.Windows.Forms;

using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;

namespace hikingtrips

{

public partial class Form1 : Form

{

private const string connectionString = "server=localhost;database=hikingtrips;uid=root;password=Fuckingpassword2;";

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

string username = textBox1.Text;

string password = textBox2.Text;

AuthenticateUser(username, password);

}

private void AuthenticateUser(string username, string password)

{

int user_ind;

using (MySqlConnection connection = new MySqlConnection(connectionString))

{

connection.Open();

string checkUserQuery = "SELECT * FROM login_password WHERE login = @Username";

using (MySqlCommand checkUserCommand = new MySqlCommand(checkUserQuery, connection))

{

checkUserCommand.Parameters.AddWithValue("@Username", username);

int userCount = Convert.ToInt32(checkUserCommand.ExecuteScalar());

if (userCount > 0)

{

string passwordQuery = "SELECT password, user FROM login_password WHERE login = @Username";

using (MySqlCommand passwordCommand = new MySqlCommand(passwordQuery, connection))

{

passwordCommand.Parameters.AddWithValue("@Username", username);

MySqlDataReader reader2 = passwordCommand.ExecuteReader();

if (reader2.Read())

{

string storedPassword = reader2["password"].ToString();

if (storedPassword == password)

{

user_ind = Convert.ToInt32(reader2["user"]);

MessageBox.Show("The login was completed successfully!", "Congratulations!", MessageBoxButtons.OK, MessageBoxIcon.Information);

Form5 frm3 = new Form5(user_ind);

frm3.Show();

this.Close();

}

else

{

MessageBox.Show("The password is incorrect.", "Sorry.", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

reader2.Close();

}

}

} else

{

MessageBox.Show("The user with this username was not found.", "Sorry.", MessageBoxButtons.OK, MessageBoxIcon.Information);

}

}

}

}

}

}

Соседние файлы в папке курсовая