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.

84 lines
2.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
using Npgsql;
namespace db_lab
{
public partial class Form1 : Form
{
string connectionString = "Server=172.27.128.1;Port=5432;UserId=postgres;Password=postgres;Database=SQL_Servers;";
NpgsqlConnection connection;
public Form1()
{
InitializeComponent();
}
private void exitBtn_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void aboutBtn_Click(object sender, EventArgs e)
{
string appName = Application.ProductName;
string appVersion = Application.ProductVersion;
string developer = "Артем Вебер";
string message = $"Приложение: {appName}\nВерсия: {appVersion}\nРазработчик: {developer}";
MessageBox.Show(message, "Информация о приложении", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void raportBtn_Click(object sender, EventArgs e)
{
RaportForm raportForm = new RaportForm(connectionString);
raportForm.Show();
}
private void dataBtn_Click(object sender, EventArgs e)
{
DataForm dataForm = new DataForm(connectionString);
dataForm.Show();
}
private void guideBtn_Click(object sender, EventArgs e)
{
GuideForm guideForm = new GuideForm();
guideForm.Show();
}
private void dbConnectBtn_Click(object sender, EventArgs e)
{
try
{
this.connection = new NpgsqlConnection(this.connectionString);
this.connection.Open();
this.connection.Close();
MessageBox.Show("Database was successfuly connected!");
} catch (Exception ex)
{
MessageBox.Show($"Error! Db connection was fatal! Log: {ex.Message}");
}
}
private void buildingButton_MouseClick(object sender, MouseEventArgs e)
{
var crudForm = new CRUDForm(this.connectionString);
crudForm.Show();
}
private void buildingButton_Click(object sender, EventArgs e)
{
var crudForm = new CRUDForm(this.connectionString);
crudForm.Show();
}
}
}