отформатировал

This commit is contained in:
DeerElk 2024-05-29 01:03:08 +04:00
parent 97c0475168
commit aa65f1afbe
8 changed files with 1 additions and 96 deletions

View File

@ -1,17 +1,5 @@
using Npgsql; using Npgsql;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Renci.SshNet;
using Renci.SshNet.Common;
using System.Runtime.InteropServices.JavaScript;
namespace DeviceAdmin namespace DeviceAdmin
{ {
public partial class FormCabinets : Form public partial class FormCabinets : Form
@ -24,7 +12,6 @@ namespace DeviceAdmin
InitializeComponent(); InitializeComponent();
LoadGridView(); LoadGridView();
} }
private void LoadGridView() private void LoadGridView()
{ {
adapter = new NpgsqlDataAdapter("SELECT * FROM cabinets;", connection); adapter = new NpgsqlDataAdapter("SELECT * FROM cabinets;", connection);
@ -44,7 +31,6 @@ namespace DeviceAdmin
command.ExecuteNonQuery(); command.ExecuteNonQuery();
LoadGridView(); LoadGridView();
} }
private void ButtonEdit_Click(object sender, EventArgs e) private void ButtonEdit_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -62,7 +48,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDelete_Click(object sender, EventArgs e) private void ButtonDelete_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -78,7 +63,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadGridView(); LoadGridView();

View File

@ -1,16 +1,5 @@
using Npgsql; using Npgsql;
using NpgsqlTypes;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceAdmin namespace DeviceAdmin
{ {
public partial class FormDevices : Form public partial class FormDevices : Form
@ -28,7 +17,6 @@ namespace DeviceAdmin
adapter2.Fill(dataTableKind); adapter2.Fill(dataTableKind);
comboBoxKind.DataSource = dataTableKind; comboBoxKind.DataSource = dataTableKind;
} }
private void LoadGridView() private void LoadGridView()
{ {
adapter = new NpgsqlDataAdapter("SELECT devices.id, model, kinds.title, serial_number, production_date, warranty_period, condition, kit_id, kits.title FROM devices LEFT JOIN kinds ON devices.kind_id = kinds.id FULL OUTER JOIN kits ON devices.kit_id=kits.id;", connection); adapter = new NpgsqlDataAdapter("SELECT devices.id, model, kinds.title, serial_number, production_date, warranty_period, condition, kit_id, kits.title FROM devices LEFT JOIN kinds ON devices.kind_id = kinds.id FULL OUTER JOIN kits ON devices.kit_id=kits.id;", connection);
@ -71,7 +59,6 @@ namespace DeviceAdmin
} }
LoadGridView(); LoadGridView();
} }
private void ButtonEdit_Click(object sender, EventArgs e) private void ButtonEdit_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -108,7 +95,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDelete_Click(object sender, EventArgs e) private void ButtonDelete_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -124,7 +110,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadGridView(); LoadGridView();

View File

@ -1,14 +1,5 @@
using Npgsql; using Npgsql;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceAdmin namespace DeviceAdmin
{ {
public partial class FormKinds : Form public partial class FormKinds : Form
@ -21,7 +12,6 @@ namespace DeviceAdmin
InitializeComponent(); InitializeComponent();
LoadGridView(); LoadGridView();
} }
private void LoadGridView() private void LoadGridView()
{ {
adapter = new NpgsqlDataAdapter("SELECT * FROM kinds;", connection); adapter = new NpgsqlDataAdapter("SELECT * FROM kinds;", connection);
@ -48,7 +38,6 @@ namespace DeviceAdmin
command.ExecuteNonQuery(); command.ExecuteNonQuery();
LoadGridView(); LoadGridView();
} }
private void ButtonEdit_Click(object sender, EventArgs e) private void ButtonEdit_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -73,7 +62,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDelete_Click(object sender, EventArgs e) private void ButtonDelete_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -89,7 +77,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadGridView(); LoadGridView();

View File

