Merge branch 'Laba2' into Laba3

This commit is contained in:
Pipiaka 2024-12-14 20:20:44 +04:00
commit 2ccb3f1956
7 changed files with 65 additions and 21 deletions

View File

@ -4,5 +4,6 @@ public enum TypePost
{
None = 0,
Developer = 1,
Manager = 2
Manager = 2,
Director = 3
}

View File

@ -7,6 +7,8 @@ public class TypeJob
public int ProductId { get; private set; }
public int Director { get; private set; }
public string Description { get; private set; } = string.Empty;
public int AllowanceForJob { get; private set; }
@ -17,13 +19,14 @@ public class TypeJob
public IEnumerable<WorkTime> WorkTimesManager { get; private set; } = [];
public static TypeJob CreateOperation(int id, int productId, string discription, int allowanceForJob,
public static TypeJob CreateOperation(int id, int productId, int director, string discription, int allowanceForJob,
IEnumerable<WorkTime> workTimesDevelop, IEnumerable<WorkTime> workTimesManager)
{
return new TypeJob
{
Id = id,
ProductId = productId,
Director = director,
Description = discription,
AllowanceForJob = allowanceForJob,
Date = DateTime.Now,

View File

@ -46,6 +46,8 @@
ColumnHoursMan = new DataGridViewTextBoxColumn();
labelDate = new Label();
dateTimePickerDate = new DateTimePicker();
comboBoxDirector = new ComboBox();
labelDirector = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownAllowanceForJob).BeginInit();
groupBoxDevelops.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewDevelops).BeginInit();
@ -64,7 +66,7 @@
//
// textBoxDescriptoin
//
textBoxDescriptoin.Location = new Point(178, 54);
textBoxDescriptoin.Location = new Point(178, 89);
textBoxDescriptoin.Name = "textBoxDescriptoin";
textBoxDescriptoin.Size = new Size(203, 27);
textBoxDescriptoin.TabIndex = 1;
@ -80,7 +82,7 @@
//
// numericUpDownAllowanceForJob
//
numericUpDownAllowanceForJob.Location = new Point(179, 87);
numericUpDownAllowanceForJob.Location = new Point(179, 122);
numericUpDownAllowanceForJob.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
numericUpDownAllowanceForJob.Name = "numericUpDownAllowanceForJob";
numericUpDownAllowanceForJob.Size = new Size(202, 27);
@ -89,7 +91,7 @@
// labelDescriptoin
//
labelDescriptoin.AutoSize = true;
labelDescriptoin.Location = new Point(22, 57);
labelDescriptoin.Location = new Point(22, 92);
labelDescriptoin.Name = "labelDescriptoin";
labelDescriptoin.Size = new Size(138, 20);
labelDescriptoin.TabIndex = 6;
@ -98,7 +100,7 @@
// labelAllowanceForJob
//
labelAllowanceForJob.AutoSize = true;
labelAllowanceForJob.Location = new Point(22, 89);
labelAllowanceForJob.Location = new Point(22, 124);
labelAllowanceForJob.Name = "labelAllowanceForJob";
labelAllowanceForJob.Size = new Size(150, 20);
labelAllowanceForJob.TabIndex = 7;
@ -106,7 +108,7 @@
//
// buttonCansle
//
buttonCansle.Location = new Point(289, 557);
buttonCansle.Location = new Point(287, 577);
buttonCansle.Name = "buttonCansle";
buttonCansle.Size = new Size(94, 29);
buttonCansle.TabIndex = 11;
@ -116,7 +118,7 @@
//
// buttonSave
//
buttonSave.Location = new Point(179, 557);
buttonSave.Location = new Point(177, 577);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 10;
@ -128,9 +130,9 @@
//
groupBoxDevelops.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxDevelops.Controls.Add(dataGridViewDevelops);
groupBoxDevelops.Location = new Point(26, 165);
groupBoxDevelops.Location = new Point(26, 188);
groupBoxDevelops.Name = "groupBoxDevelops";
groupBoxDevelops.Size = new Size(358, 167);
groupBoxDevelops.Size = new Size(358, 183);
groupBoxDevelops.TabIndex = 12;
groupBoxDevelops.TabStop = false;
groupBoxDevelops.Text = "Разработчики";
@ -167,9 +169,9 @@
//
groupBoxManagers.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxManagers.Controls.Add(dataGridViewManagers);
groupBoxManagers.Location = new Point(26, 352);
groupBoxManagers.Location = new Point(26, 377);
groupBoxManagers.Name = "groupBoxManagers";
groupBoxManagers.Size = new Size(358, 168);
groupBoxManagers.Size = new Size(358, 182);
groupBoxManagers.TabIndex = 13;
groupBoxManagers.TabStop = false;
groupBoxManagers.Text = "Менеджеры";
@ -188,7 +190,7 @@
dataGridViewManagers.RowHeadersVisible = false;
dataGridViewManagers.RowHeadersWidth = 51;
dataGridViewManagers.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewManagers.Size = new Size(352, 142);
dataGridViewManagers.Size = new Size(352, 156);
dataGridViewManagers.TabIndex = 9;
//
// ColumnManager
@ -206,7 +208,7 @@
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(22, 125);
labelDate.Location = new Point(22, 160);
labelDate.Name = "labelDate";
labelDate.Size = new Size(44, 20);
labelDate.TabIndex = 14;
@ -215,16 +217,36 @@
// dateTimePickerDate
//
dateTimePickerDate.Enabled = false;
dateTimePickerDate.Location = new Point(178, 120);
dateTimePickerDate.Location = new Point(178, 155);
dateTimePickerDate.Name = "dateTimePickerDate";
dateTimePickerDate.Size = new Size(206, 27);
dateTimePickerDate.TabIndex = 15;
//
// comboBoxDirector
//
comboBoxDirector.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxDirector.FormattingEnabled = true;
comboBoxDirector.Location = new Point(178, 55);
comboBoxDirector.Name = "comboBoxDirector";
comboBoxDirector.Size = new Size(203, 28);
comboBoxDirector.TabIndex = 17;
//
// labelDirector
//
labelDirector.AutoSize = true;
labelDirector.Location = new Point(22, 58);
labelDirector.Name = "labelDirector";
labelDirector.Size = new Size(76, 20);
labelDirector.TabIndex = 16;
labelDirector.Text = "Директор";
//
// FormTypeJob
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(391, 598);
ClientSize = new Size(391, 717);
Controls.Add(comboBoxDirector);
Controls.Add(labelDirector);
Controls.Add(dateTimePickerDate);
Controls.Add(labelDate);
Controls.Add(groupBoxManagers);
@ -269,5 +291,7 @@
private DataGridViewTextBoxColumn ColumnHoursDev;
private DataGridViewComboBoxColumn ColumnManager;
private DataGridViewTextBoxColumn ColumnHoursMan;
private ComboBox comboBoxDirector;
private Label labelDirector;
}
}

