Compare commits

...

No commits in common. "main" and "master" have entirely different histories.
main ... master

41 changed files with 4181 additions and 42 deletions

63
.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

41
.gitignore vendored
View File

@ -1,8 +1,7 @@
# ---> VisualStudio
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
@ -30,6 +29,7 @@ x86/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
@ -91,7 +91,6 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
@ -295,17 +294,6 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
*.ncb
*.aps
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@ -362,9 +350,6 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
@ -376,25 +361,3 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml

44
Database/Abstracts.cs Normal file
View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Database
{
public abstract class Abstracts
{
public abstract bool CreateUser(User user);
public abstract bool UpdateUser(User user);
public abstract bool DeleteUser(int id);
public abstract User GetUser(int id);
public abstract User GetUser(string name);
public abstract List<User> GetUsers();
public abstract bool DeleteUsers();
public abstract bool CreateType(Type type);
public abstract bool UpdateType(Type type);
public abstract bool DeleteType(int id);
public abstract Type GetType(int id);
public abstract Type GetType(string title);
public abstract List<Type> GetTypes();
public abstract bool DeleteTypes();
public abstract bool CreateData(Data data);
public abstract bool UpdateData(Data data);
public abstract bool DeleteData(int id);
public abstract Data GetData(int id);
public abstract Data GetData(int Userid, int TypeId);
public abstract List<Data> GetDatas();
public abstract bool DeleteDatas();
public abstract bool CreateDescription(Description description);
public abstract bool UpdateDescription(Description description);
public abstract bool DeleteDescription(int id);
public abstract Description GetDescription(int id);
public abstract bool CreateInvite(Invited invited);
public abstract bool DeleteInvite(int userId, int typeId);
public abstract List<Invited> GetInvited(int id);
public abstract bool DeleteInvited();
}
}

15
Database/Database.csproj Normal file
View 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="EntityFramework" Version="6.4.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.29" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.22" />
</ItemGroup>
</Project>

387
Database/Implements.cs Normal file
View File

