This commit is contained in:
mar-va 2024-12-16 23:22:23 +04:00
parent 5e47cf258b
commit f18602b2c8
25 changed files with 206 additions and 153 deletions

View File

@ -11,22 +11,21 @@ public class Contract
{ {
public int Id { get; private set; } public int Id { get; private set; }
public DateTime Date { get; private set; } public DateTime Date { get; private set; }
public decimal CustomerId { get; private set; } public decimal ProjectId { get; private set; }
public TypeProjects TypeProject { get; private set; } public IEnumerable<CustomerOnProject> CustomerId
public IEnumerable<ContractOnProject> ContractOnProject
{ {
get; get;
private set; private set;
} = []; } = [];
public static Contract CreateOpeartion(int id, DateTime date, decimal customerid, TypeProjects typeProject, IEnumerable<ContractOnProject> contractOnProjects)
public static Contract CreateOpeartion(int id, DateTime date, decimal projectid, IEnumerable<CustomerOnProject> customerOnContract)
{ {
return new Contract return new Contract
{ {
Id = id, Id = id,
Date = date, Date = date,
CustomerId = customerid, ProjectId = projectid,
TypeProject = typeProject, CustomerId = customerOnContract
ContractOnProject = contractOnProjects
}; };
} }
} }

View File

@ -1,24 +0,0 @@
using ProjectItCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectItCompany.Entities;
public class ContractOnProject
{
public int ProjectId { get; private set; }
public int ContractId { get; private set; }
public string Description { get; private set; } = string.Empty;
public static ContractOnProject CreateElement(int projectId, int contractId, string description)
{
return new ContractOnProject
{
ProjectId = projectId,
ContractId = contractId,
Description = description
};
}
}

View File

@ -0,0 +1,26 @@
using ProjectItCompany.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectItCompany.Entities;
public class CustomerOnProject
{
public int Id { get; private set; }
public decimal ContractId { get; private set; }
public decimal CustomerId { get; private set; }
public string Description { get; private set; } = string.Empty;
public static CustomerOnProject CreateElement(int id, decimal contractId, decimal customerid, string description)
{
return new CustomerOnProject
{
Id = id,
ContractId = contractId,
CustomerId = customerid,
Description = description
};
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectItCompany.Entities.Enums;
public enum Month
{
January = 0,
February = 1,
March = 2,
April = 3,
May = 4,
June = 5,
July = 6,
August = 7,
September = 8,
October = 9,
November = 10,
December = 11
}

View File

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectItCompany.Entities.Enums;
public enum TypeProjects
{
None = 0,
Creation = 1,
Maintenance = 2
}

View File

@ -1,4 +1,5 @@
using System; using ProjectItCompany.Entities.Enums;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -12,15 +13,17 @@ public class Executor
public string FullName { get; private set; } = string.Empty; public string FullName { get; private set; } = string.Empty;
public DateTime DateOfBirth { get; private set; } public DateTime DateOfBirth { get; private set; }
public decimal HourlyRate { get; private set; } public decimal HourlyRate { get; private set; }
public JobTitles JobTitles { get; private set; }
public static Executor CreateEntity(int id, string fullName, DateTime dateOfBirth, decimal hourlyRate) public static Executor CreateEntity(int id, string fullName, DateTime dateOfBirth, decimal hourlyRate, JobTitles jobTitles)
{ {
return new Executor return new Executor
{ {
Id = id, Id = id,
FullName = fullName ?? string.Empty, FullName = fullName ?? string.Empty,
DateOfBirth = dateOfBirth, DateOfBirth = dateOfBirth,
HourlyRate = hourlyRate HourlyRate = hourlyRate,
JobTitles = jobTitles
}; };
} }
} }

View File