View File

@ -19,6 +19,10 @@ namespace Accounting_Time_It_Company.Forms
comboBoxProduct.DisplayMember = "Name";
comboBoxProduct.ValueMember = "Id";
comboBoxDirector.DataSource = employeeRepositories.ReadEmployees().Where(x => x.PostId == (int)TypePost.Director).ToList();
comboBoxDirector.DisplayMember = "Name";
comboBoxDirector.ValueMember = "Id";
ColumnDevelop.DataSource = employeeRepositories.ReadEmployees().Where(x => x.PostId == (int)TypePost.Developer).ToList();
ColumnDevelop.DisplayMember = "Name";
ColumnDevelop.ValueMember = "Id";
@ -38,7 +42,7 @@ namespace Accounting_Time_It_Company.Forms
throw new Exception("Имеются незаполненные поля");
}
_typeJobRepositories.CreateTypeJob(TypeJob.CreateOperation(0, (int)comboBoxProduct.SelectedValue!, textBoxDescriptoin.Text,
_typeJobRepositories.CreateTypeJob(TypeJob.CreateOperation(0, (int)comboBoxProduct.SelectedValue!, (int)comboBoxDirector.SelectedValue!, textBoxDescriptoin.Text,
(int)numericUpDownAllowanceForJob.Value, CreateListWorkTimeFromDataGrid(dataGridViewDevelops),
CreateListWorkTimeFromDataGrid(dataGridViewManagers)));

View File

@ -123,6 +123,18 @@
<metadata name="ColumnHoursDev.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnDevelop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnHoursDev.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnManager.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnHoursMan.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnManager.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View File

@ -4,7 +4,7 @@ namespace Accounting_Time_It_Company.Repositories;
public interface ITypeJobRepositories
{
IEnumerable<TypeJob> ReadTypeJobs(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null);
IEnumerable<TypeJob> ReadTypeJobs(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null, int? directorId = null);
void CreateTypeJob(TypeJob typeJob);

View File

@ -30,7 +30,7 @@ public class TypeJobRepositories : ITypeJobRepositories
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO TypeJob
VALUES (DEFAULT, @ProductId, @Description, @AllowanceForJob, @Date);
VALUES (DEFAULT, @ProductId, @Director, @Description, @AllowanceForJob, @Date);
SELECT MAX(Id) FROM TypeJob";
var typeJobId = connection.QueryFirst<int>(queryInsert, typeJob, transaction);
var querySubInsert = @"
@ -85,7 +85,7 @@ public class TypeJobRepositories : ITypeJobRepositories
}
}
public IEnumerable<TypeJob> ReadTypeJobs(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null)
public IEnumerable<TypeJob> ReadTypeJobs(DateTime? dateFrom = null, DateTime? dateTo = null, int? productId = null, int? directorId = null)
{
_logger.LogInformation("Получение всех объектов");
try
@ -95,7 +95,7 @@ public class TypeJobRepositories : ITypeJobRepositories
var querySelect = @"SELECT * FROM TypeJob";
var typeJobs = connection.Query<TypeJob>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(typeJobs));
JsonConvert.SerializeObject(typeJobs));
return typeJobs;
}
catch (Exception ex)