Лабораторная работа №1

This commit is contained in:
Anitonchik 2024-11-13 17:27:50 +04:00
parent 07c3c74aeb
commit 33659c851e
13 changed files with 63 additions and 58 deletions

View File

@ -44,27 +44,27 @@
labelName.AutoSize = true;
labelName.Location = new Point(38, 39);
labelName.Name = "labelName";
labelName.Size = new Size(42, 20);
labelName.Size = new Size(45, 20);
labelName.TabIndex = 0;
labelName.Text = "ФИО";
labelName.Text = "ФИО:";
//
// labelType
//
labelType.AutoSize = true;
labelType.Location = new Point(38, 106);
labelType.Name = "labelType";
labelType.Size = new Size(94, 20);
labelType.Size = new Size(97, 20);
labelType.TabIndex = 1;
labelType.Text = "Тип клиента";
labelType.Text = "Тип клиента:";
//
// labelOptovik
//
labelOptovik.AutoSize = true;
labelOptovik.Location = new Point(38, 179);
labelOptovik.Name = "labelOptovik";
labelOptovik.Size = new Size(68, 20);
labelOptovik.Size = new Size(75, 20);
labelOptovik.TabIndex = 2;
labelOptovik.Text = "Оптовик";
labelOptovik.Text = "Оптовик?";
//
// textBoxName
//
@ -75,7 +75,7 @@
//
// buttonSave
//
buttonSave.BackColor = Color.FromArgb(255, 192, 128);
buttonSave.BackColor = Color.FromArgb(255, 224, 192);
buttonSave.Location = new Point(38, 255);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
@ -86,7 +86,7 @@
//
// buttonCancel
//
buttonCancel.BackColor = Color.FromArgb(255, 192, 128);
buttonCancel.BackColor = Color.FromArgb(255, 224, 192);
buttonCancel.Location = new Point(188, 255);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);

View File

@ -70,7 +70,7 @@ namespace ProjectCompanyFurniture.Forms
}
}
private void LoadList() => dataGridViewData.DataSource = _invoiceRepository.ReadInvoice();
private void LoadList() => dataGridViewData.DataSource = _invoiceRepository.ReadInvoices();
private bool TryGetIdentifierFromSelectedRow(out int id)
{

View File

@ -39,9 +39,9 @@
labelName.AutoSize = true;
labelName.Location = new Point(25, 28);
labelName.Name = "labelName";
labelName.Size = new Size(77, 20);
labelName.Size = new Size(80, 20);
labelName.TabIndex = 0;
labelName.Text = "Название";
labelName.Text = "Название:";
//
// textBoxName
//
@ -76,14 +76,14 @@
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(342, 171);
ClientSize = new Size(318, 158);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormManufacturer";
StartPosition = FormStartPosition.CenterScreen;
Text = "FormManufacturer";
Text = "Производитель";
ResumeLayout(false);
PerformLayout();
}

View File

@ -31,7 +31,7 @@ namespace ProjectCompanyFurniture.Forms
{
try
{
_container.Resolve<FormClient>().ShowDialog();
_container.Resolve<FormManufacturer>().ShowDialog();
LoadList();
}
catch (Exception ex)
@ -80,7 +80,7 @@ namespace ProjectCompanyFurniture.Forms
}
}
private void LoadList() => dataGridViewData.DataSource = _manufacturerRepository.ReadManufacturer();
private void LoadList() => dataGridViewData.DataSource = _manufacturerRepository.ReadManufacturers();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;

View File

