Остались формочки и storage типов
This commit is contained in:
parent
c0526f74fd
commit
383f82d65e
13
ComponentProgramming/BusinessLogics/BusinessLogics.csproj
Normal file
13
ComponentProgramming/BusinessLogics/BusinessLogics.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,93 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicsContracts;
|
||||
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 OrganisationTypeLogic : IOrganisationTypeLogic
|
||||
{
|
||||
private readonly IOrganisationTypeStorage _orgTypeStorage;
|
||||
|
||||
public OrganisationTypeLogic(IOrganisationTypeStorage orgTypeStorage)
|
||||
{
|
||||
_orgTypeStorage = orgTypeStorage;
|
||||
}
|
||||
|
||||
public List<OrganisationTypeViewModel>? ReadList(OrganisationTypeSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _orgTypeStorage.GetFullList() : _orgTypeStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public OrganisationTypeViewModel? ReadElement(OrganisationTypeSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _orgTypeStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(OrganisationTypeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_orgTypeStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(OrganisationTypeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_orgTypeStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(OrganisationTypeBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_orgTypeStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(OrganisationTypeBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentException("Введите название типа", nameof(model.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicsContracts;
|
||||
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 ProviderLogic : IProviderLogic
|
||||
{
|
||||
|
||||
private readonly IProviderStorage _providerStorage;
|
||||
|
||||
public ProviderLogic(IProviderStorage providerStorage)
|
||||
{
|
||||
_providerStorage = providerStorage;
|
||||
}
|
||||
|
||||
public List<ProviderViewModel>? ReadList(ProviderSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _providerStorage.GetFullList() : _providerStorage.GetFilteredList(model);
|
||||
|
||||
if(list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ProviderViewModel? ReadElement(ProviderSearchModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _providerStorage.GetElement(model);
|
||||
if(element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(ProviderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if(_providerStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ProviderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if(_providerStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ProviderBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if(_providerStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ProviderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
throw new ArgumentException("Введите название поставщика", nameof(model.Name));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.FurnitureType))
|
||||
{
|
||||
throw new ArgumentException("Введите тип мебели", nameof(model.FurnitureType));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.OrganisationType))
|
||||
{
|
||||
throw new ArgumentException("Выберите тип организации", nameof(model.OrganisationType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,9 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34714.143
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentProgramming", "ComponentProgramming\ComponentProgramming.csproj", "{97AC6509-906E-4688-9C6F-67406629A6CA}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComponentProgramming", "ComponentProgramming\ComponentProgramming.csproj", "{97AC6509-906E-4688-9C6F-67406629A6CA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Forms", "Forms\Forms.csproj", "{A490A64E-3A3B-4782-B0DB-142543BDC6A5}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Forms", "Forms\Forms.csproj", "{A490A64E-3A3B-4782-B0DB-142543BDC6A5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Contracts", "Contracts\Contracts.csproj", "{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Models", "Models\Models.csproj", "{0770DB50-E976-4257-9DB5-8032D28881FC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BusinessLogics", "BusinessLogics\BusinessLogics.csproj", "{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseImplement", "DatabaseImplement\DatabaseImplement.csproj", "{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -21,6 +29,22 @@ Global
|
||||
{A490A64E-3A3B-4782-B0DB-142543BDC6A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A490A64E-3A3B-4782-B0DB-142543BDC6A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A490A64E-3A3B-4782-B0DB-142543BDC6A5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6D33E2A8-3992-4213-B563-E4E7FDC0F5AB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0770DB50-E976-4257-9DB5-8032D28881FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0770DB50-E976-4257-9DB5-8032D28881FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0770DB50-E976-4257-9DB5-8032D28881FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0770DB50-E976-4257-9DB5-8032D28881FC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{70711FA1-A2EC-4BF8-8798-8DCBBC8A7FB2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3F0166B4-E2B0-4499-96EE-0FFFE57855BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,36 +0,0 @@
|
||||
namespace ComponentProgramming
|
||||
{
|
||||
partial class testComp
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComponentProgramming
|
||||
{
|
||||
public partial class testComp : Component
|
||||
{
|
||||
|
||||
private string _fileName;
|
||||
|
||||
public string FileName
|
||||
{
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return;
|
||||
if (!value.EndsWith(".txt"))
|
||||
{
|
||||
throw new ArgumentException("No txt file");
|
||||
}
|
||||
_fileName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public testComp()
|
||||
{
|
||||
InitializeComponent();
|
||||
_fileName = string.Empty;
|
||||
}
|
||||
|
||||
public testComp(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
_fileName = string.Empty;
|
||||
}
|
||||
|
||||
public bool saveToFile(string[] texts)
|
||||
{
|
||||
CheckFileExist();
|
||||
using var writer = new StreamWriter(_fileName, true);
|
||||
foreach (var text in texts)
|
||||
{
|
||||
writer.WriteLine(text);
|
||||
}
|
||||
writer.Flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckFileExist()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_fileName))
|
||||
{
|
||||
throw new ArgumentNullException(_fileName);
|
||||
}
|
||||
if(!File.Exists("../"+_fileName))
|
||||
{
|
||||
throw new FileNotFoundException(_fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
namespace ComponentProgramming
|
||||
{
|
||||
partial class ControlImage
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pictureBoxAvatar = new PictureBox();
|
||||
buttonLoad = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBoxAvatar
|
||||
//
|
||||
pictureBoxAvatar.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
pictureBoxAvatar.Location = new Point(3, 3);
|
||||
pictureBoxAvatar.Name = "pictureBoxAvatar";
|
||||
pictureBoxAvatar.Size = new Size(144, 115);
|
||||
pictureBoxAvatar.TabIndex = 0;
|
||||
pictureBoxAvatar.TabStop = false;
|
||||
//
|
||||
// buttonLoad
|
||||
//
|
||||
buttonLoad.Anchor = AnchorStyles.Bottom;
|
||||
buttonLoad.Location = new Point(35, 124);
|
||||
buttonLoad.Name = "buttonLoad";
|
||||
buttonLoad.Size = new Size(75, 23);
|
||||
buttonLoad.TabIndex = 1;
|
||||
buttonLoad.Text = "Загрузить";
|
||||
buttonLoad.UseVisualStyleBackColor = true;
|
||||
buttonLoad.Click += buttonLoad_Click;
|
||||
//
|
||||
// Control
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(buttonLoad);
|
||||
Controls.Add(pictureBoxAvatar);
|
||||
Name = "Control";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxAvatar;
|
||||
private Button buttonLoad;
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
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 ComponentProgramming
|
||||
{
|
||||
public partial class ControlImage : UserControl
|
||||
{
|
||||
private event EventHandler? _avatarChanged;
|
||||
private event Action? _errorOccured;
|
||||
public string Error { get; private set; }
|
||||
public Image Avatar
|
||||
{
|
||||
get
|
||||
{
|
||||
return pictureBoxAvatar.Image;
|
||||
}
|
||||
set
|
||||
{
|
||||
pictureBoxAvatar.Image = value;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler AvatarChanged
|
||||
{
|
||||
add { _avatarChanged += value; }
|
||||
remove { _avatarChanged -= value; }
|
||||
}
|
||||
|
||||
public event Action AnErrorOccured
|
||||
{
|
||||
add { _errorOccured += value; }
|
||||
remove { _errorOccured -= value; }
|
||||
}
|
||||
|
||||
public ControlImage()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
|
||||
private void buttonLoad_Click(object sender, EventArgs e)
|
||||
{
|
||||
var ofd = new OpenFileDialog();
|
||||
if(ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
pictureBoxAvatar.Image = Image.FromFile(ofd.FileName);
|
||||
pictureBoxAvatar.Width = pictureBoxAvatar.Image.Width;
|
||||
_avatarChanged?.Invoke(this, e);
|
||||
}
|
||||
catch( Exception ex)
|
||||
{
|
||||
Error = ex.Message;
|
||||
_errorOccured?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ComponentProgramming.Control
|
||||
{
|
||||
public class Person
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
|
||||
public Person() { }
|
||||
|
||||
public Person(int id, string name, string surname)
|
||||
{
|
||||
Name = name;
|
||||
Id = id;
|
||||
Surname = surname;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using Models.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class OrganisationTypeBindingModel : IOrganisationTypeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Models.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.BindingModels
|
||||
{
|
||||
public class ProviderBindingModel : IProviderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string FurnitureType { get; set; } = string.Empty;
|
||||
|
||||
public string OrganisationType { get; set; } = string.Empty;
|
||||
|
||||
public DateTime? DateLastDelivery { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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.BusinessLogicsContracts
|
||||
{
|
||||
public interface IOrganisationTypeLogic
|
||||
{
|
||||
List<OrganisationTypeViewModel>? ReadList(OrganisationTypeSearchModel? model);
|
||||
|
||||
OrganisationTypeViewModel? ReadElement(OrganisationTypeSearchModel? model);
|
||||
|
||||
bool Create(OrganisationTypeBindingModel model);
|
||||
bool Update(OrganisationTypeBindingModel model);
|
||||
bool Delete(OrganisationTypeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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.BusinessLogicsContracts
|
||||
{
|
||||
public interface IProviderLogic
|
||||
{
|
||||
List<ProviderViewModel>? ReadList(ProviderSearchModel? model);
|
||||
|
||||
ProviderViewModel? ReadElement (ProviderSearchModel? model);
|
||||
|
||||
bool Create(ProviderBindingModel model);
|
||||
bool Update(ProviderBindingModel model);
|
||||
bool Delete(ProviderBindingModel model);
|
||||
}
|
||||
}
|
13
ComponentProgramming/Contracts/Contracts.csproj
Normal file
13
ComponentProgramming/Contracts/Contracts.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Models\Models.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class OrganisationTypeSearchModel
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Contracts.SearchModels
|
||||
{
|
||||
public class ProviderSearchModel
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? OrganisationType { get; set; }
|
||||
|
||||
public DateTime? DateLastDelivery { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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 IOrganisationTypeStorage
|
||||
{
|
||||
List<OrganisationTypeViewModel> GetFullList();
|
||||
List<OrganisationTypeViewModel> GetFilteredList(OrganisationTypeSearchModel model);
|
||||
OrganisationTypeViewModel? GetElement(OrganisationTypeSearchModel model);
|
||||
|
||||
OrganisationTypeViewModel? Insert(OrganisationTypeBindingModel model);
|
||||
OrganisationTypeViewModel? Update(OrganisationTypeBindingModel model);
|
||||
OrganisationTypeViewModel? Delete(OrganisationTypeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
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 IProviderStorage
|
||||
{
|
||||
List<ProviderViewModel> GetFullList();
|
||||
List<ProviderViewModel> GetFilteredList(ProviderSearchModel model);
|
||||
ProviderViewModel? GetElement(ProviderSearchModel model);
|
||||
|
||||
ProviderViewModel? Insert(ProviderBindingModel model);
|
||||
ProviderViewModel? Update(ProviderBindingModel model);
|
||||
ProviderViewModel? Delete(ProviderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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 OrganisationTypeViewModel : IOrganisationTypeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название типа")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
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 ProviderViewModel : IProviderModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название организации")]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Перечернь производимой мебели")]
|
||||
public string FurnitureType { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Тип организации")]
|
||||
public string OrganisationType { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата последней доставки")]
|
||||
public DateTime? DateLastDelivery { get; set; }
|
||||
|
||||
}
|
||||
}
|
20
ComponentProgramming/DatabaseImplement/Database.cs
Normal file
20
ComponentProgramming/DatabaseImplement/Database.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using DatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DatabaseImplement
|
||||
{
|
||||
public class Database : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=.\SQLEXPRESS;Initial Catalog=ProvidersDatabase;Integrated Security=True;MultipleActiveResultSets=True;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
||||
public virtual DbSet<Provider> Providers { get; set; }
|
||||
public virtual DbSet<OrganisationType> OrganisationTypes { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BusinessLogics\BusinessLogics.csproj" />
|
||||
<ProjectReference Include="..\Contracts\Contracts.csproj" />
|
||||
<ProjectReference Include="..\Models\Models.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,75 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.SearchModels;
|
||||
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 ProviderStorage : IProviderStorage
|
||||
{
|
||||
public List<ProviderViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Providers.Select(x=>x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ProviderViewModel> GetFilteredList(ProviderSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.OrganisationType))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Providers.Where(x => x.OrganisationType == model.OrganisationType).Select(x=> x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ProviderViewModel? GetElement(ProviderSearchModel model)
|
||||
{
|
||||
if(string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Providers.FirstOrDefault(x => x.Name == model.Name)?.GetViewModel;
|
||||
}
|
||||
|
||||
public ProviderViewModel? Insert(ProviderBindingModel model)
|
||||
{
|
||||
var newProvider = Provider.Create(model);
|
||||
if (newProvider == null) return null;
|
||||
using var context = new Database();
|
||||
context.Providers.Add(newProvider);
|
||||
context.SaveChanges();
|
||||
return newProvider.GetViewModel;
|
||||
}
|
||||
|
||||
public ProviderViewModel? Update(ProviderBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var provider = context.Providers.FirstOrDefault(x=> x.Id == model.Id);
|
||||
if(provider == null) return null;
|
||||
provider.Update(model);
|
||||
context.SaveChanges();
|
||||
return provider.GetViewModel;
|
||||
}
|
||||
|
||||
public ProviderViewModel? Delete(ProviderBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.Providers.FirstOrDefault(x=>x.Id == model.Id);
|
||||
if(element != null)
|
||||
{
|
||||
context.Providers.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.ViewModels;
|
||||
using Models.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Models
|
||||
{
|
||||
public class OrganisationType : IOrganisationTypeModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public static OrganisationType? Create(OrganisationTypeBindingModel model)
|
||||
{
|
||||
if(model == null) return null;
|
||||
|
||||
return new OrganisationType
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrganisationTypeBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
|
||||
Name = model.Name;
|
||||
}
|
||||
|
||||
public OrganisationTypeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
};
|
||||
}
|
||||
}
|
61
ComponentProgramming/DatabaseImplement/Models/Provider.cs
Normal file
61
ComponentProgramming/DatabaseImplement/Models/Provider.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.ViewModels;
|
||||
using Models.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DatabaseImplement.Models
|
||||
{
|
||||
public class Provider : IProviderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string FurnitureType { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string OrganisationType { get; private set; } = string.Empty;
|
||||
|
||||
public DateTime? DateLastDelivery { get; private set; }
|
||||
|
||||
public static Provider? Create(ProviderBindingModel model)
|
||||
{
|
||||
if(model == null) return null;
|
||||
|
||||
return new Provider
|
||||
{
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
FurnitureType = model.FurnitureType,
|
||||
OrganisationType = model.OrganisationType,
|
||||
DateLastDelivery = model.DateLastDelivery,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ProviderBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
|
||||
Name = model.Name;
|
||||
FurnitureType = model.FurnitureType;
|
||||
OrganisationType = model.OrganisationType;
|
||||
DateLastDelivery = model.DateLastDelivery;
|
||||
}
|
||||
|
||||
public ProviderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Name = Name,
|
||||
FurnitureType = FurnitureType,
|
||||
OrganisationType = OrganisationType,
|
||||
DateLastDelivery = DateLastDelivery,
|
||||
};
|
||||
}
|
||||
}
|
119
ComponentProgramming/Forms/Form.Designer.cs
generated
119
ComponentProgramming/Forms/Form.Designer.cs
generated
@ -1,119 +0,0 @@
|
||||
namespace Forms
|
||||
{
|
||||
partial class Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
controlComboBox = new ComponentProgramming.ControlComboBox();
|
||||
controlTextBox = new ComponentProgramming.ControlTextBox();
|
||||
buttonGetObj = new Button();
|
||||
buttonEnter = new Button();
|
||||
controlListBox = new ComponentProgramming.ControlListBox();
|
||||
tableComponent = new ComponentProgramming.Components.TableComponent(components);
|
||||
diagramComponent = new ComponentProgramming.DiagramComponent(components);
|
||||
largeTextComponent = new ComponentProgramming.Components.LargeTextComponent(components);
|
||||
SuspendLayout();
|
||||
//
|
||||
// controlComboBox
|
||||
//
|
||||
controlComboBox.Location = new Point(14, 4);
|
||||
controlComboBox.Margin = new Padding(3, 5, 3, 5);
|
||||
controlComboBox.Name = "controlComboBox";
|
||||
controlComboBox.SelectedItem = "";
|
||||
controlComboBox.Size = new Size(202, 41);
|
||||
controlComboBox.TabIndex = 0;
|
||||
controlComboBox.ComboBoxChanged += controlComboBox_ComboBoxChanged;
|
||||
//
|
||||
// controlTextBox
|
||||
//
|
||||
controlTextBox.Location = new Point(258, 4);
|
||||
controlTextBox.Margin = new Padding(3, 5, 3, 5);
|
||||
controlTextBox.Name = "controlTextBox";
|
||||
controlTextBox.NumPattern = null;
|
||||
controlTextBox.Size = new Size(171, 39);
|
||||
controlTextBox.TabIndex = 1;
|
||||
//
|
||||
// buttonGetObj
|
||||
//
|
||||
buttonGetObj.Location = new Point(14, 553);
|
||||
buttonGetObj.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonGetObj.Name = "buttonGetObj";
|
||||
buttonGetObj.Size = new Size(144, 31);
|
||||
buttonGetObj.TabIndex = 3;
|
||||
buttonGetObj.Text = "Получить объект";
|
||||
buttonGetObj.UseVisualStyleBackColor = true;
|
||||
buttonGetObj.Click += buttonGetObj_Click;
|
||||
//
|
||||
// buttonEnter
|
||||
//
|
||||
buttonEnter.Location = new Point(311, 48);
|
||||
buttonEnter.Name = "buttonEnter";
|
||||
buttonEnter.Size = new Size(85, 32);
|
||||
buttonEnter.TabIndex = 5;
|
||||
buttonEnter.Text = "Ввод";
|
||||
buttonEnter.UseVisualStyleBackColor = true;
|
||||
buttonEnter.Click += buttonEnter_Click;
|
||||
//
|
||||
// controlListBox
|
||||
//
|
||||
controlListBox.GetIndex = -1;
|
||||
controlListBox.Location = new Point(14, 87);
|
||||
controlListBox.Margin = new Padding(3, 5, 3, 5);
|
||||
controlListBox.Name = "controlListBox";
|
||||
controlListBox.Size = new Size(382, 459);
|
||||
controlListBox.TabIndex = 7;
|
||||
//
|
||||
// Form
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(410, 600);
|
||||
Controls.Add(controlListBox);
|
||||
Controls.Add(buttonEnter);
|
||||
Controls.Add(buttonGetObj);
|
||||
Controls.Add(controlTextBox);
|
||||
Controls.Add(controlComboBox);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "Form";
|
||||
Text = "Form";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComponentProgramming.ControlImage control;
|
||||
private ComponentProgramming.ControlComboBox controlComboBox;
|
||||
private ComponentProgramming.ControlTextBox controlTextBox;
|
||||
private Button buttonGetObj;
|
||||
private Button buttonEnter;
|
||||
private ComponentProgramming.ControlListBox controlListBox;
|
||||
private ComponentProgramming.Components.TableComponent tableComponent;
|
||||
private ComponentProgramming.DiagramComponent diagramComponent;
|
||||
private ComponentProgramming.Components.LargeTextComponent largeTextComponent;
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
using ComponentProgramming.Components.Models;
|
||||
|
||||
namespace Forms
|
||||
{
|
||||
public partial class Form : System.Windows.Forms.Form
|
||||
{
|
||||
public Form()
|
||||
{
|
||||
InitializeComponent();
|
||||
FillBox();
|
||||
FillTextBox();
|
||||
FillList();
|
||||
string[] strings = new string[] { "Ó êîìïîíåíòà äîëæåí áûòü ïóáëè÷íûé ìåòîä, êîòîðûé äîëæåí ïðèíèìàòü íà âõîä èìÿ ôàéëà (âêëþ÷àÿ ïóòü äî ôàéëà)", "íàçâàíèå äîêóìåíòà (çàãîëîâîê â äîêóìåíòå) è ìàññèâ ñòðîê (êàæäàÿ ñòðîêà – àáçàö òåêñòà â âûõîäíîì äîêóìåíòå èëè òåêñò â ÿ÷åéêå äëÿ òàáëè÷íîãî äîêóìåíòà)" };
|
||||
largeTextComponent.CreateDocument("C:\\Users\\Ìàêñèì\\source\\repos\\PIbd-31_Yakovlev.M.G._COP_16\\ComponentProgramming\\Forms\\text.pdf", "Çàãîëîâîê", strings);
|
||||
List<ColumnInfo> colInfos = new List<ColumnInfo>()
|
||||
{
|
||||
new ColumnInfo("Name","Èìÿ",50),
|
||||
new ColumnInfo("Surname","Ôàìèëèÿ",100),
|
||||
new ColumnInfo("Phone","Òåëåôîí",100),
|
||||
new ColumnInfo("Email","Ïî÷òà",200),
|
||||
new ColumnInfo("Password","Ïàðîëü",50),
|
||||
};
|
||||
List<MergeCells> mergeCells = new List<MergeCells>()
|
||||
{
|
||||
new MergeCells("Äàííûå", new int[] {0,3,4})
|
||||
};
|
||||
List<Worker> workers = new List<Worker>()
|
||||
{
|
||||
new Worker("Ñàøêà", "Èçîòîâ", "+88005553535", "mail@gmail.ru", "pass123"),
|
||||
new Worker("Ñàøêà", "Òàáååâ", "+88005553535", "mail@gmail.ru", "pass123"),
|
||||
new Worker("Âîâêà", "Êóçüìèí", "+88005553535", "mail@gmail.ru", "pass123"),
|
||||
new Worker("Ãëåáóøêà", "Ìèîí÷èíñêèé", "+88005553535", "mail@gmail.ru", "pass123"),
|
||||
};
|
||||
tableComponent.CreateTable("C:\\Users\\Ìàêñèì\\source\\repos\\PIbd-31_Yakovlev.M.G._COP_16\\ComponentProgramming\\Forms\\table.pdf", "Çàãîëîâîê", mergeCells, colInfos, workers);
|
||||
|
||||
Dictionary<string, List<Double>> data = new Dictionary<string, List<Double>>();
|
||||
data.Add("Çíà÷1", new List<double> { 0.5, 1, 2, 5, 2 });
|
||||
data.Add("Çíà÷2", new List<double> { 3, 2, 1, 3, 6 });
|
||||
data.Add("Çíà÷3", new List<double> { 7, 3, 1, 2, 5 });
|
||||
|
||||
diagramComponent.CreateLineDiagram("C:\\Users\\Ìàêñèì\\source\\repos\\PIbd-31_Yakovlev.M.G._COP_16\\ComponentProgramming\\Forms\\diagram.pdf", "Çàãîëîâîê", "Ëèíåéíàÿ äèàãðàììà", data, LegendAlign.bottom);
|
||||
}
|
||||
|
||||
private void FillBox()
|
||||
{
|
||||
controlComboBox.ComboBoxItems.Add("Çíà÷åíèå 1");
|
||||
controlComboBox.ComboBoxItems.Add("Çíà÷åíèå 2");
|
||||
controlComboBox.ComboBoxItems.Add("Çíà÷åíèå 3");
|
||||
controlComboBox.ComboBoxItems.Add("Çíà÷åíèå 4");
|
||||
controlComboBox.SelectedItem = "dafafadsf";
|
||||
}
|
||||
private void FillTextBox()
|
||||
{
|
||||
controlTextBox.NumPattern = @"^\+7\d{10}$";
|
||||
controlTextBox.text = "+79063908075";
|
||||
}
|
||||
private void FillList()
|
||||
{
|
||||
controlListBox.SetTemplateString("Ïðèâåò [Name] [Surname]", "[", "]");
|
||||
controlListBox.FillProp<Person>(new Person(1, "Ñàøêà", "Èçîòîâ"), 0, "Name");
|
||||
controlListBox.FillProp<Person>(new Person(2, "Ñàøêà", "Èçîòîâ"), 4, "Surname");
|
||||
}
|
||||
|
||||
private void controlComboBox_ComboBoxChanged(object sender, EventArgs e)
|
||||
{
|
||||
var elem = controlComboBox.SelectedItem;
|
||||
MessageBox.Show($"Âûáðàííî: {elem}");
|
||||
}
|
||||
|
||||
private void controlTextBox_CheckBoxChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (controlTextBox.text == null)
|
||||
{
|
||||
MessageBox.Show($"CheckBox checked");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show($"CheckBox not checked");
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonGetObj_Click(object sender, EventArgs e)
|
||||
{
|
||||
var obj = controlListBox.GetSelectedObject<Person>();
|
||||
MessageBox.Show($"{obj.Name} {obj.Surname}");
|
||||
}
|
||||
private void buttonEnter_Click(object sender, EventArgs e)
|
||||
{
|
||||
var val = controlTextBox.text;
|
||||
MessageBox.Show($"Ââåäåíî {val}");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="tableComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="diagramComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>161, 17</value>
|
||||
</metadata>
|
||||
<metadata name="largeTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>351, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -9,6 +9,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc-GDI" Version="6.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
45
ComponentProgramming/Forms/MainForm.Designer.cs
generated
Normal file
45
ComponentProgramming/Forms/MainForm.Designer.cs
generated
Normal file
@ -0,0 +1,45 @@
|
||||
namespace Forms
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
SuspendLayout();
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Name = "MainForm";
|
||||
Text = "Основная форма";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
20
ComponentProgramming/Forms/MainForm.cs
Normal file
20
ComponentProgramming/Forms/MainForm.cs
Normal file
@ -0,0 +1,20 @@
|
||||
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 MainForm : Form
|
||||
{
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Forms
|
||||
{
|
||||
public class Person
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Surname { get; set; }
|
||||
|
||||
public Person() { }
|
||||
|
||||
public Person(int id, string name, string surname)
|
||||
{
|
||||
Name = name;
|
||||
Id = id;
|
||||
Surname = surname;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
namespace Forms
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
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 Form());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Forms
|
||||
{
|
||||
public class Worker
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
public Worker() { }
|
||||
|
||||
public Worker(string name, string surname, string phone, string email, string password)
|
||||
{
|
||||
Name = name;
|
||||
Surname = surname;
|
||||
Phone = phone;
|
||||
Email = email;
|
||||
Password = password;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
ComponentProgramming/Models/IId.cs
Normal file
13
ComponentProgramming/Models/IId.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Models
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
9
ComponentProgramming/Models/Models.csproj
Normal file
9
ComponentProgramming/Models/Models.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
13
ComponentProgramming/Models/Models/IOrganisationTypeModel.cs
Normal file
13
ComponentProgramming/Models/Models/IOrganisationTypeModel.cs
Normal file
@ -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 IOrganisationTypeModel: IId
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
20
ComponentProgramming/Models/Models/IProviderModel.cs
Normal file
20
ComponentProgramming/Models/Models/IProviderModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Models.Models
|
||||
{
|
||||
public interface IProviderModel : IId
|
||||
{
|
||||
|
||||
string Name { get;}
|
||||
|
||||
string FurnitureType { get;}
|
||||
|
||||
string OrganisationType { get; }
|
||||
|
||||
DateTime? DateLastDelivery { get; }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user