@ -1,10 +1,7 @@
using Npgsql;
namespace DeviceAdmin namespace DeviceAdmin
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
public NpgsqlConnection connection;
public FormMain() public FormMain()
{ {
InitializeComponent(); InitializeComponent();

View File

@ -1,15 +1,5 @@
using Npgsql; using Npgsql;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace DeviceAdmin namespace DeviceAdmin
{ {
public partial class FormOwnership : Form public partial class FormOwnership : Form
@ -32,7 +22,6 @@ namespace DeviceAdmin
adapter3.Fill(dataTableStaff); adapter3.Fill(dataTableStaff);
comboBoxStaff.DataSource = dataTableStaff; comboBoxStaff.DataSource = dataTableStaff;
} }
private void LoadGridView() private void LoadGridView()
{ {
adapter = new NpgsqlDataAdapter("SELECT kit_id, kits.title, staff_id, staff.full_name FROM ownership LEFT JOIN kits ON kit_id=kits.id FULL OUTER JOIN staff ON staff_id=staff.id;", connection); adapter = new NpgsqlDataAdapter("SELECT kit_id, kits.title, staff_id, staff.full_name FROM ownership LEFT JOIN kits ON kit_id=kits.id FULL OUTER JOIN staff ON staff_id=staff.id;", connection);
@ -53,7 +42,6 @@ namespace DeviceAdmin
command.ExecuteNonQuery(); command.ExecuteNonQuery();
LoadGridView(); LoadGridView();
} }
private void ButtonEdit_Click(object sender, EventArgs e) private void ButtonEdit_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -73,7 +61,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDelete_Click(object sender, EventArgs e) private void ButtonDelete_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -91,7 +78,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadGridView(); LoadGridView();

View File

@ -1,14 +1,5 @@
using Npgsql; using Npgsql;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceAdmin namespace DeviceAdmin
{ {
public partial class FormServices : Form public partial class FormServices : Form
@ -26,7 +17,6 @@ namespace DeviceAdmin
adapter2.Fill(dataTableDevice); adapter2.Fill(dataTableDevice);
comboBoxDevice.DataSource = dataTableDevice; comboBoxDevice.DataSource = dataTableDevice;
} }
private void LoadGridView() private void LoadGridView()
{ {
adapter = new NpgsqlDataAdapter("SELECT services.id, services.description, services.start_date, services.end_date, services.device_id, devices.model FROM services JOIN devices ON devices.id=services.device_id;", connection); adapter = new NpgsqlDataAdapter("SELECT services.id, services.description, services.start_date, services.end_date, services.device_id, devices.model FROM services JOIN devices ON devices.id=services.device_id;", connection);
@ -51,7 +41,6 @@ namespace DeviceAdmin
command.ExecuteNonQuery(); command.ExecuteNonQuery();
LoadGridView(); LoadGridView();
} }
private void ButtonEdit_Click(object sender, EventArgs e) private void ButtonEdit_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -71,7 +60,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDelete_Click(object sender, EventArgs e) private void ButtonDelete_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -87,7 +75,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadGridView(); LoadGridView();

View File

@ -1,14 +1,5 @@
using Npgsql; using Npgsql;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceAdmin namespace DeviceAdmin
{ {
public partial class FormStaff : Form public partial class FormStaff : Form
@ -21,7 +12,6 @@ namespace DeviceAdmin
InitializeComponent(); InitializeComponent();
LoadGridView(); LoadGridView();
} }
private void LoadGridView() private void LoadGridView()
{ {
adapter = new NpgsqlDataAdapter("SELECT * FROM staff;", connection); adapter = new NpgsqlDataAdapter("SELECT * FROM staff;", connection);
@ -43,7 +33,6 @@ namespace DeviceAdmin
command.ExecuteNonQuery(); command.ExecuteNonQuery();
LoadGridView(); LoadGridView();
} }
private void ButtonEdit_Click(object sender, EventArgs e) private void ButtonEdit_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -63,7 +52,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to edit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonDelete_Click(object sender, EventArgs e) private void ButtonDelete_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count > 0) if (dataGridView.SelectedRows.Count > 0)
@ -79,7 +67,6 @@ namespace DeviceAdmin
MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Please select a row to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonRefresh_Click(object sender, EventArgs e) private void ButtonRefresh_Click(object sender, EventArgs e)
{ {
LoadGridView(); LoadGridView();

View File

@ -1,7 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using Renci.SshNet; using Renci.SshNet;
using Npgsql; using Npgsql;
namespace DeviceAdmin namespace DeviceAdmin
{ {
internal static class Program internal static class Program
@ -9,15 +7,9 @@ namespace DeviceAdmin
public static NpgsqlConnection connection { get; set; } public static NpgsqlConnection connection { get; set; }
public static SshClient client; public static SshClient client;
public static ForwardedPortLocal portForwarded; public static ForwardedPortLocal portForwarded;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread] [STAThread]
static void Main() static void Main()
{ {
// To customize application configuration such as set high DPI
// settings or default font, see
// https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("127.0.0.1", 5432, "ubuntu", "ubuntu"); PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("127.0.0.1", 5432, "ubuntu", "ubuntu");
client = new SshClient(connectionInfo); client = new SshClient(connectionInfo);
@ -30,4 +22,4 @@ namespace DeviceAdmin
Application.Run(new FormMain()); Application.Run(new FormMain());
} }
} }
} }