This commit is contained in:
mar-va 2024-12-23 22:31:20 +04:00
parent 38b550bb97
commit 9847c6fd9a
15 changed files with 67 additions and 38 deletions

View File

@ -12,7 +12,7 @@ public class Contract
public int Id { get; private set; }
public DateTime Date { get; private set; }
public decimal ProjectId { get; private set; }
public IEnumerable<CustomerOnProject> CustomerId
public IEnumerable<CustomerOnProject> CustomerOnContract
{
get;
private set;
@ -25,7 +25,7 @@ public class Contract
Id = id,
Date = date,
ProjectId = projectid,
CustomerId = customerOnContract
CustomerOnContract = customerOnContract
};
}
}

View File

@ -10,17 +10,17 @@ 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 int ContractId { get; private set; }
public int CustomerId { get; private set; }
public string Description { get; private set; } = string.Empty;
public static CustomerOnProject CreateElement(int id, decimal contractId, decimal customerid, string description)
public static CustomerOnProject CreateElement(int id, int contractId, int customerid, string descriptio)
{
return new CustomerOnProject
{
Id = id,
ContractId = contractId,
CustomerId = customerid,
Description = description
Description = descriptio
};
}
}

View File

@ -32,15 +32,17 @@
ButtonCancel = new Button();
groupBoxContract = new GroupBox();
dataGridViewContract = new DataGridView();
ColumnProject = new DataGridViewComboBoxColumn();
labelProject = new Label();
comboBoxProject = new ComboBox();
ColumnCustomer = new DataGridViewComboBoxColumn();
ColumnDescription = new DataGridViewTextBoxColumn();
groupBoxContract.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewContract).BeginInit();
SuspendLayout();
//
// ButtonSave
//
ButtonSave.Location = new Point(68, 254);
ButtonSave.Location = new Point(68, 294);
ButtonSave.Name = "ButtonSave";
ButtonSave.Size = new Size(75, 23);
ButtonSave.TabIndex = 11;
@ -50,7 +52,7 @@
//
// ButtonCancel
//
ButtonCancel.Location = new Point(245, 255);
ButtonCancel.Location = new Point(245, 293);
ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(75, 23);
ButtonCancel.TabIndex = 12;
@ -61,7 +63,7 @@
// groupBoxContract
//
groupBoxContract.Controls.Add(dataGridViewContract);
groupBoxContract.Location = new Point(12, 12);
groupBoxContract.Location = new Point(12, 43);
groupBoxContract.Name = "groupBoxContract";
groupBoxContract.Size = new Size(375, 237);
groupBoxContract.TabIndex = 13;
@ -74,7 +76,7 @@
dataGridViewContract.AllowUserToResizeRows = false;
dataGridViewContract.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewContract.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewContract.Columns.AddRange(new DataGridViewColumn[] { ColumnProject, ColumnCustomer });
dataGridViewContract.Columns.AddRange(new DataGridViewColumn[] { ColumnCustomer, ColumnDescription });
dataGridViewContract.Dock = DockStyle.Right;
dataGridViewContract.Location = new Point(3, 19);
dataGridViewContract.MultiSelect = false;
@ -85,21 +87,42 @@
dataGridViewContract.Size = new Size(369, 215);
dataGridViewContract.TabIndex = 0;
//
// ColumnProject
// labelProject
//
ColumnProject.HeaderText = "Проект";
ColumnProject.Name = "ColumnProject";
labelProject.AutoSize = true;
labelProject.Location = new Point(15, 17);
labelProject.Name = "labelProject";
labelProject.Size = new Size(47, 15);
labelProject.TabIndex = 14;
labelProject.Text = "Проект";
//
// comboBoxProject
//
comboBoxProject.FormattingEnabled = true;
comboBoxProject.Location = new Point(96, 14);
comboBoxProject.Name = "comboBoxProject";
comboBoxProject.Size = new Size(224, 23);
comboBoxProject.TabIndex = 15;
//
// ColumnCustomer
//
ColumnCustomer.HeaderText = "Заказчик";
ColumnCustomer.Name = "ColumnCustomer";
//
// ColumnDescription
//
ColumnDescription.HeaderText = "Описание";
ColumnDescription.Name = "ColumnDescription";
ColumnDescription.Resizable = DataGridViewTriState.True;
ColumnDescription.SortMode = DataGridViewColumnSortMode.NotSortable;
//
// FormContract
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(399, 286);
ClientSize = new Size(399, 331);
Controls.Add(comboBoxProject);
Controls.Add(labelProject);
Controls.Add(groupBoxContract);
Controls.Add(ButtonCancel);
Controls.Add(ButtonSave);
@ -109,6 +132,7 @@
groupBoxContract.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewContract).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
@ -120,7 +144,9 @@
private Button ButtonCancel;
private GroupBox groupBoxContract;
private DataGridView dataGridViewContract;
private DataGridViewComboBoxColumn ColumnProject;
private Label labelProject;
private ComboBox comboBoxProject;
private DataGridViewComboBoxColumn ColumnCustomer;
private DataGridViewTextBoxColumn ColumnDescription;
}
}