@ -37,48 +37,47 @@
buttonSave = new Button();
buttonCancel = new Button();
labelIDManuf = new Label();
numericUpDownIDManuf = new NumericUpDown();
comboBoxManufacturer = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownStartPrice).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownIDManuf).BeginInit();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(35, 88);
labelName.Location = new Point(35, 94);
labelName.Name = "labelName";
labelName.Size = new Size(77, 20);
labelName.Size = new Size(80, 20);
labelName.TabIndex = 0;
labelName.Text = "Название";
labelName.Text = "Название:";
//
// labelCategory
//
labelCategory.AutoSize = true;
labelCategory.Location = new Point(35, 153);
labelCategory.Location = new Point(35, 161);
labelCategory.Name = "labelCategory";
labelCategory.Size = new Size(81, 20);
labelCategory.Size = new Size(84, 20);
labelCategory.TabIndex = 1;
labelCategory.Text = "Категория";
labelCategory.Text = "Категория:";
//
// labelStartPrice
//
labelStartPrice.AutoSize = true;
labelStartPrice.Location = new Point(35, 222);
labelStartPrice.Name = "labelStartPrice";
labelStartPrice.Size = new Size(123, 20);
labelStartPrice.Size = new Size(126, 20);
labelStartPrice.TabIndex = 2;
labelStartPrice.Text = "Начальная цена";
labelStartPrice.Text = "Начальная цена:";
//
// textBoxName
//
textBoxName.Location = new Point(211, 85);
textBoxName.Location = new Point(211, 91);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(125, 27);
textBoxName.TabIndex = 3;
//
// textBoxCategory
//
textBoxCategory.Location = new Point(211, 150);
textBoxCategory.Location = new Point(211, 158);
textBoxCategory.Name = "textBoxCategory";
textBoxCategory.Size = new Size(125, 27);
textBoxCategory.TabIndex = 4;
@ -92,7 +91,7 @@
//
// buttonSave
//
buttonSave.BackColor = Color.FromArgb(192, 255, 192);
buttonSave.BackColor = Color.FromArgb(255, 192, 255);
buttonSave.Location = new Point(33, 307);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(125, 29);
@ -103,7 +102,7 @@
//
// buttonCancel
//
buttonCancel.BackColor = Color.FromArgb(192, 255, 192);
buttonCancel.BackColor = Color.FromArgb(255, 192, 255);
buttonCancel.Location = new Point(211, 307);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(125, 29);
@ -117,23 +116,25 @@
labelIDManuf.AutoSize = true;
labelIDManuf.Location = new Point(35, 31);
labelIDManuf.Name = "labelIDManuf";
labelIDManuf.Size = new Size(135, 20);
labelIDManuf.Size = new Size(121, 20);
labelIDManuf.TabIndex = 8;
labelIDManuf.Text = "ID производителя";
labelIDManuf.Text = "Производитель:";
//
// numericUpDownIDManuf
// comboBoxManufacturer
//
numericUpDownIDManuf.Location = new Point(211, 29);
numericUpDownIDManuf.Name = "numericUpDownIDManuf";
numericUpDownIDManuf.Size = new Size(125, 27);
numericUpDownIDManuf.TabIndex = 9;
comboBoxManufacturer.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxManufacturer.FormattingEnabled = true;
comboBoxManufacturer.Location = new Point(211, 31);
comboBoxManufacturer.Name = "comboBoxManufacturer";
comboBoxManufacturer.Size = new Size(125, 28);
comboBoxManufacturer.TabIndex = 9;
//
// FormProduct
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(363, 394);
Controls.Add(numericUpDownIDManuf);
Controls.Add(comboBoxManufacturer);
Controls.Add(labelIDManuf);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
@ -147,7 +148,6 @@
StartPosition = FormStartPosition.CenterScreen;
Text = "Продукт";
((System.ComponentModel.ISupportInitialize)numericUpDownStartPrice).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownIDManuf).EndInit();
ResumeLayout(false);
PerformLayout();
}
@ -163,6 +163,6 @@
private Button buttonSave;
private Button buttonCancel;
private Label labelIDManuf;
private NumericUpDown numericUpDownIDManuf;
private ComboBox comboBoxManufacturer;
}
}

View File

@ -22,10 +22,10 @@ namespace ProjectCompanyFurniture.Forms
{
throw new InvalidDataException(nameof(product));
}
numericUpDownIDManuf.Value = product.ManufacturerID;
comboBoxManufacturer.SelectedValue = product.ManufacturerID;
textBoxName.Text = product.Name;
textBoxCategory.Text = product.Category;
numericUpDownIDManuf.Value = product.StartingPrice;
numericUpDownStartPrice.Value = product.StartingPrice;
_productId = value;
}
catch (Exception ex)
@ -36,10 +36,14 @@ namespace ProjectCompanyFurniture.Forms
}
}
public FormProduct(IProductRepository productRepository)
public FormProduct(IProductRepository productRepository, IManufacturerRepository manufacturerRepository)
{
InitializeComponent();
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
comboBoxManufacturer.DataSource = manufacturerRepository.ReadManufacturers();
comboBoxManufacturer.DisplayMember = "FirstName";
comboBoxManufacturer.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
@ -47,7 +51,8 @@ namespace ProjectCompanyFurniture.Forms
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text)
|| string.IsNullOrEmpty(textBoxCategory.Text))
|| string.IsNullOrEmpty(textBoxCategory.Text)
|| comboBoxManufacturer.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
@ -70,7 +75,7 @@ namespace ProjectCompanyFurniture.Forms
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Product CreateProduct(int id) => Product.CreateEntity(id, Convert.ToInt32(numericUpDownIDManuf.Value),
private Product CreateProduct(int id) => Product.CreateEntity(id, Convert.ToInt32((int)comboBoxManufacturer.SelectedValue!),
textBoxName.Text, textBoxCategory.Text, Convert.ToInt32(numericUpDownStartPrice.Value));
}
}

