пробная форма продуктов
This commit is contained in:
parent
d3bc885bc9
commit
dee1447d89
60
Laba3/ProductForm.Designer.cs
generated
60
Laba3/ProductForm.Designer.cs
generated
@ -29,41 +29,79 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dtpDeliveryDate = new WinFormsLibrary1.DateInputControl();
|
||||
comboBoxUserControl1 = new WinFormsLibrary1.ComboBoxUserControl();
|
||||
cmbManufacturer = new WinFormsLibrary1.ComboBoxUserControl();
|
||||
txtName = new Library14Petrushin.TextBoxRange();
|
||||
pbImage = new PictureBox();
|
||||
button1 = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pbImage).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dtpDeliveryDate
|
||||
//
|
||||
dtpDeliveryDate.Location = new Point(13, 65);
|
||||
dtpDeliveryDate.Location = new Point(12, 98);
|
||||
dtpDeliveryDate.Margin = new Padding(4, 5, 4, 5);
|
||||
dtpDeliveryDate.Name = "dtpDeliveryDate";
|
||||
dtpDeliveryDate.Size = new Size(186, 110);
|
||||
dtpDeliveryDate.TabIndex = 0;
|
||||
//
|
||||
// comboBoxUserControl1
|
||||
// cmbManufacturer
|
||||
//
|
||||
comboBoxUserControl1.Location = new Point(13, 115);
|
||||
comboBoxUserControl1.Margin = new Padding(4, 5, 4, 5);
|
||||
comboBoxUserControl1.Name = "comboBoxUserControl1";
|
||||
comboBoxUserControl1.SelectedValue = "";
|
||||
comboBoxUserControl1.Size = new Size(201, 40);
|
||||
comboBoxUserControl1.TabIndex = 1;
|
||||
cmbManufacturer.Location = new Point(13, 150);
|
||||
cmbManufacturer.Margin = new Padding(4, 5, 4, 5);
|
||||
cmbManufacturer.Name = "cmbManufacturer";
|
||||
cmbManufacturer.SelectedValue = "";
|
||||
cmbManufacturer.Size = new Size(201, 40);
|
||||
cmbManufacturer.TabIndex = 1;
|
||||
//
|
||||
// txtName
|
||||
//
|
||||
txtName.Location = new Point(12, 12);
|
||||
txtName.MaxLength = null;
|
||||
txtName.MinLength = null;
|
||||
txtName.Name = "txtName";
|
||||
txtName.Size = new Size(315, 108);
|
||||
txtName.TabIndex = 2;
|
||||
//
|
||||
// pbImage
|
||||
//
|
||||
pbImage.Location = new Point(320, 32);
|
||||
pbImage.Name = "pbImage";
|
||||
pbImage.Size = new Size(451, 344);
|
||||
pbImage.TabIndex = 3;
|
||||
pbImage.TabStop = false;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(320, 399);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(110, 29);
|
||||
button1.TabIndex = 4;
|
||||
button1.Text = "Choose img";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += btnBrowse_Click;
|
||||
//
|
||||
// ProductForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(comboBoxUserControl1);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(pbImage);
|
||||
Controls.Add(txtName);
|
||||
Controls.Add(cmbManufacturer);
|
||||
Controls.Add(dtpDeliveryDate);
|
||||
Name = "ProductForm";
|
||||
Text = "ProductForm";
|
||||
((System.ComponentModel.ISupportInitialize)pbImage).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private WinFormsLibrary1.DateInputControl dtpDeliveryDate;
|
||||
private WinFormsLibrary1.ComboBoxUserControl comboBoxUserControl1;
|
||||
private WinFormsLibrary1.ComboBoxUserControl cmbManufacturer;
|
||||
private Library14Petrushin.TextBoxRange txtName;
|
||||
private PictureBox pbImage;
|
||||
private Button button1;
|
||||
}
|
||||
}
|
@ -19,6 +19,8 @@ namespace Laba3
|
||||
private readonly IManufacturerRepository _manufacturerRepository;
|
||||
private Product _product;
|
||||
private bool _isNewProduct;
|
||||
private const int MINL = 3;
|
||||
private const int MAXL= 10;
|
||||
|
||||
public ProductForm(IProductRepository productRepository, IManufacturerRepository manufacturerRepository, Product product = null)
|
||||
{
|
||||
@ -27,12 +29,14 @@ namespace Laba3
|
||||
_manufacturerRepository = manufacturerRepository;
|
||||
_product = product;
|
||||
_isNewProduct = product == null;
|
||||
txtName.MinLength = MINL;
|
||||
txtName.MaxLength = MAXL;
|
||||
|
||||
if (!_isNewProduct)
|
||||
{
|
||||
txtName.Text = _product.Name;
|
||||
cmbManufacturer.SelectedItem = _product.ManufacturerName;
|
||||
dtpDeliveryDate.Value = _product.DeliveryDate;
|
||||
cmbManufacturer.SelectedValue= _product.ManufacturerName;
|
||||
dtpDeliveryDate.Date = _product.DeliveryDate;
|
||||
if (_product.Image != null)
|
||||
{
|
||||
using (var ms = new MemoryStream(_product.Image))
|
||||
@ -70,8 +74,8 @@ namespace Laba3
|
||||
}
|
||||
|
||||
_product.Name = txtName.Text;
|
||||
_product.ManufacturerName = cmbManufacturer.SelectedItem.ToString();
|
||||
_product.DeliveryDate = dtpDeliveryDate.Value;
|
||||
_product.ManufacturerName = cmbManufacturer.SelectedValue.ToString();
|
||||
_product.DeliveryDate = dtpDeliveryDate.Date;
|
||||
|
||||
if (pbImage.Image != null)
|
||||
{
|
||||
@ -90,7 +94,11 @@ namespace Laba3
|
||||
private void ProductForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
var manufacturers = _manufacturerRepository.GetAllManufacturers().Select(m => m.Name).ToList();
|
||||
cmbManufacturer.DataSource = manufacturers;
|
||||
// cmbManufacturer.Data = manufacturers;
|
||||
foreach (var manufacturer in manufacturers)
|
||||
{
|
||||
cmbManufacturer.AddItem(manufacturer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Library14Petrushin\Library14Petrushin.csproj" />
|
||||
<ProjectReference Include="..\Models\Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user