ГОТОВАЯ ЛАБА

This commit is contained in:
Sergey Kozyrev 2024-05-05 22:00:25 +04:00
parent 4a295f956d
commit 991f21f027
42 changed files with 2362 additions and 487 deletions

View File

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

View File

@ -1,31 +0,0 @@

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}") = "Database", "Database.csproj", "{7859B9B2-D187-46BF-A4BF-67C8522CC072}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "View", "..\View\View.csproj", "{9E8134F2-776C-41EB-8BC3-4AF3CB502703}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7859B9B2-D187-46BF-A4BF-67C8522CC072}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7859B9B2-D187-46BF-A4BF-67C8522CC072}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7859B9B2-D187-46BF-A4BF-67C8522CC072}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7859B9B2-D187-46BF-A4BF-67C8522CC072}.Release|Any CPU.Build.0 = Release|Any CPU
{9E8134F2-776C-41EB-8BC3-4AF3CB502703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E8134F2-776C-41EB-8BC3-4AF3CB502703}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E8134F2-776C-41EB-8BC3-4AF3CB502703}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E8134F2-776C-41EB-8BC3-4AF3CB502703}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9B1C6660-8605-4FBF-B0DB-E85FF40A057C}
EndGlobalSection
EndGlobal

View File

@ -1,14 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="8.0.2" />
</ItemGroup>
</Project>

View File

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

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>

View File

@ -12,10 +12,10 @@ namespace Database
{
private NpgsqlConnection GetConnect()
{
return new NpgsqlConnection("Host=192.168.56.100;Username=postgres;Password=postgres;Database=calendar");
return new NpgsqlConnection("Host=192.168.56.101;Username=postgres;Password=postgres;Database=calendar");
}
public override void CreateUser(User user)
public override bool CreateUser(User user)
{
using var conn = GetConnect();
conn.Open();
@ -25,19 +25,27 @@ namespace Database
cmd.Parameters.AddWithValue("@Email", user.email);
cmd.Parameters.AddWithValue("@Birthday", user.birthday);
cmd.ExecuteNonQuery();
return true;
}
public override void UpdateUser(User user)
public override bool UpdateUser(User user)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE users SET name = {user.name}, email = {user.email}, birthday = {user.birthday} WHERE id = {user.Id}", conn);
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 void DeleteUser(int id) {
public override bool DeleteUser(int id) {
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM users WHERE id = {id}", conn);
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)
{
@ -57,12 +65,30 @@ namespace Database
}
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");
using var cmd = new NpgsqlCommand("SELECT * FROM users", conn);
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
@ -76,32 +102,51 @@ namespace Database
}
return users;
}
public override void CreateType(Type type)
public override bool CreateType(Type type)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO types (title) VALUES ({type.title})", conn);
using var cmd = new NpgsqlCommand($"INSERT INTO type (title) VALUES ('{type.title}')", conn);
cmd.ExecuteNonQuery();
return true;
}
public override void DeleteType(int id)
public override bool DeleteType(int id)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"DELETE FROM types WHERE id = {id}", conn);
using var cmd = new NpgsqlCommand($"DELETE FROM type WHERE id = {id}", conn);
cmd.ExecuteNonQuery();
return true;
}
public override void UpdateType(Type type)
public override bool UpdateType(Type type)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE types SET title = {type.title} WHERE id = {type.Id}", conn);
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 types WHERE id = {id}", conn);
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())
{
@ -118,7 +163,7 @@ namespace Database
List<Type> types = new List<Type>();
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"SELECT * FROM types", conn);
using var cmd = new NpgsqlCommand($"SELECT * FROM type", conn);
using var reader = cmd.ExecuteReader();
while (reader.Read())
{
@ -126,27 +171,38 @@ namespace Database
}
return types;
}
public override void CreateData(Data data)
public override bool CreateData(Data data)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO date (datetime, userid, typeid) VALUES ({data.dateTime}, {data.userId}, {data.typeId})", conn);
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 void DeleteData(int id)
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 void UpdateData(Data data)
public override bool UpdateData(Data data)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE date SET datetime = {data.dateTime}, userid = {data.userId}, typeid = {data.typeId} WHERE id = {data.Id}", conn);
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)
@ -167,6 +223,24 @@ namespace Database
}
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>();
@ -187,28 +261,39 @@ namespace Database
return list;
}
public override void CreateDescription(Description description)
public override bool CreateDescription(Description description)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"INSERT INTO date (id, title, description, place) VALUES ({description.Id}, {description.title}, {description.descript}, {description.place})", conn);
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 void UpdateDescription(Description description)
public override bool UpdateDescription(Description description)
{
using var conn = GetConnect();
conn.Open();
using var cmd = new NpgsqlCommand($"UPDATE date SET title = {description.title}, description = {description.descript}, place = {description.place} WHERE id = {description.Id}", conn);
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 void DeleteDescription(int id)
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)
{
@ -229,19 +314,21 @@ namespace Database
return null;
}
public override void CreateInvite(Invited invited)
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 void DeleteInvite(int userId, int typeId)
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}, typeid = {typeId})", conn);
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)
{
@ -260,5 +347,41 @@ namespace Database
}
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

@ -3,24 +3,24 @@ 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}") = "Database", "ConsoleApp1\Database.csproj", "{4A0D527D-7D6C-4771-AAD9-54E396DFF7D3}"
EndProject
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
{4A0D527D-7D6C-4771-AAD9-54E396DFF7D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A0D527D-7D6C-4771-AAD9-54E396DFF7D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A0D527D-7D6C-4771-AAD9-54E396DFF7D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A0D527D-7D6C-4771-AAD9-54E396DFF7D3}.Release|Any CPU.Build.0 = Release|Any CPU
{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

1
Temp.txt Normal file
View File

@ -0,0 +1 @@


View File

@ -28,12 +28,115 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "DateForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -7,14 +8,82 @@ 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 DateForm()
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();
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,100 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "DatesForm";
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;
}
}

View File

@ -1,20 +1,97 @@
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 Database;
namespace View
{
public partial class DatesForm : Form
{
public DatesForm()
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);
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,113 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "DescriptionForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +13,74 @@ namespace View
{
public partial class DescriptionForm : Form
{
public DescriptionForm()
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);
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,70 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "InviteForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +13,53 @@ namespace View
{
public partial class InviteForm : Form
{
public InviteForm()
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);
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,86 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "InvitedForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +13,103 @@ namespace View
{
public partial class InvitedForm : Form
{
public InvitedForm()
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);
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,214 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "MainForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -7,14 +8,237 @@ 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
{
public MainForm()
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);
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -1,17 +1,37 @@
using Microsoft.Extensions.DependencyInjection;
using Database;
using System;
namespace View
{
internal static class Program
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
[STAThread]
static void Main()
public static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
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>();
}
}
}

View File

@ -28,12 +28,69 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "TypeForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +13,48 @@ namespace View
{
public partial class TypeForm : Form
{
public TypeForm()
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;
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,86 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "TypesForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -7,14 +8,78 @@ 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
{
public TypesForm()
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();
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,113 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "UserForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +13,53 @@ namespace View
{
public partial class UserForm : Form
{
public UserForm()
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;
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -28,12 +28,87 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "UsersForm";
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;
}
}

View File

@ -1,4 +1,5 @@
using System;
using Database;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +13,95 @@ namespace View
{
public partial class UsersForm : Form
{
public UsersForm()
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();
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -8,4 +8,12 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Database\Database.csproj" />
</ItemGroup>
</Project>