From 1df43b51052714f697cbb597ffcbf804bcf687ae Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Tue, 30 Mar 2021 22:34:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D1=81?= =?UTF-8?q?=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DatabaseCore/Models/Security/User.cs | 12 -- .../AbstractBaseControl.Designer.cs | 4 +- .../BaseControls/AbstractBaseControl.cs | 65 +++++++--- .../BaseControls/BaseControlBool.Designer.cs | 57 +++++++++ .../BaseControls/BaseControlBool.cs | 65 ++++++++++ .../BaseControls/BaseControlBool.resx | 120 ++++++++++++++++++ .../BaseControlDateTime.Designer.cs | 56 ++++++++ .../BaseControls/BaseControlDateTime.cs | 81 ++++++++++++ .../BaseControlDecimal.Designer.cs | 58 +++++++++ .../BaseControls/BaseControlDecimal.cs | 80 ++++++++++++ .../BaseControls/BaseControlDecimal.resx | 120 ++++++++++++++++++ .../BaseControls/BaseControlEnum.Designer.cs | 59 +++++++++ .../BaseControls/BaseControlEnum.cs | 86 +++++++++++++ .../BaseControls/BaseControlEnum.resx | 120 ++++++++++++++++++ .../BaseControls/BaseControlGuid.Designer.cs | 70 ++++++++++ .../BaseControls/BaseControlGuid.cs | 106 ++++++++++++++++ .../BaseControls/BaseControlGuid.resx | 120 ++++++++++++++++++ .../BaseControls/BaseControlImage.Designer.cs | 60 +++++++++ .../BaseControls/BaseControlImage.cs | 101 +++++++++++++++ .../BaseControls/BaseControlImage.resx | 120 ++++++++++++++++++ .../BaseControls/BaseControlInt.cs | 81 +++++++----- .../BaseControlString.Designer.cs | 44 +++++++ .../BaseControls/BaseControlString.cs | 55 ++++++++ .../BaseControls/BaseControlString.resx | 120 ++++++++++++++++++ .../BaseControls/BaseControlText.Designer.cs | 5 +- .../BaseControls/BaseControlText.cs | 38 ++++-- ...tractControlViewEntityElement.Designer.cs} | 2 +- ...cs => AbstractControlViewEntityElement.cs} | 16 +-- ... => AbstractControlViewEntityElement.resx} | 0 ...AbstractControlViewEntityList.Designer.cs} | 2 +- ...st.cs => AbstractControlViewEntityList.cs} | 35 ++++- ...esx => AbstractControlViewEntityList.resx} | 0 ...tractGenericControlEntityList.Designer.cs} | 2 +- ...cs => AbstractGenericControlEntityList.cs} | 33 +++-- ... => AbstractGenericControlEntityList.resx} | 0 .../Controls/GenericControlEntityElement.cs | 67 +++++++--- .../WindowDesktopExtensionControlModel.cs | 2 +- .../ViewModelOnElementPropertyAttribute.cs | 65 +++++++++- .../BusinessLogics/DependencyManager.cs | 7 + .../BusinessLogics/UnityContainerManager.cs | 3 + .../Common/ModuleTools/Enums/ControlType.cs | 53 ++++++++ .../Interfaces/IDependencyManager.cs | 11 +- .../DepartmentPortalDesctop/FormMain.cs | 10 +- .../BindingModels/UserBindingModels.cs | 10 +- .../SecurityBusinessLogic.csproj | 4 + .../ViewModels/AccessViewModels.cs | 3 + .../ViewModels/EnviromentSettingViewModels.cs | 7 +- .../ViewModels/RoleViewModels.cs | 5 +- .../ViewModels/UserViewModels.cs | 16 +-- .../Implementations/UserService.cs | 5 + .../Controls/AccessesControl.cs | 14 +- .../Controls/EnviromentSettingControl.cs | 14 +- .../Controls/RolesControl.cs | 14 +- .../Controls/UsersControl.cs | 15 ++- .../SecurityWindowDesktopExtension.cs | 6 +- 55 files changed, 2143 insertions(+), 181 deletions(-) create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.resx create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.resx create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.resx create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.resx create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.resx create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.Designer.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs create mode 100644 DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.resx rename DepartmentPortal/Common/DesktopTools/Controls/{BaseControlViewEntityElement.Designer.cs => AbstractControlViewEntityElement.Designer.cs} (96%) rename DepartmentPortal/Common/DesktopTools/Controls/{BaseControlViewEntityElement.cs => AbstractControlViewEntityElement.cs} (86%) rename DepartmentPortal/Common/DesktopTools/Controls/{BaseControlViewEntityElement.resx => AbstractControlViewEntityElement.resx} (100%) rename DepartmentPortal/Common/DesktopTools/Controls/{BaseControlViewEntityList.Designer.cs => AbstractControlViewEntityList.Designer.cs} (96%) rename DepartmentPortal/Common/DesktopTools/Controls/{BaseControlViewEntityList.cs => AbstractControlViewEntityList.cs} (57%) rename DepartmentPortal/Common/DesktopTools/Controls/{BaseControlViewEntityList.resx => AbstractControlViewEntityList.resx} (100%) rename DepartmentPortal/Common/DesktopTools/Controls/{GenericControlEntityList.Designer.cs => AbstractGenericControlEntityList.Designer.cs} (99%) rename DepartmentPortal/Common/DesktopTools/Controls/{GenericControlEntityList.cs => AbstractGenericControlEntityList.cs} (90%) rename DepartmentPortal/Common/DesktopTools/Controls/{GenericControlEntityList.resx => AbstractGenericControlEntityList.resx} (100%) create mode 100644 DepartmentPortal/Common/ModuleTools/Enums/ControlType.cs diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs b/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs index 1ae90a7..9309785 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Security/User.cs @@ -21,18 +21,6 @@ namespace DatabaseCore.Models.Security [MapConfiguration("Password")] public string PasswordHash { get; set; } - [DataMember] - [MapConfiguration("StudentId")] - public Guid? StudentId { get; set; } - - [DataMember] - [MapConfiguration("LecturerId")] - public Guid? LecturerId { get; set; } - - [DataMember] - [MapConfiguration("EmployeeId")] - public Guid? EmployeeId { get; set; } - [DataMember] [MapConfiguration("Avatar")] public byte[] Avatar { get; set; } diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.Designer.cs index ff108fa..2e1282a 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.Designer.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.Designer.cs @@ -51,13 +51,13 @@ namespace DesktopTools.BaseControls this.panelControl.Size = new System.Drawing.Size(407, 25); this.panelControl.TabIndex = 1; // - // BaseControl + // AbstractBaseControl // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.panelControl); this.Controls.Add(this.labelTitle); - this.Name = "BaseControl"; + this.Name = "AbstractBaseControl"; this.Size = new System.Drawing.Size(500, 25); this.ResumeLayout(false); diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs index a18528e..6875fb0 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs @@ -4,6 +4,9 @@ using System.Windows.Forms; namespace DesktopTools.BaseControls { + /// + /// Описание контрола для работы со значением свойства класса + /// public abstract partial class AbstractBaseControl : UserControl { /// @@ -14,17 +17,18 @@ namespace DesktopTools.BaseControls /// /// Необходимость проверки при получении данных /// - protected bool _mustCheckValue; + protected bool _mustFilling; /// /// Название свойства, по которму идет отображение /// - protected string PropertyName { get; private set; } + protected string _propertyName; + #region Событие изменения значения /// /// Событие изменения значения в контроле /// - protected event Action OnValueChange; + private event Action OnValueChange; /// /// Событие изменения значения в контроле @@ -35,14 +39,28 @@ namespace DesktopTools.BaseControls /// Вызов события в дочерних контролах /// protected void CallOnValueChangeEvent() => OnValueChange?.Invoke(); + #endregion - - public AbstractBaseControl(string propertyName) + /// + /// Конструктор + /// + /// Название свойстваДолжно ли оно быть заполненным обязательно + /// Устанвока контрола в режим только просмотра + public AbstractBaseControl(string propertyName, bool mustFilling, bool readOnly) { InitializeComponent(); - PropertyName = propertyName; + _propertyName = propertyName; + _mustFilling = mustFilling; + panelControl.Enabled = !readOnly; + SetDefaultValue(); } + /// + /// Установка _originalValue в значение по умолчанию + /// + protected abstract void SetDefaultValue(); + #region Работа с заголовком /// /// Установка заголовка @@ -67,29 +85,35 @@ namespace DesktopTools.BaseControls } #endregion + #region Работа со значением /// - /// Устанвока контрола в режим только просмотра + /// Извлечение значения из свойства объекта /// - /// - public abstract void SetReadOnly(bool readOnly); + /// + public void SetValue(object obj) + { + if (obj != null && _propertyName.IsNotEmpty()) + { + var property = obj.GetType().GetProperty(_propertyName); + if (property != null) + { + _originalValue = property.GetValue(obj); + SetValueToControl(_originalValue); + } + } + } /// - /// Установка значения + /// Установка значения в контрол /// /// - public virtual void SetValueToControl(object value) => _originalValue = value; + protected abstract void SetValueToControl(object value); /// /// Сброс значения /// public abstract void DropValue(); - /// - /// Установка флага необхоидмости проверки - /// - /// - public void SetMustCheckValue(bool mustCheckValue) => _mustCheckValue = mustCheckValue; - /// /// Проверка на заполненность /// @@ -106,16 +130,17 @@ namespace DesktopTools.BaseControls /// Заполнение свойства объекта значением из контрола /// /// - public void FillPropertyToObject(object obj) + public void GetValue(object obj) { - if (obj != null && PropertyName.IsNotEmpty()) + if (obj != null && _propertyName.IsNotEmpty()) { - var property = obj.GetType().GetProperty(PropertyName); + var property = obj.GetType().GetProperty(_propertyName); if (property != null) { property.SetValue(obj, GetValueFromControl()); } } } + #endregion } } diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.Designer.cs new file mode 100644 index 0000000..010aa7e --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.Designer.cs @@ -0,0 +1,57 @@ + +namespace DesktopTools.BaseControls +{ + partial class BaseControlBool + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.checkBoxNullable = new System.Windows.Forms.CheckBox(); + this.checkBox = new System.Windows.Forms.CheckBox(); + // + // checkBoxNullable + // + this.checkBoxNullable.AutoSize = true; + this.checkBoxNullable.Location = new System.Drawing.Point(41, 14); + this.checkBoxNullable.Name = "checkBoxNullable"; + this.checkBoxNullable.Size = new System.Drawing.Size(83, 19); + this.checkBoxNullable.TabIndex = 1; + this.checkBoxNullable.UseVisualStyleBackColor = true; + this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left; + // + // checkBox + // + this.checkBox.AutoSize = true; + this.checkBox.Location = new System.Drawing.Point(148, 9); + this.checkBox.Name = "checkBox"; + this.checkBox.Size = new System.Drawing.Size(83, 19); + this.checkBox.TabIndex = 1; + this.checkBox.UseVisualStyleBackColor = true; + } + + #endregion + + private System.Windows.Forms.CheckBox checkBoxNullable; + private System.Windows.Forms.CheckBox checkBox; + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.cs new file mode 100644 index 0000000..39bcb72 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.cs @@ -0,0 +1,65 @@ +using System; +using System.Windows.Forms; + +namespace DesktopTools.BaseControls +{ + /// + /// Контрол, предоставляющий работу с bool-полем + /// + public partial class BaseControlBool : AbstractBaseControl + { + /// + /// Конструктор + /// + /// + /// + /// + public BaseControlBool(string propertyName, bool mustFilling, bool readOnly) : base(propertyName, mustFilling, readOnly) + { + InitializeComponent(); + + if (!_mustFilling) + { + checkBoxNullable.CheckedChanged += (object sender, EventArgs e) => + { + checkBox.Enabled = !(sender as CheckBox).Checked; + CallOnValueChangeEvent(); + }; + panelControl.Controls.Add(checkBoxNullable); + } + + checkBox.CheckedChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; + panelControl.Controls.Add(checkBox); + } + + protected override void SetDefaultValue() => _originalValue = _mustFilling ? false : null; + + protected override void SetValueToControl(object value) + { + if (value != null) + { + checkBox.Checked = Convert.ToBoolean(value); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override void DropValue() + { + if (_originalValue != null) + { + checkBox.Checked = Convert.ToBoolean(_originalValue); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override bool CheckValue() => true; + + protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : checkBox.Checked; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.resx b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlBool.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.Designer.cs new file mode 100644 index 0000000..1eed672 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.Designer.cs @@ -0,0 +1,56 @@ + +namespace DesktopTools.BaseControls +{ + partial class BaseControlDateTime + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.checkBoxNullable = new System.Windows.Forms.CheckBox(); + this.dateTimePicker = new System.Windows.Forms.DateTimePicker(); + // + // checkBoxNullable + // + this.checkBoxNullable.AutoSize = true; + this.checkBoxNullable.Location = new System.Drawing.Point(41, 14); + this.checkBoxNullable.Name = "checkBoxNullable"; + this.checkBoxNullable.Size = new System.Drawing.Size(83, 19); + this.checkBoxNullable.TabIndex = 1; + this.checkBoxNullable.UseVisualStyleBackColor = true; + this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left; + // + // dateTimePicker + // + this.dateTimePicker.Dock = System.Windows.Forms.DockStyle.Fill; + this.dateTimePicker.Location = new System.Drawing.Point(123, 16); + this.dateTimePicker.Name = "dateTimePicker"; + this.dateTimePicker.Size = new System.Drawing.Size(200, 23); + this.dateTimePicker.TabIndex = 0; + } + + #endregion + + private System.Windows.Forms.CheckBox checkBoxNullable; + private System.Windows.Forms.DateTimePicker dateTimePicker; + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs new file mode 100644 index 0000000..3ee7eb0 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDateTime.cs @@ -0,0 +1,81 @@ +using ModuleTools.Extensions; +using System; +using System.Windows.Forms; + +namespace DesktopTools.BaseControls +{ + /// + /// Контрол, предоставляющий работу с датой + /// + public partial class BaseControlDateTime : AbstractBaseControl + { + /// + /// Конструктор + /// + /// + /// + /// + /// + /// + /// + public BaseControlDateTime(string propertyName, bool mustFilling, bool readOnly, DateTime? minDate, DateTime? maxDate, string customDateFormat) : base(propertyName, mustFilling, readOnly) + { + InitializeComponent(); + + if (!_mustFilling) + { + checkBoxNullable.CheckedChanged += (object sender, EventArgs e) => + { + dateTimePicker.Enabled = !(sender as CheckBox).Checked; + CallOnValueChangeEvent(); + }; + panelControl.Controls.Add(checkBoxNullable); + } + + dateTimePicker.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; + if (minDate.HasValue) + { + dateTimePicker.MinDate = minDate.Value; + } + if (maxDate.HasValue) + { + dateTimePicker.MaxDate = maxDate.Value; + } + if(customDateFormat.IsNotEmpty()) + { + dateTimePicker.CustomFormat = customDateFormat; + } + panelControl.Controls.Add(dateTimePicker); + } + + protected override void SetDefaultValue() => _originalValue = _mustFilling ? DateTime.Now : null; + + protected override void SetValueToControl(object value) + { + if (value != null) + { + dateTimePicker.Value = Convert.ToDateTime(value); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override void DropValue() + { + if (_originalValue != null) + { + dateTimePicker.Value = Convert.ToDateTime(_originalValue); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override bool CheckValue() => true; + + protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : Convert.ToDateTime(dateTimePicker.Value); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.Designer.cs new file mode 100644 index 0000000..d0a4fe6 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.Designer.cs @@ -0,0 +1,58 @@ + +namespace DesktopTools.BaseControls +{ + partial class BaseControlDecimal + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.checkBoxNullable = new System.Windows.Forms.CheckBox(); + this.numericUpDown = new System.Windows.Forms.NumericUpDown(); + // + // checkBoxNullable + // + this.checkBoxNullable.AutoSize = true; + this.checkBoxNullable.Location = new System.Drawing.Point(41, 14); + this.checkBoxNullable.Name = "checkBoxNullable"; + this.checkBoxNullable.Size = new System.Drawing.Size(83, 19); + this.checkBoxNullable.TabIndex = 1; + this.checkBoxNullable.UseVisualStyleBackColor = true; + this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left; + // + // numericUpDown + // + this.numericUpDown.Dock = System.Windows.Forms.DockStyle.Fill; + this.numericUpDown.Location = new System.Drawing.Point(148, 9); + this.numericUpDown.Name = "numericUpDown"; + this.numericUpDown.Size = new System.Drawing.Size(120, 23); + this.numericUpDown.TabIndex = 2; + this.numericUpDown.Minimum = decimal.MinValue; + this.numericUpDown.Maximum = decimal.MaxValue; + } + + #endregion + + private System.Windows.Forms.CheckBox checkBoxNullable; + private System.Windows.Forms.NumericUpDown numericUpDown; + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs new file mode 100644 index 0000000..bd475f3 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.cs @@ -0,0 +1,80 @@ +using System; +using System.Windows.Forms; + +namespace DesktopTools.BaseControls +{ + /// + /// Контрол, предоставляющий работу с вещественным полем + /// + public partial class BaseControlDecimal : AbstractBaseControl + { + /// + /// Конструктор + /// + /// + /// + /// + /// + /// + /// + public BaseControlDecimal(string propertyName, bool mustFilling, bool readOnly, decimal? minValue, decimal? maxValue, int? decimalPlaces) : base(propertyName, mustFilling, readOnly) + { + InitializeComponent(); + + if (!_mustFilling) + { + checkBoxNullable.CheckedChanged += (object sender, EventArgs e) => + { + numericUpDown.Enabled = !(sender as CheckBox).Checked; + CallOnValueChangeEvent(); + }; + panelControl.Controls.Add(checkBoxNullable); + } + + numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; + if (minValue.HasValue) + { + numericUpDown.Minimum = minValue.Value; + } + if (maxValue.HasValue) + { + numericUpDown.Maximum = maxValue.Value; + } + if (decimalPlaces.HasValue) + { + numericUpDown.DecimalPlaces = decimalPlaces.Value; + } + panelControl.Controls.Add(numericUpDown); + } + + protected override void SetDefaultValue() => _originalValue = _mustFilling ? 0 : null; + + protected override void SetValueToControl(object value) + { + if (value != null) + { + numericUpDown.Value = Convert.ToDecimal(value); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override void DropValue() + { + if (_originalValue != null) + { + numericUpDown.Value = Convert.ToDecimal(_originalValue); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override bool CheckValue() => true; + + protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : Convert.ToDouble(numericUpDown.Value); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.resx b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlDecimal.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.Designer.cs new file mode 100644 index 0000000..6db9900 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.Designer.cs @@ -0,0 +1,59 @@ + +namespace DesktopTools.BaseControls +{ + partial class BaseControlEnum + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.checkBoxNullable = new System.Windows.Forms.CheckBox(); + this.comboBox = new System.Windows.Forms.ComboBox(); + // + // checkBoxNullable + // + this.checkBoxNullable.AutoSize = true; + this.checkBoxNullable.Location = new System.Drawing.Point(41, 14); + this.checkBoxNullable.Name = "checkBoxNullable"; + this.checkBoxNullable.Size = new System.Drawing.Size(83, 19); + this.checkBoxNullable.TabIndex = 1; + this.checkBoxNullable.UseVisualStyleBackColor = true; + this.checkBoxNullable.Dock = System.Windows.Forms.DockStyle.Left; + // + // comboBox + // + this.comboBox.Cursor = System.Windows.Forms.Cursors.Hand; + this.comboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox.FormattingEnabled = true; + this.comboBox.Location = new System.Drawing.Point(100, 10); + this.comboBox.Name = "comboBox"; + this.comboBox.Size = new System.Drawing.Size(121, 23); + this.comboBox.TabIndex = 0; + this.comboBox.Dock = System.Windows.Forms.DockStyle.Fill; + } + + #endregion + + private System.Windows.Forms.CheckBox checkBoxNullable; + private System.Windows.Forms.ComboBox comboBox; + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.cs new file mode 100644 index 0000000..8994dbe --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.cs @@ -0,0 +1,86 @@ +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace DesktopTools.BaseControls +{ + /// + /// Контрол, предоставляющий работу с перечислениями + /// + public partial class BaseControlEnum : AbstractBaseControl + { + /// + /// Конструктор + /// + /// + /// + /// + /// + public BaseControlEnum(string propertyName, bool mustFilling, bool readOnly, Type enumType) : base(propertyName, mustFilling, readOnly) + { + InitializeComponent(); + if (!_mustFilling) + { + checkBoxNullable.CheckedChanged += (object sender, EventArgs e) => + { + comboBox.Enabled = !(sender as CheckBox).Checked; + CallOnValueChangeEvent(); + }; + panelControl.Controls.Add(checkBoxNullable); + } + + comboBox.Items.Clear(); + foreach (var val in Enum.GetValues(enumType)) + { + comboBox.Items.Add(val); + } + comboBox.SelectedIndexChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; + panelControl.Controls.Add(comboBox); + } + + protected override void SetDefaultValue() => _originalValue = null; + + protected override void SetValueToControl(object value) + { + if (value != null) + { + comboBox.SelectedIndex = comboBox.Items.IndexOf(value); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override void DropValue() + { + if (_originalValue != null) + { + comboBox.SelectedIndex = comboBox.Items.IndexOf(_originalValue); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } + } + + public override bool CheckValue() + { + if (_mustFilling && comboBox.SelectedIndex == -1) + { + BackColor = Color.OrangeRed; + return false; + } + return true; + } + + protected override object GetValueFromControl() + { + if (_mustFilling && comboBox.SelectedIndex == -1) + { + throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено"); + } + return checkBoxNullable.Checked ? null : comboBox.SelectedItem; + } + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.resx b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlEnum.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.Designer.cs new file mode 100644 index 0000000..b95cce6 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.Designer.cs @@ -0,0 +1,70 @@ + +namespace DesktopTools.BaseControls +{ + partial class BaseControlGuid + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.buttonClear = new System.Windows.Forms.Button(); + this.buttonSelect = new System.Windows.Forms.Button(); + this.textBox = new System.Windows.Forms.TextBox(); + // + // buttonClear + // + this.buttonClear.BackgroundImage = global::DesktopTools.Properties.Resources.Clear; + this.buttonClear.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonClear.Dock = System.Windows.Forms.DockStyle.Right; + this.buttonClear.Location = new System.Drawing.Point(74, 12); + this.buttonClear.Name = "buttonClear"; + this.buttonClear.Size = new System.Drawing.Size(25, 25); + this.buttonClear.TabIndex = 0; + this.buttonClear.Text = "..."; + this.buttonClear.UseVisualStyleBackColor = true; + // + // buttonSelect + // + this.buttonSelect.Dock = System.Windows.Forms.DockStyle.Right; + this.buttonSelect.Location = new System.Drawing.Point(74, 12); + this.buttonSelect.Name = "buttonSelect"; + this.buttonSelect.Size = new System.Drawing.Size(25, 25); + this.buttonSelect.TabIndex = 0; + this.buttonSelect.Text = "..."; + this.buttonSelect.UseVisualStyleBackColor = true; + // + // textBox + // + this.textBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox.Location = new System.Drawing.Point(0, 0); + this.textBox.Name = "textBox"; + this.textBox.Size = new System.Drawing.Size(1000, 1000); + this.textBox.TabIndex = 1; + } + + #endregion + + private System.Windows.Forms.Button buttonSelect; + private System.Windows.Forms.Button buttonClear; + private System.Windows.Forms.TextBox textBox; + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.cs new file mode 100644 index 0000000..fdbbe4d --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.cs @@ -0,0 +1,106 @@ +using DesktopTools.Controls; +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace DesktopTools.BaseControls +{ + public partial class BaseControlGuid : AbstractBaseControl + { + private AbstractControlViewEntityList _control; + + public BaseControlGuid(string propertyName, bool mustFilling, bool readOnly, AbstractControlViewEntityList controlType) : base(propertyName, mustFilling, readOnly) + { + InitializeComponent(); + + _control = controlType; + + panelControl.Controls.Add(textBox); + + if (!_mustFilling) + { + buttonClear.Click += (object sender, EventArgs e) => + { + textBox.Text = string.Empty; + textBox.Tag = null; + CallOnValueChangeEvent(); + }; + panelControl.Controls.Add(buttonClear); + } + + buttonSelect.Click += (object sender, EventArgs e) => + { + var form = new Form + { + Height = controlType.Height, + Width = controlType.Width, + Text = $"{controlType.Title}. Выбор", + StartPosition = FormStartPosition.CenterParent, + ControlBox = false + }; + var clone = controlType.Clone(); + form.Controls.Add(clone); + clone.Dock = DockStyle.Fill; + clone.FormForSelected = form; + clone.Open(); + if (form.ShowDialog() == DialogResult.OK) + { + textBox.Tag = clone.SelectedId; + textBox.Text = clone.SelectedText; + CallOnValueChangeEvent(); + } + }; + panelControl.Controls.Add(buttonSelect); + } + + protected override void SetDefaultValue() => _originalValue = null; + + protected override void SetValueToControl(object value) + { + if (value != null) + { + var id = new Guid(value.ToString()); + textBox.Tag = id; + textBox.Text = _control?.GetTitleFromId(id); + } + else if (!_mustFilling) + { + textBox.Tag = null; + } + } + + public override void DropValue() + { + if (_originalValue != null) + { + var id = new Guid(_originalValue.ToString()); + textBox.Tag = id; + textBox.Text = _control?.GetTitleFromId(id); + } + else if (!_mustFilling) + { + textBox.Tag = null; + textBox.Text = string.Empty; + } + } + + public override bool CheckValue() + { + if (_mustFilling && textBox.Tag == null) + { + BackColor = Color.OrangeRed; + return false; + } + return true; + } + + protected override object GetValueFromControl() + { + if (_mustFilling && textBox.Tag == null) + { + throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено"); + } + return textBox.Tag == null ? null : new Guid(textBox.Tag.ToString()); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.resx b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlGuid.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.Designer.cs new file mode 100644 index 0000000..ac7856d --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.Designer.cs @@ -0,0 +1,60 @@ + +namespace DesktopTools.BaseControls +{ + partial class BaseControlImage + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.pictureBox = new System.Windows.Forms.PictureBox(); + this.buttonLoad = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); + // + // buttonLoad + // + this.buttonLoad.Dock = System.Windows.Forms.DockStyle.Bottom; + this.buttonLoad.Location = new System.Drawing.Point(74, 12); + this.buttonLoad.Name = "buttonLoad"; + this.buttonLoad.Size = new System.Drawing.Size(25, 25); + this.buttonLoad.TabIndex = 0; + this.buttonLoad.Text = "Загрузить"; + this.buttonLoad.UseVisualStyleBackColor = true; + // + // pictureBox + // + this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBox.Location = new System.Drawing.Point(111, 19); + this.pictureBox.Name = "pictureBox"; + this.pictureBox.Size = new System.Drawing.Size(100, 50); + this.pictureBox.TabIndex = 0; + this.pictureBox.TabStop = false; + + ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit(); + } + + #endregion + + private System.Windows.Forms.Button buttonLoad; + private System.Windows.Forms.PictureBox pictureBox; + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs new file mode 100644 index 0000000..8fcc399 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.cs @@ -0,0 +1,101 @@ +using System; +using System.Drawing; +using System.IO; +using System.Windows.Forms; + +namespace DesktopTools.BaseControls +{ + /// + /// Контрол, предоставляющий работу с изображением + /// + public partial class BaseControlImage : AbstractBaseControl + { + /// + /// Конструктор + /// + /// + /// + /// + /// + /// + public BaseControlImage(string propertyName, bool mustFilling, bool readOnly, int? width, int? height) : base(propertyName, mustFilling, readOnly) + { + InitializeComponent(); + if (width.HasValue) + { + Width = width.Value; + } + if (height.HasValue) + { + Height = height.Value; + } + + buttonLoad.Click += (object sender, EventArgs e) => + { + var dialog = new OpenFileDialog(); + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + pictureBox.ClientSize = new Size(150, 150); + pictureBox.Image = new Bitmap(dialog.FileName); + CallOnValueChangeEvent(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке файла", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + }; + panelControl.Controls.Add(pictureBox); + } + + protected override void SetDefaultValue() => _originalValue = null; + + protected override void SetValueToControl(object value) + { + if (value != null) + { + using MemoryStream mStream = new(value as byte[]); + pictureBox.Image = Image.FromStream(mStream); + } + else if (!_mustFilling) + { + pictureBox.Image = null; + } + } + + public override void DropValue() + { + if (_originalValue != null) + { + using MemoryStream mStream = new(_originalValue as byte[]); + pictureBox.Image = Image.FromStream(mStream); + } + else if (!_mustFilling) + { + pictureBox.Image = null; + } + } + + public override bool CheckValue() + { + if (_mustFilling && pictureBox.Image == null) + { + BackColor = Color.OrangeRed; + return false; + } + return true; + } + + protected override object GetValueFromControl() + { + if (_mustFilling && pictureBox.Image == null) + { + throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено"); + } + var converter = new ImageConverter(); + return (byte[])converter.ConvertTo(pictureBox.Image, typeof(byte[])); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.resx b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlImage.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs index 5a57b03..6849f9c 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlInt.cs @@ -1,64 +1,75 @@ using System; -using System.Drawing; using System.Windows.Forms; namespace DesktopTools.BaseControls { + /// + /// Контрол, предоставляющий работу с целочисленным полем + /// public partial class BaseControlInt : AbstractBaseControl { - public BaseControlInt(string propertyName) : base(propertyName) + /// + /// Конструктор + /// + /// + /// + /// + /// + /// + public BaseControlInt(string propertyName, bool mustFilling, bool readOnly, decimal? minValue, decimal? maxValue) : base(propertyName, mustFilling, readOnly) { InitializeComponent(); - checkBoxNullable.Visible = false; - panelControl.Controls.Add(checkBoxNullable); - checkBoxNullable.CheckedChanged += (object sender, EventArgs e) => + + if (!_mustFilling) { - numericUpDown.Enabled = !(sender as CheckBox).Checked; - CallOnValueChangeEvent(); - }; + checkBoxNullable.CheckedChanged += (object sender, EventArgs e) => + { + numericUpDown.Enabled = !(sender as CheckBox).Checked; + CallOnValueChangeEvent(); + }; + panelControl.Controls.Add(checkBoxNullable); + } - panelControl.Controls.Add(numericUpDown); numericUpDown.ValueChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; - _originalValue = 0; + if (minValue.HasValue) + { + numericUpDown.Minimum = minValue.Value; + } + if (maxValue.HasValue) + { + numericUpDown.Maximum = maxValue.Value; + } + panelControl.Controls.Add(numericUpDown); } - public override void SetReadOnly(bool readOnly) - { - numericUpDown.Enabled = !readOnly; - checkBoxNullable.Enabled = !readOnly; - } + protected override void SetDefaultValue() => _originalValue = _mustFilling ? 0 : null; - public override void SetValueToControl(object value) + protected override void SetValueToControl(object value) { - base.SetValueToControl(value); if (value != null) { numericUpDown.Value = Convert.ToInt32(value); } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } } public override void DropValue() { - numericUpDown.Value = _originalValue != null ? Convert.ToInt32(_originalValue) : 0; + if (_originalValue != null) + { + numericUpDown.Value = Convert.ToInt32(_originalValue); + } + else if (!_mustFilling) + { + checkBoxNullable.Checked = true; + } } - public override bool CheckValue() - { - if (_mustCheckValue && checkBoxNullable.Checked) - { - BackColor = Color.OrangeRed; - return false; - } - return true; - } + public override bool CheckValue() => true; - protected override object GetValueFromControl() - { - if (_mustCheckValue && checkBoxNullable.Checked) - { - throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено"); - } - return checkBoxNullable.Checked? null : Convert.ToInt32(numericUpDown.Value); - } + protected override object GetValueFromControl() => !_mustFilling && checkBoxNullable.Checked ? null : Convert.ToInt32(numericUpDown.Value); } } \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.Designer.cs new file mode 100644 index 0000000..06f9b36 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.Designer.cs @@ -0,0 +1,44 @@ + +namespace DesktopTools.BaseControls +{ + partial class BaseControlString + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.textBox = new System.Windows.Forms.TextBox(); + // + // textBox + // + this.textBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox.Location = new System.Drawing.Point(0, 0); + this.textBox.Name = "textBox"; + this.textBox.Size = new System.Drawing.Size(1000, 1000); + this.textBox.TabIndex = 0; + } + + #endregion + + private System.Windows.Forms.TextBox textBox; + } +} diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs new file mode 100644 index 0000000..93d0f06 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.cs @@ -0,0 +1,55 @@ +using ModuleTools.Extensions; +using System; +using System.Drawing; + +namespace DesktopTools.BaseControls +{ + /// + /// Контрол, предоставляющий работу с однострочным текстовым полем + /// + public partial class BaseControlString : AbstractBaseControl + { + /// + /// Конструктор + /// + /// + /// + /// + /// + public BaseControlString(string propertyName, bool mustFilling, bool readOnly, int? maxLength) : base(propertyName, mustFilling, readOnly) + { + InitializeComponent(); + if (maxLength.HasValue) + { + textBox.MaxLength = maxLength.Value; + } + textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; + panelControl.Controls.Add(textBox); + } + + protected override void SetDefaultValue() => _originalValue = string.Empty; + + protected override void SetValueToControl(object value) => textBox.Text = value?.ToString(); + + public override void DropValue() => textBox.Text = _originalValue?.ToString(); + + public override bool CheckValue() + { + if (_mustFilling && textBox.Text.IsEmpty()) + { + BackColor = Color.OrangeRed; + return false; + } + return true; + } + + protected override object GetValueFromControl() + { + if (_mustFilling && textBox.Text.IsEmpty()) + { + throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено"); + } + return textBox.Text; + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.resx b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlString.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.Designer.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.Designer.cs index 9b1136c..27307bc 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.Designer.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.Designer.cs @@ -24,6 +24,8 @@ namespace DesktopTools.BaseControls /// private void InitializeComponent() { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.textBox = new System.Windows.Forms.TextBox(); // // textBox @@ -32,7 +34,8 @@ namespace DesktopTools.BaseControls this.textBox.Location = new System.Drawing.Point(0, 0); this.textBox.Name = "textBox"; this.textBox.Size = new System.Drawing.Size(1000, 1000); - this.textBox.TabIndex = 1; + this.textBox.Multiline = true; + this.textBox.TabIndex = 0; } #endregion diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs index fdd35da..cae8f04 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/BaseControlText.cs @@ -4,29 +4,43 @@ using System.Drawing; namespace DesktopTools.BaseControls { + /// + /// Контрол, предоставляющий работу с текстовым полем на несколько строк + /// public partial class BaseControlText : AbstractBaseControl { - public BaseControlText(string propertyName) : base(propertyName) + /// + /// Конструктор + /// + /// + /// + /// + /// + /// + public BaseControlText(string propertyName, bool mustFilling, bool readOnly, int? maxLength, int? height) : base(propertyName, mustFilling, readOnly) { InitializeComponent(); - panelControl.Controls.Add(textBox); + if (maxLength.HasValue) + { + textBox.MaxLength = maxLength.Value; + } + if (height.HasValue) + { + textBox.Height = height.Value; + } textBox.TextChanged += (object sender, EventArgs e) => { CallOnValueChangeEvent(); }; - _originalValue = string.Empty; + panelControl.Controls.Add(textBox); } - public override void SetReadOnly(bool readOnly) => textBox.Enabled = !readOnly; + protected override void SetDefaultValue() => _originalValue = string.Empty; - public override void SetValueToControl(object value) - { - base.SetValueToControl(value); - textBox.Text = value.ToString(); - } + protected override void SetValueToControl(object value) => textBox.Text = value?.ToString(); - public override void DropValue() => textBox.Text = _originalValue.ToString(); + public override void DropValue() => textBox.Text = _originalValue?.ToString(); public override bool CheckValue() { - if(_mustCheckValue && textBox.Text.IsEmpty()) + if(_mustFilling && textBox.Text.IsEmpty()) { BackColor = Color.OrangeRed; return false; @@ -36,7 +50,7 @@ namespace DesktopTools.BaseControls protected override object GetValueFromControl() { - if (_mustCheckValue && textBox.Text.IsEmpty()) + if (_mustFilling && textBox.Text.IsEmpty()) { throw new ArgumentNullException($"Поле свойства '{labelTitle.Text}' должно быть заполнено"); } diff --git a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.Designer.cs b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.Designer.cs similarity index 96% rename from DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.Designer.cs rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.Designer.cs index f7f02ab..ceb0f5b 100644 --- a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.Designer.cs +++ b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.Designer.cs @@ -1,7 +1,7 @@  namespace DesktopTools.Controls { - partial class BaseControlViewEntityElement + partial class AbstractControlViewEntityElement { /// /// Обязательная переменная конструктора. diff --git a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.cs b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.cs similarity index 86% rename from DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.cs rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.cs index 7a08c43..9c302a5 100644 --- a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.cs +++ b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.cs @@ -5,7 +5,7 @@ using System.Windows.Forms; namespace DesktopTools.Controls { - public partial class BaseControlViewEntityElement : UserControl + public abstract partial class AbstractControlViewEntityElement : UserControl { /// /// Признак налиичия изменений @@ -25,12 +25,12 @@ namespace DesktopTools.Controls /// /// Открытие формы /// - public virtual void Open() { } + public abstract void Open(Guid? id); /// /// Закрытие формы /// - public virtual void Close() + public void Close() { if(_haveChages && DialogHelper.MessageQuestion("Имеется несохраненные данные, вы действительно хотите закрыть элемент?", "Закрытие элемента") == DialogResult.Yes) @@ -45,13 +45,7 @@ namespace DesktopTools.Controls Dispose(); } - protected virtual bool Save() { return true; } - - /// - /// Дубликат контрола - /// - /// - public virtual BaseControlViewEntityElement Clone() { return null; } + protected abstract bool Save(); /// /// Установка флага, что есть изменения @@ -96,7 +90,7 @@ namespace DesktopTools.Controls /// /// Констркутор /// - public BaseControlViewEntityElement() + public AbstractControlViewEntityElement() { InitializeComponent(); } diff --git a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.resx b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.resx similarity index 100% rename from DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityElement.resx rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityElement.resx diff --git a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.Designer.cs b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.Designer.cs similarity index 96% rename from DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.Designer.cs rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.Designer.cs index 7fd47e2..220865b 100644 --- a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.Designer.cs +++ b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.Designer.cs @@ -1,7 +1,7 @@  namespace DesktopTools.Controls { - partial class BaseControlViewEntityList + partial class AbstractControlViewEntityList { /// /// Обязательная переменная конструктора. diff --git a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.cs b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.cs similarity index 57% rename from DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.cs rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.cs index 150c3c5..27f710e 100644 --- a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.cs +++ b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.cs @@ -4,7 +4,7 @@ using System.Windows.Forms; namespace DesktopTools.Controls { - public partial class BaseControlViewEntityList : UserControl + public abstract partial class AbstractControlViewEntityList : UserControl { /// /// Событие, вызываемое при закрытии контрола @@ -19,14 +19,19 @@ namespace DesktopTools.Controls /// /// Открытие формы /// - public virtual void Open() { } + public abstract void Open(); /// /// Закрытие формы /// - public virtual void Close() + public void Close() { CloseEvent?.Invoke(ControlId); + if (FormForSelected != null) + { + FormForSelected.DialogResult = DialogResult.Cancel; + FormForSelected.Close(); + } Dispose(); } @@ -34,7 +39,7 @@ namespace DesktopTools.Controls /// Дубликат контрола /// /// - public virtual BaseControlViewEntityList Clone() { return null; } + public abstract AbstractControlViewEntityList Clone(); /// /// Идентификатор контрола @@ -56,11 +61,31 @@ namespace DesktopTools.Controls /// public AccessOperation AccessOperation { get; protected set; } + /// + /// Идентификатор выбранной записи + /// + public Guid? SelectedId { get; set; } + + /// + /// Название выбранной записи + /// + public string SelectedText { get; set; } + + /// + /// Ссылка на форму, в который открыевается контрол для выбора значения + /// + public Form FormForSelected { get; set; } + + /// + /// Получение названиия объекта по его идентификатору + /// + /// + public abstract string GetTitleFromId(Guid id); /// /// Констркутор /// - public BaseControlViewEntityList() + public AbstractControlViewEntityList() { InitializeComponent(); } diff --git a/DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.resx b/DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.resx similarity index 100% rename from DepartmentPortal/Common/DesktopTools/Controls/BaseControlViewEntityList.resx rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractControlViewEntityList.resx diff --git a/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.Designer.cs b/DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.Designer.cs similarity index 99% rename from DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.Designer.cs rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.Designer.cs index 4a9039b..324f614 100644 --- a/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.Designer.cs +++ b/DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.Designer.cs @@ -1,6 +1,6 @@ namespace DesktopTools.Controls { - partial class GenericControlEntityList + partial class AbstractGenericControlEntityList { /// /// Освободить все используемые ресурсы. diff --git a/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.cs b/DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.cs similarity index 90% rename from DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.cs rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.cs index ffbb43e..c6dceba 100644 --- a/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.cs +++ b/DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.cs @@ -13,7 +13,7 @@ using System.Windows.Forms; namespace DesktopTools.Controls { - public partial class GenericControlEntityList : BaseControlViewEntityList + public abstract partial class AbstractGenericControlEntityList : AbstractControlViewEntityList where G : GetBindingModel, new() where S : SetBindingModel, new() where L : ListViewModel @@ -28,7 +28,7 @@ namespace DesktopTools.Controls /// /// Констркутор /// - public GenericControlEntityList() + public AbstractGenericControlEntityList() { InitializeComponent(); InitEvents(); @@ -37,7 +37,6 @@ namespace DesktopTools.Controls public override async void Open() { - base.Open(); if (dataGridViewList.Columns.Count == 0) { Configurate(GetConfig()); @@ -45,10 +44,7 @@ namespace DesktopTools.Controls await LoadListAsync(); } - public override void Close() - { - base.Close(); - } + public override string GetTitleFromId(Guid id) => _businessLogic.GetElement(new G { Id = id })?.ToString(); /// /// Конфигуратор контрола @@ -150,6 +146,9 @@ namespace DesktopTools.Controls { toolStripFooter.Visible = false; } + + // при вызове контрола для выбора элемента, делаем возможность выбора только одной записи + dataGridViewList.MultiSelect = FormForSelected == null; } /// @@ -184,6 +183,14 @@ namespace DesktopTools.Controls }; dataGridViewList.CellDoubleClick += (object sender, DataGridViewCellEventArgs e) => { + if (FormForSelected != null && dataGridViewList.SelectedRows.Count > 0) + { + SelectedId = new Guid(dataGridViewList.SelectedRows[0].Cells[0].Value.ToString()); + SelectedText = _businessLogic.GetElement(new G { Id = SelectedId })?.ToString(); + FormForSelected.DialogResult = DialogResult.OK; + FormForSelected.Close(); + return; + } CallUpdElementEvent(); }; @@ -343,8 +350,8 @@ namespace DesktopTools.Controls { try { - var control = new GenericControlEntityElement(id); - control.Open(); + var control = new GenericControlEntityElement(); + control.Open(id); var form = new Form { Height = control.Height, @@ -364,12 +371,12 @@ namespace DesktopTools.Controls } } - protected virtual ControlViewEntityListConfiguration GetConfig() => new(); + protected abstract ControlViewEntityListConfiguration GetConfig(); - protected virtual L GetData() { return null; } + protected abstract L GetData(); - protected virtual L GetDataWithPageName(string key) { return null; } + protected abstract L GetDataWithPageName(string key); - protected virtual L GetDataWithPageNumber(int page, int count) { return null; } + protected abstract L GetDataWithPageNumber(int page, int count); } } \ No newline at end of file diff --git a/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.resx b/DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.resx similarity index 100% rename from DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityList.resx rename to DepartmentPortal/Common/DesktopTools/Controls/AbstractGenericControlEntityList.resx diff --git a/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityElement.cs b/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityElement.cs index 9bb77f7..eae7a9d 100644 --- a/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityElement.cs +++ b/DepartmentPortal/Common/DesktopTools/Controls/GenericControlEntityElement.cs @@ -2,6 +2,8 @@ using ModuleTools.Attributes; using ModuleTools.BindingModels; using ModuleTools.BusinessLogics; +using ModuleTools.Enums; +using ModuleTools.Extensions; using ModuleTools.ViewModels; using System; using System.Linq; @@ -10,7 +12,7 @@ using System.Windows.Forms; namespace DesktopTools.Controls { - public partial class GenericControlEntityElement : BaseControlViewEntityElement + public partial class GenericControlEntityElement : AbstractControlViewEntityElement where G : GetBindingModel, new() where S : SetBindingModel, new() where L : ListViewModel @@ -24,30 +26,31 @@ namespace DesktopTools.Controls private event Action SetTitleWidth; + private event Action SetValues; + private event Action DropValues; private event Func CheckValues; private event Action GetValues; - private E Element { get; set; } - public GenericControlEntityElement(Guid? id) + private E _element = null; + private E Element { get { return _element; } set { _element = value; SetValues?.Invoke(_element); _haveChages = false; } } + + public GenericControlEntityElement() { InitializeComponent(); InitEvents(); _businessLogic = DependencyManager.Instance.Resolve(); - Element = _businessLogic.GetElement(new G { Id = id }); } - - public override void Open() + public override void Open(Guid? id) { - base.Open(); if (panelContainer.Controls.Count == 0) { Configurate(); } - //LoadList(); + Element = _businessLogic.GetElement(new G { Id = id }); } private void InitEvents() @@ -71,23 +74,46 @@ namespace DesktopTools.Controls if (attribute != null) { AbstractBaseControl control = null; - switch (property.PropertyType.Name.ToLower()) + switch (attribute.ControlType) { - case "string": - control = new BaseControlText(property.Name); + case ControlType.ControlString: + control = new BaseControlString(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MaxLength); break; - case "int32": - control = new BaseControlInt(property.Name); + case ControlType.ControlText: + control = new BaseControlText(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MaxLength, attribute.Height); + break; + case ControlType.ControlInt: + control = new BaseControlInt(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MinValue, attribute.MaxValue); + break; + case ControlType.ControlDecimal: + control = new BaseControlDecimal(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MinValue, + attribute.MaxValue, attribute.DecimalPlaces); + break; + case ControlType.ControlBool: + control = new BaseControlBool(property.Name, attribute.MustHaveValue, attribute.ReadOnly); + break; + case ControlType.ControlDateTime: + control = new BaseControlDateTime(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.MinDate, + attribute.MaxDate, attribute.CustomDateFormat); + break; + case ControlType.ControlImage: + control = new BaseControlImage(property.Name, attribute.MustHaveValue, attribute.ReadOnly, attribute.Width, attribute.Height); + break; + case ControlType.ControlEnum: + control = new BaseControlEnum(property.Name, attribute.MustHaveValue, attribute.ReadOnly, property.PropertyType); + break; + case ControlType.ControlGuid: + if (attribute.ControlTypeObject.IsNotEmpty()) + { + control = new BaseControlGuid(property.Name, attribute.MustHaveValue, attribute.ReadOnly, + DependencyManager.Instance.Resolve(Type.GetType(attribute.ControlTypeObject)) as AbstractControlViewEntityList); + } break; } if (control == null) { continue; } - if (Element != null) - { - control.SetValueToControl(property.GetValue(Element)); - } var widthTitle = control.SetTitle(attribute.DisplayName); if (widthTitle > titleWidth) @@ -96,19 +122,17 @@ namespace DesktopTools.Controls } control.OnValueChangeEvent += ValueChange; + SetValues += control.SetValue; DropValues += control.DropValue; CheckValues += control.CheckValue; SetTitleWidth += control.SetTitleWidth; - GetValues += control.FillPropertyToObject; + GetValues += control.GetValue; control.Location = new System.Drawing.Point(positionX, positionY); control.Width = Width - positionX * 2; control.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left; positionY += control.Height + interval; - control.SetReadOnly(attribute.ReadOnly); - control.SetMustCheckValue(attribute.MustHaveValue); - panelContainer.Controls.Add(control); } } @@ -141,6 +165,7 @@ namespace DesktopTools.Controls throw new Exception($"Ошибка при сохранении: {_businessLogic.Errors.LastOrDefault().Message}"); } + _haveChages = false; MessageBox.Show("Сохранение прошло успешно", "", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } diff --git a/DepartmentPortal/Common/DesktopTools/Models/WindowDesktopExtensionControlModel.cs b/DepartmentPortal/Common/DesktopTools/Models/WindowDesktopExtensionControlModel.cs index f6ba903..18c6d5a 100644 --- a/DepartmentPortal/Common/DesktopTools/Models/WindowDesktopExtensionControlModel.cs +++ b/DepartmentPortal/Common/DesktopTools/Models/WindowDesktopExtensionControlModel.cs @@ -11,6 +11,6 @@ namespace DesktopTools.Models public string Title { get; set; } - public BaseControlViewEntityList Control { get; set; } + public AbstractControlViewEntityList Control { get; set; } } } \ No newline at end of file diff --git a/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelOnElementPropertyAttribute.cs b/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelOnElementPropertyAttribute.cs index 594fe45..7a6a233 100644 --- a/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelOnElementPropertyAttribute.cs +++ b/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelOnElementPropertyAttribute.cs @@ -1,4 +1,5 @@ -using System; +using ModuleTools.Enums; +using System; namespace ModuleTools.Attributes { @@ -14,6 +15,11 @@ namespace ModuleTools.Attributes /// public string DisplayName { get; set; } + /// + /// Через какой тип контрола отображать свойство + /// + public ControlType ControlType { get; set; } + /// /// Поле должно быть обязательно заполнено /// @@ -27,31 +33,80 @@ namespace ModuleTools.Attributes /// /// Ширина /// - public int? Width { get; set; } + public int? Width { get; set; } = null; /// /// Высота /// - public int? Height { get; set; } + public int? Height { get; set; } = null; + + /// + /// Максимальное длина строки + /// + public int? MaxLength { get; set; } = null; + + /// + /// Минимальное значение для числового параметра + /// + public decimal? MinValue { get; set; } = null; + + /// + /// Максимальное значение для числового параметра + /// + public decimal? MaxValue { get; set; } = null; + + /// + /// Количество знаков после запятой + /// + public int? DecimalPlaces { get; set; } = null; + + /// + /// Минимальное значение для даты + /// + public DateTime? MinDate { get; set; } = null; + + /// + /// Максимальное значение для даты + /// + public DateTime? MaxDate { get; set; } = null; + + /// + /// Пользовательский формат отображения даты + /// + public string CustomDateFormat { get; set; } = null; + + /// + /// Имя контрола (включая namespace) для вызова формы выбора элемента-объекта другого класса + /// + public string ControlTypeObject { get; set; } = string.Empty; + + /// + /// Имя свйоства, где лежит текстовое значение для ссылочного типа (опсанного через Id на другую сущность) + /// + public string PropertyNameForTitle { get; set; } /// /// Конструктор /// /// Название на форме - public ViewModelOnElementPropertyAttribute(string displayName) + /// Через какой тип контрола отображать свойство + public ViewModelOnElementPropertyAttribute(string displayName, ControlType controlType) { DisplayName = displayName; + ControlType = controlType; } /// /// Конструктор /// /// Название на форме + /// Через какой тип контрола отображать свойство /// Ширина /// Высота - public ViewModelOnElementPropertyAttribute(string displayName, int width, int height) + public ViewModelOnElementPropertyAttribute(string displayName, ControlType controlType, int width, int height) { DisplayName = displayName; + ControlType = controlType; Width = width; Height = height; } diff --git a/DepartmentPortal/Common/ModuleTools/BusinessLogics/DependencyManager.cs b/DepartmentPortal/Common/ModuleTools/BusinessLogics/DependencyManager.cs index 3fa1776..79ccc50 100644 --- a/DepartmentPortal/Common/ModuleTools/BusinessLogics/DependencyManager.cs +++ b/DepartmentPortal/Common/ModuleTools/BusinessLogics/DependencyManager.cs @@ -58,5 +58,12 @@ namespace ModuleTools.BusinessLogics /// /// public T Resolve() => _dependencyManager.Resolve(); + + /// + /// Получение класса со всеми зависмостями + /// + /// + /// + public object Resolve(Type t) => _dependencyManager.Resolve(t); } } \ No newline at end of file diff --git a/DepartmentPortal/Common/ModuleTools/BusinessLogics/UnityContainerManager.cs b/DepartmentPortal/Common/ModuleTools/BusinessLogics/UnityContainerManager.cs index faadb9f..26a3917 100644 --- a/DepartmentPortal/Common/ModuleTools/BusinessLogics/UnityContainerManager.cs +++ b/DepartmentPortal/Common/ModuleTools/BusinessLogics/UnityContainerManager.cs @@ -1,4 +1,5 @@ using ModuleTools.Interfaces; +using System; using Unity; using Unity.Lifetime; @@ -18,5 +19,7 @@ namespace ModuleTools.BusinessLogics public void RegisterType() => _unityContainer.RegisterType(new HierarchicalLifetimeManager()); public T Resolve() => _unityContainer.Resolve(); + + public object Resolve(Type t) => _unityContainer.Resolve(t); } } \ No newline at end of file diff --git a/DepartmentPortal/Common/ModuleTools/Enums/ControlType.cs b/DepartmentPortal/Common/ModuleTools/Enums/ControlType.cs new file mode 100644 index 0000000..d0e2ed5 --- /dev/null +++ b/DepartmentPortal/Common/ModuleTools/Enums/ControlType.cs @@ -0,0 +1,53 @@ +namespace ModuleTools.Enums +{ + /// + /// Тип контрола, через который следует отображать свойство с ViewModel + /// + public enum ControlType + { + /// + /// Простое однострочное текстовое поле + /// + ControlString = 0, + + /// + /// Текстовое поле в несколько строк + /// + ControlText = 1, + + /// + /// Поле для целочисленного значения + /// + ControlInt = 2, + + /// + /// Поле для вещественного значения + /// + ControlDecimal = 3, + + /// + /// Поле для bool-значения + /// + ControlBool = 4, + + /// + /// Поле для даты + /// + ControlDateTime = 5, + + /// + /// Поле для изображения + /// + ControlImage = 6, + + /// + /// Поле для пеерчисления + /// + ControlEnum = 7, + + /// + /// Поле для идентифкатора на другую сущность + /// + ControlGuid = 8 + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/ModuleTools/Interfaces/IDependencyManager.cs b/DepartmentPortal/Common/ModuleTools/Interfaces/IDependencyManager.cs index f4f09b4..165396f 100644 --- a/DepartmentPortal/Common/ModuleTools/Interfaces/IDependencyManager.cs +++ b/DepartmentPortal/Common/ModuleTools/Interfaces/IDependencyManager.cs @@ -1,4 +1,6 @@ -namespace ModuleTools.Interfaces +using System; + +namespace ModuleTools.Interfaces { /// /// Интерфейс установки зависмости между элементами @@ -25,5 +27,12 @@ /// /// T Resolve(); + + /// + /// Получение класса со всеми зависмостями + /// + /// + /// + object Resolve(Type t); } } \ No newline at end of file diff --git a/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs b/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs index 2bcd419..1614ea6 100644 --- a/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs +++ b/DepartmentPortal/DepartmentPortalDesctop/FormMain.cs @@ -9,15 +9,15 @@ namespace DepartmentPortalDesctop { public partial class FormMain : Form { - private readonly Dictionary _baseControls; + private readonly Dictionary _baseControls; - private readonly Dictionary _controls; + private readonly Dictionary _controls; public FormMain() { InitializeComponent(); - _baseControls = new Dictionary(); - _controls = new Dictionary(); + _baseControls = new Dictionary(); + _controls = new Dictionary(); var extensions = DesktopLoader.GetWindowDesktopExtensions(); foreach (var extens in extensions) @@ -28,7 +28,7 @@ namespace DepartmentPortalDesctop var menu = new ToolStripMenuItem { Text = list[0].Title }; for (int i = 0; i < list.Count; i++) { - if (list[i].Control is BaseControlViewEntityList control) + if (list[i].Control is AbstractControlViewEntityList control) { if (_baseControls.ContainsKey(list[i].Id)) { diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs index 0b7d64f..cacea99 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/BindingModels/UserBindingModels.cs @@ -22,17 +22,9 @@ namespace SecurityBusinessLogic.BindingModels public string Login { get; set; } [Required(ErrorMessage = "required")] + [MapConfiguration("Password")] public string Password { get; set; } - [MapConfiguration("StudentId")] - public Guid? StudentId { get; set; } - - [MapConfiguration("LecturerId")] - public Guid? LecturerId { get; set; } - - [MapConfiguration("EmployeeId")] - public Guid? EmployeeId { get; set; } - [MapConfiguration("Avatar")] public byte[] Avatar { get; set; } diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj b/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj index 856967c..a6fc255 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj +++ b/DepartmentPortal/Security/SecurityBusinessLogic/SecurityBusinessLogic.csproj @@ -12,4 +12,8 @@ + + + + diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs index f211e8d..002a02e 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs @@ -16,6 +16,7 @@ namespace SecurityBusinessLogic.ViewModels public class AccessViewModel : ElementViewModel { [MapConfiguration("RoleId", AllowCopyWithoutRigth = false)] + [ViewModelOnElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ControlTypeObject = "SecurityWindowsDesktop.Controls.RolesControl, SecurityWindowsDesktop")] public Guid RoleId { get; set; } [ViewModelOnListProperty("Роль", 100)] @@ -23,12 +24,14 @@ namespace SecurityBusinessLogic.ViewModels public string RoleName { get; set; } [MapConfiguration("AccessOperation", AllowCopyWithoutRigth = false)] + [ViewModelOnElementProperty("Операция", ControlType.ControlEnum, MustHaveValue = true)] public AccessOperation AccessOperation { get; set; } [ViewModelOnListProperty("Операция")] public string AccessOperationTitle => AccessOperation.ToString("G"); [MapConfiguration("AccessType", AllowCopyWithoutRigth = false)] + [ViewModelOnElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)] public AccessType AccessType { get; set; } [ViewModelOnListProperty("Тип", 150)] diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs index 0708c4f..8bef541 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs @@ -1,4 +1,5 @@ using ModuleTools.Attributes; +using ModuleTools.Enums; using ModuleTools.ViewModels; namespace SecurityBusinessLogic.ViewModels @@ -14,17 +15,17 @@ namespace SecurityBusinessLogic.ViewModels public class EnviromentSettingViewModel : ElementViewModel { [ViewModelOnListProperty("Ключ")] - [ViewModelOnElementProperty("Ключ", MustHaveValue = true, ReadOnly = true)] + [ViewModelOnElementProperty("Ключ", ControlType.ControlString, MustHaveValue = true, ReadOnly = true)] [MapConfiguration("Key", AllowCopyWithoutRigth = false)] public string Key { get; set; } [ViewModelOnListProperty("Значение")] - [ViewModelOnElementProperty("Значение", MustHaveValue = true)] + [ViewModelOnElementProperty("Значение", ControlType.ControlString, MustHaveValue = true)] [MapConfiguration("Value", AllowCopyWithoutRigth = false)] public string Value { get; set; } [ViewModelOnListProperty("Описание")] - [ViewModelOnElementProperty("Описание")] + [ViewModelOnElementProperty("Описание", ControlType.ControlText, 0, 200)] [MapConfiguration("Description", AllowCopyWithoutRigth = false)] public string Description { get; set; } diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs index 5433185..e1ee095 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs @@ -1,4 +1,5 @@ using ModuleTools.Attributes; +using ModuleTools.Enums; using ModuleTools.ViewModels; namespace SecurityBusinessLogic.ViewModels @@ -14,12 +15,12 @@ namespace SecurityBusinessLogic.ViewModels public class RoleViewModel : ElementViewModel { [ViewModelOnListProperty("Название роли")] - [ViewModelOnElementProperty("Название роли")] + [ViewModelOnElementProperty("Название роли", ControlType.ControlString, MustHaveValue = true)] [MapConfiguration("RoleName")] public string RoleName { get; set; } [ViewModelOnListProperty("Приоритет", 100)] - [ViewModelOnElementProperty("Приоритет")] + [ViewModelOnElementProperty("Приоритет", ControlType.ControlInt, MustHaveValue = true)] [MapConfiguration("RolePriority")] public int RolePriority { get; set; } diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs index 9f5480d..cc1d479 100644 --- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs +++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs @@ -1,4 +1,5 @@ using ModuleTools.Attributes; +using ModuleTools.Enums; using ModuleTools.ViewModels; using System; @@ -15,23 +16,15 @@ namespace SecurityBusinessLogic.ViewModels public class UserViewModel : ElementViewModel { [ViewModelOnListProperty("Пользователь")] - [ViewModelOnElementProperty("Логин")] + [ViewModelOnElementProperty("Логин", ControlType.ControlString, MustHaveValue = true)] [MapConfiguration("UserName")] public string Login { get; set; } [MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)] public string Password { get; set; } - [MapConfiguration("StudentId")] - public Guid? StudentId { get; set; } - - [MapConfiguration("LecturerId")] - public Guid? LecturerId { get; set; } - - [MapConfiguration("EmployeeId")] - public Guid? EmployeeId { get; set; } - [MapConfiguration("Avatar")] + [ViewModelOnElementProperty("Фото", ControlType.ControlImage, 200, 200)] public byte[] Avatar { get; set; } [ViewModelOnListProperty("Посл. визит", 100)] @@ -39,18 +32,21 @@ namespace SecurityBusinessLogic.ViewModels public DateTime? DateLastVisit { get; set; } [MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)] + [ViewModelOnElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)] public bool IsBanned { get; set; } [ViewModelOnListProperty("Блокир.", 80)] public string Banned => IsBanned ? "Да" : "Нет"; [MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)] + [ViewModelOnElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)] public DateTime? DateBanned { get; set; } [ViewModelOnListProperty("Дата Б.", 100)] public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty; [MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)] + [ViewModelOnElementProperty("Попытки входа", ControlType.ControlInt , ReadOnly = true)] public int CountAttempt { get; set; } public override string ToString() => Login; diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs index d036aef..4a0002d 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/UserService.cs @@ -132,6 +132,11 @@ namespace SecurityImplementation.SecurityDatabaseImplementation { return OperationResultModel.Error("Error:", "Элемент был удален", ResultServiceStatusCode.WasDelete); } + if(entity.IsBanned && !model.IsBanned) + { + model.DateBanned = null; + model.CountAttempt = 0; + } entity = Mapper.MapToClass(model, entity, true); context.SaveChanges(); diff --git a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/AccessesControl.cs b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/AccessesControl.cs index bd4fadd..6f29ef2 100644 --- a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/AccessesControl.cs +++ b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/AccessesControl.cs @@ -11,7 +11,7 @@ using System.Linq; namespace SecurityWindowsDesktop.Controls { - public partial class AccessesControl : GenericControlEntityList + public partial class AccessesControl : AbstractGenericControlEntityList { private readonly RoleBusinessLogic _roleBusinessLogic; @@ -25,7 +25,7 @@ namespace SecurityWindowsDesktop.Controls AccessOperation = AccessOperation.Доступы; } - public override BaseControlViewEntityList Clone() => new AccessesControl() { ControlId = Guid.NewGuid() }; + public override AbstractControlViewEntityList Clone() => new AccessesControl() { ControlId = Guid.NewGuid() }; protected override ControlViewEntityListConfiguration GetConfig() => new() { @@ -33,10 +33,20 @@ namespace SecurityWindowsDesktop.Controls PageNamesForPagination = _roleBusinessLogic.GetList(new RoleGetBindingModel())?.List?.Select(x => x.RoleName)?.ToList() }; + protected override AccessListViewModel GetData() + { + throw new NotImplementedException(); + } + protected override AccessListViewModel GetDataWithPageName(string key) { var list = _businessLogic.GetList(new AccessGetBindingModel { RoleName = key }); return list; } + + protected override AccessListViewModel GetDataWithPageNumber(int page, int count) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/EnviromentSettingControl.cs b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/EnviromentSettingControl.cs index 2b8430a..c1d239f 100644 --- a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/EnviromentSettingControl.cs +++ b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/EnviromentSettingControl.cs @@ -9,7 +9,7 @@ using System; namespace SecurityWindowsDesktop.Controls { - public partial class EnviromentSettingControl : GenericControlEntityList + public partial class EnviromentSettingControl : AbstractGenericControlEntityList { public EnviromentSettingControl() { @@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls AccessOperation = AccessOperation.НастройкиСреды; } - public override BaseControlViewEntityList Clone() => new EnviromentSettingControl() { ControlId = Guid.NewGuid() }; + public override AbstractControlViewEntityList Clone() => new EnviromentSettingControl() { ControlId = Guid.NewGuid() }; protected override ControlViewEntityListConfiguration GetConfig() => new() { @@ -32,5 +32,15 @@ namespace SecurityWindowsDesktop.Controls var list = _businessLogic.GetList(new EnviromentSettingGetBindingModel()); return list; } + + protected override EnviromentSettingListViewModel GetDataWithPageName(string key) + { + throw new NotImplementedException(); + } + + protected override EnviromentSettingListViewModel GetDataWithPageNumber(int page, int count) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/RolesControl.cs b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/RolesControl.cs index 4073835..3bcc008 100644 --- a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/RolesControl.cs +++ b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/RolesControl.cs @@ -9,7 +9,7 @@ using System; namespace SecurityWindowsDesktop.Controls { - public partial class RolesControl : GenericControlEntityList + public partial class RolesControl : AbstractGenericControlEntityList { public RolesControl() : base() { @@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls AccessOperation = AccessOperation.Роли; } - public override BaseControlViewEntityList Clone() => new RolesControl() { ControlId = Guid.NewGuid() }; + public override AbstractControlViewEntityList Clone() => new RolesControl() { ControlId = Guid.NewGuid() }; protected override ControlViewEntityListConfiguration GetConfig() => new() { @@ -32,5 +32,15 @@ namespace SecurityWindowsDesktop.Controls var list = _businessLogic.GetList(new RoleGetBindingModel()); return list; } + + protected override RoleListViewModel GetDataWithPageName(string key) + { + throw new NotImplementedException(); + } + + protected override RoleListViewModel GetDataWithPageNumber(int page, int count) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/UsersControl.cs b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/UsersControl.cs index e437dbb..1c9d009 100644 --- a/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/UsersControl.cs +++ b/DepartmentPortal/Security/SecurityWindowsDesktop/Controls/UsersControl.cs @@ -1,6 +1,5 @@ using DesktopTools.Controls; using DesktopTools.Models; -using ModuleTools.BusinessLogics; using ModuleTools.Enums; using SecurityBusinessLogic.BindingModels; using SecurityBusinessLogic.BusinessLogics; @@ -9,7 +8,7 @@ using System; namespace SecurityWindowsDesktop.Controls { - public partial class UsersControl : GenericControlEntityList + public partial class UsersControl : AbstractGenericControlEntityList { public UsersControl() : base() { @@ -20,7 +19,7 @@ namespace SecurityWindowsDesktop.Controls AccessOperation = AccessOperation.Пользователи; } - public override BaseControlViewEntityList Clone() => new UsersControl() { ControlId = Guid.NewGuid() }; + public override AbstractControlViewEntityList Clone() => new UsersControl() { ControlId = Guid.NewGuid() }; protected override ControlViewEntityListConfiguration GetConfig() => new() { @@ -28,6 +27,16 @@ namespace SecurityWindowsDesktop.Controls CountElementsOnPage = 40 }; + protected override UserListViewModel GetData() + { + throw new NotImplementedException(); + } + + protected override UserListViewModel GetDataWithPageName(string key) + { + throw new NotImplementedException(); + } + protected override UserListViewModel GetDataWithPageNumber(int page, int count) { var list = _businessLogic.GetList(new UserGetBindingModel diff --git a/DepartmentPortal/Security/SecurityWindowsDesktop/SecurityWindowDesktopExtension.cs b/DepartmentPortal/Security/SecurityWindowsDesktop/SecurityWindowDesktopExtension.cs index 18fa103..eb4f570 100644 --- a/DepartmentPortal/Security/SecurityWindowsDesktop/SecurityWindowDesktopExtension.cs +++ b/DepartmentPortal/Security/SecurityWindowsDesktop/SecurityWindowDesktopExtension.cs @@ -31,7 +31,7 @@ namespace SecurityWindowsDesktop { new WindowDesktopExtensionControlModel { Order = 0, Title = "Администрирование" } }; - List _controls = new() + List _controls = new() { new UsersControl(), new RolesControl(), @@ -53,6 +53,10 @@ namespace SecurityWindowsDesktop }); } } + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); return list; }