View File

@ -43,27 +43,27 @@
labelProductID.AutoSize = true;
labelProductID.Location = new Point(31, 28);
labelProductID.Name = "labelProductID";
labelProductID.Size = new Size(66, 20);
labelProductID.Size = new Size(69, 20);
labelProductID.TabIndex = 0;
labelProductID.Text = "Продукт";
labelProductID.Text = "Продукт:";
//
// labelMovement
//
labelMovement.AutoSize = true;
labelMovement.Location = new Point(31, 90);
labelMovement.Location = new Point(31, 71);
labelMovement.Name = "labelMovement";
labelMovement.Size = new Size(109, 20);
labelMovement.Size = new Size(112, 20);
labelMovement.TabIndex = 1;
labelMovement.Text = "Тип движения";
labelMovement.Text = "Тип движения:";
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(31, 232);
labelDate.Name = "labelDate";
labelDate.Size = new Size(41, 20);
labelDate.Size = new Size(44, 20);
labelDate.TabIndex = 2;
labelDate.Text = "Дата";
labelDate.Text = "Дата:";
//
// dateTimePickerProductMovementDate
//
@ -100,7 +100,7 @@
checkedListBoxMovement.FormattingEnabled = true;
checkedListBoxMovement.Location = new Point(267, 71);
checkedListBoxMovement.Name = "checkedListBoxMovement";
checkedListBoxMovement.Size = new Size(181, 114);
checkedListBoxMovement.Size = new Size(181, 136);
checkedListBoxMovement.TabIndex = 8;
//
// comboBoxProduct

View File

@ -30,7 +30,7 @@ namespace ProjectCompanyFurniture.Forms
comboBoxProduct.DisplayMember = "Name";
comboBoxProduct.ValueMember = "ID";
foreach (var elem in Enum.GetValues(typeof(ProductMovement)))
foreach (var elem in Enum.GetValues(typeof(Movement)))
{
checkedListBoxMovement.Items.Add(elem);
}

View File

@ -29,7 +29,7 @@ namespace ProjectCompanyFurniture.Forms
{
try
{
_container.Resolve<FormClient>().ShowDialog();
_container.Resolve<FormProduct>().ShowDialog();
LoadList();
}
catch (Exception ex)

View File

@ -9,7 +9,7 @@ namespace ProjectCompanyFurniture.Repositories;
public interface IInvoiceRepository
{
IEnumerable<Invoice> ReadInvoice(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null);
IEnumerable<Invoice> ReadInvoices (DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null);
void CreateInvoice(Invoice invoice);
void DeleteInvoice(int id);

View File

@ -9,7 +9,7 @@ namespace ProjectCompanyFurniture.Repositories;
public interface IManufacturerRepository
{
IEnumerable<Manufacturer> ReadManufacturer();
IEnumerable<Manufacturer> ReadManufacturers();
Manufacturer ReadManufacturerById(int id);
void CreateManufacturer(Manufacturer manufacturer);
void UpdateManufacturer(Manufacturer manufacturer);

View File

@ -17,7 +17,7 @@ public class InvoiceRepository : IInvoiceRepository
{
}
public IEnumerable<Invoice> ReadInvoice(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null)
public IEnumerable<Invoice> ReadInvoices(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null)
{
return [];
}

View File

@ -17,7 +17,7 @@ public class ManufacturerRepository : IManufacturerRepository
{
}
public IEnumerable<Manufacturer> ReadManufacturer()
public IEnumerable<Manufacturer> ReadManufacturers()
{
return [];
}