Compare commits
No commits in common. "main" and "master" have entirely different histories.
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
41
.gitignore
vendored
41
.gitignore
vendored
@ -1,8 +1,7 @@
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
@ -30,6 +29,7 @@ x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Oo]ut/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
@ -91,7 +91,6 @@ StyleCopReport.xml
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
@ -295,17 +294,6 @@ node_modules/
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
@ -362,9 +350,6 @@ ASALocalRun/
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
@ -376,25 +361,3 @@ MigrationBackup/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
|
93
ConstructionFirmBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
93
ConstructionFirmBusinessLogic/BusinessLogics/ClientLogic.cs
Normal file
@ -0,0 +1,93 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ClientLogic : IClientLogic
|
||||
{
|
||||
private readonly IClientStorage _clientStorage;
|
||||
|
||||
public ClientLogic(IClientStorage buyerStorage)
|
||||
{
|
||||
_clientStorage = buyerStorage;
|
||||
}
|
||||
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _clientStorage.GetElement(model);
|
||||
if(element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||
if(list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Create(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_clientStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if(_clientStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ClientBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if(_clientStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Organization))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.Organization));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_clientStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ConstructionMaterialLogic : IConstructionMaterialLogic
|
||||
{
|
||||
private readonly IConstructionMaterialStorage _ConstructionMaterialStorage;
|
||||
|
||||
public ConstructionMaterialLogic(IConstructionMaterialStorage ConstructionMaterialStorage)
|
||||
{
|
||||
_ConstructionMaterialStorage = ConstructionMaterialStorage;
|
||||
}
|
||||
public ConstructionMaterialViewModel? ReadElement(ConstructionMaterialSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _ConstructionMaterialStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ConstructionMaterialViewModel>? ReadList(ConstructionMaterialSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _ConstructionMaterialStorage.GetFullList() : _ConstructionMaterialStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Create(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ConstructionMaterialStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_ConstructionMaterialStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ConstructionMaterialStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ConstructionMaterialBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.MaterialName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.MaterialName));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_ConstructionMaterialStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class EmployeeLogic : IEmployeeLogic
|
||||
{
|
||||
private readonly IEmployeeStorage _EmployeeStorage;
|
||||
|
||||
public EmployeeLogic(IEmployeeStorage employeeStorage)
|
||||
{
|
||||
_EmployeeStorage = employeeStorage;
|
||||
}
|
||||
public EmployeeViewModel? ReadElement(EmployeeSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _EmployeeStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _EmployeeStorage.GetFullList() : _EmployeeStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Create(EmployeeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_EmployeeStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(EmployeeBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_EmployeeStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(EmployeeBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_EmployeeStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(EmployeeBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.FullName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.FullName));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_EmployeeStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
124
ConstructionFirmBusinessLogic/BusinessLogics/ProjectLogic.cs
Normal file
124
ConstructionFirmBusinessLogic/BusinessLogics/ProjectLogic.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ConstructionFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ProjectLogic : IProjectLogic
|
||||
{
|
||||
private readonly IProjectStorage _ProjectStorage;
|
||||
|
||||
public ProjectLogic(IProjectStorage ProjectStorage)
|
||||
{
|
||||
_ProjectStorage = ProjectStorage;
|
||||
}
|
||||
public ProjectViewModel? ReadElement(ProjectSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _ProjectStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ProjectViewModel>? ReadList(ProjectSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _ProjectStorage.GetFullList() : _ProjectStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Create(ProjectBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ProjectStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ProjectBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_ProjectStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ProjectBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_ProjectStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeliveryProject(ProjectBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, ConstructionFirmDataModels.Enum.TaskStatus.Выдан);
|
||||
}
|
||||
|
||||
public bool FinishProject(ProjectBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, ConstructionFirmDataModels.Enum.TaskStatus.Готов);
|
||||
}
|
||||
|
||||
public bool TakeProjectInWork(ProjectBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, ConstructionFirmDataModels.Enum.TaskStatus.Выполняется);
|
||||
}
|
||||
|
||||
private bool StatusUpdate(ProjectBindingModel model, ConstructionFirmDataModels.Enum.TaskStatus newStatus)
|
||||
{
|
||||
|
||||
if (model.Status + 1 != newStatus)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (_ProjectStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ProjectBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_ProjectStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class SpecialtyLogic : ISpecialtyLogic
|
||||
{
|
||||
private readonly ISpecialtyStorage _SpecialtyStorage;
|
||||
|
||||
public SpecialtyLogic(ISpecialtyStorage specialtyStorage)
|
||||
{
|
||||
_SpecialtyStorage = specialtyStorage;
|
||||
}
|
||||
public SpecialtyViewModel? ReadElement(SpecialtySearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _SpecialtyStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<SpecialtyViewModel>? ReadList(SpecialtySearchModel? model)
|
||||
{
|
||||
var list = model == null ? _SpecialtyStorage.GetFullList() : _SpecialtyStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Create(SpecialtyBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_SpecialtyStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(SpecialtyBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_SpecialtyStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(SpecialtyBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_SpecialtyStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(SpecialtyBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.SpecialtyName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.SpecialtyName));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_SpecialtyStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
98
ConstructionFirmBusinessLogic/BusinessLogics/TeamLogic.cs
Normal file
98
ConstructionFirmBusinessLogic/BusinessLogics/TeamLogic.cs
Normal file
@ -0,0 +1,98 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class TeamLogic : ITeamLogic
|
||||
{
|
||||
private readonly ITeamStorage _TeamStorage;
|
||||
|
||||
public TeamLogic(ITeamStorage teamStorage)
|
||||
{
|
||||
_TeamStorage = teamStorage;
|
||||
}
|
||||
public TeamViewModel? ReadElement(TeamSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
var element = _TeamStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<TeamViewModel>? ReadList(TeamSearchModel? model)
|
||||
{
|
||||
var list = model == null ? _TeamStorage.GetFullList() : _TeamStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Create(TeamBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_TeamStorage.Insert(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(TeamBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
if (_TeamStorage.Delete(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(TeamBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_TeamStorage.Update(model) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(TeamBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.TeamName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия", nameof(model.TeamName));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearEntity()
|
||||
{
|
||||
_TeamStorage.ClearEntity();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Subd-4\ConstructionFirmContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
16
ConstructionFirmDataModels/Enum/TaskStatus.cs
Normal file
16
ConstructionFirmDataModels/Enum/TaskStatus.cs
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
namespace ConstructionFirmDataModels.Enum
|
||||
{
|
||||
public enum TaskStatus
|
||||
{
|
||||
Неизвестен = -1,
|
||||
|
||||
Принят = 0,
|
||||
|
||||
Выполняется = 1,
|
||||
|
||||
Готов = 2,
|
||||
|
||||
Выдан = 3
|
||||
}
|
||||
}
|
7
ConstructionFirmDataModels/IId.cs
Normal file
7
ConstructionFirmDataModels/IId.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace ConstructionFirmDataModels
|
||||
{
|
||||
public interface IId
|
||||
{
|
||||
int Id { get; }
|
||||
}
|
||||
}
|
16
ConstructionFirmDataModels/Models/IClientModel.cs
Normal file
16
ConstructionFirmDataModels/Models/IClientModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
{
|
||||
string Organization { get; }
|
||||
string ContractPerson { get; }
|
||||
string Phone { get; }
|
||||
string Email { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDataModels.Models
|
||||
{
|
||||
public interface IConstructionMaterialModel : IId
|
||||
{
|
||||
string MaterialName { get; }
|
||||
int Cost { get; }
|
||||
int Quantity { get; }
|
||||
}
|
||||
}
|
17
ConstructionFirmDataModels/Models/IEmployeeModel.cs
Normal file
17
ConstructionFirmDataModels/Models/IEmployeeModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDataModels.Models
|
||||
{
|
||||
public interface IEmployeeModel : IId
|
||||
{
|
||||
string FullName { get; }
|
||||
string Phone { get; }
|
||||
DateTime HireDate { get; }
|
||||
int TeamId { get; }
|
||||
int SpecialtyId { get; }
|
||||
}
|
||||
}
|
25
ConstructionFirmDataModels/Models/IProjectModel.cs
Normal file
25
ConstructionFirmDataModels/Models/IProjectModel.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace ConstructionFirmDataModels.Models
|
||||
{
|
||||
public interface IProjectModel : IId
|
||||
{
|
||||
string ClientName { get; }
|
||||
string ObjectType { get; }
|
||||
string LocationP { get; }
|
||||
int Budget { get; }
|
||||
DateTime DeadLine { get; }
|
||||
Enum.TaskStatus Status { get; }
|
||||
int CliendId { get; }
|
||||
int EmployeeId {get;}
|
||||
|
||||
Dictionary<int, (IConstructionMaterialModel, int)> ConstructionMaterialProjects { get; }
|
||||
Dictionary<int, (ITeamModel, int)> TeamProject { get; }
|
||||
}
|
||||
}
|
14
ConstructionFirmDataModels/Models/ISpecialtyModel.cs
Normal file
14
ConstructionFirmDataModels/Models/ISpecialtyModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDataModels.Models
|
||||
{
|
||||
public interface ISpecialtyModel : IId
|
||||
{
|
||||
string SpecialtyName { get; }
|
||||
int Salary { get; }
|
||||
}
|
||||
}
|
16
ConstructionFirmDataModels/Models/ITeamModel.cs
Normal file
16
ConstructionFirmDataModels/Models/ITeamModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDataModels.Models
|
||||
{
|
||||
public interface ITeamModel : IId
|
||||
{
|
||||
string TeamName { get; }
|
||||
string LeaderName { get; }
|
||||
int Experince { get; }
|
||||
string TeamType { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ConstructionFirmDatabaseImplement.Models;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement
|
||||
{
|
||||
public class ConstructionFirmDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseNpgsql(@"Host=localhost;Port=5432;Database=ConstructionFirm_db;Username=postgres;Password=admin");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
public virtual DbSet<ConstructionMaterial> ConstructionMaterials { get; set; }
|
||||
public virtual DbSet<Employee> Employees { get; set; }
|
||||
public virtual DbSet<Project> Projects { get; set; }
|
||||
public virtual DbSet<Specialty> Specialtys { get; set; }
|
||||
public virtual DbSet<Team> Teams { get; set; }
|
||||
public virtual DbSet<ConstructionMaterialProject> ConstructionMaterialProjects { get; set; }
|
||||
public virtual DbSet<ProjectTeam> ProjectTeams { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.16" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.16">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ConstructionFirmDataModels\ConstructionFirmDataModels.csproj" />
|
||||
<ProjectReference Include="..\Subd-4\ConstructionFirmContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,72 @@
|
||||
using ConstructionFirmDatabaseImplement.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Implements
|
||||
{
|
||||
public class ClientStorage : IClientStorage
|
||||
{
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Organization))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Clients.Where(x => x.Organization.Contains(model.Organization)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Clients.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ClientViewModel? Delete(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var element = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Clients.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Clients.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Organization)) && x.Organization == model.Organization || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Insert(ClientBindingModel model)
|
||||
{
|
||||
var newClient = Client.Create(model);
|
||||
if (newClient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
context.Clients.Add(newClient);
|
||||
context.SaveChanges();
|
||||
return newClient.GetViewModel;
|
||||
}
|
||||
|
||||
public ClientViewModel? Update(ClientBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var component = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
using ConstructionFirmDatabaseImplement.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Implements
|
||||
{
|
||||
public class ConstructionMaterialStorage : IConstructionMaterialStorage
|
||||
{
|
||||
public List<ConstructionMaterialViewModel> GetFilteredList(ConstructionMaterialSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.MaterialName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.ConstructionMaterials.Where(x => x.MaterialName.Contains(model.MaterialName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ConstructionMaterialViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.ConstructionMaterials.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ConstructionMaterialViewModel? Delete(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var element = context.ConstructionMaterials.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.ConstructionMaterials.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ConstructionMaterialViewModel? GetElement(ConstructionMaterialSearchModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.ConstructionMaterials.FirstOrDefault(x => (!string.IsNullOrEmpty(model.MaterialName)) && x.MaterialName == model.MaterialName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public ConstructionMaterialViewModel? Insert(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
var newConstructionMaterial = ConstructionMaterial.Create(model);
|
||||
if (newConstructionMaterial == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
context.ConstructionMaterials.Add(newConstructionMaterial);
|
||||
context.SaveChanges();
|
||||
return newConstructionMaterial.GetViewModel;
|
||||
}
|
||||
|
||||
public ConstructionMaterialViewModel? Update(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var component = context.ConstructionMaterials.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
using ConstructionFirmDatabaseImplement.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Implements
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FullName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Employees.Where(x => x.FullName.Contains(model.FullName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Employees.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Delete(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var element = context.Employees.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Employees.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? GetElement(EmployeeSearchModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Employees.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FullName)) && x.FullName == model.FullName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Insert(EmployeeBindingModel model)
|
||||
{
|
||||
var newEmployee = Employee.Create(model);
|
||||
if (newEmployee == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
context.Employees.Add(newEmployee);
|
||||
context.SaveChanges();
|
||||
return newEmployee.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Update(EmployeeBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var component = context.Employees.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
102
ConstructionFirmDatabaseImplement/Implements/ProjectStorage.cs
Normal file
102
ConstructionFirmDatabaseImplement/Implements/ProjectStorage.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Implements
|
||||
{
|
||||
public class ProjectStorage : IProjectStorage
|
||||
{
|
||||
public ProjectViewModel? Delete(ProjectBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var element = context.Projects
|
||||
.FirstOrDefault(p => p.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Projects.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ProjectViewModel? GetElement(ProjectSearchModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Projects
|
||||
.Include(x => x.MaterialProjects)
|
||||
.ThenInclude(x => x.ConstructionMaterial)
|
||||
.Include(x => x.ProjectTeams)
|
||||
.ThenInclude(x => x.Team)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ProjectViewModel> GetFilteredList(ProjectSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Projects
|
||||
.Include(x => x.MaterialProjects)
|
||||
.ThenInclude(x => x.ConstructionMaterial)
|
||||
.Include(x => x.ProjectTeams)
|
||||
.ThenInclude(x => x.Team)
|
||||
.Where(x => x.Id == model.Id).ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ProjectViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Projects
|
||||
.Include(x => x.MaterialProjects)
|
||||
.ThenInclude(x => x.ConstructionMaterial)
|
||||
.Include(x => x.ProjectTeams)
|
||||
.ThenInclude(x => x.Team)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ProjectViewModel? Insert(ProjectBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var newProject = Models.Project.Create(context, model);
|
||||
if (newProject == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Projects.Add(newProject);
|
||||
context.SaveChanges();
|
||||
return newProject.GetViewModel;
|
||||
}
|
||||
|
||||
public ProjectViewModel? Update(ProjectBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var Project = context.Projects.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (Project == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Project.Update(model);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return Project.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
using ConstructionFirmDatabaseImplement.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Implements
|
||||
{
|
||||
public class SpecialtyStorage : ISpecialtyStorage
|
||||
{
|
||||
public List<SpecialtyViewModel> GetFilteredList(SpecialtySearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.SpecialtyName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Specialtys.Where(x => x.SpecialtyName.Contains(model.SpecialtyName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<SpecialtyViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Specialtys.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public SpecialtyViewModel? Delete(SpecialtyBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var element = context.Specialtys.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Specialtys.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public SpecialtyViewModel? GetElement(SpecialtySearchModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Specialtys.FirstOrDefault(x => (!string.IsNullOrEmpty(model.SpecialtyName)) && x.SpecialtyName == model.SpecialtyName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public SpecialtyViewModel? Insert(SpecialtyBindingModel model)
|
||||
{
|
||||
var newSpecialty = Specialty.Create(model);
|
||||
if (newSpecialty == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
context.Specialtys.Add(newSpecialty);
|
||||
context.SaveChanges();
|
||||
return newSpecialty.GetViewModel;
|
||||
}
|
||||
|
||||
public SpecialtyViewModel? Update(SpecialtyBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var component = context.Specialtys.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
72
ConstructionFirmDatabaseImplement/Implements/TeamStorage.cs
Normal file
72
ConstructionFirmDatabaseImplement/Implements/TeamStorage.cs
Normal file
@ -0,0 +1,72 @@
|
||||
using ConstructionFirmDatabaseImplement.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.StoragesContracts;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Implements
|
||||
{
|
||||
public class TeamStorage : ITeamStorage
|
||||
{
|
||||
public List<TeamViewModel> GetFilteredList(TeamSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.TeamName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Teams.Where(x => x.TeamName.Contains(model.TeamName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<TeamViewModel> GetFullList()
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Teams.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public TeamViewModel? Delete(TeamBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var element = context.Teams.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Teams.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TeamViewModel? GetElement(TeamSearchModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
return context.Teams.FirstOrDefault(x => (!string.IsNullOrEmpty(model.TeamName)) && x.TeamName == model.TeamName || model.Id.HasValue && x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public TeamViewModel? Insert(TeamBindingModel model)
|
||||
{
|
||||
var newTeam = Team.Create(model);
|
||||
if (newTeam == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
context.Teams.Add(newTeam);
|
||||
context.SaveChanges();
|
||||
return newTeam.GetViewModel;
|
||||
}
|
||||
|
||||
public TeamViewModel? Update(TeamBindingModel model)
|
||||
{
|
||||
using var context = new ConstructionFirmDatabase();
|
||||
var component = context.Teams.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
300
ConstructionFirmDatabaseImplement/Migrations/20240507132319_EmployeeMigration.Designer.cs
generated
Normal file
300
ConstructionFirmDatabaseImplement/Migrations/20240507132319_EmployeeMigration.Designer.cs
generated
Normal file
@ -0,0 +1,300 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ConstructionFirmDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ConstructionFirmDatabase))]
|
||||
[Migration("20240507132319_EmployeeMigration")]
|
||||
partial class EmployeeMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.16")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ContractPerson")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Organization")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ConstructionMaterial", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Cost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("MaterialName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ConstructionMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ConstructionMaterialProject", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConstructionMaterialId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProjectId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConstructionMaterialId");
|
||||
|
||||
b.HasIndex("ProjectId");
|
||||
|
||||
b.ToTable("ConstructionMaterialProjects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("HireDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("SpecialtyId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Project", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Budget")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CliendId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ClientName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DeadLine")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("FullPrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("LocationP")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ObjectType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Projects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ProjectTeam", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountTeam")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProjectId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProjectId");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("ProjectTeams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Specialty", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Salary")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SpecialtyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Specialtys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Team", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Experince")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("LeaderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TeamName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TeamType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Teams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ConstructionMaterialProject", b =>
|
||||
{
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.ConstructionMaterial", "ConstructionMaterial")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConstructionMaterialId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.Project", "Project")
|
||||
.WithMany("MaterialProjects")
|
||||
.HasForeignKey("ProjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ConstructionMaterial");
|
||||
|
||||
b.Navigation("Project");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ProjectTeam", b =>
|
||||
{
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.Project", "Project")
|
||||
.WithMany("ProjectTeams")
|
||||
.HasForeignKey("ProjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.Team", "Team")
|
||||
.WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Project");
|
||||
|
||||
b.Navigation("Team");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Project", b =>
|
||||
{
|
||||
b.Navigation("MaterialProjects");
|
||||
|
||||
b.Navigation("ProjectTeams");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,217 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class EmployeeMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Organization = table.Column<string>(type: "text", nullable: false),
|
||||
ContractPerson = table.Column<string>(type: "text", nullable: false),
|
||||
Phone = table.Column<string>(type: "text", nullable: false),
|
||||
Email = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ConstructionMaterials",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
MaterialName = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<int>(type: "integer", nullable: false),
|
||||
Quantity = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ConstructionMaterials", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Employees",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FullName = table.Column<string>(type: "text", nullable: false),
|
||||
Phone = table.Column<string>(type: "text", nullable: false),
|
||||
HireDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
TeamId = table.Column<int>(type: "integer", nullable: false),
|
||||
SpecialtyId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Employees", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Projects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ClientName = table.Column<string>(type: "text", nullable: false),
|
||||
ObjectType = table.Column<string>(type: "text", nullable: false),
|
||||
LocationP = table.Column<string>(type: "text", nullable: false),
|
||||
Budget = table.Column<int>(type: "integer", nullable: false),
|
||||
DeadLine = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
FullPrice = table.Column<double>(type: "double precision", nullable: false),
|
||||
CliendId = table.Column<int>(type: "integer", nullable: false),
|
||||
EmployeeId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Projects", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Specialtys",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
SpecialtyName = table.Column<string>(type: "text", nullable: false),
|
||||
Salary = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Specialtys", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Teams",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
TeamName = table.Column<string>(type: "text", nullable: false),
|
||||
LeaderName = table.Column<string>(type: "text", nullable: false),
|
||||
Experince = table.Column<int>(type: "integer", nullable: false),
|
||||
TeamType = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Teams", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ConstructionMaterialProjects",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProjectId = table.Column<int>(type: "integer", nullable: false),
|
||||
ConstructionMaterialId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ConstructionMaterialProjects", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConstructionMaterialProjects_ConstructionMaterials_Construc~",
|
||||
column: x => x.ConstructionMaterialId,
|
||||
principalTable: "ConstructionMaterials",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ConstructionMaterialProjects_Projects_ProjectId",
|
||||
column: x => x.ProjectId,
|
||||
principalTable: "Projects",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ProjectTeams",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ProjectId = table.Column<int>(type: "integer", nullable: false),
|
||||
TeamId = table.Column<int>(type: "integer", nullable: false),
|
||||
CountTeam = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ProjectTeams", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProjectTeams_Projects_ProjectId",
|
||||
column: x => x.ProjectId,
|
||||
principalTable: "Projects",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProjectTeams_Teams_TeamId",
|
||||
column: x => x.TeamId,
|
||||
principalTable: "Teams",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConstructionMaterialProjects_ConstructionMaterialId",
|
||||
table: "ConstructionMaterialProjects",
|
||||
column: "ConstructionMaterialId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ConstructionMaterialProjects_ProjectId",
|
||||
table: "ConstructionMaterialProjects",
|
||||
column: "ProjectId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjectTeams_ProjectId",
|
||||
table: "ProjectTeams",
|
||||
column: "ProjectId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProjectTeams_TeamId",
|
||||
table: "ProjectTeams",
|
||||
column: "TeamId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ConstructionMaterialProjects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Employees");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ProjectTeams");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Specialtys");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ConstructionMaterials");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Projects");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Teams");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,297 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ConstructionFirmDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ConstructionFirmDatabase))]
|
||||
partial class ConstructionFirmDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.16")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ContractPerson")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Organization")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ConstructionMaterial", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Cost")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("MaterialName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Quantity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ConstructionMaterials");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ConstructionMaterialProject", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ConstructionMaterialId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProjectId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConstructionMaterialId");
|
||||
|
||||
b.HasIndex("ProjectId");
|
||||
|
||||
b.ToTable("ConstructionMaterialProjects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("HireDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("SpecialtyId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Project", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Budget")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CliendId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ClientName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DeadLine")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("EmployeeId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("FullPrice")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("LocationP")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ObjectType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Projects");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ProjectTeam", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountTeam")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ProjectId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("TeamId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProjectId");
|
||||
|
||||
b.HasIndex("TeamId");
|
||||
|
||||
b.ToTable("ProjectTeams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Specialty", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Salary")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("SpecialtyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Specialtys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Team", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Experince")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("LeaderName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TeamName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TeamType")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Teams");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ConstructionMaterialProject", b =>
|
||||
{
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.ConstructionMaterial", "ConstructionMaterial")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConstructionMaterialId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.Project", "Project")
|
||||
.WithMany("MaterialProjects")
|
||||
.HasForeignKey("ProjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ConstructionMaterial");
|
||||
|
||||
b.Navigation("Project");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.ProjectTeam", b =>
|
||||
{
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.Project", "Project")
|
||||
.WithMany("ProjectTeams")
|
||||
.HasForeignKey("ProjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ConstructionFirmDatabaseImplement.Models.Team", "Team")
|
||||
.WithMany()
|
||||
.HasForeignKey("TeamId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Project");
|
||||
|
||||
b.Navigation("Team");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ConstructionFirmDatabaseImplement.Models.Project", b =>
|
||||
{
|
||||
b.Navigation("MaterialProjects");
|
||||
|
||||
b.Navigation("ProjectTeams");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
56
ConstructionFirmDatabaseImplement/Models/Client.cs
Normal file
56
ConstructionFirmDatabaseImplement/Models/Client.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class Client : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Organization { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string ContractPerson { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
return new Client()
|
||||
{
|
||||
Id = model.Id,
|
||||
Organization = model.Organization,
|
||||
ContractPerson = model.ContractPerson,
|
||||
Phone = model.Phone,
|
||||
Email = model.Email
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ClientBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Organization = model.Organization;
|
||||
ContractPerson = model.ContractPerson;
|
||||
Phone = model.Phone;
|
||||
Email = model.Email;
|
||||
}
|
||||
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Organization = Organization,
|
||||
ContractPerson = ContractPerson,
|
||||
Phone = Phone,
|
||||
Email = Email
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class ConstructionMaterial : IConstructionMaterialModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string MaterialName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int Cost { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Quantity { get; set; }
|
||||
|
||||
public static ConstructionMaterial? Create(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
return new ConstructionMaterial()
|
||||
{
|
||||
Id = model.Id,
|
||||
MaterialName = model.MaterialName,
|
||||
Cost = model.Cost,
|
||||
Quantity = model.Quantity
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ConstructionMaterialBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
MaterialName = model.MaterialName;
|
||||
Cost = model.Cost;
|
||||
Quantity = model.Quantity;
|
||||
}
|
||||
|
||||
public ConstructionMaterialViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
MaterialName = MaterialName,
|
||||
Cost = Cost,
|
||||
Quantity = Quantity
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class ConstructionMaterialProject
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ProjectId { get; set; }
|
||||
public int ConstructionMaterialId { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Project Project { get; set; } = new();
|
||||
public virtual ConstructionMaterial ConstructionMaterial { get; set; } = new();
|
||||
}
|
||||
}
|
65
ConstructionFirmDatabaseImplement/Models/Employee.cs
Normal file
65
ConstructionFirmDatabaseImplement/Models/Employee.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class Employee : IEmployeeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public DateTime HireDate { get; set; }
|
||||
|
||||
public int TeamId { get; set; }
|
||||
|
||||
public int SpecialtyId { get; set; }
|
||||
|
||||
public static Employee? Create(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
return new Employee()
|
||||
{
|
||||
Id = model.Id,
|
||||
FullName = model.FullName,
|
||||
Phone = model.Phone,
|
||||
HireDate = model.HireDate,
|
||||
TeamId = model.TeamId,
|
||||
SpecialtyId = model.SpecialtyId
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
FullName = model.FullName;
|
||||
Phone = model.Phone;
|
||||
HireDate = model.HireDate;
|
||||
TeamId = model.TeamId;
|
||||
SpecialtyId = model.SpecialtyId;
|
||||
}
|
||||
|
||||
public EmployeeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
FullName = FullName,
|
||||
Phone = Phone,
|
||||
HireDate = HireDate,
|
||||
TeamId = TeamId,
|
||||
SpecialtyId = SpecialtyId
|
||||
};
|
||||
}
|
||||
}
|
185
ConstructionFirmDatabaseImplement/Models/Project.cs
Normal file
185
ConstructionFirmDatabaseImplement/Models/Project.cs
Normal file
@ -0,0 +1,185 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class Project : IProjectModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string ObjectType { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string LocationP { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int Budget { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DeadLine { get; set; }
|
||||
|
||||
[Required]
|
||||
public ConstructionFirmDataModels.Enum.TaskStatus Status { get; set; }
|
||||
|
||||
[Required]
|
||||
public double FullPrice { get; set; }
|
||||
|
||||
public int CliendId { get; set; }
|
||||
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
private Dictionary<int, (IConstructionMaterialModel, int)> _constructionMaterialProject = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IConstructionMaterialModel, int)> ConstructionMaterialProjects
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_constructionMaterialProject == null)
|
||||
{
|
||||
_constructionMaterialProject = MaterialProjects.ToDictionary(recTM => recTM.ConstructionMaterialId, recTM => (recTM.ConstructionMaterial as IConstructionMaterialModel, recTM.Count));
|
||||
}
|
||||
return _constructionMaterialProject;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, (ITeamModel, int)> _teamProject { get; set; } = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (ITeamModel, int)> TeamProject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_teamProject == null)
|
||||
{
|
||||
_teamProject = ProjectTeams.ToDictionary(recTM => recTM.TeamId, recTM => (recTM.Team as ITeamModel, recTM.CountTeam));
|
||||
}
|
||||
return _teamProject;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("ProjectId")]
|
||||
public virtual List<ConstructionMaterialProject> MaterialProjects { get; set; } = new();
|
||||
|
||||
[ForeignKey("ProjectId")]
|
||||
public virtual List<ProjectTeam> ProjectTeams { get; set; } = new();
|
||||
|
||||
public static Project Create(ConstructionFirmDatabase context, ProjectBindingModel model)
|
||||
{
|
||||
return new Project()
|
||||
{
|
||||
Id = model.Id,
|
||||
ClientName = model.ClientName,
|
||||
ObjectType = model.ObjectType,
|
||||
LocationP = model.LocationP,
|
||||
Budget = model.Budget,
|
||||
DeadLine = model.DeadLine,
|
||||
Status = model.Status,
|
||||
CliendId = model.CliendId,
|
||||
EmployeeId = model.EmployeeId,
|
||||
MaterialProjects = model.ConstructionMaterialProjects.Select(x => new ConstructionMaterialProject
|
||||
{
|
||||
ConstructionMaterial = context.ConstructionMaterials.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList(),
|
||||
ProjectTeams = model.TeamProject.Select(x => new ProjectTeam
|
||||
{
|
||||
Team = context.Teams.First(y => y.Id == x.Key),
|
||||
CountTeam = x.Value.Item2
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ProjectBindingModel model)
|
||||
{
|
||||
Status = model.Status;
|
||||
}
|
||||
|
||||
public ProjectViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ClientName = ClientName,
|
||||
ObjectType = ObjectType,
|
||||
LocationP = LocationP,
|
||||
Budget = Budget,
|
||||
DeadLine = DeadLine,
|
||||
Status = Status,
|
||||
CliendId = CliendId,
|
||||
EmployeeId = EmployeeId,
|
||||
ConstructionMaterialProjects = ConstructionMaterialProjects,
|
||||
TeamProject = TeamProject
|
||||
};
|
||||
|
||||
public void UpdateConstructionMaterials(ConstructionFirmDatabase context, ProjectBindingModel model)
|
||||
{
|
||||
var taskMenus = context.ConstructionMaterialProjects.Where(rec => rec.ProjectId == model.Id).ToList();
|
||||
if (taskMenus != null && taskMenus.Count > 0)
|
||||
{
|
||||
context.ConstructionMaterialProjects.RemoveRange(taskMenus.Where(rec => !model.ConstructionMaterialProjects.ContainsKey(rec.ConstructionMaterialId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateMenu in taskMenus)
|
||||
{
|
||||
updateMenu.Count = model.ConstructionMaterialProjects[updateMenu.ConstructionMaterialId].Item2;
|
||||
model.ConstructionMaterialProjects.Remove(updateMenu.ConstructionMaterialId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
var task = context.Projects.First(x => x.Id == Id);
|
||||
foreach (var rc in model.ConstructionMaterialProjects)
|
||||
{
|
||||
context.ConstructionMaterialProjects.Add(new ConstructionMaterialProject
|
||||
{
|
||||
Project = task,
|
||||
ConstructionMaterial = context.ConstructionMaterials.First(x => x.Id == rc.Key),
|
||||
Count = rc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_constructionMaterialProject = null;
|
||||
}
|
||||
|
||||
public void UpdateTeams(ConstructionFirmDatabase context, ProjectBindingModel model)
|
||||
{
|
||||
var taskTeams = context.ProjectTeams.Where(rec => rec.ProjectId == model.Id).ToList();
|
||||
if (taskTeams != null && taskTeams.Count > 0)
|
||||
{
|
||||
context.ProjectTeams.RemoveRange(taskTeams.Where(rec => !model.TeamProject.ContainsKey(rec.TeamId)));
|
||||
context.SaveChanges();
|
||||
|
||||
foreach (var updateTeam in taskTeams)
|
||||
{
|
||||
updateTeam.CountTeam = model.TeamProject[updateTeam.TeamId].Item2;
|
||||
model.TeamProject.Remove(updateTeam.TeamId);
|
||||
}
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
var task = context.Projects.First(x => x.Id == Id);
|
||||
foreach (var rc in model.TeamProject)
|
||||
{
|
||||
context.ProjectTeams.Add(new ProjectTeam
|
||||
{
|
||||
Project = task,
|
||||
Team = context.Teams.First(x => x.Id == rc.Key),
|
||||
CountTeam = rc.Value.Item2
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
_constructionMaterialProject = null;
|
||||
}
|
||||
}
|
||||
}
|
21
ConstructionFirmDatabaseImplement/Models/ProjectTeam.cs
Normal file
21
ConstructionFirmDatabaseImplement/Models/ProjectTeam.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class ProjectTeam
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ProjectId { get; set; }
|
||||
public int TeamId { get; set; }
|
||||
|
||||
public int CountTeam { get; set; }
|
||||
|
||||
public virtual Project Project { get; set; } = new();
|
||||
public virtual Team Team { get; set; } = new();
|
||||
}
|
||||
}
|
49
ConstructionFirmDatabaseImplement/Models/Specialty.cs
Normal file
49
ConstructionFirmDatabaseImplement/Models/Specialty.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class Specialty : ISpecialtyModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string SpecialtyName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int Salary { get; set; }
|
||||
|
||||
public static Specialty? Create(SpecialtyBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
return new Specialty()
|
||||
{
|
||||
Id = model.Id,
|
||||
SpecialtyName = model.SpecialtyName,
|
||||
Salary = model.Salary
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(SpecialtyBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
SpecialtyName = model.SpecialtyName;
|
||||
Salary = model.Salary;
|
||||
}
|
||||
|
||||
public SpecialtyViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
SpecialtyName = SpecialtyName,
|
||||
Salary = Salary
|
||||
};
|
||||
}
|
||||
}
|
61
ConstructionFirmDatabaseImplement/Models/Team.cs
Normal file
61
ConstructionFirmDatabaseImplement/Models/Team.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionFirmDatabaseImplement.Models
|
||||
{
|
||||
public class Team : ITeamModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string TeamName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string LeaderName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public int Experince { get; set; }
|
||||
|
||||
[Required]
|
||||
public string TeamType { get; set; } = string.Empty;
|
||||
|
||||
public static Team? Create(TeamBindingModel model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
return new Team()
|
||||
{
|
||||
Id = model.Id,
|
||||
TeamName = model.TeamName,
|
||||
LeaderName = model.LeaderName,
|
||||
Experince = model.Experince,
|
||||
TeamType = model.TeamType
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(TeamBindingModel model)
|
||||
{
|
||||
if (model == null) return;
|
||||
TeamName = model.TeamName;
|
||||
LeaderName = model.LeaderName;
|
||||
Experince = model.Experince;
|
||||
TeamType = model.TeamType;
|
||||
}
|
||||
|
||||
public TeamViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
TeamName = TeamName,
|
||||
LeaderName = LeaderName,
|
||||
Experince = Experince,
|
||||
TeamType = TeamType
|
||||
};
|
||||
}
|
||||
}
|
18
ConstructionFirmMongoDB/ConstructionFirmMongoDB.csproj
Normal file
18
ConstructionFirmMongoDB/ConstructionFirmMongoDB.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bogus" Version="35.5.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
|
||||
<PackageReference Include="MongoDB.Bson" Version="2.25.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.25.0" />
|
||||
<PackageReference Include="MongoDB.Driver.Core" Version="2.25.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.18" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
55
Subd-4.sln
Normal file
55
Subd-4.sln
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34031.279
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionFirmContracts", "Subd-4\ConstructionFirmContracts.csproj", "{EEACF577-80AB-4C43-A5BA-F98FBE74C40D}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "viewmodel", "viewmodel\viewmodel.csproj", "{AAFE0DDC-5E1B-4C5D-B67C-26024F9A5A49}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionFirmDataModels", "ConstructionFirmDataModels\ConstructionFirmDataModels.csproj", "{55585545-61F2-410B-807D-0A31F6D65DF5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionFirmBusinessLogic", "ConstructionFirmBusinessLogic\ConstructionFirmBusinessLogic.csproj", "{9615B425-B13D-4C4E-BA42-5797AF1C29EA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConstructionFirmDatabaseImplement", "ConstructionFirmDatabaseImplement\ConstructionFirmDatabaseImplement.csproj", "{B69D37F1-790E-466D-B1E6-DC608A71009D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionFirmMongoDB", "ConstructionFirmMongoDB\ConstructionFirmMongoDB.csproj", "{55B760B2-BB8C-4CDD-BE06-9ADDCB2A8EBA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EEACF577-80AB-4C43-A5BA-F98FBE74C40D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EEACF577-80AB-4C43-A5BA-F98FBE74C40D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EEACF577-80AB-4C43-A5BA-F98FBE74C40D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EEACF577-80AB-4C43-A5BA-F98FBE74C40D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AAFE0DDC-5E1B-4C5D-B67C-26024F9A5A49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AAFE0DDC-5E1B-4C5D-B67C-26024F9A5A49}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AAFE0DDC-5E1B-4C5D-B67C-26024F9A5A49}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AAFE0DDC-5E1B-4C5D-B67C-26024F9A5A49}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{55585545-61F2-410B-807D-0A31F6D65DF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{55585545-61F2-410B-807D-0A31F6D65DF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{55585545-61F2-410B-807D-0A31F6D65DF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{55585545-61F2-410B-807D-0A31F6D65DF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9615B425-B13D-4C4E-BA42-5797AF1C29EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9615B425-B13D-4C4E-BA42-5797AF1C29EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9615B425-B13D-4C4E-BA42-5797AF1C29EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9615B425-B13D-4C4E-BA42-5797AF1C29EA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B69D37F1-790E-466D-B1E6-DC608A71009D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B69D37F1-790E-466D-B1E6-DC608A71009D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B69D37F1-790E-466D-B1E6-DC608A71009D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B69D37F1-790E-466D-B1E6-DC608A71009D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{55B760B2-BB8C-4CDD-BE06-9ADDCB2A8EBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{55B760B2-BB8C-4CDD-BE06-9ADDCB2A8EBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{55B760B2-BB8C-4CDD-BE06-9ADDCB2A8EBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{55B760B2-BB8C-4CDD-BE06-9ADDCB2A8EBA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {54FDAA86-60B5-477E-8513-BAB4E49E993B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
18
Subd-4/BindingModels/ClientBindingModel.cs
Normal file
18
Subd-4/BindingModels/ClientBindingModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BindingModels
|
||||
{
|
||||
public class ClientBindingModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Organization { get; set; } = string.Empty;
|
||||
public string ContractPerson { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
17
Subd-4/BindingModels/ConstructionMaterialBindingModel.cs
Normal file
17
Subd-4/BindingModels/ConstructionMaterialBindingModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BindingModels
|
||||
{
|
||||
public class ConstructionMaterialBindingModel : IConstructionMaterialModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string MaterialName { get; set; } = string.Empty;
|
||||
public int Cost { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
19
Subd-4/BindingModels/EmployeeBindingModel.cs
Normal file
19
Subd-4/BindingModels/EmployeeBindingModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BindingModels
|
||||
{
|
||||
public class EmployeeBindingModel : IEmployeeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public DateTime HireDate { get; set; }
|
||||
public int TeamId { get; set; }
|
||||
public int SpecialtyId { get; set; }
|
||||
}
|
||||
}
|
24
Subd-4/BindingModels/ProjectBindingModel.cs
Normal file
24
Subd-4/BindingModels/ProjectBindingModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BindingModels
|
||||
{
|
||||
public class ProjectBindingModel : IProjectModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
public string ObjectType { get; set; } = string.Empty;
|
||||
public string LocationP { get; set; } = string.Empty;
|
||||
public int Budget { get; set; }
|
||||
public DateTime DeadLine { get; set; } = DateTime.Now;
|
||||
public ConstructionFirmDataModels.Enum.TaskStatus Status { get; set; } = ConstructionFirmDataModels.Enum.TaskStatus.Неизвестен;
|
||||
public int CliendId { get; set; }
|
||||
public int EmployeeId { get; set; }
|
||||
public Dictionary<int, (IConstructionMaterialModel, int)> ConstructionMaterialProjects { get; set; } = new();
|
||||
public Dictionary<int, (ITeamModel, int)> TeamProject { get; set; } = new();
|
||||
}
|
||||
}
|
15
Subd-4/BindingModels/SpecialtyBindingModel.cs
Normal file
15
Subd-4/BindingModels/SpecialtyBindingModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BindingModels
|
||||
{
|
||||
public class SpecialtyBindingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string SpecialtyName { get; } = string.Empty;
|
||||
public int Salary { get; }
|
||||
}
|
||||
}
|
19
Subd-4/BindingModels/TeamBindingModel.cs
Normal file
19
Subd-4/BindingModels/TeamBindingModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using ConstructionFirmDataModels;
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BindingModels
|
||||
{
|
||||
public class TeamBindingModel : ITeamModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string TeamName { get; set; } = string.Empty;
|
||||
public string LeaderName { get; set; } = string.Empty;
|
||||
public int Experince { get; set; }
|
||||
public string TeamType { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
21
Subd-4/BusinessLogicContracts/IClientLogic.cs
Normal file
21
Subd-4/BusinessLogicContracts/IClientLogic.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BusinessLogicContracts
|
||||
{
|
||||
public interface IClientLogic
|
||||
{
|
||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||
bool Create(ClientBindingModel model);
|
||||
bool Update(ClientBindingModel model);
|
||||
bool Delete(ClientBindingModel model);
|
||||
void ClearEntity();
|
||||
}
|
||||
}
|
15
Subd-4/BusinessLogicContracts/IConstructionMaterialLogic.cs
Normal file
15
Subd-4/BusinessLogicContracts/IConstructionMaterialLogic.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace Subd_4.BusinessLogicContracts
|
||||
{
|
||||
public interface IConstructionMaterialLogic
|
||||
{
|
||||
List<ConstructionMaterialViewModel>? ReadList(ConstructionMaterialSearchModel? model);
|
||||
ConstructionMaterialViewModel? ReadElement(ConstructionMaterialSearchModel model);
|
||||
bool Create(ConstructionMaterialBindingModel model);
|
||||
bool Update(ConstructionMaterialBindingModel model);
|
||||
bool Delete(ConstructionMaterialBindingModel model);
|
||||
}
|
||||
}
|
20
Subd-4/BusinessLogicContracts/IEmployeeLogic.cs
Normal file
20
Subd-4/BusinessLogicContracts/IEmployeeLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BusinessLogicContracts
|
||||
{
|
||||
public interface IEmployeeLogic
|
||||
{
|
||||
List<EmployeeViewModel>? ReadList(EmployeeSearchModel? model);
|
||||
EmployeeViewModel? ReadElement(EmployeeSearchModel model);
|
||||
bool Create(EmployeeBindingModel model);
|
||||
bool Update(EmployeeBindingModel model);
|
||||
bool Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
23
Subd-4/BusinessLogicContracts/IProjectLogic.cs
Normal file
23
Subd-4/BusinessLogicContracts/IProjectLogic.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BusinessLogicContracts
|
||||
{
|
||||
public interface IProjectLogic
|
||||
{
|
||||
List<ProjectViewModel>? ReadList(ProjectSearchModel? model);
|
||||
ProjectViewModel? ReadElement(ProjectSearchModel model);
|
||||
bool Create(ProjectBindingModel model);
|
||||
bool Update(ProjectBindingModel model);
|
||||
bool Delete(ProjectBindingModel model);
|
||||
bool TakeProjectInWork(ProjectBindingModel model);
|
||||
bool FinishProject(ProjectBindingModel model);
|
||||
bool DeliveryProject(ProjectBindingModel model);
|
||||
}
|
||||
}
|
20
Subd-4/BusinessLogicContracts/ISpecialtyLogic.cs
Normal file
20
Subd-4/BusinessLogicContracts/ISpecialtyLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BusinessLogicContracts
|
||||
{
|
||||
public interface ISpecialtyLogic
|
||||
{
|
||||
List<SpecialtyViewModel>? ReadList(SpecialtySearchModel? model);
|
||||
SpecialtyViewModel? ReadElement(SpecialtySearchModel model);
|
||||
bool Create(SpecialtyBindingModel model);
|
||||
bool Update(SpecialtyBindingModel model);
|
||||
bool Delete(SpecialtyBindingModel model);
|
||||
}
|
||||
}
|
20
Subd-4/BusinessLogicContracts/ITeamLogic.cs
Normal file
20
Subd-4/BusinessLogicContracts/ITeamLogic.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.BusinessLogicContracts
|
||||
{
|
||||
public interface ITeamLogic
|
||||
{
|
||||
List<TeamViewModel>? ReadList(TeamSearchModel? model);
|
||||
TeamViewModel? ReadElement(TeamSearchModel model);
|
||||
bool Create(TeamBindingModel model);
|
||||
bool Update(TeamBindingModel model);
|
||||
bool Delete(TeamBindingModel model);
|
||||
}
|
||||
}
|
22
Subd-4/ConstructionFirmContracts.csproj
Normal file
22
Subd-4/ConstructionFirmContracts.csproj
Normal file
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>Subd_4</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.16">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ConstructionFirmDataModels\ConstructionFirmDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
8
Subd-4/SearchModels/ClientSearchModel.cs
Normal file
8
Subd-4/SearchModels/ClientSearchModel.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Subd_4.SearchModels
|
||||
{
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Organization { get; set; }
|
||||
}
|
||||
}
|
14
Subd-4/SearchModels/ConstructionMaterialSearchModel.cs
Normal file
14
Subd-4/SearchModels/ConstructionMaterialSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.SearchModels
|
||||
{
|
||||
public class ConstructionMaterialSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? MaterialName { get; set; }
|
||||
}
|
||||
}
|
14
Subd-4/SearchModels/EmployeeSearchModel.cs
Normal file
14
Subd-4/SearchModels/EmployeeSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.SearchModels
|
||||
{
|
||||
public class EmployeeSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? FullName { get; set; }
|
||||
}
|
||||
}
|
14
Subd-4/SearchModels/ProjectSearchModel.cs
Normal file
14
Subd-4/SearchModels/ProjectSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.SearchModels
|
||||
{
|
||||
public class ProjectSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ClientName { get; set; }
|
||||
}
|
||||
}
|
14
Subd-4/SearchModels/SpecialtySearchModel.cs
Normal file
14
Subd-4/SearchModels/SpecialtySearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.SearchModels
|
||||
{
|
||||
public class SpecialtySearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? SpecialtyName { get; set; }
|
||||
}
|
||||
}
|
14
Subd-4/SearchModels/TeamSearchModel.cs
Normal file
14
Subd-4/SearchModels/TeamSearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.SearchModels
|
||||
{
|
||||
public class TeamSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? TeamName { get; set; }
|
||||
}
|
||||
}
|
26
Subd-4/StoragesContracts/IClientStorage.cs
Normal file
26
Subd-4/StoragesContracts/IClientStorage.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.StoragesContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
21
Subd-4/StoragesContracts/IConstructionMaterialStorage.cs
Normal file
21
Subd-4/StoragesContracts/IConstructionMaterialStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace Subd_4.StoragesContracts
|
||||
{
|
||||
public interface IConstructionMaterialStorage
|
||||
{
|
||||
List<ConstructionMaterialViewModel> GetFullList();
|
||||
|
||||
List<ConstructionMaterialViewModel> GetFilteredList(ConstructionMaterialSearchModel model);
|
||||
|
||||
ConstructionMaterialViewModel? GetElement(ConstructionMaterialSearchModel model);
|
||||
|
||||
ConstructionMaterialViewModel? Insert(ConstructionMaterialBindingModel model);
|
||||
|
||||
ConstructionMaterialViewModel? Update(ConstructionMaterialBindingModel model);
|
||||
|
||||
ConstructionMaterialViewModel? Delete(ConstructionMaterialBindingModel model);
|
||||
}
|
||||
}
|
21
Subd-4/StoragesContracts/IEmployeeStorage.cs
Normal file
21
Subd-4/StoragesContracts/IEmployeeStorage.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
|
||||
namespace Subd_4.StoragesContracts
|
||||
{
|
||||
public interface IEmployeeStorage
|
||||
{
|
||||
List<EmployeeViewModel> GetFullList();
|
||||
|
||||
List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model);
|
||||
|
||||
EmployeeViewModel? GetElement(EmployeeSearchModel model);
|
||||
|
||||
EmployeeViewModel? Insert(EmployeeBindingModel model);
|
||||
|
||||
EmployeeViewModel? Update(EmployeeBindingModel model);
|
||||
|
||||
EmployeeViewModel? Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
26
Subd-4/StoragesContracts/IProjectStorage.cs
Normal file
26
Subd-4/StoragesContracts/IProjectStorage.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.StoragesContracts
|
||||
{
|
||||
public interface IProjectStorage
|
||||
{
|
||||
List<ProjectViewModel> GetFullList();
|
||||
|
||||
List<ProjectViewModel> GetFilteredList(ProjectSearchModel model);
|
||||
|
||||
ProjectViewModel? GetElement(ProjectSearchModel model);
|
||||
|
||||
ProjectViewModel? Insert(ProjectBindingModel model);
|
||||
|
||||
ProjectViewModel? Update(ProjectBindingModel model);
|
||||
|
||||
ProjectViewModel? Delete(ProjectBindingModel model);
|
||||
}
|
||||
}
|
26
Subd-4/StoragesContracts/ISpecialtyStorage.cs
Normal file
26
Subd-4/StoragesContracts/ISpecialtyStorage.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.StoragesContracts
|
||||
{
|
||||
public interface ISpecialtyStorage
|
||||
{
|
||||
List<SpecialtyViewModel> GetFullList();
|
||||
|
||||
List<SpecialtyViewModel> GetFilteredList(SpecialtySearchModel model);
|
||||
|
||||
SpecialtyViewModel? GetElement(SpecialtySearchModel model);
|
||||
|
||||
SpecialtyViewModel? Insert(SpecialtyBindingModel model);
|
||||
|
||||
SpecialtyViewModel? Update(SpecialtyBindingModel model);
|
||||
|
||||
SpecialtyViewModel? Delete(SpecialtyBindingModel model);
|
||||
}
|
||||
}
|
26
Subd-4/StoragesContracts/ITeamStorage.cs
Normal file
26
Subd-4/StoragesContracts/ITeamStorage.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.SearchModels;
|
||||
using Subd_4.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.StoragesContracts
|
||||
{
|
||||
public interface ITeamStorage
|
||||
{
|
||||
List<TeamViewModel> GetFullList();
|
||||
|
||||
List<TeamViewModel> GetFilteredList(TeamSearchModel model);
|
||||
|
||||
TeamViewModel? GetElement(TeamSearchModel model);
|
||||
|
||||
TeamViewModel? Insert(TeamBindingModel model);
|
||||
|
||||
TeamViewModel? Update(TeamBindingModel model);
|
||||
|
||||
TeamViewModel? Delete(TeamBindingModel model);
|
||||
}
|
||||
}
|
22
Subd-4/ViewModels/ClientViewModel.cs
Normal file
22
Subd-4/ViewModels/ClientViewModel.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Subd_4.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName ("Название организации")]
|
||||
public string Organization { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Контактное лицо")]
|
||||
public string ContractPerson { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Телефон ")]
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
24
Subd-4/ViewModels/ConstructionMaterialViewModel.cs
Normal file
24
Subd-4/ViewModels/ConstructionMaterialViewModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.ViewModels
|
||||
{
|
||||
public class ConstructionMaterialViewModel : IConstructionMaterialModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название материала")]
|
||||
public string MaterialName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Cтоимость ")]
|
||||
public int Cost { get; set; }
|
||||
|
||||
[DisplayName("Количество ")]
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
31
Subd-4/ViewModels/EmployeeViewModel.cs
Normal file
31
Subd-4/ViewModels/EmployeeViewModel.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.ViewModels
|
||||
{
|
||||
public class EmployeeViewModel : IEmployeeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("ФИО")]
|
||||
public string FullName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Телефон")]
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Зачисление на работу")]
|
||||
public DateTime HireDate { get; set; } = DateTime.Now;
|
||||
|
||||
public int TeamId { get; set; }
|
||||
|
||||
public int SpecialtyId { get; set; }
|
||||
|
||||
[DisplayName ("Название специальности")]
|
||||
public string SpecialtyName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
44
Subd-4/ViewModels/ProjectViewModel.cs
Normal file
44
Subd-4/ViewModels/ProjectViewModel.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.ViewModels
|
||||
{
|
||||
public class ProjectViewModel : IProjectModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName ("Имя клиента")]
|
||||
public string ClientName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Тип объекта")]
|
||||
public string ObjectType { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Местоположение")]
|
||||
public string LocationP { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Бюджет")]
|
||||
public int Budget { get; set; }
|
||||
|
||||
[DisplayName("Срок выполнения")]
|
||||
public DateTime DeadLine { get; set; }
|
||||
|
||||
[DisplayName("Статус")]
|
||||
public ConstructionFirmDataModels.Enum.TaskStatus Status { get; set; } = ConstructionFirmDataModels.Enum.TaskStatus.Неизвестен;
|
||||
|
||||
public int CliendId { get; set; }
|
||||
|
||||
public int EmployeeId { get; set; }
|
||||
|
||||
[DisplayName("Название организации клиента")]
|
||||
public string Organization { get; set; } = string.Empty;
|
||||
|
||||
public Dictionary<int, (IConstructionMaterialModel, int)> ConstructionMaterialProjects { get; set; } = new();
|
||||
public Dictionary<int, (ITeamModel, int)> TeamProject { get; set; } = new();
|
||||
}
|
||||
}
|
21
Subd-4/ViewModels/SpecialtyViewModel.cs
Normal file
21
Subd-4/ViewModels/SpecialtyViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.ViewModels
|
||||
{
|
||||
public class SpecialtyViewModel : ISpecialtyModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название специальности")]
|
||||
public string SpecialtyName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Зарплата")]
|
||||
public int Salary { get; set; }
|
||||
}
|
||||
}
|
27
Subd-4/ViewModels/TeamViewModel.cs
Normal file
27
Subd-4/ViewModels/TeamViewModel.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Subd_4.ViewModels
|
||||
{
|
||||
public class TeamViewModel : ITeamModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название бригады")]
|
||||
public string TeamName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Имя прораба")]
|
||||
public string LeaderName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Опыт работы")]
|
||||
public int Experince { get; set; }
|
||||
|
||||
[DisplayName("Тип бригады")]
|
||||
public string TeamType { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
163
viewmodel/FormClient.Designer.cs
generated
Normal file
163
viewmodel/FormClient.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormClient
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelOrganization = new Label();
|
||||
textBoxName = new TextBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBox1 = new TextBox();
|
||||
labelContact = new Label();
|
||||
textBox2 = new TextBox();
|
||||
labelPhone = new Label();
|
||||
textBox3 = new TextBox();
|
||||
labelEmail = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelOrganization
|
||||
//
|
||||
labelOrganization.AutoSize = true;
|
||||
labelOrganization.Location = new Point(12, 20);
|
||||
labelOrganization.Name = "labelOrganization";
|
||||
labelOrganization.Size = new Size(108, 15);
|
||||
labelOrganization.TabIndex = 0;
|
||||
labelOrganization.Text = "Имя организации:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(116, 12);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(208, 23);
|
||||
textBoxName.TabIndex = 2;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(247, 130);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(77, 30);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(164, 130);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(83, 30);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
textBox1.Location = new Point(116, 41);
|
||||
textBox1.Name = "textBox1";
|
||||
textBox1.Size = new Size(208, 23);
|
||||
textBox1.TabIndex = 9;
|
||||
//
|
||||
// labelContact
|
||||
//
|
||||
labelContact.AutoSize = true;
|
||||
labelContact.Location = new Point(12, 44);
|
||||
labelContact.Name = "labelContact";
|
||||
labelContact.Size = new Size(104, 15);
|
||||
labelContact.TabIndex = 8;
|
||||
labelContact.Text = "Контактное лицо:";
|
||||
labelContact.UseWaitCursor = true;
|
||||
//
|
||||
// textBox2
|
||||
//
|
||||
textBox2.Location = new Point(116, 70);
|
||||
textBox2.Name = "textBox2";
|
||||
textBox2.Size = new Size(208, 23);
|
||||
textBox2.TabIndex = 11;
|
||||
//
|
||||
// labelPhone
|
||||
//
|
||||
labelPhone.AutoSize = true;
|
||||
labelPhone.Location = new Point(12, 78);
|
||||
labelPhone.Name = "labelPhone";
|
||||
labelPhone.Size = new Size(58, 15);
|
||||
labelPhone.TabIndex = 10;
|
||||
labelPhone.Text = "Телефон:";
|
||||
//
|
||||
// textBox3
|
||||
//
|
||||
textBox3.Location = new Point(116, 101);
|
||||
textBox3.Name = "textBox3";
|
||||
textBox3.Size = new Size(208, 23);
|
||||
textBox3.TabIndex = 13;
|
||||
//
|
||||
// labelEmail
|
||||
//
|
||||
labelEmail.AutoSize = true;
|
||||
labelEmail.Location = new Point(12, 109);
|
||||
labelEmail.Name = "labelEmail";
|
||||
labelEmail.Size = new Size(44, 15);
|
||||
labelEmail.TabIndex = 12;
|
||||
labelEmail.Text = "Почта:";
|
||||
//
|
||||
// FormClient
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(393, 194);
|
||||
Controls.Add(textBox3);
|
||||
Controls.Add(labelEmail);
|
||||
Controls.Add(textBox2);
|
||||
Controls.Add(labelPhone);
|
||||
Controls.Add(textBox1);
|
||||
Controls.Add(labelContact);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelOrganization);
|
||||
Name = "FormClient";
|
||||
Text = "Покупатель";
|
||||
Load += FormClient_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelOrganization;
|
||||
private TextBox textBoxName;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBox1;
|
||||
private Label labelContact;
|
||||
private TextBox textBox2;
|
||||
private Label labelPhone;
|
||||
private TextBox textBox3;
|
||||
private Label labelEmail;
|
||||
}
|
||||
}
|
90
viewmodel/FormClient.cs
Normal file
90
viewmodel/FormClient.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
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 viewmodel
|
||||
{
|
||||
public partial class FormClient : Form
|
||||
{
|
||||
|
||||
private readonly IClientLogic _logic;
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormClient(IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormClient_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ClientSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.Organization;
|
||||
textBox1.Text = view.ContractPerson;
|
||||
textBox2.Text = view.Phone;
|
||||
textBox3.Text = view.Email;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new ClientBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Organization = textBoxName.Text,
|
||||
ContractPerson = textBoxName.Text,
|
||||
Phone = textBoxName.Text,
|
||||
Email = textBoxName.Text
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
viewmodel/FormClient.resx
Normal file
120
viewmodel/FormClient.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
146
viewmodel/FormClients.Designer.cs
generated
Normal file
146
viewmodel/FormClients.Designer.cs
generated
Normal file
@ -0,0 +1,146 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormClients
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
button3 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.ShowCellToolTips = false;
|
||||
dataGridView.ShowEditingIcon = false;
|
||||
dataGridView.Size = new Size(525, 450);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(564, 116);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(118, 35);
|
||||
buttonDel.TabIndex = 7;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(564, 65);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(118, 35);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(564, 15);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(118, 35);
|
||||
buttonAdd.TabIndex = 5;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(564, 168);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(118, 35);
|
||||
button1.TabIndex = 8;
|
||||
button1.Text = "Тест добавления";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(564, 209);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(118, 35);
|
||||
button2.TabIndex = 9;
|
||||
button2.Text = "Тест обновления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(564, 250);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(118, 35);
|
||||
button3.TabIndex = 10;
|
||||
button3.Text = "Тест удаления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// FormClients
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(716, 450);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormClients";
|
||||
Text = "Покупатели";
|
||||
Load += FormClients_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Button button3;
|
||||
}
|
||||
}
|
189
viewmodel/FormClients.cs
Normal file
189
viewmodel/FormClients.cs
Normal file
@ -0,0 +1,189 @@
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
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 viewmodel
|
||||
{
|
||||
public partial class FormClients : Form
|
||||
{
|
||||
private readonly IClientLogic _logic;
|
||||
|
||||
public FormClients(IClientLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormClients_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Organization"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||
if (service is FormClient form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
|
||||
if (service is FormClient form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ClientBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new ClientBindingModel
|
||||
{
|
||||
Organization = "dfdfd",
|
||||
ContractPerson = "dfdfdf",
|
||||
Phone = "1323223",
|
||||
Email = "dsfdsfdsf@mail.ru"
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new ClientBindingModel
|
||||
{
|
||||
Id = i
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new ClientSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new ClientBindingModel
|
||||
{
|
||||
Id = i,
|
||||
Organization = "dfdfd",
|
||||
ContractPerson = "dfdfdf",
|
||||
Phone = "1323223",
|
||||
Email = "dsfdsfdsf@mail.ru"
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
viewmodel/FormClients.resx
Normal file
120
viewmodel/FormClients.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
140
viewmodel/FormConstructionMaterial.Designer.cs
generated
Normal file
140
viewmodel/FormConstructionMaterial.Designer.cs
generated
Normal file
@ -0,0 +1,140 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormConstructionMaterial
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
textBoxFoodName = new TextBox();
|
||||
textBoxPrice = new TextBox();
|
||||
textBoxDeskr = new TextBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 9);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(59, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Название";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 67);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(72, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Количество";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 39);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(35, 15);
|
||||
label3.TabIndex = 1;
|
||||
label3.Text = "Цена";
|
||||
//
|
||||
// textBoxFoodName
|
||||
//
|
||||
textBoxFoodName.Location = new Point(90, 6);
|
||||
textBoxFoodName.Name = "textBoxFoodName";
|
||||
textBoxFoodName.Size = new Size(218, 23);
|
||||
textBoxFoodName.TabIndex = 2;
|
||||
//
|
||||
// textBoxPrice
|
||||
//
|
||||
textBoxPrice.Location = new Point(90, 64);
|
||||
textBoxPrice.Name = "textBoxPrice";
|
||||
textBoxPrice.Size = new Size(218, 23);
|
||||
textBoxPrice.TabIndex = 3;
|
||||
//
|
||||
// textBoxDeskr
|
||||
//
|
||||
textBoxDeskr.Location = new Point(90, 36);
|
||||
textBoxDeskr.Name = "textBoxDeskr";
|
||||
textBoxDeskr.Size = new Size(218, 23);
|
||||
textBoxDeskr.TabIndex = 4;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(236, 93);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(77, 30);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(153, 93);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(83, 30);
|
||||
buttonSave.TabIndex = 6;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// FormConstructionMaterial
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(325, 130);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxDeskr);
|
||||
Controls.Add(textBoxPrice);
|
||||
Controls.Add(textBoxFoodName);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormConstructionMaterial";
|
||||
Text = "Строй материал";
|
||||
Load += FormMenu_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private TextBox textBoxFoodName;
|
||||
private TextBox textBoxPrice;
|
||||
private TextBox textBoxDeskr;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
88
viewmodel/FormConstructionMaterial.cs
Normal file
88
viewmodel/FormConstructionMaterial.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
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 viewmodel
|
||||
{
|
||||
public partial class FormConstructionMaterial : Form
|
||||
{
|
||||
|
||||
private readonly IConstructionMaterialLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormConstructionMaterial(IConstructionMaterialLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormMenu_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ConstructionMaterialSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFoodName.Text = view.MaterialName;
|
||||
textBoxDeskr.Text = view.Cost.ToString();
|
||||
textBoxPrice.Text = view.Quantity.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFoodName.Text) || string.IsNullOrEmpty(textBoxPrice.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new ConstructionMaterialBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
MaterialName = textBoxFoodName.Text,
|
||||
Cost = Convert.ToInt32(textBoxPrice.Text),
|
||||
Quantity = Convert.ToInt32(textBoxPrice.Text)
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
viewmodel/FormConstructionMaterial.resx
Normal file
120
viewmodel/FormConstructionMaterial.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
145
viewmodel/FormConstructionMaterials.Designer.cs
generated
Normal file
145
viewmodel/FormConstructionMaterials.Designer.cs
generated
Normal file
@ -0,0 +1,145 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormConstructionMaterials
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
button3 = new Button();
|
||||
button2 = new Button();
|
||||
button1 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(547, 113);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(118, 35);
|
||||
buttonDel.TabIndex = 7;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(547, 62);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(118, 35);
|
||||
buttonUpd.TabIndex = 6;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(547, 12);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(118, 35);
|
||||
buttonAdd.TabIndex = 5;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(493, 450);
|
||||
dataGridView.TabIndex = 4;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(547, 252);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(118, 35);
|
||||
button3.TabIndex = 13;
|
||||
button3.Text = "Тест удаления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(547, 211);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(118, 35);
|
||||
button2.TabIndex = 12;
|
||||
button2.Text = "Тест обновления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(547, 170);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(118, 35);
|
||||
button1.TabIndex = 11;
|
||||
button1.Text = "Тест добавления";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// FormConstructionMaterials
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(710, 450);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormConstructionMaterials";
|
||||
Text = "Строй материалы";
|
||||
Load += FormMenus_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button button1;
|
||||
}
|
||||
}
|
186
viewmodel/FormConstructionMaterials.cs
Normal file
186
viewmodel/FormConstructionMaterials.cs
Normal file
@ -0,0 +1,186 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
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 viewmodel
|
||||
{
|
||||
public partial class FormConstructionMaterials : Form
|
||||
{
|
||||
private readonly IConstructionMaterialLogic _logic;
|
||||
|
||||
public FormConstructionMaterials(IConstructionMaterialLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormMenus_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["MaterialName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormConstructionMaterial));
|
||||
if (service is FormConstructionMaterial form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormConstructionMaterial));
|
||||
if (service is FormConstructionMaterial form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ConstructionMaterialBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new ConstructionMaterialBindingModel
|
||||
{
|
||||
MaterialName = "dfdfd",
|
||||
Cost = 12312,
|
||||
Quantity = 12131
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new ConstructionMaterialSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new ConstructionMaterialBindingModel
|
||||
{
|
||||
Id = i,
|
||||
MaterialName = "dfdfd",
|
||||
Cost = 12312,
|
||||
Quantity = 12131
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new ConstructionMaterialSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new ConstructionMaterialBindingModel
|
||||
{
|
||||
Id = i
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
viewmodel/FormConstructionMaterials.resx
Normal file
120
viewmodel/FormConstructionMaterials.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
341
viewmodel/FormCreateProject.Designer.cs
generated
Normal file
341
viewmodel/FormCreateProject.Designer.cs
generated
Normal file
@ -0,0 +1,341 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormCreateProject
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
comboBoxEmployee = new ComboBox();
|
||||
groupBox1 = new GroupBox();
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
ColumnFoodName = new DataGridViewTextBoxColumn();
|
||||
ColumnDesc = new DataGridViewTextBoxColumn();
|
||||
ColumnPrice = new DataGridViewTextBoxColumn();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxPrice = new TextBox();
|
||||
label4 = new Label();
|
||||
groupBox2 = new GroupBox();
|
||||
buttonDelTeams = new Button();
|
||||
buttonUpsTeams = new Button();
|
||||
buttonAddTeams = new Button();
|
||||
dataGridViewTeams = new DataGridView();
|
||||
dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
|
||||
dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
|
||||
dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewTeams).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(16, 9);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(46, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Клиент";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(16, 42);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(88, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Управляющий";
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(100, 6);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(249, 23);
|
||||
comboBoxClient.TabIndex = 4;
|
||||
//
|
||||
// comboBoxEmployee
|
||||
//
|
||||
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxEmployee.FormattingEnabled = true;
|
||||
comboBoxEmployee.Location = new Point(100, 39);
|
||||
comboBoxEmployee.Name = "comboBoxEmployee";
|
||||
comboBoxEmployee.Size = new Size(249, 23);
|
||||
comboBoxEmployee.TabIndex = 5;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(buttonDel);
|
||||
groupBox1.Controls.Add(buttonUpd);
|
||||
groupBox1.Controls.Add(buttonAdd);
|
||||
groupBox1.Controls.Add(dataGridView);
|
||||
groupBox1.Location = new Point(12, 102);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(620, 336);
|
||||
groupBox1.TabIndex = 7;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Строй материалы";
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(480, 123);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(118, 35);
|
||||
buttonDel.TabIndex = 10;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(480, 72);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(118, 35);
|
||||
buttonUpd.TabIndex = 9;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(480, 22);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(118, 35);
|
||||
buttonAdd.TabIndex = 8;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnFoodName, ColumnDesc, ColumnPrice });
|
||||
dataGridView.Location = new Point(6, 22);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(451, 308);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ColumnFoodName
|
||||
//
|
||||
ColumnFoodName.HeaderText = "Название";
|
||||
ColumnFoodName.Name = "ColumnFoodName";
|
||||
ColumnFoodName.ReadOnly = true;
|
||||
//
|
||||
// ColumnDesc
|
||||
//
|
||||
ColumnDesc.HeaderText = "Описание";
|
||||
ColumnDesc.Name = "ColumnDesc";
|
||||
ColumnDesc.ReadOnly = true;
|
||||
//
|
||||
// ColumnPrice
|
||||
//
|
||||
ColumnPrice.HeaderText = "Цена";
|
||||
ColumnPrice.Name = "ColumnPrice";
|
||||
ColumnPrice.ReadOnly = true;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(1148, 444);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(118, 35);
|
||||
buttonCancel.TabIndex = 12;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(1024, 444);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(118, 35);
|
||||
buttonSave.TabIndex = 11;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBoxPrice
|
||||
//
|
||||
textBoxPrice.Enabled = false;
|
||||
textBoxPrice.Location = new Point(855, 451);
|
||||
textBoxPrice.Name = "textBoxPrice";
|
||||
textBoxPrice.Size = new Size(141, 23);
|
||||
textBoxPrice.TabIndex = 14;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(779, 454);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(70, 15);
|
||||
label4.TabIndex = 13;
|
||||
label4.Text = "Стоимость:";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
groupBox2.Controls.Add(buttonDelTeams);
|
||||
groupBox2.Controls.Add(buttonUpsTeams);
|
||||
groupBox2.Controls.Add(buttonAddTeams);
|
||||
groupBox2.Controls.Add(dataGridViewTeams);
|
||||
groupBox2.Location = new Point(646, 102);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new Size(620, 336);
|
||||
groupBox2.TabIndex = 15;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Бригада";
|
||||
//
|
||||
// buttonDelTeams
|
||||
//
|
||||
buttonDelTeams.Location = new Point(480, 123);
|
||||
buttonDelTeams.Name = "buttonDelTeams";
|
||||
buttonDelTeams.Size = new Size(118, 35);
|
||||
buttonDelTeams.TabIndex = 10;
|
||||
buttonDelTeams.Text = "Удалить";
|
||||
buttonDelTeams.UseVisualStyleBackColor = true;
|
||||
buttonDelTeams.Click += buttonDelTeams_Click;
|
||||
//
|
||||
// buttonUpsTeams
|
||||
//
|
||||
buttonUpsTeams.Location = new Point(480, 72);
|
||||
buttonUpsTeams.Name = "buttonUpsTeams";
|
||||
buttonUpsTeams.Size = new Size(118, 35);
|
||||
buttonUpsTeams.TabIndex = 9;
|
||||
buttonUpsTeams.Text = "Изменить";
|
||||
buttonUpsTeams.UseVisualStyleBackColor = true;
|
||||
buttonUpsTeams.Click += buttonUpsTeams_Click;
|
||||
//
|
||||
// buttonAddTeams
|
||||
//
|
||||
buttonAddTeams.Location = new Point(480, 22);
|
||||
buttonAddTeams.Name = "buttonAddTeams";
|
||||
buttonAddTeams.Size = new Size(118, 35);
|
||||
buttonAddTeams.TabIndex = 8;
|
||||
buttonAddTeams.Text = "Добавить";
|
||||
buttonAddTeams.UseVisualStyleBackColor = true;
|
||||
buttonAddTeams.Click += buttonAddTeams_Click;
|
||||
//
|
||||
// dataGridViewTeams
|
||||
//
|
||||
dataGridViewTeams.AllowUserToAddRows = false;
|
||||
dataGridViewTeams.AllowUserToDeleteRows = false;
|
||||
dataGridViewTeams.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewTeams.BackgroundColor = Color.White;
|
||||
dataGridViewTeams.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewTeams.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, dataGridViewTextBoxColumn2, dataGridViewTextBoxColumn3 });
|
||||
dataGridViewTeams.Location = new Point(6, 22);
|
||||
dataGridViewTeams.Name = "dataGridViewTeams";
|
||||
dataGridViewTeams.ReadOnly = true;
|
||||
dataGridViewTeams.RowHeadersVisible = false;
|
||||
dataGridViewTeams.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewTeams.Size = new Size(451, 308);
|
||||
dataGridViewTeams.TabIndex = 0;
|
||||
//
|
||||
// dataGridViewTextBoxColumn1
|
||||
//
|
||||
dataGridViewTextBoxColumn1.HeaderText = "Название";
|
||||
dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
|
||||
dataGridViewTextBoxColumn1.ReadOnly = true;
|
||||
//
|
||||
// dataGridViewTextBoxColumn2
|
||||
//
|
||||
dataGridViewTextBoxColumn2.HeaderText = "Описание";
|
||||
dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
|
||||
dataGridViewTextBoxColumn2.ReadOnly = true;
|
||||
//
|
||||
// dataGridViewTextBoxColumn3
|
||||
//
|
||||
dataGridViewTextBoxColumn3.HeaderText = "Цена";
|
||||
dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
|
||||
dataGridViewTextBoxColumn3.ReadOnly = true;
|
||||
//
|
||||
// FormCreateProject
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1289, 490);
|
||||
Controls.Add(groupBox2);
|
||||
Controls.Add(textBoxPrice);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(comboBoxEmployee);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormCreateProject";
|
||||
Text = "Заказ";
|
||||
Load += FormCreateTask_Load;
|
||||
groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
groupBox2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewTeams).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxClient;
|
||||
private ComboBox comboBoxEmployee;
|
||||
private GroupBox groupBox1;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxPrice;
|
||||
private Label label4;
|
||||
private DataGridViewTextBoxColumn ColumnFoodName;
|
||||
private DataGridViewTextBoxColumn ColumnDesc;
|
||||
private DataGridViewTextBoxColumn ColumnPrice;
|
||||
private GroupBox groupBox2;
|
||||
private Button buttonDelTeams;
|
||||
private Button buttonUpsTeams;
|
||||
private Button buttonAddTeams;
|
||||
private DataGridView dataGridViewTeams;
|
||||
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
|
||||
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
|
||||
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
|
||||
}
|
||||
}
|
278
viewmodel/FormCreateProject.cs
Normal file
278
viewmodel/FormCreateProject.cs
Normal file
@ -0,0 +1,278 @@
|
||||
using ConstructionFirmBusinessLogic.BusinessLogics;
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
|
||||
namespace viewmodel
|
||||
{
|
||||
public partial class FormCreateProject : Form
|
||||
{
|
||||
|
||||
private readonly IClientLogic _logicP;
|
||||
private readonly IEmployeeLogic _logicC;
|
||||
private readonly IProjectLogic _logicT;
|
||||
private int? _id;
|
||||
private Dictionary<int, (IConstructionMaterialModel, int)> _projectmaterial;
|
||||
private Dictionary<int, (ITeamModel, int)> _projecteam;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCreateProject(IProjectLogic tlogic, IClientLogic logicP, IEmployeeLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logicT = tlogic;
|
||||
_projectmaterial = new Dictionary<int, (IConstructionMaterialModel, int)>();
|
||||
_projecteam = new Dictionary<int, (ITeamModel, int)>();
|
||||
_logicP = logicP;
|
||||
_logicC = logicC;
|
||||
}
|
||||
|
||||
private void FormCreateTask_Load(object sender, EventArgs e)
|
||||
{
|
||||
var _listP = _logicP.ReadList(null);
|
||||
var _listC = _logicC.ReadList(null);
|
||||
if (_listP != null)
|
||||
{
|
||||
comboBoxClient.DisplayMember = "Organization";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxClient.DataSource = _listP;
|
||||
comboBoxClient.SelectedItem = null;
|
||||
}
|
||||
if (_listC != null)
|
||||
{
|
||||
comboBoxEmployee.DisplayMember = "FullName";
|
||||
comboBoxEmployee.ValueMember = "Id";
|
||||
comboBoxEmployee.DataSource = _listC;
|
||||
comboBoxEmployee.SelectedItem = null;
|
||||
}
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logicT.ReadElement(new ProjectSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
_projectmaterial = view.ConstructionMaterialProjects ?? new Dictionary<int, (IConstructionMaterialModel, int)>();
|
||||
_projecteam = view.TeamProject ?? new Dictionary<int, (ITeamModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
if (_projectmaterial != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var rc in _projectmaterial)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { rc.Value.Item1.MaterialName, rc.Value.Item1.Cost * rc.Value.Item2, rc.Value.Item1.Quantity });
|
||||
}
|
||||
}
|
||||
if (_projecteam != null)
|
||||
{
|
||||
dataGridViewTeams.Rows.Clear();
|
||||
foreach (var rc in _projecteam)
|
||||
{
|
||||
dataGridViewTeams.Rows.Add(new object[] { rc.Value.Item1.TeamName, rc.Value.Item1.LeaderName, rc.Value.Item1.Experince, rc.Value.Item1.TeamType });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProjectMaterial));
|
||||
if (service is FormProjectMaterial form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.MenuModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_projectmaterial.ContainsKey(form.Id))
|
||||
{
|
||||
_projectmaterial[form.Id] = (form.MenuModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_projectmaterial.Add(form.Id, (form.MenuModel, form.Count));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProjectMaterial));
|
||||
if (service is FormProjectMaterial form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _projectmaterial[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.MenuModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_projectmaterial[form.Id] = (form.MenuModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_projectmaterial?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_projectmaterial == null || _projectmaterial.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните блюда", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new ProjectBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
DeadLine = DateTime.Now,
|
||||
Status = ConstructionFirmDataModels.Enum.TaskStatus.Принят,
|
||||
CliendId = comboBoxClient.SelectedIndex + 1,
|
||||
EmployeeId = comboBoxEmployee.SelectedIndex + 1,
|
||||
ConstructionMaterialProjects = _projectmaterial,
|
||||
TeamProject = _projecteam
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logicT.Update(model) : _logicT.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private double CalcPrice()
|
||||
{
|
||||
double price = 0;
|
||||
foreach (var elem in _projectmaterial)
|
||||
{
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonAddTeams_Click(object sender, EventArgs e)
|
||||
{
|
||||
var serviceTeam = Program.ServiceProvider?.GetService(typeof(FormTeamProject));
|
||||
if (serviceTeam is FormTeamProject formTeam)
|
||||
{
|
||||
if (formTeam.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (formTeam.TeamModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_projecteam.ContainsKey(formTeam.Id))
|
||||
{
|
||||
_projecteam[formTeam.Id] = (formTeam.TeamModel, formTeam.CountTeam);
|
||||
}
|
||||
else
|
||||
{
|
||||
_projecteam.Add(formTeam.Id, (formTeam.TeamModel, formTeam.CountTeam));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpsTeams_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridViewTeams.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTeamProject));
|
||||
if (service is FormTeamProject form)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridViewTeams.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.CountTeam = _projecteam[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.TeamModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_projecteam[form.Id] = (form.TeamModel, form.CountTeam);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDelTeams_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridViewTeams.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_projecteam?.Remove(Convert.ToInt32(dataGridViewTeams.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
138
viewmodel/FormCreateProject.resx
Normal file
138
viewmodel/FormCreateProject.resx
Normal file
@ -0,0 +1,138 @@
|
||||
<?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="ColumnFoodName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnDesc.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
140
viewmodel/FormEmployee.Designer.cs
generated
Normal file
140
viewmodel/FormEmployee.Designer.cs
generated
Normal file
@ -0,0 +1,140 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormEmployee
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
textBoxPhone = new TextBox();
|
||||
labelContact = new Label();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxName = new TextBox();
|
||||
labelOrganization = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
label2 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// textBoxPhone
|
||||
//
|
||||
textBoxPhone.Location = new Point(117, 41);
|
||||
textBoxPhone.Name = "textBoxPhone";
|
||||
textBoxPhone.Size = new Size(208, 23);
|
||||
textBoxPhone.TabIndex = 19;
|
||||
//
|
||||
// labelContact
|
||||
//
|
||||
labelContact.AutoSize = true;
|
||||
labelContact.Location = new Point(13, 44);
|
||||
labelContact.Name = "labelContact";
|
||||
labelContact.Size = new Size(45, 15);
|
||||
labelContact.TabIndex = 18;
|
||||
labelContact.Text = "Номер";
|
||||
labelContact.UseWaitCursor = true;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(248, 130);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(77, 30);
|
||||
buttonCancel.TabIndex = 17;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(165, 130);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(83, 30);
|
||||
buttonSave.TabIndex = 16;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(117, 12);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(208, 23);
|
||||
textBoxName.TabIndex = 15;
|
||||
//
|
||||
// labelOrganization
|
||||
//
|
||||
labelOrganization.AutoSize = true;
|
||||
labelOrganization.Location = new Point(13, 20);
|
||||
labelOrganization.Name = "labelOrganization";
|
||||
labelOrganization.Size = new Size(31, 15);
|
||||
labelOrganization.TabIndex = 14;
|
||||
labelOrganization.Text = "Имя";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(117, 70);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(208, 23);
|
||||
dateTimePicker.TabIndex = 21;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 76);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(93, 15);
|
||||
label2.TabIndex = 20;
|
||||
label2.Text = "Дата рождения:";
|
||||
//
|
||||
// FormEmployee
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(353, 181);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(textBoxPhone);
|
||||
Controls.Add(labelContact);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelOrganization);
|
||||
Name = "FormEmployee";
|
||||
Text = "FormEmployee";
|
||||
Load += FormEmployee_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private TextBox textBoxPhone;
|
||||
private Label labelContact;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxName;
|
||||
private Label labelOrganization;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Label label2;
|
||||
}
|
||||
}
|
78
viewmodel/FormEmployee.cs
Normal file
78
viewmodel/FormEmployee.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
|
||||
namespace viewmodel
|
||||
{
|
||||
public partial class FormEmployee : Form
|
||||
{
|
||||
private readonly IEmployeeLogic _logic;
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormEmployee(IEmployeeLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormEmployee_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new EmployeeSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.FullName;
|
||||
textBoxPhone.Text = view.Phone;
|
||||
dateTimePicker.Value = (DateTime)view.HireDate;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните Имя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new EmployeeBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
FullName = textBoxName.Text,
|
||||
Phone = textBoxPhone.Text,
|
||||
HireDate = dateTimePicker.Value
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
viewmodel/FormEmployee.resx
Normal file
120
viewmodel/FormEmployee.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
146
viewmodel/FormEmployees.Designer.cs
generated
Normal file
146
viewmodel/FormEmployees.Designer.cs
generated
Normal file
@ -0,0 +1,146 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormEmployees
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonDel = new Button();
|
||||
buttonUpd = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
button3 = new Button();
|
||||
button2 = new Button();
|
||||
button1 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.Location = new Point(623, 116);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(118, 35);
|
||||
buttonDel.TabIndex = 11;
|
||||
buttonDel.Text = "Удалить";
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.Location = new Point(623, 65);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(118, 35);
|
||||
buttonUpd.TabIndex = 10;
|
||||
buttonUpd.Text = "Изменить";
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(623, 15);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(118, 35);
|
||||
buttonAdd.TabIndex = 9;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.ShowCellToolTips = false;
|
||||
dataGridView.ShowEditingIcon = false;
|
||||
dataGridView.Size = new Size(525, 450);
|
||||
dataGridView.TabIndex = 8;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(623, 263);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(118, 35);
|
||||
button3.TabIndex = 16;
|
||||
button3.Text = "Тест удаления";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(623, 222);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(118, 35);
|
||||
button2.TabIndex = 15;
|
||||
button2.Text = "Тест обновления";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(623, 181);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(118, 35);
|
||||
button1.TabIndex = 14;
|
||||
button1.Text = "Тест добавления";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// FormEmployees
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonDel);
|
||||
Controls.Add(buttonUpd);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormEmployees";
|
||||
Text = "Управляющий";
|
||||
Load += FormEmployees_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private Button button1;
|
||||
}
|
||||
}
|
186
viewmodel/FormEmployees.cs
Normal file
186
viewmodel/FormEmployees.cs
Normal file
@ -0,0 +1,186 @@
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
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 viewmodel
|
||||
{
|
||||
public partial class FormEmployees : Form
|
||||
{
|
||||
private readonly IEmployeeLogic _logic;
|
||||
|
||||
public FormEmployees(IEmployeeLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormEmployees_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["FullName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
|
||||
if (service is FormEmployee form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
|
||||
if (service is FormEmployee form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new EmployeeBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Доп информация в логах");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new EmployeeSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Delete(new EmployeeBindingModel
|
||||
{
|
||||
Id = i
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
var element = _logic.ReadElement(new EmployeeSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
for (int i = id; i < id + 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Update(new EmployeeBindingModel
|
||||
{
|
||||
Id = i,
|
||||
FullName = "dfdfd",
|
||||
Phone = "43543534",
|
||||
HireDate = DateTime.Now
|
||||
});
|
||||
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime start = DateTime.Now;
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
var operationResult = _logic.Create(new EmployeeBindingModel
|
||||
{
|
||||
FullName = "dfdfd",
|
||||
Phone = "43543534",
|
||||
HireDate = DateTime.Now
|
||||
});
|
||||
}
|
||||
DateTime stop = DateTime.Now;
|
||||
LoadData();
|
||||
MessageBox.Show((stop - start).Milliseconds.ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
viewmodel/FormEmployees.resx
Normal file
120
viewmodel/FormEmployees.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
193
viewmodel/FormMain.Designer.cs
generated
Normal file
193
viewmodel/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,193 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
объектыToolStripMenuItem = new ToolStripMenuItem();
|
||||
buyerToolStripMenuItem = new ToolStripMenuItem();
|
||||
cookToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuToolStripMenuItem = new ToolStripMenuItem();
|
||||
placeToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonIssuedTask = new Button();
|
||||
buttonTaskReady = new Button();
|
||||
buttonTakeTaskInWork = new Button();
|
||||
buttonCreateTask = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
buttonTest = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { объектыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1383, 24);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// объектыToolStripMenuItem
|
||||
//
|
||||
объектыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { buyerToolStripMenuItem, cookToolStripMenuItem, menuToolStripMenuItem, placeToolStripMenuItem });
|
||||
объектыToolStripMenuItem.Name = "объектыToolStripMenuItem";
|
||||
объектыToolStripMenuItem.Size = new Size(68, 20);
|
||||
объектыToolStripMenuItem.Text = "Объекты";
|
||||
//
|
||||
// buyerToolStripMenuItem
|
||||
//
|
||||
buyerToolStripMenuItem.Name = "buyerToolStripMenuItem";
|
||||
buyerToolStripMenuItem.Size = new Size(180, 22);
|
||||
buyerToolStripMenuItem.Text = "Клиент";
|
||||
buyerToolStripMenuItem.Click += buyerToolStripMenuItem_Click;
|
||||
//
|
||||
// cookToolStripMenuItem
|
||||
//
|
||||
cookToolStripMenuItem.Name = "cookToolStripMenuItem";
|
||||
cookToolStripMenuItem.Size = new Size(180, 22);
|
||||
cookToolStripMenuItem.Text = "Бригада";
|
||||
cookToolStripMenuItem.Click += cookToolStripMenuItem_Click;
|
||||
//
|
||||
// menuToolStripMenuItem
|
||||
//
|
||||
menuToolStripMenuItem.Name = "menuToolStripMenuItem";
|
||||
menuToolStripMenuItem.Size = new Size(180, 22);
|
||||
menuToolStripMenuItem.Text = "СтройМатериалы";
|
||||
menuToolStripMenuItem.Click += menuToolStripMenuItem_Click;
|
||||
//
|
||||
// placeToolStripMenuItem
|
||||
//
|
||||
placeToolStripMenuItem.Name = "placeToolStripMenuItem";
|
||||
placeToolStripMenuItem.Size = new Size(180, 22);
|
||||
placeToolStripMenuItem.Text = "Управляющий";
|
||||
placeToolStripMenuItem.Click += placeToolStripMenuItem_Click;
|
||||
//
|
||||
// buttonIssuedTask
|
||||
//
|
||||
buttonIssuedTask.Location = new Point(1075, 203);
|
||||
buttonIssuedTask.Name = "buttonIssuedTask";
|
||||
buttonIssuedTask.Size = new Size(198, 28);
|
||||
buttonIssuedTask.TabIndex = 11;
|
||||
buttonIssuedTask.Text = "Заказ выдан";
|
||||
buttonIssuedTask.UseVisualStyleBackColor = true;
|
||||
buttonIssuedTask.Click += buttonIssuedTask_Click;
|
||||
//
|
||||
// buttonTaskReady
|
||||
//
|
||||
buttonTaskReady.Location = new Point(1075, 151);
|
||||
buttonTaskReady.Name = "buttonTaskReady";
|
||||
buttonTaskReady.Size = new Size(198, 28);
|
||||
buttonTaskReady.TabIndex = 10;
|
||||
buttonTaskReady.Text = "Заказ готов";
|
||||
buttonTaskReady.UseVisualStyleBackColor = true;
|
||||
buttonTaskReady.Click += buttonTaskReady_Click;
|
||||
//
|
||||
// buttonTakeTaskInWork
|
||||
//
|
||||
buttonTakeTaskInWork.Location = new Point(1075, 97);
|
||||
buttonTakeTaskInWork.Name = "buttonTakeTaskInWork";
|
||||
buttonTakeTaskInWork.Size = new Size(198, 28);
|
||||
buttonTakeTaskInWork.TabIndex = 9;
|
||||
buttonTakeTaskInWork.Text = "Отдать на выполнение";
|
||||
buttonTakeTaskInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeTaskInWork.Click += buttonTakeTaskInWork_Click;
|
||||
//
|
||||
// buttonCreateTask
|
||||
//
|
||||
buttonCreateTask.Location = new Point(1075, 43);
|
||||
buttonCreateTask.Name = "buttonCreateTask";
|
||||
buttonCreateTask.Size = new Size(198, 28);
|
||||
buttonCreateTask.TabIndex = 8;
|
||||
buttonCreateTask.Text = "Создать заказ";
|
||||
buttonCreateTask.UseVisualStyleBackColor = true;
|
||||
buttonCreateTask.Click += buttonCreateTask_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.BackgroundColor = Color.White;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 24);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(1046, 426);
|
||||
dataGridView.TabIndex = 7;
|
||||
//
|
||||
// buttonTest
|
||||
//
|
||||
buttonTest.Location = new Point(1075, 259);
|
||||
buttonTest.Name = "buttonTest";
|
||||
buttonTest.Size = new Size(198, 28);
|
||||
buttonTest.TabIndex = 12;
|
||||
buttonTest.Text = "ТЕСТ";
|
||||
buttonTest.UseVisualStyleBackColor = true;
|
||||
buttonTest.Click += buttonTest_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1383, 450);
|
||||
Controls.Add(buttonTest);
|
||||
Controls.Add(buttonIssuedTask);
|
||||
Controls.Add(buttonTaskReady);
|
||||
Controls.Add(buttonTakeTaskInWork);
|
||||
Controls.Add(buttonCreateTask);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
Text = "Главное окно";
|
||||
Load += FormMain_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem объектыToolStripMenuItem;
|
||||
private ToolStripMenuItem buyerToolStripMenuItem;
|
||||
private ToolStripMenuItem cookToolStripMenuItem;
|
||||
private ToolStripMenuItem menuToolStripMenuItem;
|
||||
private ToolStripMenuItem placeToolStripMenuItem;
|
||||
private Button buttonIssuedTask;
|
||||
private Button buttonTaskReady;
|
||||
private Button buttonTakeTaskInWork;
|
||||
private Button buttonCreateTask;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonTest;
|
||||
}
|
||||
}
|
177
viewmodel/FormMain.cs
Normal file
177
viewmodel/FormMain.cs
Normal file
@ -0,0 +1,177 @@
|
||||
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
|
||||
namespace viewmodel
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
|
||||
private readonly IProjectLogic _logic;
|
||||
|
||||
public FormMain(IProjectLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void buyerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void cookToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTeams));
|
||||
if (service is FormTeams form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void placeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormEmployees));
|
||||
if (service is FormEmployees form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void menuToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormConstructionMaterials));
|
||||
if (service is FormConstructionMaterials form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
var _list = _logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
dataGridView.DataSource = _list;
|
||||
dataGridView.Columns["CliendId"].Visible = false;
|
||||
dataGridView.Columns["EmployeeId"].Visible = false;
|
||||
dataGridView.Columns["ConstructionMaterialProjects"].Visible = false;
|
||||
dataGridView.Columns["TeamProject"].Visible = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreateTask_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateProject));
|
||||
if (service is FormCreateProject form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTakeTaskInWork_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.TakeProjectInWork(new ProjectBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<ConstructionFirmDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTaskReady_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.FinishProject(new ProjectBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<ConstructionFirmDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonIssuedTask_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
try
|
||||
{
|
||||
var operationResult = _logic.DeliveryProject(new ProjectBindingModel
|
||||
{
|
||||
Id = id,
|
||||
Status = Enum.Parse<ConstructionFirmDataModels.Enum.TaskStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
//CookBindingModel model = new CookBindingModel()
|
||||
//{
|
||||
// Id = 2,
|
||||
// CookName = "Иван",
|
||||
// CookSurname = "dssfsdfs",
|
||||
// Experience = 2,
|
||||
// PhoneNumber = "+79054324312",
|
||||
// Passport = "123124"
|
||||
//};
|
||||
|
||||
//DateTime start = DateTime.Now;
|
||||
//_CLogic.Delete(model);
|
||||
//DateTime stop = DateTime.Now;
|
||||
//MessageBox.Show((start - stop).ToString(), "Test", MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
}
|
123
viewmodel/FormMain.resx
Normal file
123
viewmodel/FormMain.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
119
viewmodel/FormProjectMaterial.Designer.cs
generated
Normal file
119
viewmodel/FormProjectMaterial.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormProjectMaterial
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxCount = new TextBox();
|
||||
comboBoxMenu = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 9);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(62, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Материал";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(13, 38);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(46, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Кол-во";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(236, 64);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(90, 26);
|
||||
buttonCancel.TabIndex = 12;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(140, 64);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(90, 26);
|
||||
buttonSave.TabIndex = 11;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(77, 35);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(249, 23);
|
||||
textBoxCount.TabIndex = 9;
|
||||
//
|
||||
// comboBoxMenu
|
||||
//
|
||||
comboBoxMenu.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxMenu.FormattingEnabled = true;
|
||||
comboBoxMenu.Location = new Point(77, 6);
|
||||
comboBoxMenu.Name = "comboBoxMenu";
|
||||
comboBoxMenu.Size = new Size(249, 23);
|
||||
comboBoxMenu.TabIndex = 8;
|
||||
//
|
||||
// FormProjectMaterial
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(362, 97);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxMenu);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormProjectMaterial";
|
||||
Text = "Выбор материалов";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxCount;
|
||||
private ComboBox comboBoxMenu;
|
||||
}
|
||||
}
|
78
viewmodel/FormProjectMaterial.cs
Normal file
78
viewmodel/FormProjectMaterial.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using ConstructionFirmDataModels.Models;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.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 viewmodel
|
||||
{
|
||||
public partial class FormProjectMaterial : Form
|
||||
{
|
||||
private readonly List<ConstructionMaterialViewModel?> _list;
|
||||
public int Id { get { return Convert.ToInt32(comboBoxMenu.SelectedValue); } set { comboBoxMenu.SelectedValue = value; } }
|
||||
|
||||
public IConstructionMaterialModel? MenuModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _list)
|
||||
{
|
||||
if (elem.Id == Id)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } }
|
||||
|
||||
|
||||
public FormProjectMaterial(IConstructionMaterialLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_list = logic.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
comboBoxMenu.DisplayMember = "MaterialName";
|
||||
comboBoxMenu.ValueMember = "Id";
|
||||
comboBoxMenu.DataSource = _list;
|
||||
comboBoxMenu.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxMenu.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
viewmodel/FormProjectMaterial.resx
Normal file
120
viewmodel/FormProjectMaterial.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
162
viewmodel/FormTeam.Designer.cs
generated
Normal file
162
viewmodel/FormTeam.Designer.cs
generated
Normal file
@ -0,0 +1,162 @@
|
||||
namespace viewmodel
|
||||
{
|
||||
partial class FormTeam
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxNameLeader = new TextBox();
|
||||
textBoxExpirience = new TextBox();
|
||||
textBoxNameTeam = new TextBox();
|
||||
label3 = new Label();
|
||||
label2 = new Label();
|
||||
label1 = new Label();
|
||||
textBoxType = new TextBox();
|
||||
label4 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(240, 138);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(77, 30);
|
||||
buttonCancel.TabIndex = 15;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(157, 138);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(83, 30);
|
||||
buttonSave.TabIndex = 14;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBoxNameLeader
|
||||
//
|
||||
textBoxNameLeader.Location = new Point(131, 46);
|
||||
textBoxNameLeader.Name = "textBoxNameLeader";
|
||||
textBoxNameLeader.Size = new Size(218, 23);
|
||||
textBoxNameLeader.TabIndex = 13;
|
||||
//
|
||||
// textBoxExpirience
|
||||
//
|
||||
textBoxExpirience.Location = new Point(131, 74);
|
||||
textBoxExpirience.Name = "textBoxExpirience";
|
||||
textBoxExpirience.Size = new Size(218, 23);
|
||||
textBoxExpirience.TabIndex = 12;
|
||||
//
|
||||
// textBoxNameTeam
|
||||
//
|
||||
textBoxNameTeam.Location = new Point(131, 16);
|
||||
textBoxNameTeam.Name = "textBoxNameTeam";
|
||||
textBoxNameTeam.Size = new Size(218, 23);
|
||||
textBoxNameTeam.TabIndex = 11;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(16, 49);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(81, 15);
|
||||
label3.TabIndex = 9;
|
||||
label3.Text = "Имя прораба";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(16, 77);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(37, 15);
|
||||
label2.TabIndex = 10;
|
||||
label2.Text = "Опыт";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(16, 19);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(109, 15);
|
||||
label1.TabIndex = 8;
|
||||
label1.Text = "Название бригады";
|
||||
//
|
||||
// textBoxType
|
||||
//
|
||||
textBoxType.Location = new Point(131, 103);
|
||||
textBoxType.Name = "textBoxType";
|
||||
textBoxType.Size = new Size(218, 23);
|
||||
textBoxType.TabIndex = 17;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(16, 111);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(77, 15);
|
||||
label4.TabIndex = 16;
|
||||
label4.Text = "Тип бригады";
|
||||
//
|
||||
// FormTeam
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(380, 181);
|
||||
Controls.Add(textBoxType);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxNameLeader);
|
||||
Controls.Add(textBoxExpirience);
|
||||
Controls.Add(textBoxNameTeam);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FormTeam";
|
||||
Text = "FormTeam";
|
||||
Load += FormMenu_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxNameLeader;
|
||||
private TextBox textBoxExpirience;
|
||||
private TextBox textBoxNameTeam;
|
||||
private Label label3;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private TextBox textBoxType;
|
||||
private Label label4;
|
||||
}
|
||||
}
|
81
viewmodel/FormTeam.cs
Normal file
81
viewmodel/FormTeam.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using ConstructionFirmBusinessLogic.BusinessLogics;
|
||||
using Subd_4.BindingModels;
|
||||
using Subd_4.BusinessLogicContracts;
|
||||
using Subd_4.SearchModels;
|
||||
|
||||
namespace viewmodel
|
||||
{
|
||||
public partial class FormTeam : Form
|
||||
{
|
||||
private readonly ITeamLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormTeam(ITeamLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormMenu_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new TeamSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxNameTeam.Text = view.TeamName;
|
||||
textBoxNameLeader.Text = view.LeaderName;
|
||||
textBoxExpirience.Text = view.Experince.ToString();
|
||||
textBoxType.Text = view.TeamType;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxNameTeam.Text) || string.IsNullOrEmpty(textBoxExpirience.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var model = new TeamBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
TeamName = textBoxNameTeam.Text,
|
||||
LeaderName = textBoxNameLeader.Text,
|
||||
Experince = Convert.ToInt32(textBoxExpirience.Text),
|
||||
TeamType = textBoxType.Text
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Доп информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user