diff --git a/WinFormsLibrary1/Businesslogic/BusinessLogics/CategoryLogic.cs b/WinFormsLibrary1/Businesslogic/BusinessLogics/CategoryLogic.cs new file mode 100644 index 0000000..ad319f9 --- /dev/null +++ b/WinFormsLibrary1/Businesslogic/BusinessLogics/CategoryLogic.cs @@ -0,0 +1,69 @@ +using Contracts.BindingModels; +using Contracts.BusinessLogicContracts; +using Contracts.SearchModels; +using Contracts.StorageContracts; +using Contracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BusinessLogics.BusinessLogics +{ + public class CategoryLogic : ICategoryLogic + { + private readonly ICategoryStorage _categoryStorage; + + public CategoryLogic(ICategoryStorage categoryStorage) + { + _categoryStorage = categoryStorage; + } + + public List ReadList() + { + return _categoryStorage.GetFullList(); + } + + public bool Create(CategoryBindingModel model) + { + CheckModel(model); + if (_categoryStorage.Insert(model) == null) + { + return false; + } + return true; + } + public bool Update(CategoryBindingModel model) + { + CheckModel(model); + if (_categoryStorage.Update(model) == null) + { + return false; + } + return true; + } + + public bool Delete(CategoryBindingModel model) + { + CheckModel(model, false); + if (_categoryStorage.Delete(model) == null) + { + return false; + } + return true; + } + + private void CheckModel(CategoryBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + } + } +} diff --git a/WinFormsLibrary1/Contracts/BindingModels/CategoryBindingModel.cs b/WinFormsLibrary1/Contracts/BindingModels/CategoryBindingModel.cs new file mode 100644 index 0000000..dfbc2ca --- /dev/null +++ b/WinFormsLibrary1/Contracts/BindingModels/CategoryBindingModel.cs @@ -0,0 +1,15 @@ +using Models.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.BindingModels +{ + public class CategoryBindingModel : ICategoryModel + { + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + } +} diff --git a/WinFormsLibrary1/Contracts/BindingModels/ProductBindingModel.cs b/WinFormsLibrary1/Contracts/BindingModels/ProductBindingModel.cs index aecda91..97d136a 100644 --- a/WinFormsLibrary1/Contracts/BindingModels/ProductBindingModel.cs +++ b/WinFormsLibrary1/Contracts/BindingModels/ProductBindingModel.cs @@ -13,7 +13,7 @@ namespace Contracts.BindingModels public int Id { get; set; } public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; - public Category Category { get; set; } + public string Category { get; set; } = string.Empty; public int CountOnStorage { get; set; } } } diff --git a/WinFormsLibrary1/Contracts/BusinessLogicContracts/ICategoryLogic.cs b/WinFormsLibrary1/Contracts/BusinessLogicContracts/ICategoryLogic.cs new file mode 100644 index 0000000..0a69a4b --- /dev/null +++ b/WinFormsLibrary1/Contracts/BusinessLogicContracts/ICategoryLogic.cs @@ -0,0 +1,19 @@ +using Contracts.BindingModels; +using Contracts.SearchModels; +using Contracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.BusinessLogicContracts +{ + public interface ICategoryLogic + { + List? ReadList(); + bool Create(CategoryBindingModel model); + bool Update(CategoryBindingModel model); + bool Delete(CategoryBindingModel model); + } +} diff --git a/WinFormsLibrary1/Contracts/SearchModels/ProductSearchModel.cs b/WinFormsLibrary1/Contracts/SearchModels/ProductSearchModel.cs index e405b00..34eaeff 100644 --- a/WinFormsLibrary1/Contracts/SearchModels/ProductSearchModel.cs +++ b/WinFormsLibrary1/Contracts/SearchModels/ProductSearchModel.cs @@ -1,4 +1,5 @@ using Models.Enums; +using Models.Models; using System; using System.Collections.Generic; using System.Linq; @@ -11,6 +12,6 @@ namespace Contracts.SearchModels { public int? Id { get; set; } public string? Name { get; set; } - public Category? Category { get; set; } + public string? Category { get; set; } } } diff --git a/WinFormsLibrary1/Contracts/StorageContracts/ICategoryStorage.cs b/WinFormsLibrary1/Contracts/StorageContracts/ICategoryStorage.cs new file mode 100644 index 0000000..54e089b --- /dev/null +++ b/WinFormsLibrary1/Contracts/StorageContracts/ICategoryStorage.cs @@ -0,0 +1,19 @@ +using Contracts.BindingModels; +using Contracts.SearchModels; +using Contracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.StorageContracts +{ + public interface ICategoryStorage + { + List GetFullList(); + CategoryViewModel? Insert(CategoryBindingModel model); + CategoryViewModel? Update(CategoryBindingModel model); + CategoryViewModel? Delete(CategoryBindingModel model); + } +} diff --git a/WinFormsLibrary1/Contracts/ViewModels/CategoryViewModel.cs b/WinFormsLibrary1/Contracts/ViewModels/CategoryViewModel.cs new file mode 100644 index 0000000..af6a9b3 --- /dev/null +++ b/WinFormsLibrary1/Contracts/ViewModels/CategoryViewModel.cs @@ -0,0 +1,17 @@ +using Models.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Contracts.ViewModels +{ + public class CategoryViewModel : ICategoryModel + { + public int Id { get; set; } + [DisplayName("Название")] + public string Name { get; set; } = string.Empty; + } +} diff --git a/WinFormsLibrary1/Contracts/ViewModels/ProductViewModel.cs b/WinFormsLibrary1/Contracts/ViewModels/ProductViewModel.cs index d75dbd9..9822262 100644 --- a/WinFormsLibrary1/Contracts/ViewModels/ProductViewModel.cs +++ b/WinFormsLibrary1/Contracts/ViewModels/ProductViewModel.cs @@ -17,7 +17,7 @@ namespace Contracts.ViewModels [DisplayName("Описание")] public string Description { get; set; } = string.Empty; [DisplayName("Категория продукта")] - public Category Category { get; set; } + public string Category { get; set; } = string.Empty; [DisplayName("Количество товаров на складе")] public int CountOnStorage { get; set; } } diff --git a/WinFormsLibrary1/DatabaseImplement/Database.cs b/WinFormsLibrary1/DatabaseImplement/Database.cs index 6341781..2bd6336 100644 --- a/WinFormsLibrary1/DatabaseImplement/Database.cs +++ b/WinFormsLibrary1/DatabaseImplement/Database.cs @@ -6,6 +6,7 @@ namespace DatabaseImplement public class Database : DbContext { public DbSet Products { get; set; } + public DbSet Categories { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { diff --git a/WinFormsLibrary1/DatabaseImplement/Implements/CategoryStorage.cs b/WinFormsLibrary1/DatabaseImplement/Implements/CategoryStorage.cs new file mode 100644 index 0000000..5bcb508 --- /dev/null +++ b/WinFormsLibrary1/DatabaseImplement/Implements/CategoryStorage.cs @@ -0,0 +1,51 @@ +using Contracts.BindingModels; +using Contracts.StorageContracts; +using Contracts.ViewModels; +using DatabaseImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseImplement.Implements +{ + public class CategoryStorage : ICategoryStorage + { + public List GetFullList() + { + using var context = new Database(); + return context.Categories.Select(x => x.GetViewModel).ToList(); + } + public CategoryViewModel? Insert(CategoryBindingModel model) + { + var newProvider = Category.Create(model); + if (newProvider == null) return null; + using var context = new Database(); + context.Categories.Add(newProvider); + context.SaveChanges(); + return newProvider.GetViewModel; + } + public CategoryViewModel? Update(CategoryBindingModel model) + { + using var context = new Database(); + var provider = context.Categories.FirstOrDefault(x => x.Id == model.Id); + if (provider == null) return null; + provider.Update(model); + context.SaveChanges(); + return provider.GetViewModel; + } + public CategoryViewModel? Delete(CategoryBindingModel model) + { + using var context = new Database(); + var element = context.Categories.FirstOrDefault(x => x.Id == model.Id); + if (element != null) + { + context.Categories.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + } +} diff --git a/WinFormsLibrary1/DatabaseImplement/Migrations/20241111151239_AddCategories.Designer.cs b/WinFormsLibrary1/DatabaseImplement/Migrations/20241111151239_AddCategories.Designer.cs new file mode 100644 index 0000000..c09fe0b --- /dev/null +++ b/WinFormsLibrary1/DatabaseImplement/Migrations/20241111151239_AddCategories.Designer.cs @@ -0,0 +1,74 @@ +// +using DatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + [DbContext(typeof(Database))] + [Migration("20241111151239_AddCategories")] + partial class AddCategories + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("DatabaseImplement.Models.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("DatabaseImplement.Models.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("CountOnStorage") + .HasColumnType("integer"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Products"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WinFormsLibrary1/DatabaseImplement/Migrations/20241111151239_AddCategories.cs b/WinFormsLibrary1/DatabaseImplement/Migrations/20241111151239_AddCategories.cs new file mode 100644 index 0000000..09526b1 --- /dev/null +++ b/WinFormsLibrary1/DatabaseImplement/Migrations/20241111151239_AddCategories.cs @@ -0,0 +1,51 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace DatabaseImplement.Migrations +{ + /// + public partial class AddCategories : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Category", + table: "Products", + type: "text", + nullable: false, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Categories"); + + migrationBuilder.AlterColumn( + name: "Category", + table: "Products", + type: "integer", + nullable: false, + oldClrType: typeof(string), + oldType: "text"); + } + } +} diff --git a/WinFormsLibrary1/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs b/WinFormsLibrary1/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs index c5415f3..8ee76e6 100644 --- a/WinFormsLibrary1/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs +++ b/WinFormsLibrary1/DatabaseImplement/Migrations/DatabaseModelSnapshot.cs @@ -21,6 +21,23 @@ namespace DatabaseImplement.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + modelBuilder.Entity("DatabaseImplement.Models.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + modelBuilder.Entity("DatabaseImplement.Models.Product", b => { b.Property("Id") @@ -29,8 +46,9 @@ namespace DatabaseImplement.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("Category") - .HasColumnType("integer"); + b.Property("Category") + .IsRequired() + .HasColumnType("text"); b.Property("CountOnStorage") .HasColumnType("integer"); diff --git a/WinFormsLibrary1/DatabaseImplement/Models/Category.cs b/WinFormsLibrary1/DatabaseImplement/Models/Category.cs new file mode 100644 index 0000000..48f0df0 --- /dev/null +++ b/WinFormsLibrary1/DatabaseImplement/Models/Category.cs @@ -0,0 +1,40 @@ +using Contracts.BindingModels; +using Contracts.ViewModels; +using Models.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DatabaseImplement.Models +{ + public class Category : ICategoryModel + { + public int Id { get; set; } + public string Name { get; set; } + + public static Category? Create(CategoryBindingModel model) + { + if (model == null) return null; + + return new Category + { + Id = model.Id, + Name = model.Name, + }; + } + public void Update(CategoryBindingModel model) + { + if (model == null) return; + + Name = model.Name; + } + + public CategoryViewModel GetViewModel => new() + { + Id = Id, + Name = Name, + }; + } +} diff --git a/WinFormsLibrary1/DatabaseImplement/Models/Product.cs b/WinFormsLibrary1/DatabaseImplement/Models/Product.cs index f9bbd2e..29c1e80 100644 --- a/WinFormsLibrary1/DatabaseImplement/Models/Product.cs +++ b/WinFormsLibrary1/DatabaseImplement/Models/Product.cs @@ -23,7 +23,7 @@ namespace DatabaseImplement.Models public string Description { get; private set; } = string.Empty; [Required] - public Category Category { get; private set; } + public string Category { get; private set; } [Required] public int CountOnStorage { get; private set; } diff --git a/WinFormsLibrary1/Models/Models/ICategoryModel.cs b/WinFormsLibrary1/Models/Models/ICategoryModel.cs new file mode 100644 index 0000000..07654d6 --- /dev/null +++ b/WinFormsLibrary1/Models/Models/ICategoryModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Models.Models +{ + public interface ICategoryModel : IId + { + string Name { get; } + } +} diff --git a/WinFormsLibrary1/Models/Models/IProductModel.cs b/WinFormsLibrary1/Models/Models/IProductModel.cs index 1cf0e7a..000fd5d 100644 --- a/WinFormsLibrary1/Models/Models/IProductModel.cs +++ b/WinFormsLibrary1/Models/Models/IProductModel.cs @@ -11,7 +11,7 @@ namespace Models.Models { string Name { get;} string Description { get;} - Category Category { get;} + string Category { get;} int CountOnStorage { get;} } } diff --git a/WinFormsLibrary1/WinFormsApp1/CategoryForm.Designer.cs b/WinFormsLibrary1/WinFormsApp1/CategoryForm.Designer.cs new file mode 100644 index 0000000..358f010 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/CategoryForm.Designer.cs @@ -0,0 +1,64 @@ +namespace Forms +{ + partial class CategoryForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewCategories = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(dataGridViewCategories)).BeginInit(); + SuspendLayout(); + // + // dataGridViewCategories + // + dataGridViewCategories.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewCategories.Location = new System.Drawing.Point(12, 12); + dataGridViewCategories.Name = "dataGridViewCategories"; + dataGridViewCategories.RowHeadersWidth = 51; + dataGridViewCategories.Size = new System.Drawing.Size(711, 426); + dataGridViewCategories.TabIndex = 0; + dataGridViewCategories.CellValueChanged += dataGridViewCategories_CellValueChanged; + dataGridViewCategories.UserAddedRow += dataGridViewCategories_UserAddedRow; + dataGridViewCategories.UserDeletingRow += dataGridViewCategories_UserDeletingRow; + dataGridViewCategories.KeyDown += dataGridViewCategories_KeyDown; + // + // CategoryForm + // + AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(731, 450); + Controls.Add(dataGridViewCategories); + Name = "CategoryForm"; + Text = "CategoryForm"; + ((System.ComponentModel.ISupportInitialize)(dataGridViewCategories)).EndInit(); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridViewCategories; + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/CategoryForm.cs b/WinFormsLibrary1/WinFormsApp1/CategoryForm.cs new file mode 100644 index 0000000..755ed00 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/CategoryForm.cs @@ -0,0 +1,106 @@ +using Contracts.BindingModels; +using Contracts.BusinessLogicContracts; +using Contracts.ViewModels; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Forms +{ + public partial class CategoryForm : Form + { + private readonly ICategoryLogic _categoryLogic; + + public CategoryForm(ICategoryLogic categoryLogic) + { + InitializeComponent(); + _categoryLogic = categoryLogic; + LoadCategories(); + } + + private void LoadCategories() + { + var categories = _categoryLogic.ReadList().ToList(); + dataGridViewCategories.DataSource = categories; + } + + private void dataGridViewCategories_CellValueChanged(object sender, DataGridViewCellEventArgs e) + { + if (e.RowIndex >= 0) + { + var category = dataGridViewCategories.Rows[e.RowIndex].DataBoundItem as CategoryViewModel; + if (category != null) + { + var model = new CategoryBindingModel + { + Id = category.Id, + Name = category.Name + }; + _categoryLogic.Update(model); + } + } + } + + private void dataGridViewCategories_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) + { + var category = e.Row.DataBoundItem as CategoryViewModel; + if (category != null) + { + if (MessageBox.Show("Вы уверены, что хотите удалить выбранную категорию?", "Да", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + _categoryLogic.Delete(new CategoryBindingModel { Id = category.Id }); + } + else + { + e.Cancel = true; + } + } + } + + private void dataGridViewCategories_UserAddedRow(object sender, DataGridViewRowEventArgs e) + { + var category = new CategoryViewModel { Name = "" }; + var model = new CategoryBindingModel + { + Name = category.Name + }; + _categoryLogic.Create(model); + LoadCategories(); + } + + private void dataGridViewCategories_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Insert) + { + var category = new CategoryViewModel { Name = "" }; + var model = new CategoryBindingModel + { + Name = category.Name + }; + _categoryLogic.Create(model); + LoadCategories(); + } + else if (e.KeyCode == Keys.Delete) + { + if (dataGridViewCategories.SelectedRows.Count > 0) + { + var selectedCategory = dataGridViewCategories.SelectedRows[0].DataBoundItem as CategoryViewModel; + if (selectedCategory != null) + { + if (MessageBox.Show("Вы уверены, что хотите удалить выбранную категорию?", "Да", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + _categoryLogic.Delete(new CategoryBindingModel { Id = selectedCategory.Id }); + LoadCategories(); + } + } + } + } + } + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/CategoryForm.resx b/WinFormsLibrary1/WinFormsApp1/CategoryForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/CategoryForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/Forms.csproj b/WinFormsLibrary1/WinFormsApp1/Forms.csproj index f406c44..c432a0a 100644 --- a/WinFormsLibrary1/WinFormsApp1/Forms.csproj +++ b/WinFormsLibrary1/WinFormsApp1/Forms.csproj @@ -22,7 +22,7 @@ - + \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/MainForm.Designer.cs b/WinFormsLibrary1/WinFormsApp1/MainForm.Designer.cs new file mode 100644 index 0000000..005c6b1 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/MainForm.Designer.cs @@ -0,0 +1,64 @@ +namespace Forms +{ + partial class MainForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + _productListControl = new Library15Gerimovich.OutputTableResults(); + wordTablesComponent1 = new Library15Gerimovich.WordTablesComponent(components); + SuspendLayout(); + // + // _productListControl + // + _productListControl.Dock = DockStyle.Fill; + _productListControl.Location = new Point(0, 0); + _productListControl.Margin = new Padding(3, 5, 3, 5); + _productListControl.Name = "_productListControl"; + _productListControl.SelectedRow = -1; + _productListControl.Size = new Size(487, 335); + _productListControl.TabIndex = 0; + // + // MainForm + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(487, 335); + Controls.Add(_productListControl); + Margin = new Padding(3, 4, 3, 4); + Name = "MainForm"; + Text = "Учет продуктов в магазине"; + Load += MainForm_Load; + ResumeLayout(false); + } + + #endregion + + private Library15Gerimovich.OutputTableResults _productListControl; + private Library15Gerimovich.WordTablesComponent wordTablesComponent1; + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/MainForm.cs b/WinFormsLibrary1/WinFormsApp1/MainForm.cs new file mode 100644 index 0000000..e47303c --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/MainForm.cs @@ -0,0 +1,291 @@ +using System; +using System.Windows.Forms; +using Contracts.BindingModels; +using Contracts.BusinessLogicContracts; +using Contracts.SearchModels; +using Contracts.ViewModels; +using Library14Petrushin; +using Library14Petrushin.Classes; +using Library15Gerimovich; +using Library15Gerimovich.OfficePackage.HelperModels; +using WinFormsLibrary1; +using WinFormsLibrary1.Models; +using LegendPosition = Library14Petrushin.Classes.LegendPosition; + +namespace Forms +{ + public partial class MainForm : Form + { + private readonly IProductLogic _productLogic; + private readonly ICategoryLogic _categoryLogic; + private ToolStrip toolStrip; + + public MainForm(IProductLogic productLogic, ICategoryLogic categoryLogic) + { + InitializeComponent(); + _productLogic = productLogic; + _categoryLogic = categoryLogic; + LoadProducts(); + } + + private void LoadProducts() + { + var products = _productLogic.ReadList(null); + _productListControl.ClearGrid(); + + // Создаем список столбцов + var columns = new List + { + new ColumnInfo("ID", 50, false, "Id"), + new ColumnInfo("Название", 150, true, "Name"), + new ColumnInfo("Описание", 200, true, "Description"), + new ColumnInfo("Категория продукта", 150, true, "Category"), + new ColumnInfo("Количество товаров на складе", 150, true, "CountOnStorage") + }; + + // Настраиваем столбцы в DataGridView + _productListControl.ConfigureColumns(columns); + + // Добавляем строки + foreach (var product in products) + { + _productListControl.InsertValue(product); + } + } + + private void MainForm_Load(object sender, EventArgs e) + { + // Настройка контекстного меню и горячих клавиш + var contextMenu = new ContextMenuStrip(); + contextMenu.Items.Add("Добавить", null, (s, ev) => AddProduct()); + contextMenu.Items.Add("Редактировать", null, (s, ev) => EditProduct()); + contextMenu.Items.Add("Удалить", null, (s, ev) => DeleteProduct()); + contextMenu.Items.Add("Создать документ", null, (s, ev) => CreateDocument()); + contextMenu.Items.Add("Создать документ с таблицей", null, (s, ev) => CreateTableDocument()); + contextMenu.Items.Add("Создать документ с диаграммой", null, (s, ev) => CreateChartDocument()); + + // Привязка контекстного меню к компоненту вывода списков + _productListControl.ContextMenuStrip = contextMenu; + + // Настройка горячих клавиш + this.KeyDown += MainForm_KeyDown; + + // Настройка панели инструментов + toolStrip = new ToolStrip(); + toolStrip.Items.Add("Продукты", null, (s, ev) => OpenProductForm()); + toolStrip.Items.Add("Категории", null, (s, ev) => OpenCategoryForm()); + this.Controls.Add(toolStrip); + } + + private void OpenProductForm() + { + var form = new ProductForm(_productLogic, _categoryLogic); + form.ShowDialog(); + } + + private void OpenCategoryForm() + { + var form = new CategoryForm(_categoryLogic); + if (form.ShowDialog() == DialogResult.OK) + { + LoadProducts(); + } + } + + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + if (keyData == (Keys.Control | Keys.A)) + { + AddProduct(); + return true; + } + else if (keyData == (Keys.Control | Keys.U)) + { + EditProduct(); + return true; + } + else if (keyData == (Keys.Control | Keys.D)) + { + DeleteProduct(); + return true; + } + else if (keyData == (Keys.Control | Keys.S)) + { + CreateDocument(); + return true; + } + else if (keyData == (Keys.Control | Keys.T)) + { + CreateTableDocument(); + return true; + } + else if (keyData == (Keys.Control | Keys.C)) + { + CreateChartDocument(); + return true; + } + + return base.ProcessCmdKey(ref msg, keyData); + } + + private void MainForm_KeyDown(object sender, KeyEventArgs e) + { + if (e.Control) + { + switch (e.KeyCode) + { + case Keys.A: + AddProduct(); + break; + case Keys.U: + EditProduct(); + break; + case Keys.D: + DeleteProduct(); + break; + case Keys.S: + CreateDocument(); + break; + case Keys.T: + CreateTableDocument(); + break; + case Keys.C: + CreateChartDocument(); + break; + } + } + } + + private void AddProduct() + { + // Логика добавления нового продукта + var form = new ProductForm(_productLogic, _categoryLogic); + if (form.ShowDialog() == DialogResult.OK) + { + LoadProducts(); + } + } + + private void EditProduct() + { + // Логика редактирования выбранного продукта + var selectedProduct = _productListControl.GetSelectedObject(); + if (selectedProduct != null) + { + var form = new ProductForm(_productLogic, _categoryLogic, selectedProduct); + if (form.ShowDialog() == DialogResult.OK) + { + LoadProducts(); + } + } + } + + private void DeleteProduct() + { + // Логика удаления выбранного продукта + var selectedProduct = _productListControl.GetSelectedObject(); + if (selectedProduct != null) + { + var result = MessageBox.Show("Вы действительно хотите удалить этот продукт?", "Подтверждение", MessageBoxButtons.YesNo); + if (result == DialogResult.Yes) + { + _productLogic.Delete(new ProductBindingModel { Id = selectedProduct.Id }); + LoadProducts(); + } + } + } + + private void CreateDocument() + { + using (var saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + var products = _productLogic.ReadList(null); + var rows = products.Select(p => $"{p.Name} - {p.Description}").ToArray(); + var component = new ComponentWithBigText(); + component.CreateDocument(saveFileDialog.FileName, "Список продуктов", rows); + MessageBox.Show("Документ успешно создан."); + } + } + } + + private void CreateTableDocument() + { + using (var saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "Word files (*.docx)|*.docx|All files (*.*)|*.*"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + var products = _productLogic.ReadList(null); + if (products == null || products.Count == 0) + { + MessageBox.Show("Нет данных для создания документа."); + return; + } + var headers = new List<(int, int, string, string)> + { + (0, 0, "Id", "Id"), + (1, 0, "Name", "Name"), + (2, 0, "Category", "Category"), + (3, 0, "CountOnStorage", "CountOnStorage") + }; + + var columnsRowsWidth = new List<(int Column, int Row)> + { + (100, 0), + (200, 1), + (150, 2), + (150, 3) + }; + + var config = new WordTableWithData + { + FileName = saveFileDialog.FileName, + Title = "Список продуктов", + Headers = headers, + Data = products, + ColumnsRowsWidth = columnsRowsWidth, + NullReplace = "-", + }; + + wordTablesComponent1.CreateTable(config); + MessageBox.Show("Документ успешно создан."); + } + } + } + + private void CreateChartDocument() + { + using (var saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + var products = _productLogic.ReadList(null); + var categories = products.Where(p => p.CountOnStorage == 0).GroupBy(p => p.Category) + .Select(g => new ChartData + { + SeriesName = g.Key, + Value = g.Count(p => p.CountOnStorage == 0) + }).ToList(); + + if (categories.Count == 0) + { + MessageBox.Show("Нет данных для создания диаграммы."); + return; + } + + + var component = new PdfCirclDiagr(); + component.GeneratePdf(saveFileDialog.FileName, + "Диаграмма продуктов", "Продукты без наличия", + LegendPosition.Right, + categories); + MessageBox.Show("Документ успешно создан."); + } + } + } + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/MainForm.resx b/WinFormsLibrary1/WinFormsApp1/MainForm.resx new file mode 100644 index 0000000..d1c8aed --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/MainForm.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/ProductForm.Designer.cs b/WinFormsLibrary1/WinFormsApp1/ProductForm.Designer.cs new file mode 100644 index 0000000..3dda880 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/ProductForm.Designer.cs @@ -0,0 +1,172 @@ +using Library15Gerimovich; +using WinFormsLibrary1; + +namespace Forms +{ + partial class ProductForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + textBoxName = new TextBox(); + textBoxDescription = new TextBox(); + labelName = new Label(); + labelDescription = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + labelCategory = new Label(); + labelCountOnStorage = new Label(); + _categoryComboBox = new ComboBoxUserControl(); + _countOnStorageControl = new InputRealNumber(); + SuspendLayout(); + // + // textBoxName + // + textBoxName.Location = new Point(120, 25); + textBoxName.Margin = new Padding(3, 4, 3, 4); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(200, 27); + textBoxName.TabIndex = 0; + // + // textBoxDescription + // + textBoxDescription.Location = new Point(120, 76); + textBoxDescription.Margin = new Padding(3, 4, 3, 4); + textBoxDescription.Name = "textBoxDescription"; + textBoxDescription.Size = new Size(200, 27); + textBoxDescription.TabIndex = 1; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(20, 29); + labelName.Name = "labelName"; + labelName.Size = new Size(80, 20); + labelName.TabIndex = 2; + labelName.Text = "Название:"; + // + // labelDescription + // + labelDescription.AutoSize = true; + labelDescription.Location = new Point(20, 79); + labelDescription.Name = "labelDescription"; + labelDescription.Size = new Size(82, 20); + labelDescription.TabIndex = 3; + labelDescription.Text = "Описание:"; + // + // buttonSave + // + buttonSave.Location = new Point(12, 358); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(150, 38); + buttonSave.TabIndex = 4; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(190, 358); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(150, 38); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // labelCategory + // + labelCategory.AutoSize = true; + labelCategory.Location = new Point(20, 129); + labelCategory.Name = "labelCategory"; + labelCategory.Size = new Size(84, 20); + labelCategory.TabIndex = 6; + labelCategory.Text = "Категория:"; + // + // labelCountOnStorage + // + labelCountOnStorage.AutoSize = true; + labelCountOnStorage.Location = new Point(23, 193); + labelCountOnStorage.Name = "labelCountOnStorage"; + labelCountOnStorage.Size = new Size(81, 20); + labelCountOnStorage.TabIndex = 7; + labelCountOnStorage.Text = "На складе:"; + // + // _categoryComboBox + // + _categoryComboBox.Location = new Point(120, 125); + _categoryComboBox.Margin = new Padding(4, 5, 4, 5); + _categoryComboBox.Name = "_categoryComboBox"; + _categoryComboBox.SelectedValue = ""; + _categoryComboBox.Size = new Size(200, 27); + _categoryComboBox.TabIndex = 0; + // + // _countOnStorageControl + // + _countOnStorageControl.Location = new Point(120, 161); + _countOnStorageControl.Margin = new Padding(3, 4, 3, 4); + _countOnStorageControl.Name = "_countOnStorageControl"; + _countOnStorageControl.Size = new Size(192, 114); + _countOnStorageControl.TabIndex = 8; + // + // ProductForm + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(361, 409); + Controls.Add(_countOnStorageControl); + Controls.Add(_categoryComboBox); + Controls.Add(labelCountOnStorage); + Controls.Add(labelCategory); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelDescription); + Controls.Add(labelName); + Controls.Add(textBoxDescription); + Controls.Add(textBoxName); + Margin = new Padding(3, 4, 3, 4); + Name = "ProductForm"; + Text = "Добавление/Редактирование продукта"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private System.Windows.Forms.TextBox textBoxName; + private System.Windows.Forms.TextBox textBoxDescription; + private System.Windows.Forms.Label labelName; + private System.Windows.Forms.Label labelDescription; + private System.Windows.Forms.Button buttonSave; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Label labelCategory; + private System.Windows.Forms.Label labelCountOnStorage; + private ComboBoxUserControl _categoryComboBox; + private InputRealNumber _countOnStorageControl; + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/ProductForm.cs b/WinFormsLibrary1/WinFormsApp1/ProductForm.cs new file mode 100644 index 0000000..44aa411 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/ProductForm.cs @@ -0,0 +1,81 @@ +using System; +using System.Windows.Forms; +using Contracts.BindingModels; +using Contracts.BusinessLogicContracts; +using Contracts.ViewModels; +using Library15Gerimovich; +using WinFormsLibrary1; + +namespace Forms +{ + public partial class ProductForm : Form + { + private readonly IProductLogic _productLogic; + private readonly ICategoryLogic _categoryLogic; + private ProductViewModel _product; + private bool _isNewProduct; + + public ProductForm(IProductLogic productLogic, ICategoryLogic categoryLogic, ProductViewModel product = null) + { + InitializeComponent(); + _categoryLogic = categoryLogic; + _productLogic = productLogic; + _product = product; + _isNewProduct = product == null; + + LoadCategories(); + LoadProduct(); + } + + private void LoadCategories() + { + var categories = _categoryLogic.ReadList(); + _categoryComboBox.ClearItems(); + foreach (var category in categories) + { + _categoryComboBox.AddItem(category.Name); + } + } + + private void LoadProduct() + { + if (_product != null) + { + textBoxName.Text = _product.Name; + textBoxDescription.Text = _product.Description; + _categoryComboBox.SelectedValue = _product.Category; + _countOnStorageControl.DoubleValue = _product.CountOnStorage; + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + var model = new ProductBindingModel + { + Id = _product?.Id ?? 0, + Name = textBoxName.Text, + Description = textBoxDescription.Text, + Category = _categoryComboBox.SelectedValue, + CountOnStorage = (int)_countOnStorageControl.DoubleValue + }; + + if (_isNewProduct) + { + _productLogic.Create(model); + } + else + { + _productLogic.Update(model); + } + + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + } +} \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/ProductForm.resx b/WinFormsLibrary1/WinFormsApp1/ProductForm.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/WinFormsLibrary1/WinFormsApp1/ProductForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsApp1/Program.cs b/WinFormsLibrary1/WinFormsApp1/Program.cs index a0e4848..7d963d5 100644 --- a/WinFormsLibrary1/WinFormsApp1/Program.cs +++ b/WinFormsLibrary1/WinFormsApp1/Program.cs @@ -1,7 +1,19 @@ +using BusinessLogics.BusinessLogics; +using Contracts.BusinessLogicContracts; +using Contracts.StorageContracts; +using DatabaseImplement.Implements; +using Forms; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + namespace WinFormsApp1 { internal static class Program { + + private static ServiceProvider? _serviceProvider; + + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// @@ -11,7 +23,30 @@ namespace WinFormsApp1 // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form2()); + + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + + Application.Run(_serviceProvider.GetRequiredService()); + } + + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + }); + + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/WinFormsLibrary1/WinFormsLibrary1.sln b/WinFormsLibrary1/WinFormsLibrary1.sln index efbd16f..0dd272b 100644 --- a/WinFormsLibrary1/WinFormsLibrary1.sln +++ b/WinFormsLibrary1/WinFormsLibrary1.sln @@ -3,17 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.10.34916.146 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components", "WinFormsLibrary1\Components.csproj", "{4F13F436-1BE0-4F8D-A720-FCBF3893BA55}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinFormsLibrary1", "WinFormsLibrary1\WinFormsLibrary1.csproj", "{4F13F436-1BE0-4F8D-A720-FCBF3893BA55}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "WinFormsApp1\Forms.csproj", "{4B1A0E96-B60A-4D73-B4AB-CF5157E593E5}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "Models\Models.csproj", "{C4816B78-EBAF-4183-8775-1180D91250D5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogics", "Businesslogic\BusinessLogics.csproj", "{753AC945-F64F-4A41-9036-6450AAB5A890}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BusinessLogics", "Businesslogic\BusinessLogics.csproj", "{753AC945-F64F-4A41-9036-6450AAB5A890}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{027FB9BF-E927-4C34-AFAD-C71EB03398EE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Contracts", "Contracts\Contracts.csproj", "{027FB9BF-E927-4C34-AFAD-C71EB03398EE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{02E84641-9C21-43C3-99CD-765878F8C8F6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{02E84641-9C21-43C3-99CD-765878F8C8F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/WinFormsLibrary1/WinFormsLibrary1/DateInputControl.cs b/WinFormsLibrary1/WinFormsLibrary1/DateInputControl.cs index 37e8ab9..553a6f3 100644 --- a/WinFormsLibrary1/WinFormsLibrary1/DateInputControl.cs +++ b/WinFormsLibrary1/WinFormsLibrary1/DateInputControl.cs @@ -4,7 +4,7 @@ namespace WinFormsLibrary1 { public partial class DateInputControl : UserControl { - private string DateFormat{ get; set; } + public string DateFormat{ get; set; } public DateInputControl() { @@ -35,11 +35,13 @@ namespace WinFormsLibrary1 } set { - if (string.IsNullOrEmpty(DateFormat)) + if (!string.IsNullOrEmpty(DateFormat)) { textBoxDate.Text = value.ToString(DateFormat); + } else + { + textBoxDate.Text = string.Empty; } - textBoxDate.Text = string.Empty; } } diff --git a/WinFormsLibrary1/WinFormsLibrary1/Components.csproj b/WinFormsLibrary1/WinFormsLibrary1/WinFormsLibrary1.csproj similarity index 86% rename from WinFormsLibrary1/WinFormsLibrary1/Components.csproj rename to WinFormsLibrary1/WinFormsLibrary1/WinFormsLibrary1.csproj index 22ca5db..45d0c53 100644 --- a/WinFormsLibrary1/WinFormsLibrary1/Components.csproj +++ b/WinFormsLibrary1/WinFormsLibrary1/WinFormsLibrary1.csproj @@ -6,6 +6,8 @@ true enable True + 1.0.2 + Library13StroevV