@ -11,15 +11,16 @@ public class Project
{ {
public int Id { get; private set; } public int Id { get; private set; }
public string NameProject { get; private set; } = string.Empty; public string NameProject { get; private set; } = string.Empty;
public decimal CustomerId { get; private set; }
public CompletedStages CompletedStages { get; private set; } public CompletedStages CompletedStages { get; private set; }
public static Project CreateEntity(int id, string nameProject, decimal customerid, CompletedStages completedStages)
public static Project CreateEntity(int id, string nameProject, CompletedStages completedStages)
{ {
return new Project return new Project
{ {
Id = id, Id = id,
NameProject = nameProject ?? string.Empty, NameProject = nameProject ?? string.Empty,
CustomerId = customerid,
CompletedStages = completedStages CompletedStages = completedStages
}; };
} }

View File

@ -1,4 +1,5 @@
using System; using ProjectItCompany.Entities.Enums;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -9,16 +10,16 @@ namespace ProjectItCompany.Entities;
public class Wage public class Wage
{ {
public int Id { get; private set; } public int Id { get; private set; }
public string Month { get; private set; } = string.Empty; public Month Month { get; private set; }
public int Year { get; private set; } public int Year { get; private set; }
public int NumberOfHours { get; private set; } public int NumberOfHours { get; private set; }
public int ExecutorID { get; private set; } public int ExecutorID { get; private set; }
public static Wage CreateOpeartion(int id, string month, int year, int numberOfHours, int executorId) public static Wage CreateOpeartion(int id, Month month, int year, int numberOfHours, int executorId)
{ {
return new Wage return new Wage
{ {
Id = id, Id = id,
Month = month ?? string.Empty, Month = month,
Year = year, Year = year,
NumberOfHours = numberOfHours, NumberOfHours = numberOfHours,
ExecutorID = executorId ExecutorID = executorId

View File

@ -1,6 +1,6 @@
namespace ProjectItCompany.Forms namespace ProjectItCompany.Forms
{ {
partial class FormContractOnProject partial class FormContract
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -28,30 +28,19 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
labelCustomer = new Label();
ButtonSave = new Button(); ButtonSave = new Button();
ButtonCancel = new Button(); ButtonCancel = new Button();
groupBox1 = new GroupBox(); groupBoxContract = new GroupBox();
dataGridViewContract = new DataGridView(); dataGridViewContract = new DataGridView();
comboBoxCustomer = new ComboBox();
ColumnProject = new DataGridViewComboBoxColumn(); ColumnProject = new DataGridViewComboBoxColumn();
ColumnContract = new DataGridViewComboBoxColumn(); ColumnCustomer = new DataGridViewComboBoxColumn();
groupBox1.SuspendLayout(); groupBoxContract.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewContract).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewContract).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// labelCustomer
//
labelCustomer.AutoSize = true;
labelCustomer.Location = new Point(15, 16);
labelCustomer.Name = "labelCustomer";
labelCustomer.Size = new Size(57, 15);
labelCustomer.TabIndex = 2;
labelCustomer.Text = "Заказчик";
//
// ButtonSave // ButtonSave
// //
ButtonSave.Location = new Point(39, 265); ButtonSave.Location = new Point(68, 254);
ButtonSave.Name = "ButtonSave"; ButtonSave.Name = "ButtonSave";
ButtonSave.Size = new Size(75, 23); ButtonSave.Size = new Size(75, 23);
ButtonSave.TabIndex = 11; ButtonSave.TabIndex = 11;
@ -61,7 +50,7 @@
// //
// ButtonCancel // ButtonCancel
// //
ButtonCancel.Location = new Point(161, 265); ButtonCancel.Location = new Point(245, 255);
ButtonCancel.Name = "ButtonCancel"; ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(75, 23); ButtonCancel.Size = new Size(75, 23);
ButtonCancel.TabIndex = 12; ButtonCancel.TabIndex = 12;
@ -69,16 +58,15 @@
ButtonCancel.UseVisualStyleBackColor = true; ButtonCancel.UseVisualStyleBackColor = true;
ButtonCancel.Click += ButtonCancel_Click; ButtonCancel.Click += ButtonCancel_Click;
// //
// groupBox1 // groupBoxContract
// //
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; groupBoxContract.Controls.Add(dataGridViewContract);
groupBox1.Controls.Add(dataGridViewContract); groupBoxContract.Location = new Point(12, 12);
groupBox1.Location = new Point(12, 37); groupBoxContract.Name = "groupBoxContract";
groupBox1.Name = "groupBox1"; groupBoxContract.Size = new Size(375, 237);
groupBox1.Size = new Size(267, 222); groupBoxContract.TabIndex = 13;
groupBox1.TabIndex = 13; groupBoxContract.TabStop = false;
groupBox1.TabStop = false; groupBoxContract.Text = "Договоры";
groupBox1.Text = "Договоры";
// //
// dataGridViewContract // dataGridViewContract
// //
@ -86,66 +74,53 @@
dataGridViewContract.AllowUserToResizeRows = false; dataGridViewContract.AllowUserToResizeRows = false;
dataGridViewContract.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridViewContract.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewContract.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridViewContract.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewContract.Columns.AddRange(new DataGridViewColumn[] { ColumnProject, ColumnContract }); dataGridViewContract.Columns.AddRange(new DataGridViewColumn[] { ColumnProject, ColumnCustomer });
dataGridViewContract.Dock = DockStyle.Fill; dataGridViewContract.Dock = DockStyle.Right;
dataGridViewContract.Location = new Point(3, 19); dataGridViewContract.Location = new Point(3, 19);
dataGridViewContract.MultiSelect = false; dataGridViewContract.MultiSelect = false;
dataGridViewContract.Name = "dataGridViewContract"; dataGridViewContract.Name = "dataGridViewContract";
dataGridViewContract.RowHeadersVisible = false; dataGridViewContract.RowHeadersVisible = false;
dataGridViewContract.RowTemplate.Height = 25; dataGridViewContract.RowTemplate.Height = 25;
dataGridViewContract.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewContract.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewContract.Size = new Size(261, 200); dataGridViewContract.Size = new Size(369, 215);
dataGridViewContract.TabIndex = 0; dataGridViewContract.TabIndex = 0;
// //
// comboBoxCustomer
//
comboBoxCustomer.FormattingEnabled = true;
comboBoxCustomer.Location = new Point(78, 8);
comboBoxCustomer.Name = "comboBoxCustomer";
comboBoxCustomer.Size = new Size(194, 23);
comboBoxCustomer.TabIndex = 14;
//
// ColumnProject // ColumnProject
// //
ColumnProject.HeaderText = "Проект"; ColumnProject.HeaderText = "Проект";
ColumnProject.Name = "ColumnProject"; ColumnProject.Name = "ColumnProject";
// //
// ColumnContract // ColumnCustomer
// //
ColumnContract.HeaderText = "Контракт"; ColumnCustomer.HeaderText = "Заказчик";
ColumnContract.Name = "ColumnContract"; ColumnCustomer.Name = "ColumnCustomer";
// //
// FormContractOnProject // FormContract
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(291, 300); ClientSize = new Size(399, 286);
Controls.Add(comboBoxCustomer); Controls.Add(groupBoxContract);
Controls.Add(groupBox1);
Controls.Add(ButtonCancel); Controls.Add(ButtonCancel);
Controls.Add(ButtonSave); Controls.Add(ButtonSave);
Controls.Add(labelCustomer); Name = "FormContract";
Name = "FormContractOnProject";
StartPosition = FormStartPosition.CenterParent; StartPosition = FormStartPosition.CenterParent;
Text = "Заключение договора"; Text = "Заключение договора";
groupBox1.ResumeLayout(false); groupBoxContract.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewContract).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridViewContract).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
private Label labelDate; private Label labelDate;
private Label labelCustomer;
private DateTimePicker dateTimePickerDate; private DateTimePicker dateTimePickerDate;
private ComboBox comboBoxTypeProject; private ComboBox comboBoxTypeProject;
private Button ButtonSave; private Button ButtonSave;
private Button ButtonCancel; private Button ButtonCancel;
private GroupBox groupBox1; private GroupBox groupBoxContract;
private DataGridView dataGridViewContract; private DataGridView dataGridViewContract;
private ComboBox comboBoxCustomer;
private DataGridViewComboBoxColumn ColumnProject; private DataGridViewComboBoxColumn ColumnProject;
private DataGridViewComboBoxColumn ColumnContract; private DataGridViewComboBoxColumn ColumnCustomer;
} }
} }

View File

@ -1,4 +1,5 @@
using ProjectItCompany.Entities; using ProjectItCompany.Entities;
using ProjectItCompany.Entities.Enums;
using ProjectItCompany.Repositories; using ProjectItCompany.Repositories;
using ProjectItCompany.Repositories.Implementations; using ProjectItCompany.Repositories.Implementations;
using System; using System;
@ -13,35 +14,34 @@ using System.Windows.Forms;
namespace ProjectItCompany.Forms namespace ProjectItCompany.Forms
{ {
public partial class FormContractOnProject : Form public partial class FormContract : Form
{ {
private readonly IContractRepository _contractRepository; private readonly IContractRepository _contractRepository;
public FormContractOnProject(IContractRepository contractRepository, public FormContract(IContractRepository contractRepository,
IProjectRepository projectRepository, ICustomerRepository customerRepository) IProjectRepository projectRepository, ICustomerRepository customerRepository)
{ {
InitializeComponent(); InitializeComponent();
_contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository)); _contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository));
comboBoxCustomer.DataSource = customerRepository.ReadCustomers();
ColumnProject.DataSource = projectRepository.ReadProjects(); ColumnProject.DataSource = projectRepository.ReadProjects();
ColumnProject.DisplayMember = "NameProject"; ColumnProject.DisplayMember = "NameProject";
ColumnProject.ValueMember = "Id"; ColumnProject.ValueMember = "Id";
ColumnContract.DataSource = contractRepository.ReadContract(); ColumnCustomer.DataSource = customerRepository.ReadCustomers();
ColumnContract.ValueMember = "Id"; ColumnCustomer.DisplayMember = "NameCustomer";
ColumnCustomer.ValueMember = "Id";
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
{ {
try try
{ {
if (comboBoxCustomer.SelectedIndex < 0 || dataGridViewContract.RowCount < 1) if (dataGridViewContract.RowCount < 1)
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
_contractRepository.CreateContract(Contract.CreateOpeartion(0, DateTime.Today, 0, Entities.Enums.TypeProjects.Maintenance, CreateListExecutorOnProject())); _contractRepository.CreateContract(Contract.CreateOpeartion(0, DateTime.Now, 0, CreateListExecutorOnProject()));
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)
@ -53,9 +53,9 @@ namespace ProjectItCompany.Forms
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private List<ContractOnProject> CreateListExecutorOnProject() private List<Entities.CustomerOnProject> CreateListExecutorOnProject()
{ {
var list = new List<ContractOnProject>(); var list = new List<Entities.CustomerOnProject>();
foreach (DataGridViewRow row in dataGridViewContract.Rows) foreach (DataGridViewRow row in dataGridViewContract.Rows)
{ {
if (row.Cells["ColumnProject"].Value == null || if (row.Cells["ColumnProject"].Value == null ||
@ -63,9 +63,8 @@ namespace ProjectItCompany.Forms
{ {
continue; continue;
} }
list.Add(ContractOnProject.CreateElement( list.Add(Entities.CustomerOnProject.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnProject"].Value), Convert.ToInt32(row.Cells["ColumnProject"].Value), Convert.ToInt32(row.Cells["ColumnCustomer"].Value), string.Empty));
Convert.ToInt32(row.Cells["ColumnContract"].Value), string.Empty));
} }
return list; return list;
} }

View File

@ -27,13 +27,12 @@ namespace ProjectItCompany.Forms
{ {
try try
{ {
_container.Resolve<FormContractOnProject>().ShowDialog(); _container.Resolve<FormContract>().ShowDialog();
LoadList(); LoadList();
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }

View File

@ -36,6 +36,8 @@
numericUpDownHourlyRate = new NumericUpDown(); numericUpDownHourlyRate = new NumericUpDown();
ButtonSave = new Button(); ButtonSave = new Button();
ButtonCancel = new Button(); ButtonCancel = new Button();
labelJobTitle = new Label();
comboBoxJobTitle = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownHourlyRate).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownHourlyRate).BeginInit();
SuspendLayout(); SuspendLayout();
// //
@ -89,7 +91,7 @@
// //
// ButtonSave // ButtonSave
// //
ButtonSave.Location = new Point(68, 128); ButtonSave.Location = new Point(68, 160);
ButtonSave.Name = "ButtonSave"; ButtonSave.Name = "ButtonSave";
ButtonSave.Size = new Size(75, 23); ButtonSave.Size = new Size(75, 23);
ButtonSave.TabIndex = 6; ButtonSave.TabIndex = 6;
@ -99,7 +101,7 @@
// //
// ButtonCancel // ButtonCancel
// //
ButtonCancel.Location = new Point(165, 128); ButtonCancel.Location = new Point(165, 160);
ButtonCancel.Name = "ButtonCancel"; ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(75, 23); ButtonCancel.Size = new Size(75, 23);
ButtonCancel.TabIndex = 7; ButtonCancel.TabIndex = 7;
@ -107,11 +109,30 @@
ButtonCancel.UseVisualStyleBackColor = true; ButtonCancel.UseVisualStyleBackColor = true;
ButtonCancel.Click += ButtonCancel_Click; ButtonCancel.Click += ButtonCancel_Click;
// //
// labelJobTitle
//
labelJobTitle.AutoSize = true;
labelJobTitle.Location = new Point(21, 120);
labelJobTitle.Name = "labelJobTitle";
labelJobTitle.Size = new Size(69, 15);
labelJobTitle.TabIndex = 8;
labelJobTitle.Text = "Должность";
//
// comboBoxJobTitle
//
comboBoxJobTitle.FormattingEnabled = true;
comboBoxJobTitle.Location = new Point(136, 116);
comboBoxJobTitle.Name = "comboBoxJobTitle";
comboBoxJobTitle.Size = new Size(151, 23);
comboBoxJobTitle.TabIndex = 9;
//
// FormExecutor // FormExecutor
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(319, 173); ClientSize = new Size(319, 217);
Controls.Add(comboBoxJobTitle);
Controls.Add(labelJobTitle);
Controls.Add(ButtonCancel); Controls.Add(ButtonCancel);
Controls.Add(ButtonSave); Controls.Add(ButtonSave);
Controls.Add(numericUpDownHourlyRate); Controls.Add(numericUpDownHourlyRate);
@ -138,5 +159,7 @@
private NumericUpDown numericUpDownHourlyRate; private NumericUpDown numericUpDownHourlyRate;
private Button ButtonSave; private Button ButtonSave;
private Button ButtonCancel; private Button ButtonCancel;
private Label labelJobTitle;
private ComboBox comboBoxJobTitle;
} }
} }

View File

@ -1,4 +1,5 @@
using ProjectItCompany.Entities; using ProjectItCompany.Entities;
using ProjectItCompany.Entities.Enums;
using ProjectItCompany.Repositories; using ProjectItCompany.Repositories;
using ProjectItCompany.Repositories.Implementations; using ProjectItCompany.Repositories.Implementations;
using System; using System;
@ -32,6 +33,7 @@ namespace ProjectItCompany.Forms
textBoxFullName.Text = executor.FullName; textBoxFullName.Text = executor.FullName;
dateTimePickerDateOfBirth.Value = executor.DateOfBirth; dateTimePickerDateOfBirth.Value = executor.DateOfBirth;
numericUpDownHourlyRate.Value = executor.HourlyRate; numericUpDownHourlyRate.Value = executor.HourlyRate;
comboBoxJobTitle.SelectedItem = executor.JobTitles;
_executorId = value; _executorId = value;
} }
catch (Exception ex) catch (Exception ex)
@ -45,6 +47,9 @@ namespace ProjectItCompany.Forms
{ {
InitializeComponent(); InitializeComponent();
_executorRepository = executorRepository ?? throw new ArgumentNullException(nameof(executorRepository)); _executorRepository = executorRepository ?? throw new ArgumentNullException(nameof(executorRepository));
comboBoxJobTitle.DataSource = Enum.GetValues(typeof(JobTitles));
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
@ -75,6 +80,6 @@ namespace ProjectItCompany.Forms
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Executor CreateExecutor(int id) => Executor.CreateEntity(id, textBoxFullName.Text, dateTimePickerDateOfBirth.Value, numericUpDownHourlyRate.Value); private Executor CreateExecutor(int id) => Executor.CreateEntity(id, textBoxFullName.Text, dateTimePickerDateOfBirth.Value, numericUpDownHourlyRate.Value, Entities.Enums.JobTitles.Analyst);
} }
} }

View File

@ -62,7 +62,7 @@ namespace ProjectItCompany.Forms
} }
try try
{ {
var form = _container.Resolve<FormCustomer>(); var form = _container.Resolve<FormExecutor>();
form.Id = findId; form.Id = findId;
form.ShowDialog(); form.ShowDialog();
LoadList(); LoadList();

View File

@ -34,6 +34,8 @@
ButtonSave = new Button(); ButtonSave = new Button();
ButtonCancel = new Button(); ButtonCancel = new Button();
checkedListBoxCompletedStage = new CheckedListBox(); checkedListBoxCompletedStage = new CheckedListBox();
labelCustomer = new Label();
comboBoxCustomer = new ComboBox();
SuspendLayout(); SuspendLayout();
// //
// labelNameProject // labelNameProject
@ -48,7 +50,7 @@
// labelCompletedStages // labelCompletedStages
// //
labelCompletedStages.AutoSize = true; labelCompletedStages.AutoSize = true;
labelCompletedStages.Location = new Point(12, 39); labelCompletedStages.Location = new Point(12, 72);
labelCompletedStages.Name = "labelCompletedStages"; labelCompletedStages.Name = "labelCompletedStages";
labelCompletedStages.Size = new Size(121, 15); labelCompletedStages.Size = new Size(121, 15);
labelCompletedStages.TabIndex = 2; labelCompletedStages.TabIndex = 2;
@ -63,7 +65,7 @@
// //
// ButtonSave // ButtonSave
// //
ButtonSave.Location = new Point(53, 126); ButtonSave.Location = new Point(43, 185);
ButtonSave.Name = "ButtonSave"; ButtonSave.Name = "ButtonSave";
ButtonSave.Size = new Size(75, 23); ButtonSave.Size = new Size(75, 23);
ButtonSave.TabIndex = 10; ButtonSave.TabIndex = 10;
@ -73,7 +75,7 @@
// //
// ButtonCancel // ButtonCancel
// //
ButtonCancel.Location = new Point(164, 124); ButtonCancel.Location = new Point(154, 184);
ButtonCancel.Name = "ButtonCancel"; ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(75, 23); ButtonCancel.Size = new Size(75, 23);
ButtonCancel.TabIndex = 11; ButtonCancel.TabIndex = 11;
@ -84,16 +86,35 @@
// checkedListBoxCompletedStage // checkedListBoxCompletedStage
// //
checkedListBoxCompletedStage.FormattingEnabled = true; checkedListBoxCompletedStage.FormattingEnabled = true;
checkedListBoxCompletedStage.Location = new Point(154, 35); checkedListBoxCompletedStage.Location = new Point(154, 74);
checkedListBoxCompletedStage.Name = "checkedListBoxCompletedStage"; checkedListBoxCompletedStage.Name = "checkedListBoxCompletedStage";
checkedListBoxCompletedStage.Size = new Size(150, 76); checkedListBoxCompletedStage.Size = new Size(150, 94);
checkedListBoxCompletedStage.TabIndex = 12; checkedListBoxCompletedStage.TabIndex = 12;
// //
// labelCustomer
//
labelCustomer.AutoSize = true;
labelCustomer.Location = new Point(12, 40);
labelCustomer.Name = "labelCustomer";
labelCustomer.Size = new Size(57, 15);
labelCustomer.TabIndex = 13;
labelCustomer.Text = "Заказчик";
//
// comboBoxCustomer
//
comboBoxCustomer.FormattingEnabled = true;
comboBoxCustomer.Location = new Point(154, 39);
comboBoxCustomer.Name = "comboBoxCustomer";
comboBoxCustomer.Size = new Size(150, 23);
comboBoxCustomer.TabIndex = 14;
//
// FormProject // FormProject
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(315, 157); ClientSize = new Size(315, 217);
Controls.Add(comboBoxCustomer);
Controls.Add(labelCustomer);
Controls.Add(checkedListBoxCompletedStage); Controls.Add(checkedListBoxCompletedStage);
Controls.Add(ButtonCancel); Controls.Add(ButtonCancel);
Controls.Add(ButtonSave); Controls.Add(ButtonSave);
@ -115,5 +136,7 @@
private Button ButtonSave; private Button ButtonSave;
private Button ButtonCancel; private Button ButtonCancel;
private CheckedListBox checkedListBoxCompletedStage; private CheckedListBox checkedListBoxCompletedStage;
private Label labelCustomer;
private ComboBox comboBoxCustomer;
} }
} }

