Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
26e699c393 | |||
9494d07ff5 | |||
e1a8670392 |
52
SUBD_LABA/Database/Abstracts.cs
Normal file
52
SUBD_LABA/Database/Abstracts.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Commentbase
|
||||
{
|
||||
public abstract class Abstracts
|
||||
{
|
||||
public abstract void CreateAlbum(Album album);
|
||||
public abstract void UpdateAlbum(Album album);
|
||||
public abstract void DeleteAlbum(int id);
|
||||
public abstract Album GetAlbum(int id);
|
||||
public abstract Album GetAlbum(string title);
|
||||
public abstract List<Album> GetAlbums();
|
||||
public abstract void DeleteAllAlbums();
|
||||
|
||||
public abstract void CreateLocation(Location location);
|
||||
public abstract void UpdateLocation(Location location);
|
||||
public abstract void DeleteLocation(int id);
|
||||
public abstract Location GetLocation(int id);
|
||||
public abstract Location GetLocation(string name);
|
||||
public abstract List<Location> GetLocations();
|
||||
public abstract void DeleteAllLocations();
|
||||
|
||||
public abstract void CreatePhoto(Photo photo);
|
||||
public abstract void UpdatePhoto(Photo photo);
|
||||
public abstract void DeletePhoto(int id);
|
||||
public abstract Photo GetPhoto(int id);
|
||||
public abstract Photo GetPhoto(int AlbumId, int LocationId, int AuthorId);
|
||||
public abstract List<Photo> GetPhotos();
|
||||
public abstract void DeleteAllPhotos();
|
||||
|
||||
public abstract void CreateAuthor(Author author);
|
||||
public abstract void UpdateAuthor(Author author);
|
||||
public abstract void DeleteAuthor(int id);
|
||||
public abstract Author GetAuthor(int id);
|
||||
public abstract Author GetAuthor(string name);
|
||||
public abstract List<Author> GetAuthors();
|
||||
public abstract void DeleteAllAuthors();
|
||||
|
||||
public abstract void CreateComment(Comment comment);
|
||||
public abstract void UpdateComment(Comment comment);
|
||||
public abstract void DeleteComment(int id);
|
||||
public abstract Comment GetComment(int id);
|
||||
public abstract Comment GetCommentPhoto(int PhotoId);
|
||||
public abstract List<Comment> GetComments();
|
||||
public abstract void DeleteAllComments();
|
||||
}
|
||||
}
|
15
SUBD_LABA/Database/Database.csproj
Normal file
15
SUBD_LABA/Database/Database.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MongoDB.Bson" Version="2.25.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.25.0" />
|
||||
<PackageReference Include="Npgsql" Version="8.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
244
SUBD_LABA/Database/ImplementsMongoDB.cs
Normal file
244
SUBD_LABA/Database/ImplementsMongoDB.cs
Normal file
@ -0,0 +1,244 @@
|
||||
using Commentbase;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Database
|
||||
{
|
||||
public class ImplementsMongoDB : Abstracts
|
||||
{
|
||||
private IMongoDatabase _database;
|
||||
private IMongoCollection<Album> _albumCollection;
|
||||
private IMongoCollection<Location> _locationCollection;
|
||||
private IMongoCollection<Author> _authorCollection;
|
||||
private IMongoCollection<Photo> _photoCollection;
|
||||
private IMongoCollection<Comment> _commentCollection;
|
||||
private IMongoCollection<Sequence> _sequenceCollection;
|
||||
|
||||
public ImplementsMongoDB()
|
||||
{
|
||||
var client = new MongoClient("mongodb://localhost:27017");
|
||||
_database = client.GetDatabase("SUBD");
|
||||
|
||||
_albumCollection = _database.GetCollection<Album>("Album");
|
||||
_locationCollection = _database.GetCollection<Location>("Location");
|
||||
_authorCollection = _database.GetCollection<Author>("Author");
|
||||
_photoCollection = _database.GetCollection<Photo>("Photo");
|
||||
_commentCollection = _database.GetCollection<Comment>("Comment");
|
||||
_sequenceCollection = _database.GetCollection<Sequence>("sequence");
|
||||
}
|
||||
//Album
|
||||
public override void CreateAlbum(Album album)
|
||||
{
|
||||
if (album.Id == 0)
|
||||
{
|
||||
Sequence sequence = _sequenceCollection.Find(seq => seq.Id == "Album").FirstOrDefault();
|
||||
sequence.Count++;
|
||||
album.Id = sequence.Count;
|
||||
_sequenceCollection.ReplaceOne(seq => seq.Id == "Album", sequence);
|
||||
}
|
||||
_albumCollection.InsertOne(album);
|
||||
}
|
||||
|
||||
public override List<Album> GetAlbums()
|
||||
{
|
||||
return _albumCollection.Find(_ => true).ToList();
|
||||
}
|
||||
|
||||
public override Album GetAlbum(int id)
|
||||
{
|
||||
return _albumCollection.Find(album => album.Id == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public override void UpdateAlbum(Album album)
|
||||
{
|
||||
_albumCollection.ReplaceOne(c => c.Id == album.Id, album);
|
||||
}
|
||||
|
||||
public override void DeleteAlbum(int id)
|
||||
{
|
||||
_albumCollection.DeleteOne(album => album.Id == id);
|
||||
}
|
||||
public override Album GetAlbum(string title)
|
||||
{
|
||||
return _albumCollection.Find(album => album.Title == title).FirstOrDefault();
|
||||
}
|
||||
public override void DeleteAllAlbums()
|
||||
{
|
||||
_albumCollection.DeleteManyAsync(Builders<Album>.Filter.Empty);
|
||||
}
|
||||
|
||||
// Location
|
||||
public override void CreateLocation(Location location)
|
||||
{
|
||||
if (location.Id == 0)
|
||||
{
|
||||
Sequence sequence = _sequenceCollection.Find(seq => seq.Id == "Location").FirstOrDefault();
|
||||
sequence.Count++;
|
||||
location.Id = sequence.Count;
|
||||
_sequenceCollection.ReplaceOne(seq => seq.Id == "Location", sequence);
|
||||
}
|
||||
_locationCollection.InsertOne(location);
|
||||
}
|
||||
|
||||
public override List<Location> GetLocations()
|
||||
{
|
||||
return _locationCollection.Find(_ => true).ToList();
|
||||
}
|
||||
|
||||
public override Location GetLocation(int id)
|
||||
{
|
||||
return _locationCollection.Find(location => location.Id == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public override void UpdateLocation(Location location)
|
||||
{
|
||||
_locationCollection.ReplaceOne(c => c.Id == location.Id, location);
|
||||
}
|
||||
|
||||
public override void DeleteLocation(int id)
|
||||
{
|
||||
_locationCollection.DeleteOne(location => location.Id == id);
|
||||
}
|
||||
public override Location GetLocation(string name)
|
||||
{
|
||||
return _locationCollection.Find(location => location.Name == name).FirstOrDefault();
|
||||
}
|
||||
public override void DeleteAllLocations()
|
||||
{
|
||||
_locationCollection.DeleteManyAsync(Builders<Location>.Filter.Empty);
|
||||
}
|
||||
|
||||
// Author
|
||||
public override void CreateAuthor(Author author)
|
||||
{
|
||||
if (author.Id == 0)
|
||||
{
|
||||
Sequence sequence = _sequenceCollection.Find(seq => seq.Id == "Author").FirstOrDefault();
|
||||
sequence.Count++;
|
||||
author.Id = sequence.Count;
|
||||
_sequenceCollection.ReplaceOne(seq => seq.Id == "Author", sequence);
|
||||
}
|
||||
_authorCollection.InsertOne(author);
|
||||
}
|
||||
|
||||
public override List<Author> GetAuthors()
|
||||
{
|
||||
return _authorCollection.Find(_ => true).ToList();
|
||||
}
|
||||
|
||||
public override Author GetAuthor(int id)
|
||||
{
|
||||
return _authorCollection.Find(author => author.Id == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public override void UpdateAuthor(Author author)
|
||||
{
|
||||
_authorCollection.ReplaceOne(r => r.Id == author.Id, author);
|
||||
}
|
||||
|
||||
public override void DeleteAuthor(int id)
|
||||
{
|
||||
_authorCollection.DeleteOne(author => author.Id == id);
|
||||
}
|
||||
public override Author GetAuthor(string name)
|
||||
{
|
||||
return _authorCollection.Find(author => author.Name == name).FirstOrDefault();
|
||||
}
|
||||
public override void DeleteAllAuthors()
|
||||
{
|
||||
_authorCollection.DeleteManyAsync(Builders<Author>.Filter.Empty);
|
||||
}
|
||||
|
||||
// Photo
|
||||
public override void CreatePhoto(Photo photo)
|
||||
{
|
||||
if (photo.Id == 0)
|
||||
{
|
||||
Sequence sequence = _sequenceCollection.Find(seq => seq.Id == "Photo").FirstOrDefault();
|
||||
sequence.Count++;
|
||||
photo.Id = sequence.Count;
|
||||
_sequenceCollection.ReplaceOne(seq => seq.Id == "Photo", sequence);
|
||||
}
|
||||
_photoCollection.InsertOne(photo);
|
||||
}
|
||||
|
||||
public override List<Photo> GetPhotos()
|
||||
{
|
||||
return _photoCollection.Find(_ => true).ToList();
|
||||
}
|
||||
|
||||
public override Photo GetPhoto(int id)
|
||||
{
|
||||
return _photoCollection.Find(photo => photo.Id == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public override void UpdatePhoto(Photo photo)
|
||||
{
|
||||
_photoCollection.ReplaceOne(b => b.Id == photo.Id, photo);
|
||||
}
|
||||
|
||||
public override void DeletePhoto(int id)
|
||||
{
|
||||
_photoCollection.DeleteOne(photo => photo.Id == id);
|
||||
}
|
||||
public override Photo GetPhoto(int AlbumId, int LocationId, int AuthorId)
|
||||
{
|
||||
return _photoCollection.Find(photo => (photo.AlbumId == AlbumId && photo.LocationId == LocationId && photo.AuthorId == AuthorId)).FirstOrDefault();
|
||||
}
|
||||
public override void DeleteAllPhotos()
|
||||
{
|
||||
_photoCollection.DeleteManyAsync(Builders<Photo>.Filter.Empty);
|
||||
}
|
||||
|
||||
// Comment
|
||||
public override void CreateComment(Comment comment)
|
||||
{
|
||||
if (comment.Id == 0)
|
||||
{
|
||||
Sequence sequence = _sequenceCollection.Find(seq => seq.Id == "Comment").FirstOrDefault();
|
||||
sequence.Count++;
|
||||
comment.Id = sequence.Count;
|
||||
_sequenceCollection.ReplaceOne(seq => seq.Id == "Comment", sequence);
|
||||
}
|
||||
_commentCollection.InsertOne(comment);
|
||||
}
|
||||
|
||||
public override List<Comment> GetComments()
|
||||
{
|
||||
return _commentCollection.Find(_ => true).ToList();
|
||||
}
|
||||
|
||||
public override Comment GetComment(int id)
|
||||
{
|
||||
return _commentCollection.Find(comment => comment.Id == id).FirstOrDefault();
|
||||
}
|
||||
|
||||
public override void UpdateComment(Comment comment)
|
||||
{
|
||||
_commentCollection.ReplaceOne(b => b.Id == comment.Id, comment);
|
||||
}
|
||||
|
||||
public override void DeleteComment(int id)
|
||||
{
|
||||
_commentCollection.DeleteOne(comment => comment.Id == id);
|
||||
}
|
||||
public override Comment GetCommentPhoto(int PhotoId)
|
||||
{
|
||||
return _commentCollection.Find(comment => comment.PhotoId == PhotoId).FirstOrDefault();
|
||||
}
|
||||
public override void DeleteAllComments()
|
||||
{
|
||||
_commentCollection.DeleteManyAsync(Builders<Comment>.Filter.Empty);
|
||||
}
|
||||
|
||||
public void UpdateSequence(Sequence sequence)
|
||||
{
|
||||
_sequenceCollection.ReplaceOne(seq => seq.Id == sequence.Id, sequence);
|
||||
}
|
||||
}
|
||||
}
|
562
SUBD_LABA/Database/ImplementsPostgres.cs
Normal file
562
SUBD_LABA/Database/ImplementsPostgres.cs
Normal file
@ -0,0 +1,562 @@
|
||||
using Commentbase;
|
||||
using Npgsql;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Database
|
||||
{
|
||||
public class ImplementsPostgres : Abstracts
|
||||
{
|
||||
private NpgsqlConnection GetConnect()
|
||||
{
|
||||
return new NpgsqlConnection("Host=192.168.56.102;Username=postgres;Password=postgres;Database=postgres");
|
||||
}
|
||||
public override void CreateAlbum(Album album)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO Album (Title, Description) " +
|
||||
"VALUES (@Title, @Description)", conn);
|
||||
cmd.Parameters.AddWithValue("@Title", album.Title);
|
||||
cmd.Parameters.AddWithValue("@Description", album.Description);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void UpdateAlbum(Album album)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"UPDATE Album SET Title = @Title, Description = @Description WHERE id = @Id", conn);
|
||||
cmd.Parameters.AddWithValue("@Title", album.Title);
|
||||
cmd.Parameters.AddWithValue("@Description", album.Description);
|
||||
cmd.Parameters.AddWithValue("@Id", album.Id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void DeleteAlbum(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Album WHERE id = @Id", conn);
|
||||
cmd.Parameters.AddWithValue("@Id", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override Album GetAlbum(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Album WHERE id = {id}", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Album
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Title = reader.GetString(1),
|
||||
Description = reader.GetString(2),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Album GetAlbum(string title)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Album WHERE Title = '{title}'", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Album
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Title = reader.GetString(1),
|
||||
Description = reader.GetString(2),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override List<Album> GetAlbums()
|
||||
{
|
||||
List<Album> albums = new List<Album>();
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("SELECT * FROM Album", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
albums.Add(new Album
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Title = reader.GetString(1),
|
||||
Description = reader.GetString(2),
|
||||
});
|
||||
}
|
||||
return albums;
|
||||
}
|
||||
|
||||
public override void DeleteAllAlbums()
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Album", conn);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void CreateLocation(Location location)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO Location (Name, Shortname) " +
|
||||
"VALUES (@Name, @Shortname)", conn);
|
||||
cmd.Parameters.AddWithValue("@Name", location.Name);
|
||||
cmd.Parameters.AddWithValue("@Shortname", location.ShortName);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void UpdateLocation(Location location)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
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();
|
||||
}
|
||||
|
||||
public override void DeleteLocation(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Location WHERE id = @Id", conn);
|
||||
cmd.Parameters.AddWithValue("@Id", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override Location GetLocation(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Location WHERE id = {id}", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Location
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.GetString(1),
|
||||
ShortName = reader.GetString(2),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Location GetLocation(string name)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Location WHERE Name = '{name}'", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Location
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.GetString(1),
|
||||
ShortName = reader.GetString(2),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override List<Location> GetLocations()
|
||||
{
|
||||
List<Location> locations = new List<Location>();
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("SELECT * FROM Location", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
locations.Add(new Location
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.GetString(1),
|
||||
ShortName = reader.GetString(2),
|
||||
});
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
|
||||
public override void DeleteAllLocations()
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Location", conn);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void CreatePhoto(Photo photo)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO Photo (Title, Description, Privacy, UploadDate, ImagePath, AlbumId, LocationId, AuthorId) " +
|
||||
"VALUES (@Title, @Description, @Privacy, @UploadDate, @ImagePath, @Album, @Location, @Author)", conn);
|
||||
cmd.Parameters.AddWithValue("@Title", photo.Title);
|
||||
cmd.Parameters.AddWithValue("@Description", photo.Description);
|
||||
cmd.Parameters.AddWithValue("@Privacy", photo.Privacy);
|
||||
cmd.Parameters.AddWithValue("@UploadDate", photo.UploadDate);
|
||||
cmd.Parameters.AddWithValue("@ImagePath", photo.ImagePath);
|
||||
cmd.Parameters.AddWithValue("@Album", photo.AlbumId);
|
||||
cmd.Parameters.AddWithValue("@Location", photo.LocationId);
|
||||
cmd.Parameters.AddWithValue("@Author", photo.AuthorId);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void UpdatePhoto(Photo photo)
|
||||
{
|
||||
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 WHERE id = @Id", conn);
|
||||
cmd.Parameters.AddWithValue("@Title", photo.Title);
|
||||
cmd.Parameters.AddWithValue("@Description", photo.Description);
|
||||
cmd.Parameters.AddWithValue("@Privacy", photo.Privacy);
|
||||
cmd.Parameters.AddWithValue("@UploadDate", photo.UploadDate);
|
||||
cmd.Parameters.AddWithValue("@ImagePath", photo.ImagePath);
|
||||
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();
|
||||
}
|
||||
|
||||
public override void DeletePhoto(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Photo WHERE id = @Id", conn);
|
||||
cmd.Parameters.AddWithValue("@Id", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override Photo GetPhoto(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Photo WHERE id = {id}", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Photo
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
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;
|
||||
}
|
||||
|
||||
public override Photo GetPhoto(int AlbumId, int LocationId, int AuthorId)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Photo WHERE (AlbumId = {AlbumId} AND LocationId = {LocationId} AND AuthorId = {AuthorId})", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Photo
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
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;
|
||||
}
|
||||
|
||||
public override List<Photo> GetPhotos()
|
||||
{
|
||||
List<Photo> photos = new List<Photo>();
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("SELECT * FROM Photo", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
photos.Add(new Photo
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
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;
|
||||
}
|
||||
|
||||
public override void DeleteAllPhotos()
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Photo", conn);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void CreateAuthor(Author author)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("INSERT INTO Author (Name, PhoneNum, Email) " +
|
||||
"VALUES (@Name, @PhoneNum, @Email)", conn);
|
||||
cmd.Parameters.AddWithValue("@Name", author.Name);
|
||||
cmd.Parameters.AddWithValue("@PhoneNum", author.PhoneNum);
|
||||
cmd.Parameters.AddWithValue("@Email", author.Email);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void UpdateAuthor(Author author)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
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();
|
||||
}
|
||||
|
||||
public override void DeleteAuthor(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Author WHERE id = @Id", conn);
|
||||
cmd.Parameters.AddWithValue("@Id", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override Author GetAuthor(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Author WHERE id = {id}", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Author
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.GetString(1),
|
||||
PhoneNum = reader.GetString(2),
|
||||
Email = reader.GetString(3)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Author GetAuthor(string name)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Author WHERE Name = '{name}'", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Author
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.GetString(1),
|
||||
PhoneNum = reader.GetString(2),
|
||||
Email = reader.GetString(3)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override List<Author> GetAuthors()
|
||||
{
|
||||
List<Author> authors = new List<Author>();
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("SELECT * FROM Author", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
authors.Add(new Author
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.GetString(1),
|
||||
PhoneNum = reader.GetString(2),
|
||||
Email = reader.GetString(3)
|
||||
});
|
||||
}
|
||||
return authors;
|
||||
}
|
||||
|
||||
public override void DeleteAllAuthors()
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Author", conn);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void CreateComment(Comment comment)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
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);
|
||||
cmd.Parameters.AddWithValue("@Photo", comment.PhotoId);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override void UpdateComment(Comment comment)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
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();
|
||||
}
|
||||
|
||||
public override void DeleteComment(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Comment WHERE id = @Id", conn);
|
||||
cmd.Parameters.AddWithValue("@Id", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public override Comment GetComment(int id)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"SELECT * FROM Comment WHERE id = {id}", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Comment
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
PostDate = reader.GetDateTime(2),
|
||||
Content = reader.GetString(3),
|
||||
PhotoId = reader.GetInt32(1)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override Comment GetCommentPhoto(int PhotoId)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
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(2),
|
||||
Content = reader.GetString(3),
|
||||
PhotoId = reader.GetInt32(1)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override List<Comment> GetComments()
|
||||
{
|
||||
List<Comment> comments = new List<Comment>();
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("SELECT * FROM Comment", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
comments.Add(new Comment
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
PostDate = reader.GetDateTime(2),
|
||||
Content = reader.GetString(3),
|
||||
PhotoId = reader.GetInt32(1)
|
||||
});
|
||||
}
|
||||
return comments;
|
||||
}
|
||||
|
||||
public override void DeleteAllComments()
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand($"DELETE FROM Comment", conn);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
private Sequence GetSequence(string nameInPg, string nameInApp)
|
||||
{
|
||||
using var conn = GetConnect();
|
||||
conn.Open();
|
||||
using var cmd = new NpgsqlCommand("SELECT sequencename, last_value " +
|
||||
"FROM pg_sequences " +
|
||||
"WHERE sequencename = '" + nameInPg + "_id_seq'", conn);
|
||||
using var reader = cmd.ExecuteReader();
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Sequence
|
||||
{
|
||||
Id = nameInApp,
|
||||
Count = reader.GetInt32(1)
|
||||
};
|
||||
}
|
||||
else
|
||||
return new Sequence
|
||||
{
|
||||
Id = nameInApp,
|
||||
Count = 0
|
||||
};
|
||||
}
|
||||
|
||||
public List<Sequence> GetSequences()
|
||||
{
|
||||
return new List<Sequence>{
|
||||
GetSequence("album", "Album"),
|
||||
GetSequence("location", "Location"),
|
||||
GetSequence("author", "Author"),
|
||||
GetSequence("photo", "Photo"),
|
||||
GetSequence("comment", "Comment")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
60
SUBD_LABA/Database/Models.cs
Normal file
60
SUBD_LABA/Database/Models.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Database
|
||||
{
|
||||
public class Album
|
||||
{
|
||||
[BsonRepresentation(BsonType.Int32)]
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
public class Location
|
||||
{
|
||||
[BsonRepresentation(BsonType.Int32)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ShortName { get; set; }
|
||||
}
|
||||
public class Author
|
||||
{
|
||||
[BsonRepresentation(BsonType.Int32)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string PhoneNum { get; set; }
|
||||
public string Email { get; set; }
|
||||
}
|
||||
public class Photo
|
||||
{
|
||||
[BsonRepresentation(BsonType.Int32)]
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Privacy { get; set; }
|
||||
public DateTime UploadDate { get; set; }
|
||||
public string ImagePath { get; set; }
|
||||
public int AlbumId { get; set; }
|
||||
public int LocationId { get; set; }
|
||||
public int AuthorId { get; set; }
|
||||
}
|
||||
public class Comment
|
||||
{
|
||||
[BsonRepresentation(BsonType.Int32)]
|
||||
public int Id { get; set; }
|
||||
public DateTime PostDate { get; set; }
|
||||
public string Content { get; set; }
|
||||
public int PhotoId { get; set; }
|
||||
}
|
||||
public class Sequence
|
||||
{
|
||||
[BsonRepresentation(BsonType.String)]
|
||||
public string Id { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
31
SUBD_LABA/SUBD_LAB.sln
Normal file
31
SUBD_LABA/SUBD_LAB.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.6.33801.468
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
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
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{7D559A78-17F8-4ADB-BA91-30D71CE60CC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{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
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {21800503-431A-49CE-A6F1-523F96E07432}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
118
SUBD_LABA/View/FormAlbum.Designer.cs
generated
Normal file
118
SUBD_LABA/View/FormAlbum.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormAlbum
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
62
SUBD_LABA/View/FormAlbum.cs
Normal file
62
SUBD_LABA/View/FormAlbum.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormAlbum.resx
Normal file
120
SUBD_LABA/View/FormAlbum.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
114
SUBD_LABA/View/FormAlbums.Designer.cs
generated
Normal file
114
SUBD_LABA/View/FormAlbums.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormAlbums
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
89
SUBD_LABA/View/FormAlbums.cs
Normal file
89
SUBD_LABA/View/FormAlbums.cs
Normal file
@ -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<Album> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormAlbums.resx
Normal file
120
SUBD_LABA/View/FormAlbums.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
140
SUBD_LABA/View/FormAuthor.Designer.cs
generated
Normal file
140
SUBD_LABA/View/FormAuthor.Designer.cs
generated
Normal file
@ -0,0 +1,140 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormAuthor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
65
SUBD_LABA/View/FormAuthor.cs
Normal file
65
SUBD_LABA/View/FormAuthor.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormAuthor.resx
Normal file
120
SUBD_LABA/View/FormAuthor.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
114
SUBD_LABA/View/FormAuthors.Designer.cs
generated
Normal file
114
SUBD_LABA/View/FormAuthors.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormAuthors
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
106
SUBD_LABA/View/FormAuthors.cs
Normal file
106
SUBD_LABA/View/FormAuthors.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormAuthors.resx
Normal file
120
SUBD_LABA/View/FormAuthors.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
141
SUBD_LABA/View/FormComment.Designer.cs
generated
Normal file
141
SUBD_LABA/View/FormComment.Designer.cs
generated
Normal file
@ -0,0 +1,141 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormComment
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
83
SUBD_LABA/View/FormComment.cs
Normal file
83
SUBD_LABA/View/FormComment.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormComment.resx
Normal file
120
SUBD_LABA/View/FormComment.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
114
SUBD_LABA/View/FormComments.Designer.cs
generated
Normal file
114
SUBD_LABA/View/FormComments.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormComments
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
89
SUBD_LABA/View/FormComments.cs
Normal file
89
SUBD_LABA/View/FormComments.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormComments.resx
Normal file
120
SUBD_LABA/View/FormComments.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
118
SUBD_LABA/View/FormLocation.Designer.cs
generated
Normal file
118
SUBD_LABA/View/FormLocation.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
61
SUBD_LABA/View/FormLocation.cs
Normal file
61
SUBD_LABA/View/FormLocation.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormLocation.resx
Normal file
120
SUBD_LABA/View/FormLocation.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
114
SUBD_LABA/View/FormLocations.Designer.cs
generated
Normal file
114
SUBD_LABA/View/FormLocations.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormLocations
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
105
SUBD_LABA/View/FormLocations.cs
Normal file
105
SUBD_LABA/View/FormLocations.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormLocations.resx
Normal file
120
SUBD_LABA/View/FormLocations.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
253
SUBD_LABA/View/FormPhoto.Designer.cs
generated
Normal file
253
SUBD_LABA/View/FormPhoto.Designer.cs
generated
Normal file
@ -0,0 +1,253 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormPhoto
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
103
SUBD_LABA/View/FormPhoto.cs
Normal file
103
SUBD_LABA/View/FormPhoto.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormPhoto.resx
Normal file
120
SUBD_LABA/View/FormPhoto.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
114
SUBD_LABA/View/FormPhotos.Designer.cs
generated
Normal file
114
SUBD_LABA/View/FormPhotos.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace View
|
||||
{
|
||||
partial class FormPhotos
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
89
SUBD_LABA/View/FormPhotos.cs
Normal file
89
SUBD_LABA/View/FormPhotos.cs
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SUBD_LABA/View/FormPhotos.resx
Normal file
120
SUBD_LABA/View/FormPhotos.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
194
SUBD_LABA/View/MainForm.Designer.cs
generated
Normal file
194
SUBD_LABA/View/MainForm.Designer.cs
generated
Normal file
@ -0,0 +1,194 @@
|
||||
namespace View
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
сущностиToolStripMenuItem = new ToolStripMenuItem();
|
||||
albumToolStripMenuItem = new ToolStripMenuItem();
|
||||
locationToolStripMenuItem = new ToolStripMenuItem();
|
||||
authorToolStripMenuItem = new ToolStripMenuItem();
|
||||
photoToolStripMenuItem = new ToolStripMenuItem();
|
||||
commentToolStripMenuItem = new ToolStripMenuItem();
|
||||
trackBarDB = new TrackBar();
|
||||
labelMongoDB = new Label();
|
||||
label1 = new Label();
|
||||
buttonTransferDataFromPostgresToMongo = new Button();
|
||||
buttonTest = new Button();
|
||||
textBoxTest = new TextBox();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBarDB).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { сущностиToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1135, 28);
|
||||
menuStrip1.TabIndex = 20;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// сущностиToolStripMenuItem
|
||||
//
|
||||
сущностиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { albumToolStripMenuItem, locationToolStripMenuItem, authorToolStripMenuItem, photoToolStripMenuItem, commentToolStripMenuItem });
|
||||
сущностиToolStripMenuItem.Name = "сущностиToolStripMenuItem";
|
||||
сущностиToolStripMenuItem.Size = new Size(91, 24);
|
||||
сущностиToolStripMenuItem.Text = "Сущности";
|
||||
//
|
||||
// albumToolStripMenuItem
|
||||
//
|
||||
albumToolStripMenuItem.Name = "albumToolStripMenuItem";
|
||||
albumToolStripMenuItem.Size = new Size(190, 26);
|
||||
albumToolStripMenuItem.Text = "Альбом";
|
||||
albumToolStripMenuItem.Click += albumToolStripMenuItem_Click;
|
||||
//
|
||||
// locationToolStripMenuItem
|
||||
//
|
||||
locationToolStripMenuItem.Name = "locationToolStripMenuItem";
|
||||
locationToolStripMenuItem.Size = new Size(190, 26);
|
||||
locationToolStripMenuItem.Text = "Локация";
|
||||
locationToolStripMenuItem.Click += locationToolStripMenuItem_Click;
|
||||
//
|
||||
// authorToolStripMenuItem
|
||||
//
|
||||
authorToolStripMenuItem.Name = "authorToolStripMenuItem";
|
||||
authorToolStripMenuItem.Size = new Size(190, 26);
|
||||
authorToolStripMenuItem.Text = "Автор";
|
||||
authorToolStripMenuItem.Click += authorToolStripMenuItem_Click;
|
||||
//
|
||||
// photoToolStripMenuItem
|
||||
//
|
||||
photoToolStripMenuItem.Name = "photoToolStripMenuItem";
|
||||
photoToolStripMenuItem.Size = new Size(190, 26);
|
||||
photoToolStripMenuItem.Text = "Фотография";
|
||||
photoToolStripMenuItem.Click += photoToolStripMenuItem_Click;
|
||||
//
|
||||
// commentToolStripMenuItem
|
||||
//
|
||||
commentToolStripMenuItem.Name = "commentToolStripMenuItem";
|
||||
commentToolStripMenuItem.Size = new Size(190, 26);
|
||||
commentToolStripMenuItem.Text = "Комментарий";
|
||||
commentToolStripMenuItem.Click += commentToolStripMenuItem_Click;
|
||||
//
|
||||
// trackBarDB
|
||||
//
|
||||
trackBarDB.LargeChange = 1;
|
||||
trackBarDB.Location = new Point(31, 89);
|
||||
trackBarDB.Maximum = 100;
|
||||
trackBarDB.Name = "trackBarDB";
|
||||
trackBarDB.Orientation = Orientation.Vertical;
|
||||
trackBarDB.Size = new Size(56, 119);
|
||||
trackBarDB.TabIndex = 3;
|
||||
trackBarDB.MouseUp += trackBarDB_MouseUp;
|
||||
//
|
||||
// labelMongoDB
|
||||
//
|
||||
labelMongoDB.AutoSize = true;
|
||||
labelMongoDB.Location = new Point(93, 89);
|
||||
labelMongoDB.Name = "labelMongoDB";
|
||||
labelMongoDB.Size = new Size(77, 20);
|
||||
labelMongoDB.TabIndex = 22;
|
||||
labelMongoDB.Text = "MongoDB";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(93, 188);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(64, 20);
|
||||
label1.TabIndex = 23;
|
||||
label1.Text = "Postgres";
|
||||
//
|
||||
// buttonTransferDataFromPostgresToMongo
|
||||
//
|
||||
buttonTransferDataFromPostgresToMongo.Location = new Point(834, 80);
|
||||
buttonTransferDataFromPostgresToMongo.Name = "buttonTransferDataFromPostgresToMongo";
|
||||
buttonTransferDataFromPostgresToMongo.Size = new Size(245, 128);
|
||||
buttonTransferDataFromPostgresToMongo.TabIndex = 24;
|
||||
buttonTransferDataFromPostgresToMongo.Text = "Transfer data from PostgresSQL to MongoDB";
|
||||
buttonTransferDataFromPostgresToMongo.UseVisualStyleBackColor = true;
|
||||
buttonTransferDataFromPostgresToMongo.Click += buttonTransferDataFromPostgresToMongo_Click;
|
||||
//
|
||||
// buttonTest
|
||||
//
|
||||
buttonTest.Location = new Point(439, 318);
|
||||
buttonTest.Name = "buttonTest";
|
||||
buttonTest.Size = new Size(94, 29);
|
||||
buttonTest.TabIndex = 25;
|
||||
buttonTest.Text = "test";
|
||||
buttonTest.UseVisualStyleBackColor = true;
|
||||
buttonTest.Click += buttonTest_Click;
|
||||
//
|
||||
// textBoxTest
|
||||
//
|
||||
textBoxTest.Location = new Point(310, 80);
|
||||
textBoxTest.Multiline = true;
|
||||
textBoxTest.Name = "textBoxTest";
|
||||
textBoxTest.Size = new Size(377, 128);
|
||||
textBoxTest.TabIndex = 26;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1135, 436);
|
||||
Controls.Add(textBoxTest);
|
||||
Controls.Add(buttonTest);
|
||||
Controls.Add(buttonTransferDataFromPostgresToMongo);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(labelMongoDB);
|
||||
Controls.Add(trackBarDB);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "MainForm";
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)trackBarDB).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem сущностиToolStripMenuItem;
|
||||
private ToolStripMenuItem albumToolStripMenuItem;
|
||||
private ToolStripMenuItem locationToolStripMenuItem;
|
||||
private ToolStripMenuItem authorToolStripMenuItem;
|
||||
private ToolStripMenuItem photoToolStripMenuItem;
|
||||
private ToolStripMenuItem commentToolStripMenuItem;
|
||||
private TrackBar trackBarDB;
|
||||
private Label labelMongoDB;
|
||||
private Label label1;
|
||||
private Button buttonTransferDataFromPostgresToMongo;
|
||||
private Button buttonTest;
|
||||
private TextBox textBoxTest;
|
||||
}
|
||||
}
|
171
SUBD_LABA/View/MainForm.cs
Normal file
171
SUBD_LABA/View/MainForm.cs
Normal file
@ -0,0 +1,171 @@
|
||||
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;
|
||||
using static System.Windows.Forms.DataFormats;
|
||||
|
||||
namespace View
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void albumToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAlbums));
|
||||
if (service is FormAlbums form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void locationToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormLocations));
|
||||
if (service is FormLocations form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void authorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAuthors));
|
||||
if (service is FormAuthors form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void photoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPhotos));
|
||||
if (service is FormPhotos form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void commentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComments));
|
||||
if (service is FormComments form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void buttonTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
var photo = new Photo()
|
||||
{
|
||||
Id = 0,
|
||||
Title = "photo",
|
||||
Description = "cool photo",
|
||||
Privacy = "public",
|
||||
UploadDate = DateTime.Now,
|
||||
ImagePath = "Image/312",
|
||||
AlbumId = 1,
|
||||
LocationId = 1,
|
||||
AuthorId = 1,
|
||||
};
|
||||
ImplementsPostgres bd = new();
|
||||
DateTime startTime = DateTime.Now;
|
||||
bd.DeletePhoto(40);
|
||||
bd.DeletePhoto(41);
|
||||
bd.DeletePhoto(42);
|
||||
bd.DeletePhoto(43);
|
||||
bd.DeletePhoto(44);
|
||||
DateTime endTime = DateTime.Now;
|
||||
|
||||
// Выводим время выполнения запроса в консоль
|
||||
textBoxTest.Text = $"Время выполнения запроса в постгресе: {(endTime - startTime).TotalMilliseconds} миллисекунд ";
|
||||
|
||||
ImplementsMongoDB bdMongodb = new();
|
||||
|
||||
startTime = DateTime.Now;
|
||||
bdMongodb.DeletePhoto(40);
|
||||
bdMongodb.DeletePhoto(41);
|
||||
bdMongodb.DeletePhoto(42);
|
||||
bdMongodb.DeletePhoto(43);
|
||||
bdMongodb.DeletePhoto(44);
|
||||
endTime = DateTime.Now;
|
||||
|
||||
textBoxTest.Text += $"Время выполнения запроса в монгоДб: {(endTime - startTime).TotalMilliseconds} миллисекунд";
|
||||
}
|
||||
|
||||
private void trackBarDB_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (trackBarDB.Value > 50)
|
||||
{
|
||||
trackBarDB.Value = 100;
|
||||
Program.ChangeDB(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
trackBarDB.Value = 0;
|
||||
Program.ChangeDB(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTransferDataFromPostgresToMongo_Click(object sender, EventArgs e)
|
||||
{
|
||||
ImplementsMongoDB implementsMongoDB = new();
|
||||
|
||||
// очищаем всё
|
||||
foreach (var it in implementsMongoDB.GetAlbums())
|
||||
implementsMongoDB.DeleteAlbum(it.Id);
|
||||
foreach (var it in implementsMongoDB.GetLocations())
|
||||
implementsMongoDB.DeleteLocation(it.Id);
|
||||
foreach (var it in implementsMongoDB.GetAuthors())
|
||||
implementsMongoDB.DeleteAuthor(it.Id);
|
||||
foreach (var it in implementsMongoDB.GetPhotos())
|
||||
implementsMongoDB.DeletePhoto(it.Id);
|
||||
foreach (var it in implementsMongoDB.GetComments())
|
||||
implementsMongoDB.DeleteComment(it.Id);
|
||||
|
||||
ImplementsPostgres implementsPostgres = new();
|
||||
|
||||
// скачиваем из постгреса
|
||||
var listAlbums = implementsPostgres.GetAlbums();
|
||||
var listLocations = implementsPostgres.GetLocations();
|
||||
var listAuthors = implementsPostgres.GetAuthors();
|
||||
var listPhotos = implementsPostgres.GetPhotos();
|
||||
var listComments = implementsPostgres.GetComments();
|
||||
|
||||
// вливаем данные монго дб
|
||||
foreach (var it in listAlbums)
|
||||
implementsMongoDB.CreateAlbum(it);
|
||||
foreach (var it in listLocations)
|
||||
implementsMongoDB.CreateLocation(it);
|
||||
foreach (var it in listAuthors)
|
||||
implementsMongoDB.CreateAuthor(it);
|
||||
foreach (var it in listPhotos)
|
||||
implementsMongoDB.CreatePhoto(it);
|
||||
foreach (var it in listComments)
|
||||
implementsMongoDB.CreateComment(it);
|
||||
|
||||
// забираем информацию о последовательностях
|
||||
var listSequence = implementsPostgres.GetSequences();
|
||||
foreach (var it in listSequence)
|
||||
if (it.Id == "Album" ||
|
||||
it.Id == "Location" ||
|
||||
it.Id == "Author" ||
|
||||
it.Id == "Photo" ||
|
||||
it.Id == "Comment"
|
||||
)
|
||||
implementsMongoDB.UpdateSequence(it);
|
||||
else
|
||||
throw new Exception("неправильнй id последовательности");
|
||||
}
|
||||
}
|
||||
}
|
123
SUBD_LABA/View/MainForm.resx
Normal file
123
SUBD_LABA/View/MainForm.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
64
SUBD_LABA/View/Program.cs
Normal file
64
SUBD_LABA/View/Program.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Database;
|
||||
using System;
|
||||
using Commentbase;
|
||||
using Microsoft.VisualBasic;
|
||||
using static System.Windows.Forms.DataFormats;
|
||||
|
||||
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<MainForm>());
|
||||
}
|
||||
|
||||
private static bool isPostgreSQL = true;
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
if (isPostgreSQL)
|
||||
{
|
||||
services.AddTransient<Abstracts, ImplementsPostgres>();
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddTransient<Abstracts, ImplementsMongoDB>();
|
||||
}
|
||||
services.AddTransient<MainForm>();
|
||||
services.AddTransient<FormAlbum>();
|
||||
services.AddTransient<FormAlbums>();
|
||||
services.AddTransient<FormLocation>();
|
||||
services.AddTransient<FormLocations>();
|
||||
services.AddTransient<FormAuthor>();
|
||||
services.AddTransient<FormAuthors>();
|
||||
services.AddTransient<FormPhoto>();
|
||||
services.AddTransient<FormPhotos>();
|
||||
services.AddTransient<FormComment>();
|
||||
services.AddTransient<FormComments>();
|
||||
}
|
||||
public static void ChangeDB()
|
||||
{
|
||||
isPostgreSQL = !isPostgreSQL;
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
public static void ChangeDB(bool newIsPostrgeSQL)
|
||||
{
|
||||
if (newIsPostrgeSQL == isPostgreSQL)
|
||||
return;
|
||||
isPostgreSQL = newIsPostrgeSQL;
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
}
|
||||
}
|
19
SUBD_LABA/View/View.csproj
Normal file
19
SUBD_LABA/View/View.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Database\Database.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user