View File

@ -24,9 +24,9 @@ namespace ProjectItCompany.Forms
InitializeComponent();
_contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository));
ColumnProject.DataSource = projectRepository.ReadProjects();
ColumnProject.DisplayMember = "NameProject";
ColumnProject.ValueMember = "Id";
comboBoxProject.DataSource = projectRepository.ReadProjects();
comboBoxProject.DisplayMember = "NameProject";
comboBoxProject.ValueMember = "Id";
ColumnCustomer.DataSource = customerRepository.ReadCustomers();
ColumnCustomer.DisplayMember = "NameCustomer";
@ -41,7 +41,7 @@ namespace ProjectItCompany.Forms
{
throw new Exception("Имеются незаполненные поля");
}
_contractRepository.CreateContract(Contract.CreateOpeartion(0, DateTime.Now, 0, CreateListExecutorOnProject()));
_contractRepository.CreateContract(Contract.CreateOpeartion(0, DateTime.Now, (int)comboBoxProject.SelectedValue, CreateListExecutorOnProject()));
Close();
}
catch (Exception ex)
@ -58,13 +58,13 @@ namespace ProjectItCompany.Forms
var list = new List<Entities.CustomerOnProject>();
foreach (DataGridViewRow row in dataGridViewContract.Rows)
{
if (row.Cells["ColumnProject"].Value == null ||
row.Cells["ColumnCustomer"].Value == null)
if (row.Cells["ColumnCustomer"].Value == null ||
row.Cells["ColumnDescription"].Value == null)
{
continue;
}
list.Add(Entities.CustomerOnProject.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnProject"].Value), Convert.ToInt32(row.Cells["ColumnCustomer"].Value), string.Empty));
list.Add(Entities.CustomerOnProject.CreateElement(0, 0,
Convert.ToInt32(row.Cells["ColumnCustomer"].Value), row.Cells["ColumnDescription"].Value?.ToString()));
}
return list;
}

View File

@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnProject.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="ColumnCustomer.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -95,7 +95,6 @@
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowTemplate.Height = 25;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(580, 427);

View File

@ -1140,7 +1140,7 @@
<data name="ButtonDelete.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vwAADr8BOAVTJAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAD8lSURBVHhe7d0H
vgAADr4B6kKxwAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAD8lSURBVHhe7d0H
nFTlufjxiRqxd4PtRk2MGjWxEDUq7MxO3QEhatxoLFhQbFGwgWJbFRRjBSsKoogNFVOvsaWbm+v1aqJR
k39u7EmMjaLUnXOe/3OGdwLOvsiWKec95/f7fL4hssvuzJxz3uedYdlNEFG4kykDPi8/PGAreTS1R+ej
LfnSoy3f8R5NjvRmt4xVV6pbvdmD7vNnt/zQf3TQk6XZLb/zZief8x5p+au+7XX1UZWlSqoEv/fp93uk

View File

@ -85,9 +85,12 @@
// numericUpDownHourlyRate
//
numericUpDownHourlyRate.Location = new Point(136, 84);
numericUpDownHourlyRate.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
numericUpDownHourlyRate.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
numericUpDownHourlyRate.Name = "numericUpDownHourlyRate";
numericUpDownHourlyRate.Size = new Size(151, 23);
numericUpDownHourlyRate.TabIndex = 5;
numericUpDownHourlyRate.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// ButtonSave
//

View File

@ -51,7 +51,6 @@
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowTemplate.Height = 25;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(638, 450);
@ -111,6 +110,7 @@
Name = "FormExecutors";
StartPosition = FormStartPosition.CenterParent;
Text = "Исполнители";
Load += FormExecutors_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel1.ResumeLayout(false);
ResumeLayout(false);