@ -0,0 +1,387 @@
using Npgsql;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Database
{
public class Implements : Abstracts
{
private NpgsqlConnection GetConnect()
{
return new NpgsqlConnection("Host=192.168.56.101;Username=postgres;Password=postgres;Database=calendar");
}
public override bool CreateUser(User user)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand("INSERT INTO users (name, email, birthday) " +
"VALUES (@Name, @Email, @Birthday)", conn);
cmd.Parameters.AddWithValue("@Name", user.name);
cmd.Parameters.AddWithValue("@Email", user.email);
cmd.Parameters.AddWithValue("@Birthday", user.birthday);
cmd.ExecuteNonQuery();
return true;
}
public override bool UpdateUser(User user)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE users SET name = @Name, email = @Email, birthday = @Birthday WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Name", user.name);
cmd.Parameters.AddWithValue("@Email", user.email);
cmd.Parameters.AddWithValue("@Birthday", user.birthday);
cmd.Parameters.AddWithValue("@Id", user.Id);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteUser(int id) {
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM users WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Id", id);
cmd.ExecuteNonQuery();
return true;
}
public override User GetUser(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM users WHERE id = {id}", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new User
{
Id = reader.GetInt32(0),
name = reader.GetString(1),
email = reader.GetString(2),
birthday = reader.GetDateTime(3),
};
}
return null;
}
public override User GetUser(string name)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM users WHERE name = '{name}'", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new User
{
Id = reader.GetInt32(0),
name = reader.GetString(1),
email = reader.GetString(2),
birthday = reader.GetDateTime(3),
};
}
return null;
}
public override List<User> GetUsers()
{
List<User> users = new List<User>();
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand("SELECT * FROM users", conn);
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
users.Add(new User
{
Id = reader.GetInt32(0),
name = reader.GetString(1),
email = reader.GetString(2),
birthday = reader.GetDateTime(3),
});
}
return users;
}
public override bool CreateType(Type type)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO type (title) VALUES ('{type.title}')", conn);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteType(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM type WHERE id = {id}", conn);
cmd.ExecuteNonQuery();
return true;
}
public override bool UpdateType(Type type)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE type SET title = '{type.title}' WHERE id = {type.Id}", conn);
cmd.ExecuteNonQuery();
return true;
}
public override Type GetType(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM type WHERE id = {id}", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new Type
{
Id = reader.GetInt32(0),
title = reader.GetString(1)
};
}
return null;
}
public override Type GetType(string title)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM type WHERE title = '{title}'", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new Type
{
Id = reader.GetInt32(0),
title = reader.GetString(1)
};
}
return null;
}
public override List<Type> GetTypes()
{
List<Type> types = new List<Type>();
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM type", conn);
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
types.Add(new Type { Id = reader.GetInt32(0), title = reader.GetString(1) });
}
return types;
}
public override bool CreateData(Data data)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO date (datetime, userid, typeid) VALUES (@Date, @User, @Type)", conn);
cmd.Parameters.AddWithValue("@Date", data.dateTime);
cmd.Parameters.AddWithValue("@User", data.userId);
cmd.Parameters.AddWithValue("@Type", data.typeId);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteData(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM date WHERE id = {id}", conn);
cmd.ExecuteNonQuery();
return true;
}
public override bool UpdateData(Data data)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE date SET datetime = @Date, userid = @User, typeid = @Type WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Date", data.dateTime);
cmd.Parameters.AddWithValue("@User", data.userId);
cmd.Parameters.AddWithValue("@Type", data.typeId);
cmd.Parameters.AddWithValue("@Id", data.Id);
cmd.ExecuteNonQuery();
return true;
}
public override Data GetData(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM date WHERE id = {id}", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new Data
{
Id = reader.GetInt32(0),
dateTime = reader.GetDateTime(1),
userId = reader.GetInt32(2),
typeId = reader.GetInt32(3)
};
}
return null;
}
public override Data GetData(int UserId, int TypeId)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM date WHERE (userId = {UserId} AND typeId = {TypeId})", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new Data
{
Id = reader.GetInt32(0),
dateTime = reader.GetDateTime(1),
userId = reader.GetInt32(2),
typeId = reader.GetInt32(3)
};
}
return null;
}
public override List<Data> GetDatas()
{
List<Data> list = new List<Data>();
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM date", conn);
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
list.Add( new Data
{
Id = reader.GetInt32(0),
dateTime = reader.GetDateTime(1),
userId = reader.GetInt32(2),
typeId = reader.GetInt32(3)
});
}
return list;
}
public override bool CreateDescription(Description description)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO description (id, title, description, place) VALUES (@Id, @Title, @Desc, @Place)", conn);
cmd.Parameters.AddWithValue("@Title", description.title);
cmd.Parameters.AddWithValue("@Desc", description.descript);
cmd.Parameters.AddWithValue("@Place", description.place);
cmd.Parameters.AddWithValue("@Id", description.Id);
cmd.ExecuteNonQuery();
return true;
}
public override bool UpdateDescription(Description description)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE description SET title = @Title, description = @Desc, place = @Place WHERE id = @Id", conn);
cmd.Parameters.AddWithValue("@Title", description.title);
cmd.Parameters.AddWithValue("@Desc", description.descript);
cmd.Parameters.AddWithValue("@Place", description.place);
cmd.Parameters.AddWithValue("@Id", description.Id);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteDescription(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM description WHERE id = {id}", conn);
cmd.ExecuteNonQuery();
return true;
}
public override Description GetDescription(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM description WHERE id = {id}", conn);
using var reader = cmd.ExecuteReader();
if (reader.Read())
{
return new Description
{
Id = reader.GetInt32(0),
title = reader.GetString(1),
descript = reader.GetString(2),
place = reader.GetString(3)
};
}
return null;
}
public override bool CreateInvite(Invited invited)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO invited (userId, dateId) VALUES ({invited.userId}, {invited.typeId})", conn);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteInvite(int userId, int typeId)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM invited WHERE (userid = {userId} AND dateid = {typeId})", conn);
cmd.ExecuteNonQuery();
return true;
}
public override List<Invited> GetInvited(int id)
{
List<Invited> list = new();
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM invited WHERE dateid = {id}", conn);
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
list.Add(new Invited
{
userId = reader.GetInt32(0),
typeId = reader.GetInt32(1),
});
}
return list;
}
public override bool DeleteUsers()
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM users", conn);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteTypes()
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM type", conn);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteDatas()
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM date", conn);
cmd.ExecuteNonQuery();
return true;
}
public override bool DeleteInvited()
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM invited", conn);
cmd.ExecuteNonQuery();
return true;
}
}
}

45
Database/Models.cs Normal file
View File

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Database
{
public class User
{
public int Id { get; set; }
public string name { get; set; }
public string email { get; set; }
public DateTime birthday { get; set; }
}
public class Type
{
public int Id { get; set; }
public string title { get; set; }
}
public class Data
{
public int Id { get; set; }
public DateTime dateTime { get; set; }
public int userId { get; set; }
public int typeId { get; set; }
}
public class Description
{
public int Id { get; set; }
public string title { get; set; }
public string descript { get; set; }
public string place { get; set; }
}
public class Invited
{
public int userId { get; set; }
public int typeId { get; set; }
}
}

View File

@ -1,2 +0,0 @@
# SUBD

31
SUBD.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34009.444
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "View", "View\View.csproj", "{3F32D13B-5E0D-4F48-80F4-4927419ECCD1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Database", "Database\Database.csproj", "{4BBF78DE-90EF-4BB4-9067-2023E714C8ED}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F32D13B-5E0D-4F48-80F4-4927419ECCD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F32D13B-5E0D-4F48-80F4-4927419ECCD1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F32D13B-5E0D-4F48-80F4-4927419ECCD1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F32D13B-5E0D-4F48-80F4-4927419ECCD1}.Release|Any CPU.Build.0 = Release|Any CPU
{4BBF78DE-90EF-4BB4-9067-2023E714C8ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4BBF78DE-90EF-4BB4-9067-2023E714C8ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4BBF78DE-90EF-4BB4-9067-2023E714C8ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4BBF78DE-90EF-4BB4-9067-2023E714C8ED}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {76AD4464-09BB-4D99-94DB-6E56F70CBC02}
EndGlobalSection
EndGlobal

