работает 1 лаба у всех

This commit is contained in:
GokaPek 2024-10-30 19:23:38 +04:00
parent 5ae61a964d
commit bfd19f346c
4 changed files with 32 additions and 8 deletions

View File

@ -58,7 +58,7 @@ namespace View
}
//
// событие не вызывается
private void dataGridView_UserAddedRow(object sender, DataGridViewRowEventArgs e)
{
var manufacturer = new Manufacturer { Name = "" };
@ -78,5 +78,7 @@ namespace View
LoadManufacturers();
}
}
// TODO удаление
}
}

View File

@ -33,11 +33,13 @@
txtName = new Library14Petrushin.TextBoxRange();
pbImage = new PictureBox();
button1 = new Button();
button2 = new Button();
((System.ComponentModel.ISupportInitialize)pbImage).BeginInit();
SuspendLayout();
//
// dtpDeliveryDate
//
dtpDeliveryDate.DateFormat = null;
dtpDeliveryDate.Location = new Point(13, 137);
dtpDeliveryDate.Margin = new Padding(4, 5, 4, 5);
dtpDeliveryDate.Name = "dtpDeliveryDate";
@ -80,11 +82,22 @@
button1.UseVisualStyleBackColor = true;
button1.Click += btnBrowse_Click;
//
// button2
//
button2.Location = new Point(12, 326);
button2.Name = "button2";
button2.Size = new Size(94, 29);
button2.TabIndex = 5;
button2.Text = "Save";
button2.UseVisualStyleBackColor = true;
button2.Click += btnSave_Click;
//
// ProductForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(pbImage);
Controls.Add(txtName);
@ -104,5 +117,6 @@
private Library14Petrushin.TextBoxRange txtName;
private PictureBox pbImage;
private Button button1;
private Button button2;
}
}

View File

@ -31,11 +31,11 @@ namespace Laba3
_isNewProduct = product == null;
txtName.MinLength = MINL;
txtName.MaxLength = MAXL;
// dtpDeliveryDate.DateFormat = "DD month YYYY";
dtpDeliveryDate.DateFormat = "dd MMMM yyyy";
if (!_isNewProduct)
{
txtName.Text = _product.Name;
txtName.InputValue = _product.Name;
cmbManufacturer.SelectedValue= _product.ManufacturerName;
dtpDeliveryDate.Date = _product.DeliveryDate;
if (_product.Image != null)
@ -62,7 +62,7 @@ namespace Laba3
private void btnSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtName.Text))
if (string.IsNullOrEmpty(txtName.InputValue))
{
MessageBox.Show("Name is required.");
return;
@ -71,10 +71,9 @@ namespace Laba3
if (_isNewProduct)
{
_product = new Product();
_productRepository.AddProduct(_product);
}
_product.Name = txtName.Text;
_product.Name = txtName.InputValue;
_product.ManufacturerName = cmbManufacturer.SelectedValue.ToString();
_product.DeliveryDate = dtpDeliveryDate.Date;
@ -87,7 +86,16 @@ namespace Laba3
}
}
if (_isNewProduct)
{
_productRepository.AddProduct(_product);
}
else
{
_productRepository.UpdateProduct(_product);
}
DialogResult = DialogResult.OK;
Close();
}

View File

@ -9,7 +9,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Components" Version="1.0.0" />
<PackageReference Include="Library15Gerimovich" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
@ -18,6 +17,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
<PackageReference Include="WinFormsLibrary1" Version="1.0.0" />
</ItemGroup>
<ItemGroup>