View File

@ -121,7 +121,7 @@
<data name="ButtonUpd.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAABLAAAASwCAIAAABkQySYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wQAADsEBuJFr7QAA/7JJREFUeF7s/UlsbUua74fxNtlXZr16neBnC7b8BEiC5YGggXsJFmDA8MywbAuQ
vQAADr0BR/uQrQAA/7JJREFUeF7s/UlsbUua74fxNtlXZr16neBnC7b8BEiC5YGggXsJFmDA8MywbAuQ
ZFgTTeyJAQHWxJAnHnhgAxbgRjZgCLAnBoSnga2np6rK9vb3Ztar0itVVWZlZXfzno49D09/zqV/Eb9v
fwzuvcnDQ/Jwr334/UAEvogVK1asWGtF/P97bZIbR0VRFEVRFEVRFMWNpAxhURRFURRFURTFDaUMYVEU
RVEURVEUxQ2lDGFRFEVRFEVRFMUNpQxhURRFURRFURTFDaUMYVEURVEURVEUxQ2lDGFRFEVRFEVRFMUN
@ -6527,7 +6527,7 @@
<data name="ButtonDelete.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vQAADr0BR/uQrQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAD8lSURBVHhe7d0H
vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAD8lSURBVHhe7d0H
nFTlufjxiRqxd4PtRk2MGjWxEDUq7MxO3QEhatxoLFhQbFGwgWJbFRRjBSsKoogNFVOvsaWbm+v1aqJR
k39u7EmMjaLUnXOe/3OGdwLOvsiWKec95/f7fL4hssvuzJxz3uedYdlNEFG4kykDPi8/PGAreTS1R+ej
LfnSoy3f8R5NjvRmt4xVV6pbvdmD7vNnt/zQf3TQk6XZLb/zZief8x5p+au+7XX1UZWlSqoEv/fp93uk

View File

@ -91,6 +91,7 @@
// numericUpDownNumberOfHours
//
numericUpDownNumberOfHours.Location = new Point(130, 60);
numericUpDownNumberOfHours.Maximum = new decimal(new int[] { 100000000, 0, 0, 0 });
numericUpDownNumberOfHours.Name = "numericUpDownNumberOfHours";
numericUpDownNumberOfHours.Size = new Size(120, 23);
numericUpDownNumberOfHours.TabIndex = 6;

View File

@ -35,11 +35,11 @@ public class ContractRepository : IContractRepository
using var transaction = connection.BeginTransaction();
var queryInsert = @"INSERT INTO contract (Date, ProjectId)
VALUES (@Date, @ProjectId);
SELECT MAX(Id) FROM Contracts";
SELECT MAX(Id) FROM contract";
var feedReplenishmentId = connection.QueryFirst<int>(queryInsert, contract, transaction);
var querySubInsert = @"INSERT INTO customerOnProject (ContractId, CostomerId, Description)
VALUES (@ContractId,@CostomerId, @Description)";
foreach (var elem in contract.CustomerId)
var querySubInsert = @"INSERT INTO customeronproject (Description, ContractId, CustomerId)
VALUES ( @Description, @ContractId,@CustomerId)";
foreach (var elem in contract.CustomerOnContract)
{
connection.Execute(querySubInsert, new
{
@ -65,7 +65,7 @@ public class ContractRepository : IContractRepository
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"DELETE FROM contract
WHERE ID=@id";
WHERE ID=@Id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)

View File

@ -50,7 +50,7 @@ public class CustomerRepository : ICustomerRepository
var queryUpdate = @"UPDATE customer SET
NameCustomer=@NameCustomer,
Description=@Description
WHERE ID=@id";
WHERE ID=@Id";
connection.Execute(queryUpdate, customer);
}
catch (Exception ex)

View File

@ -52,7 +52,7 @@ public class ExecutorRepository : IExecutorRepository
DateOfBirth=@DateOfBirth,
HourlyRate=@HourlyRate,
JobTitles = @JobTitles
WHERE ID=@id";
WHERE ID=@Id";
connection.Execute(queryUpdate, executor);
}
catch (Exception ex)

View File

@ -51,7 +51,7 @@ public class ProjectRepository : IProjectRepository
NameProject=@NameProject,
CustomerId=@CustomerId,
CompletedStages=@CompletedStages
WHERE ID=@id";
WHERE ID=@Id";
connection.Execute(queryUpdate, project);
}
catch (Exception ex)