1
Temp.txt Normal file
View File

@ -0,0 +1 @@


142
View/DateForm.Designer.cs generated Normal file
View File

@ -0,0 +1,142 @@
namespace View
{
partial class DateForm
{
/// <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()
{
comboBoxUser = new ComboBox();
label1 = new Label();
label2 = new Label();
comboBoxType = new ComboBox();
label3 = new Label();
dateTimePicker1 = new DateTimePicker();
button1 = new Button();
button2 = new Button();
SuspendLayout();
//
// comboBoxUser
//
comboBoxUser.FormattingEnabled = true;
comboBoxUser.Location = new Point(209, 29);
comboBoxUser.Name = "comboBoxUser";
comboBoxUser.Size = new Size(306, 28);
comboBoxUser.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(50, 32);
label1.Name = "label1";
label1.Size = new Size(107, 20);
label1.TabIndex = 1;
label1.Text = "Пользователь";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(50, 77);
label2.Name = "label2";
label2.Size = new Size(35, 20);
label2.TabIndex = 3;
label2.Text = "Тип";
//
// comboBoxType
//
comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(209, 74);
comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(306, 28);
comboBoxType.TabIndex = 2;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(50, 137);
label3.Name = "label3";
label3.Size = new Size(41, 20);
label3.TabIndex = 5;
label3.Text = "Дата";
//
// dateTimePicker1
//
dateTimePicker1.Location = new Point(209, 132);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(250, 27);
dateTimePicker1.TabIndex = 6;
//
// button1
//
button1.Location = new Point(63, 243);
button1.Name = "button1";
button1.Size = new Size(94, 29);
button1.TabIndex = 7;
button1.Text = "Сохранить";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// button2
//
button2.Location = new Point(421, 243);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 8;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// DateForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(616, 324);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(dateTimePicker1);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(comboBoxType);
Controls.Add(label1);
Controls.Add(comboBoxUser);
Name = "DateForm";
Text = "DateForm";
Load += DateForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxUser;
private Label label1;
private Label label2;
private ComboBox comboBoxType;
private Label label3;
private DateTimePicker dateTimePicker1;
private Button button1;
private Button button2;
}
}

89
View/DateForm.cs Normal file
View File

@ -0,0 +1,89 @@
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;
using Type = Database.Type;
namespace View
{
public partial class DateForm : Form
{
public int? DateId;
private Abstracts db;
public DateForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (DateId.HasValue)
{
db.UpdateData(new()
{
Id = DateId.Value,
dateTime = dateTimePicker1.Value,
userId = (comboBoxUser.SelectedItem as User).Id,
typeId = (comboBoxType.SelectedItem as Type).Id,
});
}
else
{
db.CreateData(new()
{
dateTime = dateTimePicker1.Value,
userId = (comboBoxUser.SelectedItem as User).Id,
typeId = (comboBoxType.SelectedItem as Type).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 users = db.GetUsers();
var types = db.GetTypes();
comboBoxUser.DataSource = users;
comboBoxType.DataSource = types;
comboBoxUser.DisplayMember = "name";
comboBoxType.DisplayMember = "title";
comboBoxUser.ValueMember = "Id";
comboBoxType.ValueMember = "Id";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void DateForm_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

120
View/DateForm.resx Normal file
View 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>

127
View/DatesForm.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace View
{
partial class DatesForm
{
/// <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();
buttonDesc = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(21, 18);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.Size = new Size(529, 420);
dataGridView1.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(618, 47);
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(618, 122);
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(618, 205);
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(618, 293);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(94, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += buttonReload_Click;
//
// buttonDesc
//
buttonDesc.Location = new Point(618, 365);
buttonDesc.Name = "buttonDesc";
buttonDesc.Size = new Size(94, 55);
buttonDesc.TabIndex = 5;
buttonDesc.Text = "Добавить описание";
buttonDesc.UseVisualStyleBackColor = true;
buttonDesc.Click += buttonDesc_Click;
//
// DatesForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(buttonDesc);
Controls.Add(buttonReload);
Controls.Add(buttonDelete);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(dataGridView1);
Name = "DatesForm";
Text = "DatesForm";
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;
private Button buttonDesc;
}
}

97
View/DatesForm.cs Normal file
View File

@ -0,0 +1,97 @@
using Database;
namespace View
{
public partial class DatesForm : Form
{
private readonly Abstracts db;
public DatesForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void buttonDesc_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(DescriptionForm));
if (service is DescriptionForm form)
{
form.id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1) {
var service = Program.ServiceProvider?.GetService(typeof(DateForm));
if (service is DateForm form)
{
form.DateId = 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.DeleteData(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(DateForm));
if (service is DateForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void DatesForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = db.GetDatas();
dataGridView1.DataSource = list;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

120
View/DatesForm.resx Normal file
View 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
View/DescriptionForm.Designer.cs generated Normal file
View File

@ -0,0 +1,140 @@
namespace View
{
partial class DescriptionForm
{
/// <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()
{
label1 = new Label();
textBoxTitle = new TextBox();
textBoxDesc = new TextBox();
label2 = new Label();
textBoxPlace = new TextBox();
label3 = new Label();
button1 = new Button();
button2 = new Button();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(51, 38);
label1.Name = "label1";
label1.Size = new Size(77, 20);
label1.TabIndex = 0;
label1.Text = "Название";
//
// textBoxTitle
//
textBoxTitle.Location = new Point(223, 35);
textBoxTitle.Name = "textBoxTitle";
textBoxTitle.Size = new Size(125, 27);
textBoxTitle.TabIndex = 1;
//
// textBoxDesc
//
textBoxDesc.Location = new Point(223, 89);
textBoxDesc.Name = "textBoxDesc";
textBoxDesc.Size = new Size(125, 27);
textBoxDesc.TabIndex = 3;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(51, 92);
label2.Name = "label2";
label2.Size = new Size(79, 20);
label2.TabIndex = 2;
label2.Text = "Описание";
//
// textBoxPlace
//
textBoxPlace.Location = new Point(223, 144);
textBoxPlace.Name = "textBoxPlace";
textBoxPlace.Size = new Size(125, 27);
textBoxPlace.TabIndex = 5;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(51, 147);
label3.Name = "label3";
label3.Size = new Size(52, 20);
label3.TabIndex = 4;
label3.Text = "Место";
//
// button1
//
button1.Location = new Point(51, 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(254, 197);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 7;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// DescriptionForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(415, 254);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(textBoxPlace);
Controls.Add(label3);
Controls.Add(textBoxDesc);
Controls.Add(label2);
Controls.Add(textBoxTitle);
Controls.Add(label1);
Name = "DescriptionForm";
Text = "DescriptionForm";
Load += DescriptionForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private TextBox textBoxTitle;
private TextBox textBoxDesc;
private Label label2;
private TextBox textBoxPlace;
private Label label3;
private Button button1;
private Button button2;
}
}

86
View/DescriptionForm.cs Normal file
View File

@ -0,0 +1,86 @@
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 DescriptionForm : Form
{
public int id;
private bool flag = false;
private Abstracts db;
public DescriptionForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (!flag)
{
db.CreateDescription(new()
{
Id = id,
descript = textBoxDesc.Text,
place = textBoxPlace.Text,
title = textBoxTitle.Text
});
}
else
{
db.UpdateDescription(new()
{
Id = id,
descript = textBoxDesc.Text,
place = textBoxPlace.Text,
title = textBoxTitle.Text
});
}
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 DescriptionForm_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var item = db.GetDescription(id);
if (item != null)
{
textBoxTitle.Text = item.title;
textBoxDesc.Text = item.descript;
textBoxPlace.Text = item.place;
flag = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

120
View/DescriptionForm.resx Normal file
View 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>

97
View/InviteForm.Designer.cs generated Normal file
View File

@ -0,0 +1,97 @@
namespace View
{
partial class InviteForm
{
/// <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()
{
button1 = new Button();
button2 = new Button();
comboBox1 = new ComboBox();
label1 = new Label();
SuspendLayout();
//
// button1
//
button1.Location = new Point(26, 90);
button1.Name = "button1";
button1.Size = new Size(94, 29);
button1.TabIndex = 0;
button1.Text = "Сохранить";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// button2
//
button2.Location = new Point(147, 90);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 1;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// comboBox1
//
comboBox1.FormattingEnabled = true;
comboBox1.Location = new Point(121, 36);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(151, 28);
comboBox1.TabIndex = 2;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(8, 39);
label1.Name = "label1";
label1.Size = new Size(107, 20);
label1.TabIndex = 3;
label1.Text = "Пользователь";
//
// InviteForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(284, 142);
Controls.Add(label1);
Controls.Add(comboBox1);
Controls.Add(button2);
Controls.Add(button1);
Name = "InviteForm";
Text = "InviteForm";
Load += InviteForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button button1;
private Button button2;
private ComboBox comboBox1;
private Label label1;
}
}

65
View/InviteForm.cs Normal file
View File

@ -0,0 +1,65 @@
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 InviteForm : Form
{
public int DateId;
private Abstracts db;
public InviteForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void button1_Click(object sender, EventArgs e)
{
try {
var item = comboBox1.SelectedItem as User;
if (item != null)
{
db.CreateInvite(new()
{
userId = item.Id,
typeId = DateId
});
}
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel; Close();
}
private void InviteForm_Load(object sender, EventArgs e)
{
try
{
var list = db.GetUsers();
comboBox1.DataSource = list;
comboBox1.DisplayMember = "name";
comboBox1.ValueMember = "Id";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

120
View/InviteForm.resx Normal file
View 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>

113
View/InvitedForm.Designer.cs generated Normal file
View File

@ -0,0 +1,113 @@
namespace View
{
partial class InvitedForm
{
/// <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();
buttonDelete = new Button();
buttonReload = new Button();
comboBox1 = new ComboBox();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(14, 18);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.Size = new Size(398, 420);
dataGridView1.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(490, 224);
buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(104, 29);
buttonCreate.TabIndex = 1;
buttonCreate.Text = "Пригласить";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += buttonCreate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(490, 294);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(104, 29);
buttonDelete.TabIndex = 3;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// buttonReload
//
buttonReload.Location = new Point(490, 365);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(104, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += buttonReload_Click;
//
// comboBox1
//
comboBox1.FormattingEnabled = true;
comboBox1.Location = new Point(473, 40);
comboBox1.Name = "comboBox1";
comboBox1.Size = new Size(151, 28);
comboBox1.TabIndex = 5;
comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
//
// InvitedForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(670, 450);
Controls.Add(comboBox1);
Controls.Add(buttonReload);
Controls.Add(buttonDelete);
Controls.Add(buttonCreate);
Controls.Add(dataGridView1);
Name = "InvitedForm";
Text = "InvitedForm";
Load += InvitedForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button buttonCreate;
private Button buttonDelete;
private Button buttonReload;
private ComboBox comboBox1;
}
}

115
View/InvitedForm.cs Normal file
View File

@ -0,0 +1,115 @@
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 InvitedForm : Form
{
private Abstracts db;
private int? index;
public InvitedForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void buttonReload_Click(object sender, EventArgs e)
{
LoadData();
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["UserId"].Value);
try
{
db.DeleteInvite(id, index.Value);
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(InviteForm));
if (service is InviteForm form)
{
form.DateId = index.Value;
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void InvitedForm_Load(object sender, EventArgs e)
{
LoadDatas();
}
private void LoadData()
{
if (dataGridView1.Columns.Count == 0)
{
dataGridView1.Columns.Add("UserId", "UserId");
dataGridView1.Columns.Add("DateId", "DateId");
}
try
{
if (!index.HasValue)
return;
var list = db.GetInvited(index.Value);
dataGridView1.Rows.Clear();
foreach (var i in list)
{
dataGridView1.Rows.Add(i.userId, i.typeId);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadDatas()
{
try
{
var list = db.GetDatas();
comboBox1.DataSource = list;
comboBox1.DisplayMember = "DateTime";
comboBox1.ValueMember = "Id";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
var item = comboBox1.SelectedItem as Data;
index = item!.Id;
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

120
View/InvitedForm.resx Normal file
View 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>

241
View/MainForm.Designer.cs generated Normal file
View File

@ -0,0 +1,241 @@
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()
{
button1 = new Button();
button2 = new Button();
button3 = new Button();
button4 = new Button();
button5 = new Button();
button6 = new Button();
button7 = new Button();
button9 = new Button();
button10 = new Button();
button11 = new Button();
button12 = new Button();
button8 = new Button();
button13 = new Button();
button14 = new Button();
button15 = new Button();
SuspendLayout();
//
// button1
//
button1.Location = new Point(64, 34);
button1.Name = "button1";
button1.Size = new Size(179, 29);
button1.TabIndex = 0;
button1.Text = "Пользователь";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// button2
//
button2.Location = new Point(64, 94);
button2.Name = "button2";
button2.Size = new Size(179, 29);
button2.TabIndex = 1;
button2.Text = "Тип";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// button3
//
button3.Location = new Point(64, 154);
button3.Name = "button3";
button3.Size = new Size(179, 29);
button3.TabIndex = 2;
button3.Text = "Событие";
button3.UseVisualStyleBackColor = true;
button3.Click += button3_Click;
//
// button4
//
button4.Location = new Point(64, 217);
button4.Name = "button4";
button4.Size = new Size(179, 29);
button4.TabIndex = 3;
button4.Text = "Приглашенные";
button4.UseVisualStyleBackColor = true;
button4.Click += button4_Click;
//
// button5
//
button5.Location = new Point(278, 34);
button5.Name = "button5";
button5.Size = new Size(333, 29);
button5.TabIndex = 4;
button5.Text = "Создать 1000 пользователей";
button5.UseVisualStyleBackColor = true;
button5.Click += button5_Click;
//
// button6
//
button6.Location = new Point(278, 94);
button6.Name = "button6";
button6.Size = new Size(333, 29);
button6.TabIndex = 5;
button6.Text = "Создать 1000 типов";
button6.UseVisualStyleBackColor = true;
button6.Click += button6_Click;
//
// button7
//
button7.Location = new Point(278, 154);
button7.Name = "button7";
button7.Size = new Size(333, 29);
button7.TabIndex = 6;
button7.Text = "Создать 1000 событий";
button7.UseVisualStyleBackColor = true;
button7.Click += button7_Click;
//
// button9
//
button9.Location = new Point(278, 217);
button9.Name = "button9";
button9.Size = new Size(333, 29);
button9.TabIndex = 8;
button9.Text = "Создать 10000 приглашений";
button9.UseVisualStyleBackColor = true;
button9.Click += button9_Click;
//
// button10
//
button10.Location = new Point(629, 154);
button10.Name = "button10";
button10.Size = new Size(333, 29);
button10.TabIndex = 11;
button10.Text = "Изменить 1000 событий";
button10.UseVisualStyleBackColor = true;
button10.Click += button10_Click;
//
// button11
//
button11.Location = new Point(629, 94);
button11.Name = "button11";
button11.Size = new Size(333, 29);
button11.TabIndex = 10;
button11.Text = "Изменить 1000 типов";
button11.UseVisualStyleBackColor = true;
button11.Click += button11_Click;
//
// button12
//
button12.Location = new Point(629, 34);
button12.Name = "button12";
button12.Size = new Size(333, 29);
button12.TabIndex = 9;
button12.Text = "Изменить 1000 пользователей";
button12.UseVisualStyleBackColor = true;
button12.Click += button12_Click;
//
// button8
//
button8.Location = new Point(978, 217);
button8.Name = "button8";
button8.Size = new Size(333, 29);
button8.TabIndex = 15;
button8.Text = "Удалить 10000 приглашений";
button8.UseVisualStyleBackColor = true;
button8.Click += button8_Click;
//
// button13
//
button13.Location = new Point(978, 154);
button13.Name = "button13";
button13.Size = new Size(333, 29);
button13.TabIndex = 14;
button13.Text = "Удалить 1000 событий";
button13.UseVisualStyleBackColor = true;
button13.Click += button13_Click;
//
// button14
//
button14.Location = new Point(978, 94);
button14.Name = "button14";
button14.Size = new Size(333, 29);
button14.TabIndex = 13;
button14.Text = "Удалить 1000 типов";
button14.UseVisualStyleBackColor = true;
button14.Click += button14_Click;
//
// button15
//
button15.Location = new Point(978, 34);
button15.Name = "button15";
button15.Size = new Size(333, 29);
button15.TabIndex = 12;
button15.Text = "Удалить 1000 пользователей";
button15.UseVisualStyleBackColor = true;
button15.Click += button15_Click;
//
// MainForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1323, 292);
Controls.Add(button8);
Controls.Add(button13);
Controls.Add(button14);
Controls.Add(button15);
Controls.Add(button10);
Controls.Add(button11);
Controls.Add(button12);
Controls.Add(button9);
Controls.Add(button7);
Controls.Add(button6);
Controls.Add(button5);
Controls.Add(button4);
Controls.Add(button3);
Controls.Add(button2);
Controls.Add(button1);
Name = "MainForm";
Text = "MainForm";
ResumeLayout(false);
}
#endregion
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private Button button5;
private Button button6;
private Button button7;
private Button button9;
private Button button10;
private Button button11;
private Button button12;
private Button button8;
private Button button13;
private Button button14;
private Button button15;
}
}

244
View/MainForm.cs Normal file
View File

@ -0,0 +1,244 @@
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;
using Type = Database.Type;
namespace View
{
public partial class MainForm : Form
{
private readonly Abstracts db;
public MainForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void button1_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(UsersForm));
if (service is UsersForm form)
{
form.Show();
}
}
private void button2_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(TypesForm));
if (service is TypesForm form)
{
form.Show();
}
}
private void button4_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(InvitedForm));
if (service is InvitedForm form)
{
form.Show();
}
}
private void button3_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(DatesForm));
if (service is DatesForm form)
{
form.Show();
}
}
private void button5_Click(object sender, EventArgs e)
{
string UserName = "БИБА";
string Email = "biba@rambler.ru";
DateTime date = DateTime.Now;
DateTime start = DateTime.Now;
bool last = false;
for (int i = 0; i < 1000; i++)
{
last = db.CreateUser(new()
{
name = $"{UserName}{i}",
email = $"{Email}{i}",
birthday = date
});
}
if (last)
{
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button6_Click(object sender, EventArgs e)
{
string title = "type";
DateTime start = DateTime.Now;
bool last = false;
for (int i = 0; i < 1000; i++)
{
last = db.CreateType(new() { title = $"{title}{i}" });
}
if (last)
{
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button7_Click(object sender, EventArgs e)
{
User userId = db.GetUser("БИБА0");
Type typeId = db.GetType("type0");
DateTime start = DateTime.Now;
bool last = false;
for (int i = 0; i < 1000; i++)
{
last = db.CreateData(new()
{
dateTime = DateTime.Now,
typeId = typeId.Id + i,
userId = userId.Id + i
});
}
if (last)
{
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button9_Click(object sender, EventArgs e)
{
User userId = db.GetUser("БИБА0");
Type typeId = db.GetType("type0");
Data data = db.GetData(userId.Id, typeId.Id);
DateTime start = DateTime.Now;
bool last = false;
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 100; j++)
{
last = db.CreateInvite(new()
{
typeId = data.Id + j,
userId = userId.Id + i
});
}
}
if (last)
{
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button12_Click(object sender, EventArgs e)
{
User userId = db.GetUser("БИБА0");
string UserName = "БИБА1";
string Email = "biba1@rambler.ru";
DateTime date = DateTime.Now;
DateTime start = DateTime.Now;
bool last = false;
for (int i = 0; i < 1000; i++)
{
last = db.UpdateUser(new()
{
Id = userId.Id + i,
name = $"{UserName}{i}",
email = $"{Email}{i}",
birthday = date
});
}
if (last)
{
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button11_Click(object sender, EventArgs e)
{
Type typeId = db.GetType("type0");
string title = "type1";
DateTime start = DateTime.Now;
bool last = false;
for (int i = 0; i < 1000; i++)
{
last = db.UpdateType(new() { Id = typeId.Id + i, title = $"{title}{i}" });
}
if (last)
{
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button10_Click(object sender, EventArgs e)
{
User userId = db.GetUser("БИБА0");
Type typeId = db.GetType("type0");
Data data = db.GetData(userId.Id, typeId.Id);
DateTime start = DateTime.Now;
bool last = false;
for (int i = 0; i < 1000; i++)
{
last = db.UpdateData(new()
{
Id = data.Id + i,
dateTime = DateTime.Today,
typeId = typeId.Id + i,
userId = userId.Id + i
});
}
if (last)
{
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void button15_Click(object sender, EventArgs e)
{
DateTime start = DateTime.Now;
db.DeleteUsers();
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button14_Click(object sender, EventArgs e)
{
DateTime start = DateTime.Now;
db.DeleteTypes();
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button13_Click(object sender, EventArgs e)
{
DateTime start = DateTime.Now;
db.DeleteDatas();
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void button8_Click(object sender, EventArgs e)
{
DateTime start = DateTime.Now;
db.DeleteInvited();
DateTime end = DateTime.Now;
MessageBox.Show((end - start).Milliseconds.ToString(), "Время работы", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

120
View/MainForm.resx Normal file
View 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>

37
View/Program.cs Normal file
View File

@ -0,0 +1,37 @@
using Microsoft.Extensions.DependencyInjection;
using Database;
using System;
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 void ConfigureServices(ServiceCollection services)
{
services.AddTransient<Abstracts, Implements>();
services.AddTransient<MainForm>();
services.AddTransient<TypeForm>();
services.AddTransient<TypesForm>();
services.AddTransient<InvitedForm>();
services.AddTransient<InviteForm>();
services.AddTransient<DatesForm>();
services.AddTransient<DateForm>();
services.AddTransient<DescriptionForm>();
services.AddTransient<UsersForm>();
services.AddTransient<UserForm>();
}
}
}

96
View/TypeForm.Designer.cs generated Normal file
View File

@ -0,0 +1,96 @@
namespace View
{
partial class TypeForm
{
/// <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()
{
button1 = new Button();
button2 = new Button();
label1 = new Label();
textBox1 = new TextBox();
SuspendLayout();
//
// button1
//
button1.Location = new Point(57, 87);
button1.Name = "button1";
button1.Size = new Size(94, 29);
button1.TabIndex = 0;
button1.Text = "Сохранить";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// button2
//
button2.Location = new Point(209, 87);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 1;
button2.Text = "Отмена";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 32);
label1.Name = "label1";
label1.Size = new Size(176, 20);
label1.TabIndex = 2;
label1.Text = "Название типа события";
//
// textBox1
//
textBox1.Location = new Point(209, 29);
textBox1.Name = "textBox1";
textBox1.Size = new Size(173, 27);
textBox1.TabIndex = 3;
//
// TypeForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(394, 139);
Controls.Add(textBox1);
Controls.Add(label1);
Controls.Add(button2);
Controls.Add(button1);
Name = "TypeForm";
Text = "TypeForm";
Load += TypeForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button button1;
private Button button2;
private Label label1;
private TextBox textBox1;
}
}

60
View/TypeForm.cs Normal file
View File

@ -0,0 +1,60 @@
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 TypeForm : Form
{
public int? TypeId { get; set; }
private Abstracts db;
public TypeForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void button1_Click(object sender, EventArgs e)
{
if (TypeId.HasValue)
{
db.UpdateType(new()
{
Id = TypeId.Value,
title = textBox1.Text
});
}
else
{
db.CreateType(new() {
title = textBox1.Text
});
}
DialogResult = DialogResult.OK;
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void TypeForm_Load(object sender, EventArgs e)
{
if (TypeId.HasValue)
{
var type = db.GetType(TypeId.Value);
textBox1.Text = type.title;
}
}
}
}

120
View/TypeForm.resx Normal file
View 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>

113
View/TypesForm.Designer.cs generated Normal file
View File

@ -0,0 +1,113 @@
namespace View
{
partial class TypesForm
{
/// <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(565, 426);
dataGridView1.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(624, 32);
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(624, 95);
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(624, 161);
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(624, 231);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(94, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += buttonReload_Click;
//
// TypesForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(781, 450);
Controls.Add(buttonReload);
Controls.Add(buttonDelete);
Controls.Add(buttonUpdate);
Controls.Add(buttonCreate);
Controls.Add(dataGridView1);
Name = "TypesForm";
Text = "TypesForm";
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonReload;
}
}

85
View/TypesForm.cs Normal file
View File

@ -0,0 +1,85 @@
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;
using Type = Database.Type;
namespace View
{
public partial class TypesForm : Form
{
private Abstracts abstracts;
public TypesForm(Abstracts abstracts)
{
InitializeComponent();
this.abstracts = abstracts;
}
private void LoadData()
{
List<Type> types = abstracts.GetTypes();
dataGridView1.Rows.Clear();
if (dataGridView1.Columns.Count == 0)
{
dataGridView1.Columns.Add("Id", "Id");
dataGridView1.Columns.Add("Title", "title");
}
foreach (Type type in types)
{
dataGridView1.Rows.Add(type.Id, type.title);
}
}
private void buttonCreate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(TypeForm));
if (service is TypeForm 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(TypeForm));
if (service is TypeForm form)
{
form.TypeId = 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.DeleteType(elem);
LoadData();
}
}
}
}

120
View/TypesForm.resx Normal file
View 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
View/UserForm.Designer.cs generated Normal file
View File

@ -0,0 +1,140 @@
namespace View
{
partial class UserForm
{
/// <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()
{
label1 = new Label();
textBox1 = new TextBox();
textBox2 = new TextBox();
label2 = new Label();
label3 = new Label();
dateTimePicker1 = new DateTimePicker();
button1 = new Button();
button2 = new Button();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(38, 33);
label1.Name = "label1";
label1.Size = new Size(39, 20);
label1.TabIndex = 0;
label1.Text = "Имя";
//
// textBox1
//
textBox1.Location = new Point(205, 33);
textBox1.Name = "textBox1";
textBox1.Size = new Size(189, 27);
textBox1.TabIndex = 1;
//
// textBox2
//
textBox2.Location = new Point(205, 87);
textBox2.Name = "textBox2";
textBox2.Size = new Size(189, 27);
textBox2.TabIndex = 3;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(38, 87);
label2.Name = "label2";
label2.Size = new Size(51, 20);
label2.TabIndex = 2;
label2.Text = "Почта";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(38, 148);
label3.Name = "label3";
label3.Size = new Size(116, 20);
label3.TabIndex = 4;
label3.Text = "Дата рождения";
//
// dateTimePicker1
//
dateTimePicker1.Location = new Point(205, 143);
dateTimePicker1.Name = "dateTimePicker1";
dateTimePicker1.Size = new Size(189, 27);
dateTimePicker1.TabIndex = 5;
//
// button1
//
button1.Location = new Point(38, 235);
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(311, 235);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 7;
button2.Text = "Отменить";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// UserForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(480, 311);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(dateTimePicker1);
Controls.Add(label3);
Controls.Add(textBox2);
Controls.Add(label2);
Controls.Add(textBox1);
Controls.Add(label1);
Name = "UserForm";
Text = "UserForm";
Load += UserForm_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private TextBox textBox1;
private TextBox textBox2;
private Label label2;
private Label label3;
private DateTimePicker dateTimePicker1;
private Button button1;
private Button button2;
}
}

65
View/UserForm.cs Normal file
View File

@ -0,0 +1,65 @@
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 UserForm : Form
{
public int? UserId { get; set; }
private Abstracts db;
public UserForm(Abstracts abstracts)
{
InitializeComponent();
db = abstracts;
}
private void button1_Click(object sender, EventArgs e)
{
if (UserId.HasValue)
{
db.UpdateUser(new()
{
Id = UserId.Value,
name = textBox1.Text,
email = textBox2.Text,
birthday = dateTimePicker1.Value
});
}
else
{
db.CreateUser(new()
{
name = textBox1.Text,
email = textBox2.Text,
birthday = dateTimePicker1.Value
});
}
DialogResult = DialogResult.OK;
}
private void button2_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void UserForm_Load(object sender, EventArgs e)
{
if (UserId.HasValue)
{
var user = db.GetUser(UserId.Value);
textBox1.Text = user.name;
textBox2.Text = user.email;
dateTimePicker1.Value = user.birthday;
}
}
}
}

120
View/UserForm.resx Normal file
View 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
View/UsersForm.Designer.cs generated Normal file
View File

@ -0,0 +1,114 @@
namespace View
{
partial class UsersForm
{
/// <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(545, 426);
dataGridView1.TabIndex = 0;
//
// buttonCreate
//
buttonCreate.Location = new Point(649, 35);
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(649, 93);
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(649, 156);
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(649, 216);
buttonReload.Name = "buttonReload";
buttonReload.Size = new Size(94, 29);
buttonReload.TabIndex = 4;
buttonReload.Text = "Обновить";
buttonReload.UseVisualStyleBackColor = true;
buttonReload.Click += buttonReload_Click;
//
// UsersForm
//
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 = "UsersForm";
Text = "UsersForm";
Load += UsersForm_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonReload;
}
}

107
View/UsersForm.cs Normal file
View File

@ -0,0 +1,107 @@
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 UsersForm : Form
{
private Abstracts db;
public UsersForm(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(UserForm));
if (service is UserForm form)
{
form.UserId = 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.DeleteUser(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(UserForm));
if (service is UserForm 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("Email", "Email");
dataGridView1.Columns.Add("Birthday", "Birthday");
}
var list = db.GetUsers();
if (list != null)
{
dataGridView1.Rows.Clear();
foreach (var user in list)
{
dataGridView1.Rows.Add(user.Id, user.name, user.email, user.birthday);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void UsersForm_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

120
View/UsersForm.resx Normal file
View 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>

19
View/View.csproj Normal file
View 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>