You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.5 KiB

using Npgsql;
using System;
8 months ago
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 db_lab
{
public partial class RaportForm : Form
{
NpgsqlConnection connection;
private void load_data()
{
try
{
connection.Open();
string sql = @"SELECT
ead.id AS interaction_id,
e.name AS equipment_name,
r.room_name AS room_name,
d.name AS department_name,
b.address AS building_address,
ead.arrival_date,
ead.departure_date
FROM Equipment_Arrival_Departure ead
JOIN Equipment e ON ead.equipment_id = e.id
JOIN Rooms r ON e.room_id = r.id
JOIN Department d ON r.building_id = d.building_id
JOIN Building b ON d.building_id = b.id;
";
NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(sql, this.connection);
DataSet dataset = new DataSet();
adapter.Fill(dataset, "data");
dataGridView1.DataSource = dataset.Tables["data"];
connection.Close();
}
catch (Exception ex)
{
MessageBox.Show($"Error! Log: {ex.Message}");
connection.Close();
}
}
public RaportForm(string connection)
8 months ago
{
this.connection = new NpgsqlConnection(connection);
8 months ago
InitializeComponent();
load_data();
8 months ago
}
}
}