diff --git a/SUBD_LABA/Database/Implements.cs b/SUBD_LABA/Database/Implements.cs
index e1b647c..08f8175 100644
--- a/SUBD_LABA/Database/Implements.cs
+++ b/SUBD_LABA/Database/Implements.cs
@@ -12,7 +12,7 @@ namespace Database
{
private NpgsqlConnection GetConnect()
{
- return new NpgsqlConnection("Host=192.168.56.101;Username=postgres;Password=postgres;Database=calendar");
+ return new NpgsqlConnection("Host=192.168.56.102;Username=postgres;Password=postgres;Database=postgres");
}
public override void CreateAlbum(Album album)
{
@@ -67,7 +67,7 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand($"SELECT * FROM Album WHERE Title = {title}", conn);
+ using var cmd = new NpgsqlCommand($"SELECT * FROM Album WHERE Title = '{title}'", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
@@ -123,9 +123,10 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand("UPDATE Location SET Name = @Name, ShortName = @Shortname WHERE Id = @Id", conn);
+ using var cmd = new NpgsqlCommand("UPDATE Location SET Name = @Name, ShortName = @Shortname WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Name", location.Name);
cmd.Parameters.AddWithValue("@Shortname", location.ShortName);
+ cmd.Parameters.AddWithValue("@Id", location.Id);
cmd.ExecuteNonQuery();
}
@@ -160,7 +161,7 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand($"SELECT * FROM Location WHERE Name = {name}", conn);
+ using var cmd = new NpgsqlCommand($"SELECT * FROM Location WHERE Name = '{name}'", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
@@ -222,7 +223,7 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand("UPDATE Photo SET Title = @Title, Description = @Description, Privacy = @Privacy, UploadDate = @UploadDate, ImagePath = @ImagePath, AlbumId = @Album, LocationId = @Location, AuthorId = @Author", conn);
+ using var cmd = new NpgsqlCommand("UPDATE Photo SET Title = @Title, Description = @Description, Privacy = @Privacy, UploadDate = @UploadDate, ImagePath = @ImagePath, AlbumId = @Album, LocationId = @Location, AuthorId = @Author WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Title", photo.Title);
cmd.Parameters.AddWithValue("@Description", photo.Description);
cmd.Parameters.AddWithValue("@Privacy", photo.Privacy);
@@ -231,6 +232,7 @@ namespace Database
cmd.Parameters.AddWithValue("@Album", photo.AlbumId);
cmd.Parameters.AddWithValue("@Location", photo.LocationId);
cmd.Parameters.AddWithValue("@Author", photo.AuthorId);
+ cmd.Parameters.AddWithValue("@Id", photo.Id);
cmd.ExecuteNonQuery();
}
@@ -254,14 +256,14 @@ namespace Database
return new Photo
{
Id = reader.GetInt32(0),
- Title = reader.GetString(1),
- Description = reader.GetString(2),
- Privacy = reader.GetString(3),
- UploadDate = reader.GetDateTime(4),
- ImagePath = reader.GetString(5),
- AlbumId = reader.GetInt32(6),
- LocationId = reader.GetInt32(7),
- AuthorId = reader.GetInt32(8)
+ Title = reader.GetString(4),
+ Description = reader.GetString(5),
+ Privacy = reader.GetString(6),
+ UploadDate = reader.GetDateTime(7),
+ ImagePath = reader.GetString(8),
+ AlbumId = reader.GetInt32(1),
+ LocationId = reader.GetInt32(2),
+ AuthorId = reader.GetInt32(3)
};
}
return null;
@@ -278,14 +280,14 @@ namespace Database
return new Photo
{
Id = reader.GetInt32(0),
- Title = reader.GetString(1),
- Description = reader.GetString(2),
- Privacy = reader.GetString(3),
- UploadDate = reader.GetDateTime(4),
- ImagePath = reader.GetString(5),
- AlbumId=reader.GetInt32(6),
- LocationId = reader.GetInt32(7),
- AuthorId = reader.GetInt32(8)
+ Title = reader.GetString(4),
+ Description = reader.GetString(5),
+ Privacy = reader.GetString(6),
+ UploadDate = reader.GetDateTime(7),
+ ImagePath = reader.GetString(8),
+ AlbumId = reader.GetInt32(1),
+ LocationId = reader.GetInt32(2),
+ AuthorId = reader.GetInt32(3)
};
}
return null;
@@ -303,14 +305,14 @@ namespace Database
photos.Add(new Photo
{
Id = reader.GetInt32(0),
- Title = reader.GetString(1),
- Description = reader.GetString(2),
- Privacy = reader.GetString(3),
- UploadDate = reader.GetDateTime(4),
- ImagePath = reader.GetString(5),
- AlbumId = reader.GetInt32(6),
- LocationId = reader.GetInt32(7),
- AuthorId = reader.GetInt32(8)
+ Title = reader.GetString(4),
+ Description = reader.GetString(5),
+ Privacy = reader.GetString(6),
+ UploadDate = reader.GetDateTime(7),
+ ImagePath = reader.GetString(8),
+ AlbumId = reader.GetInt32(1),
+ LocationId = reader.GetInt32(2),
+ AuthorId = reader.GetInt32(3)
});
}
return photos;
@@ -340,10 +342,11 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand("UPDATE Author SET Name = @Name, PhoneNum = @PhoneNum, Email = @Email", conn);
+ using var cmd = new NpgsqlCommand("UPDATE Author SET Name = @Name, PhoneNum = @PhoneNum, Email = @Email WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Name", author.Name);
cmd.Parameters.AddWithValue("@PhoneNum", author.PhoneNum);
cmd.Parameters.AddWithValue("@Email", author.Email);
+ cmd.Parameters.AddWithValue("@Id", author.Id);
cmd.ExecuteNonQuery();
}
@@ -379,7 +382,7 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand($"SELECT * FROM Author WHERE Name = {name}", conn);
+ using var cmd = new NpgsqlCommand($"SELECT * FROM Author WHERE Name = '{name}'", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
@@ -426,7 +429,7 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand("INSERT INTO Comment (PostDate, Content, PhotoId) " +
+ using var cmd = new NpgsqlCommand("INSERT INTO Comment (PostDate, Content, Photold) " +
"VALUES (@PostDate, @Content, @Photo)", conn);
cmd.Parameters.AddWithValue("@PostDate", comment.PostDate);
cmd.Parameters.AddWithValue("@Content", comment.Content);
@@ -438,10 +441,11 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand("UPDATE Comment SET PostDate = @PostDate, Content = @Content, PhotoId = @Photo", conn);
+ using var cmd = new NpgsqlCommand("UPDATE Comment SET PostDate = @PostDate, Content = @Content, Photold = @Photo WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@PostDate", comment.PostDate);
cmd.Parameters.AddWithValue("@Content", comment.Content);
cmd.Parameters.AddWithValue("@Photo", comment.PhotoId);
+ cmd.Parameters.AddWithValue("@Id", comment.Id);
cmd.ExecuteNonQuery();
}
@@ -465,9 +469,9 @@ namespace Database
return new Comment
{
Id = reader.GetInt32(0),
- PostDate = reader.GetDateTime(1),
- Content = reader.GetString(2),
- PhotoId = reader.GetInt32(3)
+ PostDate = reader.GetDateTime(2),
+ Content = reader.GetString(3),
+ PhotoId = reader.GetInt32(1)
};
}
return null;
@@ -477,16 +481,16 @@ namespace Database
{
using var conn = GetConnect();
conn.Open();
- using var cmd = new NpgsqlCommand($"SELECT * FROM Comment WHERE PhotoId = {PhotoId}", conn);
+ using var cmd = new NpgsqlCommand($"SELECT * FROM Comment WHERE Photold = {PhotoId}", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new Comment
{
Id = reader.GetInt32(0),
- PostDate = reader.GetDateTime(1),
- Content = reader.GetString(2),
- PhotoId = reader.GetInt32(3)
+ PostDate = reader.GetDateTime(2),
+ Content = reader.GetString(3),
+ PhotoId = reader.GetInt32(1)
};
}
return null;
@@ -504,9 +508,9 @@ namespace Database
comments.Add(new Comment
{
Id = reader.GetInt32(0),
- PostDate = reader.GetDateTime(1),
- Content = reader.GetString(2),
- PhotoId = reader.GetInt32(3)
+ PostDate = reader.GetDateTime(2),
+ Content = reader.GetString(3),
+ PhotoId = reader.GetInt32(1)
});
}
return comments;
diff --git a/SUBD_LABA/SUBD_LAB.sln b/SUBD_LABA/SUBD_LAB.sln
index e9b6012..7986c22 100644
--- a/SUBD_LABA/SUBD_LAB.sln
+++ b/SUBD_LABA/SUBD_LAB.sln
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.6.33801.468
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database", "Database\Database.csproj", "{7D559A78-17F8-4ADB-BA91-30D71CE60CC6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Database", "Database\Database.csproj", "{7D559A78-17F8-4ADB-BA91-30D71CE60CC6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "View", "View\View.csproj", "{E1BCFE07-5B32-44FA-B28A-E1BF44614311}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{7D559A78-17F8-4ADB-BA91-30D71CE60CC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D559A78-17F8-4ADB-BA91-30D71CE60CC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D559A78-17F8-4ADB-BA91-30D71CE60CC6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E1BCFE07-5B32-44FA-B28A-E1BF44614311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E1BCFE07-5B32-44FA-B28A-E1BF44614311}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E1BCFE07-5B32-44FA-B28A-E1BF44614311}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E1BCFE07-5B32-44FA-B28A-E1BF44614311}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/SUBD_LABA/View/FormAlbum.Designer.cs b/SUBD_LABA/View/FormAlbum.Designer.cs
new file mode 100644
index 0000000..5b8b4f4
--- /dev/null
+++ b/SUBD_LABA/View/FormAlbum.Designer.cs
@@ -0,0 +1,118 @@
+namespace View
+{
+ partial class FormAlbum
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ textBox1 = new TextBox();
+ textBox2 = new TextBox();
+ button1 = new Button();
+ button2 = new Button();
+ label1 = new Label();
+ label2 = new Label();
+ SuspendLayout();
+ //
+ // textBox1
+ //
+ textBox1.Location = new Point(192, 26);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(216, 27);
+ textBox1.TabIndex = 0;
+ //
+ // textBox2
+ //
+ textBox2.Location = new Point(192, 77);
+ textBox2.Name = "textBox2";
+ textBox2.Size = new Size(216, 27);
+ textBox2.TabIndex = 1;
+ //
+ // button1
+ //
+ button1.Location = new Point(68, 138);
+ button1.Name = "button1";
+ button1.Size = new Size(94, 29);
+ button1.TabIndex = 2;
+ button1.Text = "Сохранить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += button1_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(264, 138);
+ button2.Name = "button2";
+ button2.Size = new Size(94, 29);
+ button2.TabIndex = 3;
+ button2.Text = "Отмена";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += button2_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(41, 29);
+ label1.Name = "label1";
+ label1.Size = new Size(77, 20);
+ label1.TabIndex = 4;
+ label1.Text = "Название";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(41, 80);
+ label2.Name = "label2";
+ label2.Size = new Size(79, 20);
+ label2.TabIndex = 5;
+ label2.Text = "Описание";
+ //
+ // FormAlbum
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(420, 179);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ Controls.Add(textBox2);
+ Controls.Add(textBox1);
+ Name = "FormAlbum";
+ Text = "FormAlbum";
+ Load += FormAlbum_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private TextBox textBox1;
+ private TextBox textBox2;
+ private Button button1;
+ private Button button2;
+ private Label label1;
+ private Label label2;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormAlbum.cs b/SUBD_LABA/View/FormAlbum.cs
new file mode 100644
index 0000000..ec75be6
--- /dev/null
+++ b/SUBD_LABA/View/FormAlbum.cs
@@ -0,0 +1,62 @@
+using Commentbase;
+using Npgsql.Internal.Postgres;
+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 View
+{
+ public partial class FormAlbum : Form
+ {
+ public int? AlbumId { get; set; }
+ private Abstracts db;
+ public FormAlbum(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void button1_Click(object sender, EventArgs e)
+ {
+ if (AlbumId.HasValue)
+ {
+ db.UpdateAlbum(new()
+ {
+ Id = AlbumId.Value,
+ Title = textBox1.Text,
+ Description = textBox2.Text,
+ });
+ }
+ else
+ {
+ db.CreateAlbum(new()
+ {
+ Title = textBox1.Text,
+ Description = textBox2.Text
+ });
+
+ }
+ DialogResult = DialogResult.OK;
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ private void FormAlbum_Load(object sender, EventArgs e)
+ {
+ if (AlbumId.HasValue)
+ {
+ var album = db.GetAlbum(AlbumId.Value);
+ textBox1.Text = album.Title;
+ textBox2.Text = album.Description;
+ }
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormAlbum.resx b/SUBD_LABA/View/FormAlbum.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormAlbum.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormAlbums.Designer.cs b/SUBD_LABA/View/FormAlbums.Designer.cs
new file mode 100644
index 0000000..e2088b2
--- /dev/null
+++ b/SUBD_LABA/View/FormAlbums.Designer.cs
@@ -0,0 +1,114 @@
+namespace View
+{
+ partial class FormAlbums
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView1 = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView1
+ //
+ dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView1.Location = new Point(12, 12);
+ dataGridView1.Name = "dataGridView1";
+ dataGridView1.RowHeadersWidth = 51;
+ dataGridView1.RowTemplate.Height = 29;
+ dataGridView1.Size = new Size(617, 426);
+ dataGridView1.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(668, 41);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(94, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += buttonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(668, 106);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(94, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(668, 177);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(94, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(668, 246);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(94, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += buttonReload_Click;
+ //
+ // FormAlbums
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView1);
+ Name = "FormAlbums";
+ Text = "FormAlbums";
+ Load += FormAlbums_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView1;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormAlbums.cs b/SUBD_LABA/View/FormAlbums.cs
new file mode 100644
index 0000000..a28964f
--- /dev/null
+++ b/SUBD_LABA/View/FormAlbums.cs
@@ -0,0 +1,89 @@
+using Commentbase;
+using Database;
+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 View
+{
+ public partial class FormAlbums : Form
+ {
+ private Abstracts abstracts;
+ public FormAlbums(Abstracts abstracts)
+ {
+ InitializeComponent();
+ this.abstracts = abstracts;
+ }
+ private void LoadData()
+ {
+ List albums = abstracts.GetAlbums();
+ dataGridView1.Rows.Clear();
+ if (dataGridView1.Columns.Count == 0)
+ {
+ dataGridView1.Columns.Add("Id", "Id");
+ dataGridView1.Columns.Add("Title", "title");
+ dataGridView1.Columns.Add("Description", "description");
+ }
+
+ foreach (Album album in albums)
+ {
+ dataGridView1.Rows.Add(album.Id, album.Title, album.Description);
+ }
+ }
+ private void FormAlbums_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormAlbum));
+ if (service is FormAlbum form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void buttonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormAlbum));
+ if (service is FormAlbum form)
+ {
+ form.AlbumId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ var i = dataGridView1.CurrentCell.RowIndex;
+ var elem = (int)dataGridView1.Rows[i].Cells["Id"].Value;
+
+ abstracts.DeleteAlbum(elem);
+ LoadData();
+ }
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormAlbums.resx b/SUBD_LABA/View/FormAlbums.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormAlbums.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormAuthor.Designer.cs b/SUBD_LABA/View/FormAuthor.Designer.cs
new file mode 100644
index 0000000..62754bd
--- /dev/null
+++ b/SUBD_LABA/View/FormAuthor.Designer.cs
@@ -0,0 +1,140 @@
+namespace View
+{
+ partial class FormAuthor
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ textBox1 = new TextBox();
+ textBox2 = new TextBox();
+ textBox3 = new TextBox();
+ label1 = new Label();
+ label2 = new Label();
+ label3 = new Label();
+ button1 = new Button();
+ button2 = new Button();
+ SuspendLayout();
+ //
+ // textBox1
+ //
+ textBox1.Location = new Point(204, 24);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(251, 27);
+ textBox1.TabIndex = 0;
+ //
+ // textBox2
+ //
+ textBox2.Location = new Point(204, 75);
+ textBox2.Name = "textBox2";
+ textBox2.Size = new Size(251, 27);
+ textBox2.TabIndex = 1;
+ //
+ // textBox3
+ //
+ textBox3.Location = new Point(204, 126);
+ textBox3.Name = "textBox3";
+ textBox3.Size = new Size(251, 27);
+ textBox3.TabIndex = 2;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(36, 27);
+ label1.Name = "label1";
+ label1.Size = new Size(39, 20);
+ label1.TabIndex = 3;
+ label1.Text = "Имя";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(36, 78);
+ label2.Name = "label2";
+ label2.Size = new Size(127, 20);
+ label2.TabIndex = 4;
+ label2.Text = "Номер телефона";
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(36, 129);
+ label3.Name = "label3";
+ label3.Size = new Size(93, 20);
+ label3.TabIndex = 5;
+ label3.Text = "Email почты";
+ //
+ // button1
+ //
+ button1.Location = new Point(69, 197);
+ button1.Name = "button1";
+ button1.Size = new Size(94, 29);
+ button1.TabIndex = 6;
+ button1.Text = "Сохранить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += button1_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(294, 197);
+ button2.Name = "button2";
+ button2.Size = new Size(94, 29);
+ button2.TabIndex = 7;
+ button2.Text = "Отмена";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += button2_Click;
+ //
+ // FormAuthor
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(467, 251);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(textBox3);
+ Controls.Add(textBox2);
+ Controls.Add(textBox1);
+ Name = "FormAuthor";
+ Text = "FormAuthor";
+ Load += FormAuthor_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private TextBox textBox1;
+ private TextBox textBox2;
+ private TextBox textBox3;
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ private Button button1;
+ private Button button2;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormAuthor.cs b/SUBD_LABA/View/FormAuthor.cs
new file mode 100644
index 0000000..eca496b
--- /dev/null
+++ b/SUBD_LABA/View/FormAuthor.cs
@@ -0,0 +1,65 @@
+using Commentbase;
+using Microsoft.VisualBasic.ApplicationServices;
+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 View
+{
+ public partial class FormAuthor : Form
+ {
+ public int? AuthorId { get; set; }
+ private Abstracts db;
+ public FormAuthor(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void button1_Click(object sender, EventArgs e)
+ {
+ if (AuthorId.HasValue)
+ {
+ db.UpdateAuthor(new()
+ {
+ Id = AuthorId.Value,
+ Name = textBox1.Text,
+ PhoneNum = textBox2.Text,
+ Email = textBox3.Text
+ });
+ }
+ else
+ {
+ db.CreateAuthor(new()
+ {
+ Name = textBox1.Text,
+ PhoneNum = textBox2.Text,
+ Email = textBox3.Text
+ });
+ }
+ DialogResult = DialogResult.OK;
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void FormAuthor_Load(object sender, EventArgs e)
+ {
+ if (AuthorId.HasValue)
+ {
+ var author = db.GetAuthor(AuthorId.Value);
+ textBox1.Text = author.Name;
+ textBox2.Text = author.PhoneNum;
+ textBox3.Text = author.Email;
+ }
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormAuthor.resx b/SUBD_LABA/View/FormAuthor.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormAuthor.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormAuthors.Designer.cs b/SUBD_LABA/View/FormAuthors.Designer.cs
new file mode 100644
index 0000000..71b880d
--- /dev/null
+++ b/SUBD_LABA/View/FormAuthors.Designer.cs
@@ -0,0 +1,114 @@
+namespace View
+{
+ partial class FormAuthors
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView1 = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView1
+ //
+ dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView1.Location = new Point(12, 12);
+ dataGridView1.Name = "dataGridView1";
+ dataGridView1.RowHeadersWidth = 51;
+ dataGridView1.RowTemplate.Height = 29;
+ dataGridView1.Size = new Size(614, 426);
+ dataGridView1.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(669, 31);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(94, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += buttonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(669, 102);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(94, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(669, 174);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(94, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(669, 247);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(94, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += buttonReload_Click;
+ //
+ // FormAuthors
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView1);
+ Name = "FormAuthors";
+ Text = "FormAuthors";
+ Load += FormAuthors_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView1;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormAuthors.cs b/SUBD_LABA/View/FormAuthors.cs
new file mode 100644
index 0000000..54385b9
--- /dev/null
+++ b/SUBD_LABA/View/FormAuthors.cs
@@ -0,0 +1,106 @@
+using Commentbase;
+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 View
+{
+ public partial class FormAuthors : Form
+ {
+ private Abstracts db;
+ public FormAuthors(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void buttonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ var service = Program.ServiceProvider?.GetService(typeof(FormAuthor));
+ if (service is FormAuthor form)
+ {
+ form.AuthorId = id;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ try
+ {
+ db.DeleteAuthor(id);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormAuthor));
+ if (service is FormAuthor form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ if (dataGridView1.ColumnCount == 0)
+ {
+ dataGridView1.Columns.Add("Id", "Id");
+ dataGridView1.Columns.Add("Name", "Name");
+ dataGridView1.Columns.Add("PhoneNum", "PhoneNum");
+ dataGridView1.Columns.Add("Email", "Email");
+ }
+
+ var list = db.GetAuthors();
+ if (list != null)
+ {
+ dataGridView1.Rows.Clear();
+ foreach (var author in list)
+ {
+ dataGridView1.Rows.Add(author.Id, author.Name, author.PhoneNum, author.Email);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormAuthors_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormAuthors.resx b/SUBD_LABA/View/FormAuthors.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormAuthors.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormComment.Designer.cs b/SUBD_LABA/View/FormComment.Designer.cs
new file mode 100644
index 0000000..e7ad8ba
--- /dev/null
+++ b/SUBD_LABA/View/FormComment.Designer.cs
@@ -0,0 +1,141 @@
+namespace View
+{
+ partial class FormComment
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dateTimePicker1 = new DateTimePicker();
+ textBox1 = new TextBox();
+ comboBoxPhoto = new ComboBox();
+ button1 = new Button();
+ button2 = new Button();
+ label1 = new Label();
+ label2 = new Label();
+ label3 = new Label();
+ SuspendLayout();
+ //
+ // dateTimePicker1
+ //
+ dateTimePicker1.Location = new Point(219, 24);
+ dateTimePicker1.Name = "dateTimePicker1";
+ dateTimePicker1.Size = new Size(310, 27);
+ dateTimePicker1.TabIndex = 0;
+ //
+ // textBox1
+ //
+ textBox1.Location = new Point(219, 74);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(310, 27);
+ textBox1.TabIndex = 1;
+ //
+ // comboBoxPhoto
+ //
+ comboBoxPhoto.FormattingEnabled = true;
+ comboBoxPhoto.Location = new Point(219, 127);
+ comboBoxPhoto.Name = "comboBoxPhoto";
+ comboBoxPhoto.Size = new Size(310, 28);
+ comboBoxPhoto.TabIndex = 2;
+ //
+ // button1
+ //
+ button1.Location = new Point(91, 181);
+ button1.Name = "button1";
+ button1.Size = new Size(94, 29);
+ button1.TabIndex = 3;
+ button1.Text = "Сохранить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += button1_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(371, 181);
+ button2.Name = "button2";
+ button2.Size = new Size(94, 29);
+ button2.TabIndex = 4;
+ button2.Text = "Отмена";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += button2_Click;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(41, 29);
+ label1.Name = "label1";
+ label1.Size = new Size(140, 20);
+ label1.TabIndex = 5;
+ label1.Text = "Дата комментария";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(41, 77);
+ label2.Name = "label2";
+ label2.Size = new Size(65, 20);
+ label2.TabIndex = 6;
+ label2.Text = "Контент";
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(41, 130);
+ label3.Name = "label3";
+ label3.Size = new Size(144, 20);
+ label3.TabIndex = 7;
+ label3.Text = "Выбор фотография";
+ //
+ // FormComment
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(541, 222);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ Controls.Add(comboBoxPhoto);
+ Controls.Add(textBox1);
+ Controls.Add(dateTimePicker1);
+ Name = "FormComment";
+ Text = "FormComment";
+ Load += FormComment_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private DateTimePicker dateTimePicker1;
+ private TextBox textBox1;
+ private ComboBox comboBoxPhoto;
+ private Button button1;
+ private Button button2;
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormComment.cs b/SUBD_LABA/View/FormComment.cs
new file mode 100644
index 0000000..51a7073
--- /dev/null
+++ b/SUBD_LABA/View/FormComment.cs
@@ -0,0 +1,83 @@
+using Commentbase;
+using Database;
+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 View
+{
+ public partial class FormComment : Form
+ {
+ public int? CommentId { get; set; }
+ private Abstracts db;
+ public FormComment(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void button1_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (CommentId.HasValue)
+ {
+ db.UpdateComment(new()
+ {
+ Id = CommentId.Value,
+ PostDate = dateTimePicker1.Value,
+ Content = textBox1.Text,
+ PhotoId = (comboBoxPhoto.SelectedItem as Photo).Id
+ });
+ }
+ else
+ {
+ db.CreateComment(new()
+ {
+ PostDate = dateTimePicker1.Value,
+ Content = textBox1.Text,
+ PhotoId = (comboBoxPhoto.SelectedItem as Photo).Id
+ });
+ }
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var photos = db.GetPhotos();
+ comboBoxPhoto.DataSource = photos;
+
+ comboBoxPhoto.DisplayMember = "Title";
+ comboBoxPhoto.ValueMember = "Id";
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormComment_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormComment.resx b/SUBD_LABA/View/FormComment.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormComment.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormComments.Designer.cs b/SUBD_LABA/View/FormComments.Designer.cs
new file mode 100644
index 0000000..00d1e2b
--- /dev/null
+++ b/SUBD_LABA/View/FormComments.Designer.cs
@@ -0,0 +1,114 @@
+namespace View
+{
+ partial class FormComments
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView1 = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView1
+ //
+ dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView1.Location = new Point(12, 12);
+ dataGridView1.Name = "dataGridView1";
+ dataGridView1.RowHeadersWidth = 51;
+ dataGridView1.RowTemplate.Height = 29;
+ dataGridView1.Size = new Size(609, 426);
+ dataGridView1.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(667, 42);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(94, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += buttonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(667, 107);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(94, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(667, 166);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(94, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(667, 238);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(94, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += buttonReload_Click;
+ //
+ // FormComments
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView1);
+ Name = "FormComments";
+ Text = "FormComments";
+ Load += DatesForm_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView1;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormComments.cs b/SUBD_LABA/View/FormComments.cs
new file mode 100644
index 0000000..e5a6118
--- /dev/null
+++ b/SUBD_LABA/View/FormComments.cs
@@ -0,0 +1,89 @@
+using Commentbase;
+using Microsoft.VisualBasic;
+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 View
+{
+ public partial class FormComments : Form
+ {
+ private readonly Abstracts db;
+ public FormComments(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComment));
+ if (service is FormComment form)
+ {
+ form.CommentId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void buttonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ try
+ {
+ int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ db.DeleteComment(id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComment));
+ if (service is FormComment form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void DatesForm_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = db.GetComments();
+ dataGridView1.DataSource = list;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormComments.resx b/SUBD_LABA/View/FormComments.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormComments.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormLocation.Designer.cs b/SUBD_LABA/View/FormLocation.Designer.cs
new file mode 100644
index 0000000..f1e7363
--- /dev/null
+++ b/SUBD_LABA/View/FormLocation.Designer.cs
@@ -0,0 +1,118 @@
+namespace View
+{
+ partial class FormLocation
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ textBox1 = new TextBox();
+ textBox2 = new TextBox();
+ label1 = new Label();
+ label2 = new Label();
+ button1 = new Button();
+ button2 = new Button();
+ SuspendLayout();
+ //
+ // textBox1
+ //
+ textBox1.Location = new Point(253, 33);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(268, 27);
+ textBox1.TabIndex = 0;
+ //
+ // textBox2
+ //
+ textBox2.Location = new Point(253, 96);
+ textBox2.Name = "textBox2";
+ textBox2.Size = new Size(268, 27);
+ textBox2.TabIndex = 1;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(53, 36);
+ label1.Name = "label1";
+ label1.Size = new Size(77, 20);
+ label1.TabIndex = 2;
+ label1.Text = "Название";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(53, 99);
+ label2.Name = "label2";
+ label2.Size = new Size(145, 20);
+ label2.TabIndex = 3;
+ label2.Text = "Короткое название";
+ //
+ // button1
+ //
+ button1.Location = new Point(69, 171);
+ button1.Name = "button1";
+ button1.Size = new Size(94, 29);
+ button1.TabIndex = 4;
+ button1.Text = "Сохранить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += button1_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(352, 171);
+ button2.Name = "button2";
+ button2.Size = new Size(94, 29);
+ button2.TabIndex = 5;
+ button2.Text = "Отмена";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += button2_Click;
+ //
+ // FormLocation
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(533, 224);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(textBox2);
+ Controls.Add(textBox1);
+ Name = "FormLocation";
+ Text = "FormLocation";
+ Load += FormLocation_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private TextBox textBox1;
+ private TextBox textBox2;
+ private Label label1;
+ private Label label2;
+ private Button button1;
+ private Button button2;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormLocation.cs b/SUBD_LABA/View/FormLocation.cs
new file mode 100644
index 0000000..3ab49a2
--- /dev/null
+++ b/SUBD_LABA/View/FormLocation.cs
@@ -0,0 +1,61 @@
+using Commentbase;
+using Microsoft.VisualBasic.ApplicationServices;
+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 View
+{
+ public partial class FormLocation : Form
+ {
+ public int? LocationId { get; set; }
+ private Abstracts db;
+ public FormLocation(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void FormLocation_Load(object sender, EventArgs e)
+ {
+ if (LocationId.HasValue)
+ {
+ var location = db.GetLocation(LocationId.Value);
+ textBox1.Text = location.Name;
+ textBox2.Text = location.ShortName;
+ }
+ }
+ private void button1_Click(object sender, EventArgs e)
+ {
+ if (LocationId.HasValue)
+ {
+ db.UpdateLocation(new()
+ {
+ Id = LocationId.Value,
+ Name = textBox1.Text,
+ ShortName = textBox2.Text
+ });
+ }
+ else
+ {
+ db.CreateLocation(new()
+ {
+ Name = textBox1.Text,
+ ShortName = textBox2.Text
+ });
+ }
+ DialogResult = DialogResult.OK;
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormLocation.resx b/SUBD_LABA/View/FormLocation.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormLocation.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormLocations.Designer.cs b/SUBD_LABA/View/FormLocations.Designer.cs
new file mode 100644
index 0000000..baf7a72
--- /dev/null
+++ b/SUBD_LABA/View/FormLocations.Designer.cs
@@ -0,0 +1,114 @@
+namespace View
+{
+ partial class FormLocations
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView1 = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView1
+ //
+ dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView1.Location = new Point(12, 12);
+ dataGridView1.Name = "dataGridView1";
+ dataGridView1.RowHeadersWidth = 51;
+ dataGridView1.RowTemplate.Height = 29;
+ dataGridView1.Size = new Size(637, 426);
+ dataGridView1.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(683, 38);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(94, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += buttonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(683, 103);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(94, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(683, 171);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(94, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(683, 237);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(94, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += buttonReload_Click;
+ //
+ // FormLocations
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView1);
+ Name = "FormLocations";
+ Text = "FormLocations";
+ Load += FormLocations_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView1;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormLocations.cs b/SUBD_LABA/View/FormLocations.cs
new file mode 100644
index 0000000..389366d
--- /dev/null
+++ b/SUBD_LABA/View/FormLocations.cs
@@ -0,0 +1,105 @@
+using Commentbase;
+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 View
+{
+ public partial class FormLocations : Form
+ {
+ private Abstracts db;
+ public FormLocations(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void buttonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ var service = Program.ServiceProvider?.GetService(typeof(FormLocation));
+ if (service is FormLocation form)
+ {
+ form.LocationId = id;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ try
+ {
+ db.DeleteLocation(id);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormLocation));
+ if (service is FormLocation form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ if (dataGridView1.ColumnCount == 0)
+ {
+ dataGridView1.Columns.Add("Id", "Id");
+ dataGridView1.Columns.Add("Name", "Name");
+ dataGridView1.Columns.Add("ShortName", "Shortname");
+ }
+
+ var list = db.GetLocations();
+ if (list != null)
+ {
+ dataGridView1.Rows.Clear();
+ foreach (var location in list)
+ {
+ dataGridView1.Rows.Add(location.Id, location.Name, location.ShortName);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormLocations_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormLocations.resx b/SUBD_LABA/View/FormLocations.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormLocations.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormPhoto.Designer.cs b/SUBD_LABA/View/FormPhoto.Designer.cs
new file mode 100644
index 0000000..ea6f4df
--- /dev/null
+++ b/SUBD_LABA/View/FormPhoto.Designer.cs
@@ -0,0 +1,253 @@
+namespace View
+{
+ partial class FormPhoto
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ comboBoxAlbum = new ComboBox();
+ comboBoxLocation = new ComboBox();
+ comboBoxAuthor = new ComboBox();
+ textBox1 = new TextBox();
+ textBox2 = new TextBox();
+ textBox3 = new TextBox();
+ dateTimePicker1 = new DateTimePicker();
+ textBox4 = new TextBox();
+ label1 = new Label();
+ label2 = new Label();
+ label3 = new Label();
+ label4 = new Label();
+ label5 = new Label();
+ label6 = new Label();
+ label7 = new Label();
+ label8 = new Label();
+ button1 = new Button();
+ button2 = new Button();
+ SuspendLayout();
+ //
+ // comboBoxAlbum
+ //
+ comboBoxAlbum.FormattingEnabled = true;
+ comboBoxAlbum.Location = new Point(260, 259);
+ comboBoxAlbum.Name = "comboBoxAlbum";
+ comboBoxAlbum.Size = new Size(294, 28);
+ comboBoxAlbum.TabIndex = 0;
+ //
+ // comboBoxLocation
+ //
+ comboBoxLocation.FormattingEnabled = true;
+ comboBoxLocation.Location = new Point(260, 310);
+ comboBoxLocation.Name = "comboBoxLocation";
+ comboBoxLocation.Size = new Size(294, 28);
+ comboBoxLocation.TabIndex = 1;
+ //
+ // comboBoxAuthor
+ //
+ comboBoxAuthor.FormattingEnabled = true;
+ comboBoxAuthor.Location = new Point(260, 364);
+ comboBoxAuthor.Name = "comboBoxAuthor";
+ comboBoxAuthor.Size = new Size(294, 28);
+ comboBoxAuthor.TabIndex = 2;
+ //
+ // textBox1
+ //
+ textBox1.Location = new Point(260, 23);
+ textBox1.Name = "textBox1";
+ textBox1.Size = new Size(294, 27);
+ textBox1.TabIndex = 3;
+ //
+ // textBox2
+ //
+ textBox2.Location = new Point(260, 68);
+ textBox2.Name = "textBox2";
+ textBox2.Size = new Size(294, 27);
+ textBox2.TabIndex = 4;
+ //
+ // textBox3
+ //
+ textBox3.Location = new Point(260, 114);
+ textBox3.Name = "textBox3";
+ textBox3.Size = new Size(294, 27);
+ textBox3.TabIndex = 5;
+ //
+ // dateTimePicker1
+ //
+ dateTimePicker1.Location = new Point(260, 162);
+ dateTimePicker1.Name = "dateTimePicker1";
+ dateTimePicker1.Size = new Size(294, 27);
+ dateTimePicker1.TabIndex = 6;
+ //
+ // textBox4
+ //
+ textBox4.Location = new Point(260, 210);
+ textBox4.Name = "textBox4";
+ textBox4.Size = new Size(294, 27);
+ textBox4.TabIndex = 7;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(35, 26);
+ label1.Name = "label1";
+ label1.Size = new Size(77, 20);
+ label1.TabIndex = 8;
+ label1.Text = "Название";
+ //
+ // label2
+ //
+ label2.AutoSize = true;
+ label2.Location = new Point(35, 71);
+ label2.Name = "label2";
+ label2.Size = new Size(79, 20);
+ label2.TabIndex = 9;
+ label2.Text = "Описание";
+ //
+ // label3
+ //
+ label3.AutoSize = true;
+ label3.Location = new Point(35, 117);
+ label3.Name = "label3";
+ label3.Size = new Size(99, 20);
+ label3.TabIndex = 10;
+ label3.Text = "Приватность";
+ //
+ // label4
+ //
+ label4.AutoSize = true;
+ label4.Location = new Point(35, 167);
+ label4.Name = "label4";
+ label4.Size = new Size(105, 20);
+ label4.TabIndex = 11;
+ label4.Text = "Дата загрузки";
+ //
+ // label5
+ //
+ label5.AutoSize = true;
+ label5.Location = new Point(35, 213);
+ label5.Name = "label5";
+ label5.Size = new Size(130, 20);
+ label5.TabIndex = 12;
+ label5.Text = "Путь фотографии";
+ //
+ // label6
+ //
+ label6.AutoSize = true;
+ label6.Location = new Point(35, 262);
+ label6.Name = "label6";
+ label6.Size = new Size(64, 20);
+ label6.TabIndex = 13;
+ label6.Text = "Альбом";
+ //
+ // label7
+ //
+ label7.AutoSize = true;
+ label7.Location = new Point(35, 313);
+ label7.Name = "label7";
+ label7.Size = new Size(69, 20);
+ label7.TabIndex = 14;
+ label7.Text = "Локация";
+ //
+ // label8
+ //
+ label8.AutoSize = true;
+ label8.Location = new Point(35, 367);
+ label8.Name = "label8";
+ label8.Size = new Size(51, 20);
+ label8.TabIndex = 15;
+ label8.Text = "Автор";
+ //
+ // button1
+ //
+ button1.Location = new Point(80, 421);
+ button1.Name = "button1";
+ button1.Size = new Size(94, 29);
+ button1.TabIndex = 16;
+ button1.Text = "Сохранить";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += button1_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(380, 421);
+ button2.Name = "button2";
+ button2.Size = new Size(94, 29);
+ button2.TabIndex = 17;
+ button2.Text = "Отмена";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += button2_Click;
+ //
+ // FormPhoto
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(566, 462);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ Controls.Add(label8);
+ Controls.Add(label7);
+ Controls.Add(label6);
+ Controls.Add(label5);
+ Controls.Add(label4);
+ Controls.Add(label3);
+ Controls.Add(label2);
+ Controls.Add(label1);
+ Controls.Add(textBox4);
+ Controls.Add(dateTimePicker1);
+ Controls.Add(textBox3);
+ Controls.Add(textBox2);
+ Controls.Add(textBox1);
+ Controls.Add(comboBoxAuthor);
+ Controls.Add(comboBoxLocation);
+ Controls.Add(comboBoxAlbum);
+ Name = "FormPhoto";
+ Text = "FormPhoto";
+ Load += FormPhoto_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private ComboBox comboBoxAlbum;
+ private ComboBox comboBoxLocation;
+ private ComboBox comboBoxAuthor;
+ private TextBox textBox1;
+ private TextBox textBox2;
+ private TextBox textBox3;
+ private DateTimePicker dateTimePicker1;
+ private TextBox textBox4;
+ private Label label1;
+ private Label label2;
+ private Label label3;
+ private Label label4;
+ private Label label5;
+ private Label label6;
+ private Label label7;
+ private Label label8;
+ private Button button1;
+ private Button button2;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormPhoto.cs b/SUBD_LABA/View/FormPhoto.cs
new file mode 100644
index 0000000..c5d1fb5
--- /dev/null
+++ b/SUBD_LABA/View/FormPhoto.cs
@@ -0,0 +1,103 @@
+using Commentbase;
+using Database;
+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 View
+{
+ public partial class FormPhoto : Form
+ {
+ public int? PhotoId { get; set; }
+ private Abstracts db;
+ public FormPhoto(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void button1_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (PhotoId.HasValue)
+ {
+ db.UpdatePhoto(new()
+ {
+ Id = PhotoId.Value,
+ Title = textBox1.Text,
+ Description = textBox2.Text,
+ Privacy = textBox3.Text,
+ UploadDate = dateTimePicker1.Value,
+ ImagePath = textBox4.Text,
+ AlbumId = (comboBoxAlbum.SelectedItem as Album).Id,
+ LocationId = (comboBoxLocation.SelectedItem as Location).Id,
+ AuthorId = (comboBoxAuthor.SelectedItem as Author).Id
+ });
+ }
+ else
+ {
+ db.CreatePhoto(new()
+ {
+ Title = textBox1.Text,
+ Description = textBox2.Text,
+ Privacy = textBox3.Text,
+ UploadDate = dateTimePicker1.Value,
+ ImagePath = textBox4.Text,
+ AlbumId = (comboBoxAlbum.SelectedItem as Album).Id,
+ LocationId = (comboBoxLocation.SelectedItem as Location).Id,
+ AuthorId = (comboBoxAuthor.SelectedItem as Author).Id
+ });
+ }
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var albums = db.GetAlbums();
+ var locations = db.GetLocations();
+ var authors = db.GetAuthors();
+ comboBoxAlbum.DataSource = albums;
+ comboBoxLocation.DataSource = locations;
+ comboBoxAuthor.DataSource = authors;
+
+ comboBoxAlbum.DisplayMember = "Title";
+ comboBoxLocation.DisplayMember = "Name";
+ comboBoxAuthor.DisplayMember = "Name";
+
+ comboBoxAlbum.ValueMember = "Id";
+ comboBoxLocation.ValueMember = "Id";
+ comboBoxAuthor.ValueMember = "Id";
+
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void FormPhoto_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormPhoto.resx b/SUBD_LABA/View/FormPhoto.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormPhoto.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormPhotos.Designer.cs b/SUBD_LABA/View/FormPhotos.Designer.cs
new file mode 100644
index 0000000..227da6f
--- /dev/null
+++ b/SUBD_LABA/View/FormPhotos.Designer.cs
@@ -0,0 +1,114 @@
+namespace View
+{
+ partial class FormPhotos
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView1 = new DataGridView();
+ buttonCreate = new Button();
+ buttonUpdate = new Button();
+ buttonDelete = new Button();
+ buttonReload = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView1
+ //
+ dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView1.Location = new Point(12, 12);
+ dataGridView1.Name = "dataGridView1";
+ dataGridView1.RowHeadersWidth = 51;
+ dataGridView1.RowTemplate.Height = 29;
+ dataGridView1.Size = new Size(636, 426);
+ dataGridView1.TabIndex = 0;
+ //
+ // buttonCreate
+ //
+ buttonCreate.Location = new Point(680, 42);
+ buttonCreate.Name = "buttonCreate";
+ buttonCreate.Size = new Size(94, 29);
+ buttonCreate.TabIndex = 1;
+ buttonCreate.Text = "Создать";
+ buttonCreate.UseVisualStyleBackColor = true;
+ buttonCreate.Click += buttonCreate_Click;
+ //
+ // buttonUpdate
+ //
+ buttonUpdate.Location = new Point(680, 113);
+ buttonUpdate.Name = "buttonUpdate";
+ buttonUpdate.Size = new Size(94, 29);
+ buttonUpdate.TabIndex = 2;
+ buttonUpdate.Text = "Изменить";
+ buttonUpdate.UseVisualStyleBackColor = true;
+ buttonUpdate.Click += buttonUpdate_Click;
+ //
+ // buttonDelete
+ //
+ buttonDelete.Location = new Point(680, 181);
+ buttonDelete.Name = "buttonDelete";
+ buttonDelete.Size = new Size(94, 29);
+ buttonDelete.TabIndex = 3;
+ buttonDelete.Text = "Удалить";
+ buttonDelete.UseVisualStyleBackColor = true;
+ buttonDelete.Click += buttonDelete_Click;
+ //
+ // buttonReload
+ //
+ buttonReload.Location = new Point(680, 257);
+ buttonReload.Name = "buttonReload";
+ buttonReload.Size = new Size(94, 29);
+ buttonReload.TabIndex = 4;
+ buttonReload.Text = "Обновить";
+ buttonReload.UseVisualStyleBackColor = true;
+ buttonReload.Click += buttonReload_Click;
+ //
+ // FormPhotos
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(800, 450);
+ Controls.Add(buttonReload);
+ Controls.Add(buttonDelete);
+ Controls.Add(buttonUpdate);
+ Controls.Add(buttonCreate);
+ Controls.Add(dataGridView1);
+ Name = "FormPhotos";
+ Text = "FormPhotos";
+ Load += FormPhotos_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView dataGridView1;
+ private Button buttonCreate;
+ private Button buttonUpdate;
+ private Button buttonDelete;
+ private Button buttonReload;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/FormPhotos.cs b/SUBD_LABA/View/FormPhotos.cs
new file mode 100644
index 0000000..520eeb4
--- /dev/null
+++ b/SUBD_LABA/View/FormPhotos.cs
@@ -0,0 +1,89 @@
+using Commentbase;
+using Microsoft.VisualBasic;
+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 View
+{
+ public partial class FormPhotos : Form
+ {
+ private readonly Abstracts db;
+ public FormPhotos(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void buttonUpdate_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPhoto));
+ if (service is FormPhoto form)
+ {
+ form.PhotoId = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+ private void buttonDelete_Click(object sender, EventArgs e)
+ {
+ if (dataGridView1.SelectedRows.Count == 1)
+ {
+ try
+ {
+ int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ db.DeletePhoto(id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void buttonReload_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void buttonCreate_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPhoto));
+ if (service is FormPhoto form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void FormPhotos_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ try
+ {
+ var list = db.GetPhotos();
+ dataGridView1.DataSource = list;
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}
diff --git a/SUBD_LABA/View/FormPhotos.resx b/SUBD_LABA/View/FormPhotos.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/FormPhotos.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/MainForm.Designer.cs b/SUBD_LABA/View/MainForm.Designer.cs
new file mode 100644
index 0000000..daeecaf
--- /dev/null
+++ b/SUBD_LABA/View/MainForm.Designer.cs
@@ -0,0 +1,306 @@
+namespace View
+{
+ partial class MainForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ button1 = new Button();
+ button2 = new Button();
+ button3 = new Button();
+ button4 = new Button();
+ button5 = new Button();
+ button6 = new Button();
+ button7 = new Button();
+ button8 = new Button();
+ button9 = new Button();
+ button10 = new Button();
+ button11 = new Button();
+ button12 = new Button();
+ button13 = new Button();
+ button14 = new Button();
+ button15 = new Button();
+ button16 = new Button();
+ button17 = new Button();
+ button18 = new Button();
+ button19 = new Button();
+ button20 = new Button();
+ SuspendLayout();
+ //
+ // button1
+ //
+ button1.Location = new Point(41, 32);
+ button1.Name = "button1";
+ button1.Size = new Size(137, 29);
+ button1.TabIndex = 0;
+ button1.Text = "Альбом";
+ button1.UseVisualStyleBackColor = true;
+ button1.Click += button1_Click;
+ //
+ // button2
+ //
+ button2.Location = new Point(243, 32);
+ button2.Name = "button2";
+ button2.Size = new Size(137, 29);
+ button2.TabIndex = 1;
+ button2.Text = "Локация";
+ button2.UseVisualStyleBackColor = true;
+ button2.Click += button2_Click;
+ //
+ // button3
+ //
+ button3.Location = new Point(451, 32);
+ button3.Name = "button3";
+ button3.Size = new Size(137, 29);
+ button3.TabIndex = 2;
+ button3.Text = "Автор";
+ button3.UseVisualStyleBackColor = true;
+ button3.Click += button3_Click;
+ //
+ // button4
+ //
+ button4.Location = new Point(675, 32);
+ button4.Name = "button4";
+ button4.Size = new Size(137, 29);
+ button4.TabIndex = 3;
+ button4.Text = "Фотография";
+ button4.UseVisualStyleBackColor = true;
+ button4.Click += button4_Click;
+ //
+ // button5
+ //
+ button5.Location = new Point(922, 32);
+ button5.Name = "button5";
+ button5.Size = new Size(137, 29);
+ button5.TabIndex = 4;
+ button5.Text = "Комментарий";
+ button5.UseVisualStyleBackColor = true;
+ button5.Click += button5_Click;
+ //
+ // button6
+ //
+ button6.Location = new Point(12, 120);
+ button6.Name = "button6";
+ button6.Size = new Size(189, 29);
+ button6.TabIndex = 5;
+ button6.Text = "Создать 1000 альбомов";
+ button6.UseVisualStyleBackColor = true;
+ button6.Click += button6_Click;
+ //
+ // button7
+ //
+ button7.Location = new Point(216, 120);
+ button7.Name = "button7";
+ button7.Size = new Size(189, 29);
+ button7.TabIndex = 6;
+ button7.Text = "Создать 1000 локаций";
+ button7.UseVisualStyleBackColor = true;
+ button7.Click += button7_Click;
+ //
+ // button8
+ //
+ button8.Location = new Point(424, 120);
+ button8.Name = "button8";
+ button8.Size = new Size(189, 29);
+ button8.TabIndex = 7;
+ button8.Text = "Создать 1000 авторов";
+ button8.UseVisualStyleBackColor = true;
+ button8.Click += button8_Click;
+ //
+ // button9
+ //
+ button9.Location = new Point(650, 120);
+ button9.Name = "button9";
+ button9.Size = new Size(201, 29);
+ button9.TabIndex = 8;
+ button9.Text = "Создать 1000 фотографий";
+ button9.UseVisualStyleBackColor = true;
+ button9.Click += button9_Click;
+ //
+ // button10
+ //
+ button10.Location = new Point(880, 120);
+ button10.Name = "button10";
+ button10.Size = new Size(218, 29);
+ button10.TabIndex = 9;
+ button10.Text = "Создать 1000 комментариев";
+ button10.UseVisualStyleBackColor = true;
+ button10.Click += button10_Click;
+ //
+ // button11
+ //
+ button11.Location = new Point(12, 187);
+ button11.Name = "button11";
+ button11.Size = new Size(198, 29);
+ button11.TabIndex = 10;
+ button11.Text = "Изменить 1000 альбомов";
+ button11.UseVisualStyleBackColor = true;
+ button11.Click += button11_Click;
+ //
+ // button12
+ //
+ button12.Location = new Point(216, 187);
+ button12.Name = "button12";
+ button12.Size = new Size(189, 29);
+ button12.TabIndex = 11;
+ button12.Text = "Изменить 1000 локаций";
+ button12.UseVisualStyleBackColor = true;
+ button12.Click += button12_Click;
+ //
+ // button13
+ //
+ button13.Location = new Point(424, 187);
+ button13.Name = "button13";
+ button13.Size = new Size(189, 29);
+ button13.TabIndex = 12;
+ button13.Text = "Изменить 1000 авторов";
+ button13.UseVisualStyleBackColor = true;
+ button13.Click += button13_Click;
+ //
+ // button14
+ //
+ button14.Location = new Point(639, 187);
+ button14.Name = "button14";
+ button14.Size = new Size(224, 29);
+ button14.TabIndex = 13;
+ button14.Text = "Изменить 1000 фотографий";
+ button14.UseVisualStyleBackColor = true;
+ button14.Click += button14_Click;
+ //
+ // button15
+ //
+ button15.Location = new Point(869, 187);
+ button15.Name = "button15";
+ button15.Size = new Size(239, 29);
+ button15.TabIndex = 14;
+ button15.Text = "Изменить 1000 комментариев";
+ button15.UseVisualStyleBackColor = true;
+ button15.Click += button15_Click;
+ //
+ // button16
+ //
+ button16.Location = new Point(12, 257);
+ button16.Name = "button16";
+ button16.Size = new Size(198, 29);
+ button16.TabIndex = 15;
+ button16.Text = "Удалить 1000 альбомов";
+ button16.UseVisualStyleBackColor = true;
+ button16.Click += button16_Click;
+ //
+ // button17
+ //
+ button17.Location = new Point(216, 257);
+ button17.Name = "button17";
+ button17.Size = new Size(189, 29);
+ button17.TabIndex = 16;
+ button17.Text = "Удалить 1000 локаций";
+ button17.UseVisualStyleBackColor = true;
+ button17.Click += button17_Click;
+ //
+ // button18
+ //
+ button18.Location = new Point(424, 257);
+ button18.Name = "button18";
+ button18.Size = new Size(189, 29);
+ button18.TabIndex = 17;
+ button18.Text = "Удалить 1000 авторов";
+ button18.UseVisualStyleBackColor = true;
+ button18.Click += button18_Click;
+ //
+ // button19
+ //
+ button19.Location = new Point(639, 257);
+ button19.Name = "button19";
+ button19.Size = new Size(224, 29);
+ button19.TabIndex = 18;
+ button19.Text = "Удалить 1000 фотографий";
+ button19.UseVisualStyleBackColor = true;
+ button19.Click += button19_Click;
+ //
+ // button20
+ //
+ button20.Location = new Point(869, 257);
+ button20.Name = "button20";
+ button20.Size = new Size(239, 29);
+ button20.TabIndex = 19;
+ button20.Text = "Удалить 1000 комментариев";
+ button20.UseVisualStyleBackColor = true;
+ button20.Click += button20_Click;
+ //
+ // MainForm
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1131, 318);
+ Controls.Add(button20);
+ Controls.Add(button19);
+ Controls.Add(button18);
+ Controls.Add(button17);
+ Controls.Add(button16);
+ Controls.Add(button15);
+ Controls.Add(button14);
+ Controls.Add(button13);
+ Controls.Add(button12);
+ Controls.Add(button11);
+ Controls.Add(button10);
+ Controls.Add(button9);
+ Controls.Add(button8);
+ Controls.Add(button7);
+ Controls.Add(button6);
+ Controls.Add(button5);
+ Controls.Add(button4);
+ Controls.Add(button3);
+ Controls.Add(button2);
+ Controls.Add(button1);
+ Name = "MainForm";
+ Text = "MainForm";
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button button1;
+ private Button button2;
+ private Button button3;
+ private Button button4;
+ private Button button5;
+ private Button button6;
+ private Button button7;
+ private Button button8;
+ private Button button9;
+ private Button button10;
+ private Button button11;
+ private Button button12;
+ private Button button13;
+ private Button button14;
+ private Button button15;
+ private Button button16;
+ private Button button17;
+ private Button button18;
+ private Button button19;
+ private Button button20;
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/MainForm.cs b/SUBD_LABA/View/MainForm.cs
new file mode 100644
index 0000000..33c6a52
--- /dev/null
+++ b/SUBD_LABA/View/MainForm.cs
@@ -0,0 +1,308 @@
+using Commentbase;
+using Database;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace View
+{
+ public partial class MainForm : Form
+ {
+ private readonly Abstracts db;
+ public MainForm(Abstracts abstracts)
+ {
+ InitializeComponent();
+ db = abstracts;
+ }
+ private void button1_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormAlbums));
+ if (service is FormAlbums form)
+ {
+ form.Show();
+ }
+ }
+ private void button2_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormLocations));
+ if (service is FormLocations form)
+ {
+ form.Show();
+ }
+ }
+ private void button3_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormAuthors));
+ if (service is FormAuthors form)
+ {
+ form.Show();
+ }
+ }
+ private void button4_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormPhotos));
+ if (service is FormPhotos form)
+ {
+ form.Show();
+ }
+ }
+ private void button5_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormComments));
+ if (service is FormComments form)
+ {
+ form.Show();
+ }
+ }
+ private void button6_Click(object sender, EventArgs e)
+ {
+ string Title = "Шикарный альбом";
+ string Description = "Тут даже нечего сказать";
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.CreateAlbum(new()
+ {
+ Title = $"{Title}{i}",
+ Description = $"{Description}{i}"
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button7_Click(object sender, EventArgs e)
+ {
+ string Name = "Москва, Россия";
+ string ShortName = "RUS";
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.CreateLocation(new()
+ {
+ Name = $"{Name}{i}",
+ ShortName = $"{ShortName}{i}"
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button8_Click(object sender, EventArgs e)
+ {
+ string Name = "Эрик Житель";
+ string PhoneNum = "+79999999999";
+ string Email = "laba@mail.ru";
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.CreateAuthor(new()
+ {
+ Name = $"{Name}{i}",
+ PhoneNum = $"{PhoneNum}{i}",
+ Email = $"{Email}{i}"
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button9_Click(object sender, EventArgs e)
+ {
+ string Title = "image";
+ string Description = "photo";
+ string Privacy = "Общий доступ";
+ DateTime UploadData = DateTime.Now;
+ string ImagePath = "Image/Ch8cfe8vfevb";
+ Album albumId = db.GetAlbum("Шикарный альбом0");
+ Location locationId = db.GetLocation("Москва, Россия0");
+ Author authorId = db.GetAuthor("Эрик Житель0");
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.CreatePhoto(new()
+ {
+ Title = $"{Title}{i}",
+ Description = $"{Description}{i}",
+ Privacy = $"{Privacy}{i}",
+ UploadDate = UploadData,
+ ImagePath = $"{ImagePath}{i}",
+ AlbumId = albumId.Id + i,
+ LocationId = locationId.Id + i,
+ AuthorId = authorId.Id + i
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button10_Click(object sender, EventArgs e)
+ {
+ DateTime PostDate = DateTime.Now;
+ string Content = "Вай, как круто!";
+ Album albumId = db.GetAlbum("Шикарный альбом0");
+ Location locationId = db.GetLocation("Москва, Россия0");
+ Author authorId = db.GetAuthor("Эрик Житель0");
+ Photo photoId = db.GetPhoto(albumId.Id, locationId.Id, authorId.Id);
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.CreateComment(new()
+ {
+ PostDate = PostDate,
+ Content = $"{Content}{i}",
+ PhotoId = photoId.Id + i
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button11_Click(object sender, EventArgs e)
+ {
+ Album AlbumId = db.GetAlbum("Шикарный альбом0");
+ string Title = "Шикарный альбом1";
+ string Description = "Тут даже нечего сказать опять";
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.UpdateAlbum(new()
+ {
+ Id = AlbumId.Id + i,
+ Title = $"{Title}{i}",
+ Description = $"{Description}{i}"
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button12_Click(object sender, EventArgs e)
+ {
+ Location locationId = db.GetLocation("Москва, Россия0");
+ string Name = "Рим, Италия";
+ string ShortName = "ITA";
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.UpdateLocation(new()
+ {
+ Id = locationId.Id + i,
+ Name = $"{Name}{i}",
+ ShortName = $"{ShortName}{i}"
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button13_Click(object sender, EventArgs e)
+ {
+ Author authorId = db.GetAuthor("Эрик Житель0");
+ string Name = "Chel";
+ string PhoneNum = "+79991112233";
+ string Email = "laba4@mail.ru";
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.UpdateAuthor(new()
+ {
+ Id = authorId.Id + i,
+ Name = $"{Name}{i}",
+ PhoneNum = $"{PhoneNum}{i}",
+ Email = $"{Email}{i}"
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button14_Click(object sender, EventArgs e)
+ {
+ string Title = "image";
+ string Description = "photo";
+ string Privacy = "Общий доступ";
+ DateTime UploadData = DateTime.Now;
+ string ImagePath = "Image/sndbkKSB23842KJH";
+ Album albumId = db.GetAlbum("Шикарный альбом0");
+ Location locationId = db.GetLocation("Москва, Россия0");
+ Author authorId = db.GetAuthor("Эрик Житель0");
+ Photo photo = db.GetPhoto(albumId.Id, locationId.Id, authorId.Id);
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.UpdatePhoto(new()
+ {
+ Id = photo.Id + i,
+ Title = $"{Title}{i}",
+ Description = $"{Description}{i}",
+ Privacy = $"{Privacy}{i}",
+ UploadDate = UploadData,
+ ImagePath = $"{ImagePath}{i}",
+ AlbumId = albumId.Id + i,
+ LocationId = locationId.Id + i,
+ AuthorId = authorId.Id + i
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button15_Click(object sender, EventArgs e)
+ {
+ DateTime PostDate = DateTime.Now;
+ string Content = "О боже мой!";
+ Album albumId = db.GetAlbum("Шикарный альбом0");
+ Location locationId = db.GetLocation("Москва, Россия0");
+ Author authorId = db.GetAuthor("Эрик Житель0");
+ Photo photo = db.GetPhoto(albumId.Id, locationId.Id, authorId.Id);
+ Comment comment = db.GetComment(photo.Id);
+ DateTime start = DateTime.Now;
+ for (int i = 0; i < 1000; i++)
+ {
+ db.UpdateComment(new()
+ {
+ Id = comment.Id + i,
+ PostDate = PostDate,
+ Content = $"{Content}{i}",
+ PhotoId = photo.Id + i
+ });
+ }
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button16_Click(object sender, EventArgs e)
+ {
+ DateTime start = DateTime.Now;
+ db.DeleteAllAlbums();
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button17_Click(object sender, EventArgs e)
+ {
+ DateTime start = DateTime.Now;
+ db.DeleteAllLocations();
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button18_Click(object sender, EventArgs e)
+ {
+ DateTime start = DateTime.Now;
+ db.DeleteAllAuthors();
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button19_Click(object sender, EventArgs e)
+ {
+ DateTime start = DateTime.Now;
+ db.DeleteAllPhotos();
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ private void button20_Click(object sender, EventArgs e)
+ {
+ DateTime start = DateTime.Now;
+ db.DeleteAllComments();
+ DateTime end = DateTime.Now;
+ MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+}
diff --git a/SUBD_LABA/View/MainForm.resx b/SUBD_LABA/View/MainForm.resx
new file mode 100644
index 0000000..a395bff
--- /dev/null
+++ b/SUBD_LABA/View/MainForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/SUBD_LABA/View/Program.cs b/SUBD_LABA/View/Program.cs
new file mode 100644
index 0000000..5456aa4
--- /dev/null
+++ b/SUBD_LABA/View/Program.cs
@@ -0,0 +1,39 @@
+using Microsoft.Extensions.DependencyInjection;
+using Database;
+using System;
+using Commentbase;
+using Microsoft.VisualBasic;
+
+namespace View
+{
+ public static class Program
+ {
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
+ [STAThread]
+ public static void Main()
+ {
+ ApplicationConfiguration.Initialize();
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+ Application.Run(_serviceProvider.GetRequiredService());
+ }
+
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ }
+ }
+}
\ No newline at end of file
diff --git a/SUBD_LABA/View/View.csproj b/SUBD_LABA/View/View.csproj
new file mode 100644
index 0000000..3a85ec5
--- /dev/null
+++ b/SUBD_LABA/View/View.csproj
@@ -0,0 +1,19 @@
+
+
+
+ WinExe
+ net6.0-windows
+ enable
+ true
+ enable
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file