View File

@ -39,7 +39,6 @@ namespace ProjectItCompany.Forms
} }
} }
textBoxNameProject.Text = project.NameProject; textBoxNameProject.Text = project.NameProject;
_projectId = value; _projectId = value;
} }
@ -88,6 +87,6 @@ namespace ProjectItCompany.Forms
private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Project CreateProject(int id) => Project.CreateEntity(id, textBoxNameProject.Text, (CompletedStages)checkedListBoxCompletedStage.SelectedItem!); private Project CreateProject(int id) => Project.CreateEntity(id, textBoxNameProject.Text, (int)comboBoxCustomer.SelectedValue, (CompletedStages)checkedListBoxCompletedStage.SelectedItem!);
} }
} }

View File

@ -32,12 +32,12 @@
labelYear = new Label(); labelYear = new Label();
labelNumberOfHours = new Label(); labelNumberOfHours = new Label();
labelExecutor = new Label(); labelExecutor = new Label();
textBoxMonth = new TextBox();
numericUpDownYear = new NumericUpDown(); numericUpDownYear = new NumericUpDown();
numericUpDownNumberOfHours = new NumericUpDown(); numericUpDownNumberOfHours = new NumericUpDown();
ButtonSave = new Button(); ButtonSave = new Button();
ButtonCancel = new Button(); ButtonCancel = new Button();
comboBoxExecutor = new ComboBox(); comboBoxExecutor = new ComboBox();
comboBoxMonth = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownYear).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownYear).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownNumberOfHours).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownNumberOfHours).BeginInit();
SuspendLayout(); SuspendLayout();
@ -78,13 +78,6 @@
labelExecutor.TabIndex = 3; labelExecutor.TabIndex = 3;
labelExecutor.Text = "Исполнитель"; labelExecutor.Text = "Исполнитель";
// //
// textBoxMonth
//
textBoxMonth.Location = new Point(130, 5);
textBoxMonth.Name = "textBoxMonth";
textBoxMonth.Size = new Size(120, 23);
textBoxMonth.TabIndex = 4;
//
// numericUpDownYear // numericUpDownYear
// //
numericUpDownYear.Location = new Point(130, 32); numericUpDownYear.Location = new Point(130, 32);
@ -127,17 +120,25 @@
comboBoxExecutor.Size = new Size(121, 23); comboBoxExecutor.Size = new Size(121, 23);
comboBoxExecutor.TabIndex = 10; comboBoxExecutor.TabIndex = 10;
// //
// comboBoxMonth
//
comboBoxMonth.FormattingEnabled = true;
comboBoxMonth.Location = new Point(129, 4);
comboBoxMonth.Name = "comboBoxMonth";
comboBoxMonth.Size = new Size(121, 23);
comboBoxMonth.TabIndex = 11;
//
// FormWage // FormWage
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(267, 161); ClientSize = new Size(267, 161);
Controls.Add(comboBoxMonth);
Controls.Add(comboBoxExecutor); Controls.Add(comboBoxExecutor);
Controls.Add(ButtonCancel); Controls.Add(ButtonCancel);
Controls.Add(ButtonSave); Controls.Add(ButtonSave);
Controls.Add(numericUpDownNumberOfHours); Controls.Add(numericUpDownNumberOfHours);
Controls.Add(numericUpDownYear); Controls.Add(numericUpDownYear);
Controls.Add(textBoxMonth);
Controls.Add(labelExecutor); Controls.Add(labelExecutor);
Controls.Add(labelNumberOfHours); Controls.Add(labelNumberOfHours);
Controls.Add(labelYear); Controls.Add(labelYear);
@ -157,11 +158,11 @@
private Label labelYear; private Label labelYear;
private Label labelNumberOfHours; private Label labelNumberOfHours;
private Label labelExecutor; private Label labelExecutor;
private TextBox textBoxMonth;
private NumericUpDown numericUpDownYear; private NumericUpDown numericUpDownYear;
private NumericUpDown numericUpDownNumberOfHours; private NumericUpDown numericUpDownNumberOfHours;
private Button ButtonSave; private Button ButtonSave;
private Button ButtonCancel; private Button ButtonCancel;
private ComboBox comboBoxExecutor; private ComboBox comboBoxExecutor;
private ComboBox comboBoxMonth;
} }
} }

View File

@ -1,10 +1,12 @@
using ProjectItCompany.Entities; using ProjectItCompany.Entities;
using ProjectItCompany.Entities.Enums;
using ProjectItCompany.Repositories; using ProjectItCompany.Repositories;
using ProjectItCompany.Repositories.Implementations; using ProjectItCompany.Repositories.Implementations;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Diagnostics.Tracing;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -17,12 +19,16 @@ namespace ProjectItCompany.Forms
{ {
private readonly IWageRepository _wageRepository; private readonly IWageRepository _wageRepository;
public FormWage(IWageRepository wageRepository, IExecutorRepository executorRepository)
public FormWage(IWageRepository wageRepository)
{ {
InitializeComponent(); InitializeComponent();
_wageRepository = wageRepository ?? throw new ArgumentNullException(nameof(wageRepository)); _wageRepository = wageRepository ?? throw new ArgumentNullException(nameof(wageRepository));
comboBoxExecutor.DataSource = executorRepository.ReadExecutors();
comboBoxExecutor.DisplayMember = "FullName";
comboBoxExecutor.ValueMember = "Id";
comboBoxMonth.DataSource = Enum.GetValues(typeof(Month));
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
@ -33,7 +39,7 @@ namespace ProjectItCompany.Forms
{ {
throw new Exception("Имеются незаполненные поля"); throw new Exception("Имеются незаполненные поля");
} }
_wageRepository.CreateWage(Wage.CreateOpeartion(0, string.Empty, 2022, 180, 1)); _wageRepository.CreateWage(Wage.CreateOpeartion(0, (Month)comboBoxMonth.SelectedValue!, Convert.ToInt32(numericUpDownYear.Value), Convert.ToInt32(numericUpDownNumberOfHours.Value), (int)comboBoxExecutor.SelectedValue));
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)

View File

@ -11,4 +11,6 @@ public interface IContractRepository
{ {
IEnumerable<Contract> ReadContract(DateTime? dateForm = null, DateTime? dateTo = null, decimal? typeProject = null, int? customerId = null); IEnumerable<Contract> ReadContract(DateTime? dateForm = null, DateTime? dateTo = null, decimal? typeProject = null, int? customerId = null);
void CreateContract(Contract contract); void CreateContract(Contract contract);
void DeleteContract(int id);
} }

View File

@ -9,6 +9,7 @@ namespace ProjectItCompany.Repositories;
public interface IWageRepository public interface IWageRepository
{ {
IEnumerable<Wage> ReadWage(int? yearForm = null, int? yearTo = null, int? numberOfHoursFrom = null, int? numberOfHoursTo = null, int? executorId = null); IEnumerable<Wage> ReadWage(int? yearForm = null, int? yearTo = null,
int? numberOfHoursFrom = null, int? numberOfHoursTo = null, int? executorId = null);
void CreateWage(Wage wages); void CreateWage(Wage wages);
} }

View File

@ -14,6 +14,11 @@ internal class ContractRepository : IContractRepository
} }
public void DeleteContract(int id)
{
}
public IEnumerable<Contract> ReadContract(DateTime? dateForm = null, DateTime? dateTo = null, decimal? typeProject = null, int? customerId = null) public IEnumerable<Contract> ReadContract(DateTime? dateForm = null, DateTime? dateTo = null, decimal? typeProject = null, int? customerId = null)
{ {
return []; return [];

View File

@ -21,7 +21,7 @@ internal class ExecutorRepository : IExecutorRepository
public Executor ReadExecutorById(int id) public Executor ReadExecutorById(int id)
{ {
return Executor.CreateEntity(0, string.Empty, DateTime.Today, 1000); return Executor.CreateEntity(0, string.Empty, DateTime.Today, 1000, Entities.Enums.JobTitles.Developer);
} }
public IEnumerable<Executor> ReadExecutors() public IEnumerable<Executor> ReadExecutors()

View File

@ -21,7 +21,7 @@ internal class ProjectRepository : IProjectRepository
public Project ReadProjectById(int id) public Project ReadProjectById(int id)
{ {
return Project.CreateEntity(1, string.Empty, Entities.Enums.CompletedStages.Planning); return Project.CreateEntity(1, string.Empty, 0, Entities.Enums.CompletedStages.Planning);
} }
public IEnumerable<Project> ReadProjects() public IEnumerable<Project> ReadProjects()