Upload changes not done

This commit is contained in:
ENDORFIT 2024-11-09 13:13:13 +04:00
parent ffa3ecde4a
commit 607502ce23
53 changed files with 840 additions and 1323 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,15 +6,15 @@
public int AccessoriesID { get; private set; }
public int OrderID { get; private set; }
public double TotalCost { get; private set; }
public static BundleOrder CreateBundleOrder(int id, int accessoriesID, int orderID)
public static BundleOrder CreateBundleOrder(int id, int accessoriesID, double totalCost)
{
return new BundleOrder
{
ID = id,
AccessoriesID = accessoriesID,
OrderID = orderID,
TotalCost = totalCost
};
}
}

View File

@ -0,0 +1,31 @@
using ProjectOptika.Scripts.Entities.Enums;
namespace ProjectOptika.Scripts.Entities
{
public class Employee
{
public int ID { get; private set; }
public PositionEmployee PositionEmployee { get; private set; }
public string FirstName { get; private set; }
public string SecondName { get; private set; }
public string Surname { get; private set; }
public IEnumerable<BundleOrder> BundleOrder { get; private set; }
public static Employee CreateEmployee(int id, PositionEmployee positionEmployee, string firstName, string secondName, string surname, IEnumerable<BundleOrder> bundleOrder) {
return new Employee
{
ID = id,
PositionEmployee = positionEmployee,
FirstName = firstName,
SecondName = secondName,
Surname = surname,
BundleOrder = bundleOrder
};
}
}
}

View File

@ -0,0 +1,13 @@
namespace ProjectOptika.Scripts.Entities.Enums
{
[System.Flags]
public enum PositionEmployee
{
None = 0,
SeniorSalesman = 1,
Salesman = 2,
SellerCashier = 3,
Administrator = 4,
Accountant = 5
}
}

View File

@ -6,17 +6,14 @@
public int AccessoriesID { get; private set; }
public int OrderID { get; private set; }
public int Count { get; private set; }
public static ItemOrder CreateItemOrder (int id, int accessoriesID, int orderID, int count)
public static ItemOrder CreateItemOrder (int id, int accessoriesID, int count)
{
return new ItemOrder
{
ID = id,
AccessoriesID = accessoriesID,
OrderID = orderID,
Count = count
};
}

View File

@ -4,16 +4,22 @@
{
public int ID { get; private set; }
public int EmployeeID { get; private set; }
public DateTime OrderDate { get; private set; }
public double TotalCost { get; private set; }
public static Order CreateOrder(int id, double totalCost)
public IEnumerable<ItemOrder> ItemOrders { get; private set; }
public static Order CreateOrder(int id, int employeeID, double totalCost, IEnumerable<ItemOrder> itemOrders)
{
return new Order {
ID = id,
EmployeeID = employeeID,
OrderDate = DateTime.Now,
TotalCost = totalCost
TotalCost = totalCost,
ItemOrders = itemOrders
};
}
}

View File

@ -1,7 +1,9 @@
namespace ProjectOptika.Scripts.Entities
{
public class Lens
public class Specifications
{
public int ID { get; private set; }
public int AccessoriesID { get; private set; }
public string Material { get; private set; }
@ -14,10 +16,11 @@
public double TimeProduction { get; private set; }
public static Lens CreateLens(int accessoriesID, string material, string astigmatism, string dioptericity, string originCountry, double timeProduction)
public static Specifications CreateSpecifications(int id, int accessoriesID, string material, string astigmatism, string dioptericity, string originCountry, double timeProduction)
{
return new Lens
return new Specifications
{
ID = id,
AccessoriesID = accessoriesID,
Material = material,
Astigmatism = astigmatism,

View File

@ -21,6 +21,15 @@ namespace ProjectOptika.Scripts.Forms
if (accessory == null) throw new InvalidDataException(nameof(accessory));
_accessoriesID = accessory.ID;
textBoxBrand.Text = accessory.Brand;
textBoxName.Text = accessory.Name;
numericUpDownCost.Value = accessory.Cost;
numericUpDownAvailabilityStore.Value = accessory.AvailabilityStore;
numericUpDownStockAvailability.Value = accessory.StockAvailability;
dateTimePickerDeliveryDate.Value = accessory.DeliveryDate;
comboBoxCategoryName.DataSource = Enum.GetValues(typeof(CategoryType));
comboBoxCategoryName.SelectedIndex = (int)accessory.CategoryName;
}
catch (Exception ex)
{
@ -36,12 +45,6 @@ namespace ProjectOptika.Scripts.Forms
_accessoriesRepositories = accessoriesRepositories
?? throw new ArgumentNullException(nameof(accessoriesRepositories));
comboBoxCategoryName.Items.Clear();
foreach (var i in Enum.GetValues(typeof(CategoryType)))
{
comboBoxCategoryName.Items.Add(i);
}
}
private void ButtonSave_Click(object sender, EventArgs e)

View File

@ -28,94 +28,146 @@
/// </summary>
private void InitializeComponent()
{
comboBoxEmployee = new ComboBox();
labelEmployee = new Label();
groupBoxOrders = new GroupBox();
dataGridView = new DataGridView();
ColumnAccessories = new DataGridViewComboBoxColumn();
ColumnCost = new DataGridViewTextBoxColumn();
buttonCancel = new Button();
buttonSave = new Button();
labelOrderID = new Label();
comboBoxOrderID = new ComboBox();
labelAccessoriesID = new Label();
comboBoxAccessoriesID = new ComboBox();
labelTotalCost = new Label();
numericUpDownTotalCost = new NumericUpDown();
groupBoxOrders.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownTotalCost).BeginInit();
SuspendLayout();
//
// comboBoxEmployee
//
comboBoxEmployee.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(101, 9);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(190, 28);
comboBoxEmployee.TabIndex = 7;
//
// labelEmployee
//
labelEmployee.AutoSize = true;
labelEmployee.Location = new Point(13, 12);
labelEmployee.Name = "labelEmployee";
labelEmployee.Size = new Size(82, 20);
labelEmployee.TabIndex = 5;
labelEmployee.Text = "Сотрудник";
//
// groupBoxOrders
//
groupBoxOrders.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxOrders.Controls.Add(dataGridView);
groupBoxOrders.Location = new Point(5, 98);
groupBoxOrders.Name = "groupBoxOrders";
groupBoxOrders.Size = new Size(309, 294);
groupBoxOrders.TabIndex = 4;
groupBoxOrders.TabStop = false;
groupBoxOrders.Text = "Заказы";
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnAccessories, ColumnCost });
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(3, 23);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.Size = new Size(303, 268);
dataGridView.TabIndex = 0;
//
// ColumnAccessories
//
ColumnAccessories.HeaderText = "Аксессуар";
ColumnAccessories.MinimumWidth = 6;
ColumnAccessories.Name = "ColumnAccessories";
ColumnAccessories.Width = 125;
//
// ColumnCost
//
ColumnCost.HeaderText = "Стоимость";
ColumnCost.MinimumWidth = 6;
ColumnCost.Name = "ColumnCost";
ColumnCost.Width = 125;
//
// buttonCancel
//
buttonCancel.Location = new Point(186, 110);
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(213, 412);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 15;
buttonCancel.Text = "Отмена";
buttonCancel.TabIndex = 8;
buttonCancel.Text = "Отменить";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(60, 110);
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(13, 412);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 14;
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// labelOrderID
// labelTotalCost
//
labelOrderID.AutoSize = true;
labelOrderID.Location = new Point(12, 68);
labelOrderID.Name = "labelOrderID";
labelOrderID.Size = new Size(73, 20);
labelOrderID.TabIndex = 13;
labelOrderID.Text = "ID заказа";
labelTotalCost.AutoSize = true;
labelTotalCost.Location = new Point(12, 54);
labelTotalCost.Name = "labelTotalCost";
labelTotalCost.Size = new Size(133, 20);
labelTotalCost.TabIndex = 9;
labelTotalCost.Text = "Общая стоимость";
//
// comboBoxOrderID
// numericUpDownTotalCost
//
comboBoxOrderID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxOrderID.FormattingEnabled = true;
comboBoxOrderID.Location = new Point(185, 65);
comboBoxOrderID.Name = "comboBoxOrderID";
comboBoxOrderID.Size = new Size(155, 28);
comboBoxOrderID.TabIndex = 12;
//
// labelAccessoriesID
//
labelAccessoriesID.AutoSize = true;
labelAccessoriesID.Location = new Point(11, 15);
labelAccessoriesID.Name = "labelAccessoriesID";
labelAccessoriesID.Size = new Size(156, 20);
labelAccessoriesID.TabIndex = 11;
labelAccessoriesID.Text = "Название аксуссуара";
//
// comboBoxAccessoriesID
//
comboBoxAccessoriesID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxAccessoriesID.FormattingEnabled = true;
comboBoxAccessoriesID.Location = new Point(185, 12);
comboBoxAccessoriesID.Name = "comboBoxAccessoriesID";
comboBoxAccessoriesID.Size = new Size(155, 28);
comboBoxAccessoriesID.TabIndex = 10;
numericUpDownTotalCost.Location = new Point(164, 52);
numericUpDownTotalCost.Name = "numericUpDownTotalCost";
numericUpDownTotalCost.Size = new Size(150, 27);
numericUpDownTotalCost.TabIndex = 10;
//
// FormBundleOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(358, 163);
ClientSize = new Size(318, 450);
Controls.Add(numericUpDownTotalCost);
Controls.Add(labelTotalCost);
Controls.Add(comboBoxEmployee);
Controls.Add(labelEmployee);
Controls.Add(groupBoxOrders);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelOrderID);
Controls.Add(comboBoxOrderID);
Controls.Add(labelAccessoriesID);
Controls.Add(comboBoxAccessoriesID);
Name = "FormBundleOrder";
Text = "BundleOrder";
Text = "FormBundleOrder";
groupBoxOrders.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownTotalCost).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxEmployee;
private Label labelEmployee;
private GroupBox groupBoxOrders;
private DataGridView dataGridView;
private Button buttonCancel;
private Button buttonSave;
private Label labelOrderID;
private ComboBox comboBoxOrderID;
private Label labelAccessoriesID;
private ComboBox comboBoxAccessoriesID;
private DataGridViewComboBoxColumn ColumnAccessories;
private DataGridViewTextBoxColumn ColumnCost;
private Label labelTotalCost;
private NumericUpDown numericUpDownTotalCost;
}
}

View File

@ -5,70 +5,39 @@ namespace ProjectOptika.Scripts.Forms
{
public partial class FormBundleOrder : Form
{
private IEmployeeRepositories _employeeRepositories;
private readonly IBundleOrderRepositories _bundleOrderRepositories;
private int? _bundleOrderID;
public int ID
{
set
{
try
{
var itemOrder = _bundleOrderRepositories.GetBundleOrderByID(value);
if (itemOrder == null) throw new InvalidDataException(nameof(itemOrder));
_bundleOrderID = itemOrder.ID;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormBundleOrder(IBundleOrderRepositories bundleOrderRepositories, IAccessoriesRepositories accessoriesRepositories, IOrderRepositories orderRepositories)
public FormBundleOrder(IEmployeeRepositories employeeRepositories, IAccessoriesRepositories accessoriesRepositories)
{
InitializeComponent();
_employeeRepositories = employeeRepositories ??
throw new ArgumentNullException(nameof(employeeRepositories));
_bundleOrderRepositories = bundleOrderRepositories
?? throw new ArgumentNullException(nameof(bundleOrderRepositories));
comboBoxEmployee.DataSource = employeeRepositories.GetEmployees();
comboBoxEmployee.DisplayMember = "ID";
comboBoxEmployee.ValueMember = "ID";
comboBoxAccessoriesID.DataSource = accessoriesRepositories.GetAccessories();
comboBoxAccessoriesID.DisplayMember = "Name";
comboBoxAccessoriesID.ValueMember = "ID";
comboBoxAccessoriesID.DataSource = orderRepositories.GetOrders();
comboBoxAccessoriesID.DisplayMember = "ID";
comboBoxAccessoriesID.ValueMember = "ID";
ColumnAccessories.DataSource = accessoriesRepositories.GetAccessories();
ColumnAccessories.DisplayMember = "Name";
ColumnAccessories.ValueMember = "ID";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxAccessoriesID.SelectedIndex < 1 || comboBoxOrderID.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные данные");
}
if (dataGridView.RowCount < 1 || comboBoxEmployee.SelectedIndex < 0) throw new Exception("Имеются не заполненные поля");
if (_bundleOrderID.HasValue)
{
_bundleOrderRepositories.UpdateBundleOrder(CreateBundleOrder(_bundleOrderID.Value));
}
else
{
_bundleOrderRepositories.CreateBundleOrder(CreateBundleOrder(0));
}
var employee = _employeeRepositories.GetEmployeerByID((int)comboBoxEmployee.SelectedItem);
_employeeRepositories.CreateEmployee(Employee.CreateEmployee(employee.ID, employee.PositionEmployee, employee.FirstName, employee.SecondName, employee.Surname, CreateListIBundleOrderFromDataGrid()));
Close();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
@ -76,9 +45,21 @@ namespace ProjectOptika.Scripts.Forms
Close();
}
private BundleOrder CreateBundleOrder(int id)
private List<BundleOrder> CreateListIBundleOrderFromDataGrid()
{
return BundleOrder.CreateBundleOrder(id, (int)comboBoxAccessoriesID.SelectedValue, (int)comboBoxOrderID.SelectedValue);
var list = new List<BundleOrder>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumnAccessories"].Value == null || row.Cells["ColumnCost"].Value == null)
{
continue;
}
list.Add(BundleOrder.CreateBundleOrder(0, Convert.ToInt32(row.Cells["ColumnAccessories"].Value), Convert.ToInt32(row.Cells["ColumnCost"].Value)));
}
return list;
}
}
}

View File

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

View File

@ -1,126 +0,0 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormBundleOrders
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
buttonRemove = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonRemove);
panel1.Controls.Add(buttonUpdate);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(696, 0);
panel1.Name = "panel1";
panel1.Size = new Size(104, 450);
panel1.TabIndex = 8;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources.Remove;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(3, 166);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(96, 71);
buttonRemove.TabIndex = 2;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(3, 89);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(96, 71);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(3, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 9;
//
// FormBundleOrders
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormBundleOrders";
Text = "FormBundleOrders";
Load += Form_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -1,97 +0,0 @@
using ProjectOptika.Scripts.Repositories;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormBundleOrders : Form
{
private readonly IUnityContainer _container;
private readonly IBundleOrderRepositories _bundleOrderRepositories;
public FormBundleOrders(IUnityContainer container, IBundleOrderRepositories bundleOrderRepositories)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_bundleOrderRepositories = bundleOrderRepositories ??
throw new ArgumentException(nameof(bundleOrderRepositories));
}
private void Form_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormBundleOrder>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
try
{
var form = _container.Resolve<FormBundleOrder>();
form.ID = findID;
form.ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
try
{
_bundleOrderRepositories.DeleteItemOrder(findID);
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _bundleOrderRepositories.GetBundleOrders();
private bool TryGetIdentifierFromSelectedRows(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
return true;
}
}
}

View File

@ -0,0 +1,162 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormEmployee
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
checkedListBoxPositionEmployee = new CheckedListBox();
labelFirstName = new Label();
textBoxFirstName = new TextBox();
textBoxSecondName = new TextBox();
labelSecondName = new Label();
textBoxSurname = new TextBox();
labelSurname = new Label();
labelPositionEmployee = new Label();
buttonCancel = new Button();
buttonSave = new Button();
SuspendLayout();
//
// checkedListBoxPositionEmployee
//
checkedListBoxPositionEmployee.FormattingEnabled = true;
checkedListBoxPositionEmployee.Location = new Point(298, 45);
checkedListBoxPositionEmployee.Name = "checkedListBoxPositionEmployee";
checkedListBoxPositionEmployee.Size = new Size(225, 180);
checkedListBoxPositionEmployee.TabIndex = 0;
//
// labelFirstName
//
labelFirstName.AutoSize = true;
labelFirstName.Location = new Point(12, 9);
labelFirstName.Name = "labelFirstName";
labelFirstName.Size = new Size(39, 20);
labelFirstName.TabIndex = 1;
labelFirstName.Text = "Имя";
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(109, 6);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(125, 27);
textBoxFirstName.TabIndex = 2;
//
// textBoxSecondName
//
textBoxSecondName.Location = new Point(109, 54);
textBoxSecondName.Name = "textBoxSecondName";
textBoxSecondName.Size = new Size(125, 27);
textBoxSecondName.TabIndex = 4;
//
// labelSecondName
//
labelSecondName.AutoSize = true;
labelSecondName.Location = new Point(12, 57);
labelSecondName.Name = "labelSecondName";
labelSecondName.Size = new Size(72, 20);
labelSecondName.TabIndex = 3;
labelSecondName.Text = "Отчество";
//
// textBoxSurname
//
textBoxSurname.Location = new Point(109, 105);
textBoxSurname.Name = "textBoxSurname";
textBoxSurname.Size = new Size(125, 27);
textBoxSurname.TabIndex = 6;
//
// labelSurname
//
labelSurname.AutoSize = true;
labelSurname.Location = new Point(12, 108);
labelSurname.Name = "labelSurname";
labelSurname.Size = new Size(74, 20);
labelSurname.TabIndex = 5;
labelSurname.Text = "Фимилия";
//
// labelPositionEmployee
//
labelPositionEmployee.AutoSize = true;
labelPositionEmployee.Location = new Point(298, 13);
labelPositionEmployee.Name = "labelPositionEmployee";
labelPositionEmployee.Size = new Size(86, 20);
labelPositionEmployee.TabIndex = 7;
labelPositionEmployee.Text = "Должность";
//
// buttonCancel
//
buttonCancel.Location = new Point(151, 196);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 15;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(12, 196);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 14;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// FormEmployee
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(537, 255);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelPositionEmployee);
Controls.Add(textBoxSurname);
Controls.Add(labelSurname);
Controls.Add(textBoxSecondName);
Controls.Add(labelSecondName);
Controls.Add(textBoxFirstName);
Controls.Add(labelFirstName);
Controls.Add(checkedListBoxPositionEmployee);
Name = "FormEmployee";
Text = "FormEmployee";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckedListBox checkedListBoxPositionEmployee;
private Label labelFirstName;
private TextBox textBoxFirstName;
private TextBox textBoxSecondName;
private Label labelSecondName;
private TextBox textBoxSurname;
private Label labelSurname;
private Label labelPositionEmployee;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,99 @@
using ProjectOptika.Scripts.Entities.Enums;
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormEmployee : Form
{
private readonly IEmployeeRepositories _employeeRepositories;
private int? _employeeID;
public int ID
{
set
{
try
{
var employee = _employeeRepositories.GetEmployeerByID(value);
if (employee == null) throw new InvalidDataException(nameof(employee));
_employeeID = employee.ID;
textBoxFirstName.Text = employee.FirstName;
textBoxSecondName.Text = employee.SecondName;
textBoxSurname.Text = employee.Surname;
foreach(PositionEmployee element in Enum.GetValues(typeof(PositionEmployee)))
{
if ((element & employee.PositionEmployee) != 0)
{
checkedListBoxPositionEmployee.SetItemChecked(checkedListBoxPositionEmployee.Items.IndexOf(element), true);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormEmployee(IEmployeeRepositories employeeRepositories)
{
InitializeComponent();
_employeeRepositories = employeeRepositories ??
throw new ArgumentNullException(nameof(employeeRepositories));
foreach (var i in Enum.GetValues(typeof(PositionEmployee)))
{
checkedListBoxPositionEmployee.Items.Add(i);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxSecondName.Text) || string.IsNullOrEmpty(textBoxSurname.Text) || string.IsNullOrEmpty(textBoxFirstName.Text))
{
throw new Exception("Имеются незаполненные данные");
}
if (_employeeID.HasValue)
{
_employeeRepositories.UpdateEmployee(CreateEmployee(_employeeID.Value));
}
else
{
_employeeRepositories.CreateEmployee(CreateEmployee(0));
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Employee CreateEmployee(int id)
{
PositionEmployee positionEmployee = PositionEmployee.None;
foreach(var element in checkedListBoxPositionEmployee.CheckedItems)
{
positionEmployee |= (PositionEmployee)element;
}
return Employee.CreateEmployee(id, positionEmployee, textBoxFirstName.Text, textBoxSecondName.Text, textBoxSurname.Text, null);
}
}
}

View File

@ -1,6 +1,6 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormOrders
partial class FormEmplyees
{
/// <summary>
/// Required designer variable.
@ -100,15 +100,15 @@
dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 7;
//
// FormOrders
// FormEmplyees
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormOrders";
Text = "Заказ";
Name = "FormEmplyees";
Text = "FormEmplyees";
Load += Form_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();

View File

@ -1,23 +1,33 @@
using ProjectOptika.Scripts.Repositories;
using ProjectOptika.Scripts.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormOrders : Form
public partial class FormEmplyees : Form
{
private readonly IUnityContainer _container;
private readonly IOrderRepositories _orderRepositories;
private readonly IEmployeeRepositories _employeeRepositories;
public FormOrders(IUnityContainer container, IOrderRepositories orderRepositories)
public FormEmplyees(IUnityContainer container, IEmployeeRepositories employeeRepositories)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_orderRepositories = orderRepositories ??
throw new ArgumentException(nameof(orderRepositories));
_employeeRepositories = employeeRepositories ??
throw new ArgumentException(nameof(employeeRepositories));
}
private void Form_Load(object sender, EventArgs e)
@ -36,7 +46,7 @@ namespace ProjectOptika.Scripts.Forms
{
try
{
_container.Resolve<FormOrder>().ShowDialog();
_container.Resolve<FormEmployee>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
@ -51,7 +61,7 @@ namespace ProjectOptika.Scripts.Forms
try
{
var form = _container.Resolve<FormOrder>();
var form = _container.Resolve<FormEmployee>();
form.ID = findID;
form.ShowDialog();
LoadList();
@ -70,7 +80,7 @@ namespace ProjectOptika.Scripts.Forms
try
{
_orderRepositories.DeleteOrder(findID);
_employeeRepositories.DeleteEmployee(findID);
LoadList();
}
catch (System.Exception ex)
@ -79,7 +89,7 @@ namespace ProjectOptika.Scripts.Forms
}
}
private void LoadList() => dataGridView.DataSource = _orderRepositories.GetOrders();
private void LoadList() => dataGridView.DataSource = _employeeRepositories.GetEmployees();
private bool TryGetIdentifierFromSelectedRows(out int id)
{

View File

@ -28,118 +28,122 @@
/// </summary>
private void InitializeComponent()
{
labelCount = new Label();
numericUpDownCount = new NumericUpDown();
comboBoxAccessoriesID = new ComboBox();
labelAccessoriesID = new Label();
labelOrderID = new Label();
comboBoxOrderID = new ComboBox();
buttonCancel = new Button();
groupBoxOrders = new GroupBox();
dataGridView = new DataGridView();
ColumnAccessories = new DataGridViewComboBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
labelEmployee = new Label();
comboBoxEmployee = new ComboBox();
buttonSave = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
buttonCancel = new Button();
groupBoxOrders.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// labelCount
// groupBoxOrders
//
labelCount.AutoSize = true;
labelCount.Location = new Point(12, 9);
labelCount.Name = "labelCount";
labelCount.Size = new Size(90, 20);
labelCount.TabIndex = 0;
labelCount.Text = "Количество";
groupBoxOrders.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxOrders.Controls.Add(dataGridView);
groupBoxOrders.Location = new Point(4, 53);
groupBoxOrders.Name = "groupBoxOrders";
groupBoxOrders.Size = new Size(309, 336);
groupBoxOrders.TabIndex = 0;
groupBoxOrders.TabStop = false;
groupBoxOrders.Text = "Заказы";
//
// numericUpDownCount
// dataGridView
//
numericUpDownCount.Location = new Point(187, 7);
numericUpDownCount.Name = "numericUpDownCount";
numericUpDownCount.Size = new Size(154, 27);
numericUpDownCount.TabIndex = 1;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnAccessories, ColumnCount });
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(3, 23);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.Size = new Size(303, 310);
dataGridView.TabIndex = 0;
//
// comboBoxAccessoriesID
// ColumnAccessories
//
comboBoxAccessoriesID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxAccessoriesID.FormattingEnabled = true;
comboBoxAccessoriesID.Location = new Point(186, 60);
comboBoxAccessoriesID.Name = "comboBoxAccessoriesID";
comboBoxAccessoriesID.Size = new Size(155, 28);
comboBoxAccessoriesID.TabIndex = 2;
ColumnAccessories.HeaderText = "Аксессуар";
ColumnAccessories.MinimumWidth = 6;
ColumnAccessories.Name = "ColumnAccessories";
ColumnAccessories.Width = 125;
//
// labelAccessoriesID
// ColumnCount
//
labelAccessoriesID.AutoSize = true;
labelAccessoriesID.Location = new Point(12, 63);
labelAccessoriesID.Name = "labelAccessoriesID";
labelAccessoriesID.Size = new Size(156, 20);
labelAccessoriesID.TabIndex = 3;
labelAccessoriesID.Text = "Название аксуссуара";
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
ColumnCount.Width = 125;
//
// labelOrderID
// labelEmployee
//
labelOrderID.AutoSize = true;
labelOrderID.Location = new Point(13, 116);
labelOrderID.Name = "labelOrderID";
labelOrderID.Size = new Size(73, 20);
labelOrderID.TabIndex = 5;
labelOrderID.Text = "ID заказа";
labelEmployee.AutoSize = true;
labelEmployee.Location = new Point(12, 9);
labelEmployee.Name = "labelEmployee";
labelEmployee.Size = new Size(82, 20);
labelEmployee.TabIndex = 1;
labelEmployee.Text = "Сотрудник";
//
// comboBoxOrderID
// comboBoxEmployee
//
comboBoxOrderID.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxOrderID.FormattingEnabled = true;
comboBoxOrderID.Location = new Point(186, 113);
comboBoxOrderID.Name = "comboBoxOrderID";
comboBoxOrderID.Size = new Size(155, 28);
comboBoxOrderID.TabIndex = 4;
//
// buttonCancel
//
buttonCancel.Location = new Point(187, 158);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
comboBoxEmployee.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(100, 6);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(190, 28);
comboBoxEmployee.TabIndex = 2;
//
// buttonSave
//
buttonSave.Location = new Point(61, 158);
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(12, 409);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 8;
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(212, 409);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отменить";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormItemOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(349, 203);
ClientSize = new Size(318, 450);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelOrderID);
Controls.Add(comboBoxOrderID);
Controls.Add(labelAccessoriesID);
Controls.Add(comboBoxAccessoriesID);
Controls.Add(numericUpDownCount);
Controls.Add(labelCount);
Controls.Add(comboBoxEmployee);
Controls.Add(labelEmployee);
Controls.Add(groupBoxOrders);
Name = "FormItemOrder";
Text = "FormItemOrder";
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
groupBoxOrders.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelCount;
private NumericUpDown numericUpDownCount;
private ComboBox comboBoxAccessoriesID;
private Label labelAccessoriesID;
private Label labelOrderID;
private ComboBox comboBoxOrderID;
private Button buttonCancel;
private GroupBox groupBoxOrders;
private Label labelEmployee;
private ComboBox comboBoxEmployee;
private DataGridView dataGridView;
private Button buttonSave;
private Button buttonCancel;
private DataGridViewComboBoxColumn ColumnAccessories;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -5,79 +5,59 @@ namespace ProjectOptika.Scripts.Forms
{
public partial class FormItemOrder : Form
{
private readonly IItemOrderRepositories _itemOrderRepositories;
private IOrderRepositories _orderRepositories;
private int? _itemOrderID;
public int ID
{
set
{
try
{
var itemOrder = _itemOrderRepositories.GetItemOrderByID(value);
if (itemOrder == null) throw new InvalidDataException(nameof(itemOrder));
_itemOrderID = itemOrder.ID;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormItemOrder(IItemOrderRepositories itemOrderRepositories, IAccessoriesRepositories accessoriesRepositories, IOrderRepositories orderRepositories)
public FormItemOrder(IOrderRepositories orderRepositories, IEmployeeRepositories employeeRepositories, IAccessoriesRepositories accessoriesRepositories)
{
InitializeComponent();
_itemOrderRepositories = itemOrderRepositories
?? throw new ArgumentNullException(nameof(itemOrderRepositories));
_orderRepositories = orderRepositories ??
throw new ArgumentNullException(nameof(orderRepositories));
comboBoxAccessoriesID.DataSource = accessoriesRepositories.GetAccessories();
comboBoxAccessoriesID.DisplayMember = "Name";
comboBoxAccessoriesID.ValueMember = "ID";
comboBoxEmployee.DataSource = employeeRepositories.GetEmployees();
comboBoxEmployee.DisplayMember = "FirstName";
comboBoxEmployee.ValueMember = "ID";
comboBoxAccessoriesID.DataSource = orderRepositories.GetOrders();
comboBoxAccessoriesID.DisplayMember = "ID";
comboBoxAccessoriesID.ValueMember = "ID";
ColumnAccessories.DataSource = accessoriesRepositories.GetAccessories();
ColumnAccessories.DisplayMember = "Name";
ColumnAccessories.ValueMember = "ID";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxAccessoriesID.SelectedIndex < 1 || comboBoxOrderID.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные данные");
}
if (dataGridView.RowCount < 1 || comboBoxEmployee.SelectedIndex < 0) throw new Exception("Имеются не заполненные поля");
_orderRepositories.CreateOrder(Order.CreateOrder(0, (int)comboBoxEmployee.SelectedItem, 0, CreateListItemOrderFromDataGrid()));
if (_itemOrderID.HasValue)
{
_itemOrderRepositories.UpdateItemOrder(CreateItemOrder(_itemOrderID.Value));
}
else
{
_itemOrderRepositories.CreateItemOrder(CreateItemOrder(0));
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private ItemOrder CreateItemOrder(int id)
private List<ItemOrder> CreateListItemOrderFromDataGrid()
{
return ItemOrder.CreateItemOrder(id, (int)comboBoxAccessoriesID.SelectedValue, (int)comboBoxOrderID.SelectedValue, (int)numericUpDownCount.Value);
var list = new List<ItemOrder>();
foreach(DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumnAccessories"].Value == null || row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(ItemOrder.CreateItemOrder(0, Convert.ToInt32(row.Cells["ColumnAccessories"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
}
}

View File

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

View File

@ -1,126 +0,0 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormItemOrders
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel1 = new Panel();
buttonRemove = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(buttonRemove);
panel1.Controls.Add(buttonUpdate);
panel1.Controls.Add(buttonAdd);
panel1.Dock = DockStyle.Right;
panel1.Location = new Point(696, 0);
panel1.Name = "panel1";
panel1.Size = new Size(104, 450);
panel1.TabIndex = 6;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources.Remove;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(3, 166);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(96, 71);
buttonRemove.TabIndex = 2;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(3, 89);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(96, 71);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(3, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 7;
//
// FormItemOrders
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel1);
Controls.Add(dataGridView);
Name = "FormItemOrders";
Text = "FormItemOrders";
Load += Form_Load;
panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel1;
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -1,97 +0,0 @@
using ProjectOptika.Scripts.Repositories;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormItemOrders : Form
{
private readonly IUnityContainer _container;
private readonly IItemOrderRepositories _itemOrderRepositories;
public FormItemOrders(IUnityContainer container, IItemOrderRepositories itemOrderRepositories)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_itemOrderRepositories = itemOrderRepositories ??
throw new ArgumentException(nameof(itemOrderRepositories));
}
private void Form_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormItemOrder>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
try
{
var form = _container.Resolve<FormItemOrder>();
form.ID = findID;
form.ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
try
{
_itemOrderRepositories.DeleteItemOrder(findID);
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _itemOrderRepositories.GetItemOrders();
private bool TryGetIdentifierFromSelectedRows(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
return true;
}
}
}

View File

@ -1,80 +0,0 @@
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormLen : Form
{
private readonly IAccessoriesRepositories _accessoriesRepositories;
private readonly ILensRepositories _lensRepositories;
private int? _accessoriesID;
public int ID
{
set
{
try
{
var accessories = _accessoriesRepositories.GetAccessoriesByID(value);
if (accessories == null) throw new InvalidDataException(nameof(accessories));
_accessoriesID = accessories.ID;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormLen(IAccessoriesRepositories accessoriesRepositories, ILensRepositories lensRepositories)
{
InitializeComponent();
_accessoriesRepositories = accessoriesRepositories
?? throw new ArgumentNullException(nameof(accessoriesRepositories));
_lensRepositories = lensRepositories
?? throw new ArgumentNullException(nameof(lensRepositories));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxMaterial.Text) || string.IsNullOrEmpty(textBoxAstigmatism.Text) ||
string.IsNullOrEmpty(textBoxDioptericity.Text) || string.IsNullOrEmpty(textBoxOriginCountry.Text))
{
throw new Exception("Имеются незаполненные данные");
}
if (_accessoriesID.HasValue)
{
_lensRepositories.UpdateLens(CreateLens(_accessoriesID.Value));
}
else
{
_lensRepositories.CreateLens(CreateLens(0));
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Lens CreateLens(int id)
{
return Lens.CreateLens(id, textBoxMaterial.Text, textBoxAstigmatism.Text, textBoxDioptericity.Text, textBoxOriginCountry.Text, (double)numericUpDownTimeProduction.Value);
}
}
}

View File

@ -31,8 +31,8 @@
menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
accessoriesToolStripMenuItem = new ToolStripMenuItem();
orderToolStripMenuItem = new ToolStripMenuItem();
lensToolStripMenuItem = new ToolStripMenuItem();
сотрудникToolStripMenuItem = new ToolStripMenuItem();
оперToolStripMenuItem = new ToolStripMenuItem();
itemOrderToolStripMenuItem = new ToolStripMenuItem();
bundleOrderToolStripMenuItem = new ToolStripMenuItem();
@ -52,7 +52,7 @@
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { accessoriesToolStripMenuItem, orderToolStripMenuItem, lensToolStripMenuItem });
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { accessoriesToolStripMenuItem, lensToolStripMenuItem, сотрудникToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
@ -64,20 +64,20 @@
accessoriesToolStripMenuItem.Text = "Аксессуар";
accessoriesToolStripMenuItem.Click += AccessoriesToolStripMenuItem_Click;
//
// orderToolStripMenuItem
//
orderToolStripMenuItem.Name = "orderToolStripMenuItem";
orderToolStripMenuItem.Size = new Size(224, 26);
orderToolStripMenuItem.Text = "Заказ";
orderToolStripMenuItem.Click += OrderToolStripMenuItem_Click;
//
// lensToolStripMenuItem
//
lensToolStripMenuItem.Name = "lensToolStripMenuItem";
lensToolStripMenuItem.Size = new Size(224, 26);
lensToolStripMenuItem.Text = "Линзы";
lensToolStripMenuItem.Text = "Характеристики";
lensToolStripMenuItem.Click += LensToolStripMenuItem_Click;
//
// сотрудникToolStripMenuItem
//
сотрудникToolStripMenuItem.Name = "сотрудникToolStripMenuItem";
сотрудникToolStripMenuItem.Size = new Size(224, 26);
сотрудникToolStripMenuItem.Text = "Сотрудник";
сотрудникToolStripMenuItem.Click += EmplyeeToolStripMenuItem_Click;
//
// оперToolStripMenuItem
//
оперToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { itemOrderToolStripMenuItem, bundleOrderToolStripMenuItem });
@ -128,8 +128,8 @@
private ToolStripMenuItem отчетToolStripMenuItem;
private ToolStripMenuItem accessoriesToolStripMenuItem;
private ToolStripMenuItem itemOrderToolStripMenuItem;
private ToolStripMenuItem orderToolStripMenuItem;
private ToolStripMenuItem lensToolStripMenuItem;
private ToolStripMenuItem bundleOrderToolStripMenuItem;
private ToolStripMenuItem сотрудникToolStripMenuItem;
}
}

View File

@ -27,23 +27,11 @@ namespace ProjectOptika
}
}
private void OrderToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormOrders>().ShowDialog();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LensToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormLens>().ShowDialog();
_container.Resolve<FormSpecifications>().ShowDialog();
}
catch (System.Exception ex)
{
@ -55,7 +43,7 @@ namespace ProjectOptika
{
try
{
_container.Resolve<FormItemOrders>().ShowDialog();
_container.Resolve<FormItemOrder>().ShowDialog();
}
catch (System.Exception ex)
{
@ -67,7 +55,19 @@ namespace ProjectOptika
{
try
{
_container.Resolve<FormBundleOrders>().ShowDialog();
_container.Resolve<FormBundleOrder>().ShowDialog();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void EmplyeeToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormEmplyees>().ShowDialog();
}
catch (System.Exception ex)
{

View File

@ -1,97 +0,0 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormOrder
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
labelTotalCost = new Label();
numericUpDownTotalCost = new NumericUpDown();
buttonCancel = new Button();
buttonSave = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownTotalCost).BeginInit();
SuspendLayout();
//
// labelTotalCost
//
labelTotalCost.AutoSize = true;
labelTotalCost.Location = new Point(11, 12);
labelTotalCost.Name = "labelTotalCost";
labelTotalCost.Size = new Size(133, 20);
labelTotalCost.TabIndex = 1;
labelTotalCost.Text = "Общая стоимость";
//
// numericUpDownTotalCost
//
numericUpDownTotalCost.Location = new Point(150, 12);
numericUpDownTotalCost.Name = "numericUpDownTotalCost";
numericUpDownTotalCost.Size = new Size(180, 27);
numericUpDownTotalCost.TabIndex = 2;
//
// buttonCancel
//
buttonCancel.Location = new Point(150, 70);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 13;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// buttonSave
//
buttonSave.Location = new Point(11, 70);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 12;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
//
// FormOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(342, 111);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownTotalCost);
Controls.Add(labelTotalCost);
Name = "FormOrder";
Text = "Заказ";
((System.ComponentModel.ISupportInitialize)numericUpDownTotalCost).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelOrderDate;
private Label labelTotalCost;
private NumericUpDown numericUpDownTotalCost;
private DateTimePicker dateTimePicker1;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -1,70 +0,0 @@
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormOrder : Form
{
private readonly IOrderRepositories _orderRepositories;
private int? _orderID;
public int ID
{
set
{
try
{
var accessory = _orderRepositories.GetOrderByID(value);
if (accessory == null) throw new InvalidDataException(nameof(accessory));
_orderID = accessory.ID;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormOrder(IOrderRepositories orderRepositories)
{
InitializeComponent();
_orderRepositories = orderRepositories
?? throw new ArgumentNullException(nameof(orderRepositories));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (_orderID.HasValue)
{
_orderRepositories.UpdateOrder(CreateOrder(_orderID.Value));
}
else
{
_orderRepositories.CreateOrder(CreateOrder(0));
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Order CreateOrder(int id)
{
return Order.CreateOrder(id, (double)numericUpDownTotalCost.Value);
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,6 +1,6 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormLen
partial class FormSpecification
{
/// <summary>
/// Required designer variable.
@ -131,6 +131,7 @@
buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
@ -140,8 +141,9 @@
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// FormLen
// FormSpecification
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
@ -158,7 +160,7 @@
Controls.Add(labelAstigmatism);
Controls.Add(textBoxMaterial);
Controls.Add(labelMaterial);
Name = "FormLen";
Name = "FormSpecification";
Text = "Линзы";
((System.ComponentModel.ISupportInitialize)numericUpDownTimeProduction).EndInit();
ResumeLayout(false);

View File

@ -0,0 +1,83 @@
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormSpecification : Form
{
private readonly ISpecificationsRepositories _specificationsRepositories;
private int? _specificationsID;
private int? _accessoriesID;
public int ID
{
set
{
try
{
var specifications = _specificationsRepositories.GetSpecificationsByID(value);
if (specifications == null) throw new InvalidDataException(nameof(specifications));
_specificationsID = specifications.ID;
_accessoriesID = specifications.AccessoriesID;
textBoxMaterial.Text = specifications.Material;
textBoxAstigmatism.Text = specifications.Astigmatism;
textBoxDioptericity.Text = specifications.Dioptericity;
textBoxOriginCountry.Text = specifications.OriginCountry;
numericUpDownTimeProduction.Value = (decimal)specifications.TimeProduction;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormSpecification(ISpecificationsRepositories specifications)
{
InitializeComponent();
_specificationsRepositories = specifications
?? throw new ArgumentNullException(nameof(specifications));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxMaterial.Text) || string.IsNullOrEmpty(textBoxAstigmatism.Text) ||
string.IsNullOrEmpty(textBoxDioptericity.Text) || string.IsNullOrEmpty(textBoxOriginCountry.Text))
{
throw new Exception("Имеются незаполненные данные");
}
if (_specificationsID.HasValue)
{
_specificationsRepositories.UpdateSpecifications(CreateSpecifications(_specificationsID.Value, _accessoriesID.Value));
}
else
{
_specificationsRepositories.CreateSpecifications(CreateSpecifications(0, 0));
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Specifications CreateSpecifications(int id, int accessoriesID)
{
return Specifications.CreateSpecifications(id, accessoriesID, textBoxMaterial.Text, textBoxAstigmatism.Text, textBoxDioptericity.Text, textBoxOriginCountry.Text, (double)numericUpDownTimeProduction.Value);
}
}
}

View File

@ -1,6 +1,6 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormLens
partial class FormSpecifications
{
/// <summary>
/// Required designer variable.

View File

@ -3,13 +3,13 @@ using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormLens : Form
public partial class FormSpecifications : Form
{
private readonly IUnityContainer _container;
private readonly ILensRepositories _lensRepositories;
private readonly ISpecificationsRepositories _lensRepositories;
public FormLens(IUnityContainer container, ILensRepositories lensRepositories)
public FormSpecifications(IUnityContainer container, ISpecificationsRepositories lensRepositories)
{
InitializeComponent();
@ -36,7 +36,7 @@ namespace ProjectOptika.Scripts.Forms
{
try
{
_container.Resolve<FormLen>().ShowDialog();
_container.Resolve<FormSpecification>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
@ -51,7 +51,7 @@ namespace ProjectOptika.Scripts.Forms
try
{
var form = _container.Resolve<FormLen>();
var form = _container.Resolve<FormSpecification>();
form.ID = findID;
form.ShowDialog();
LoadList();
@ -70,7 +70,7 @@ namespace ProjectOptika.Scripts.Forms
try
{
_lensRepositories.DeleteLens(findID);
_lensRepositories.DeleteSpecifications(findID);
LoadList();
}
catch (System.Exception ex)
@ -79,7 +79,7 @@ namespace ProjectOptika.Scripts.Forms
}
}
private void LoadList() => dataGridView.DataSource = _lensRepositories.GetLens();
private void LoadList() => dataGridView.DataSource = _lensRepositories.GetSpecifications();
private bool TryGetIdentifierFromSelectedRows(out int id)
{

View File

@ -23,8 +23,8 @@ namespace ProjectOptika.Scripts
container.RegisterType<IAccessoriesRepositories, AccessoriesRepositories>();
container.RegisterType<IBundleOrderRepositories, BundleOrderRepositories>();
container.RegisterType<IItemOrderRepositories, ItemOrderRepositories>();
container.RegisterType<ILensRepositories, LensRepositories>();
container.RegisterType<IEmployeeRepositories, EmployeeRepositories>();
container.RegisterType<ISpecificationsRepositories, SpecificationsRepositories>();
container.RegisterType<IOrderRepositories, OrderRepositories>();
return container;

View File

@ -0,0 +1,17 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface IEmployeeRepositories
{
IEnumerable<Employee> GetEmployees();
Employee GetEmployeerByID(int id);
void CreateEmployee(Employee employee);
void UpdateEmployee(Employee employee);
void DeleteEmployee(int id);
}
}

View File

@ -1,17 +0,0 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface IItemOrderRepositories
{
IEnumerable<ItemOrder> GetItemOrders(int? accessoriesID = null, int? orderID = null, int? count = null);
ItemOrder GetItemOrderByID(int id);
void CreateItemOrder(ItemOrder itemOrder);
void UpdateItemOrder(ItemOrder itemOrder);
void DeleteItemOrder(int id);
}
}

View File

@ -1,17 +0,0 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface ILensRepositories
{
IEnumerable<Lens> GetLens();
Lens GetLensByID(int id);
void CreateLens(Lens order);
void UpdateLens(Lens order);
void DeleteLens(int id);
}
}

View File

@ -0,0 +1,17 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface ISpecificationsRepositories
{
IEnumerable<Specifications> GetSpecifications();
Specifications GetSpecificationsByID(int id);
void CreateSpecifications(Specifications specifications);
void UpdateSpecifications(Specifications specifications);
void DeleteSpecifications(int id);
}
}

View File

@ -19,7 +19,7 @@ namespace ProjectOptika.Scripts.Repositories.Implementations
public BundleOrder GetBundleOrderByID(int id)
{
return BundleOrder.CreateBundleOrder(0,0,0);
return BundleOrder.CreateBundleOrder(0,0, 0.0);
}
public void UpdateBundleOrder(BundleOrder bundleOrder)

View File

@ -0,0 +1,29 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class EmployeeRepositories : IEmployeeRepositories
{
public void CreateEmployee(Employee employee)
{
}
public void DeleteEmployee(int id)
{
}
public Employee GetEmployeerByID(int id)
{
return Employee.CreateEmployee(0, Entities.Enums.PositionEmployee.None, string.Empty, string.Empty, string.Empty, null);
}
public IEnumerable<Employee> GetEmployees()
{
return [];
}
public void UpdateEmployee(Employee employee)
{
}
}
}

View File

@ -1,29 +0,0 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class ItemOrderRepositories : IItemOrderRepositories
{
public void CreateItemOrder(ItemOrder itemOrder)
{
}
public ItemOrder GetItemOrderByID(int id)
{
return ItemOrder.CreateItemOrder(0, 0, 0, 0);
}
public IEnumerable<ItemOrder> GetItemOrders(int? accessoriesID = null, int? orderID = null, int? count = null)
{
return [];
}
public void UpdateItemOrder(ItemOrder itemOrder)
{
}
public void DeleteItemOrder(int id)
{
}
}
}

View File

@ -1,29 +0,0 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class LensRepositories : ILensRepositories
{
public void CreateLens(Lens order)
{
}
public void DeleteLens(int id)
{
}
public IEnumerable<Lens> GetLens()
{
return [];
}
public Lens GetLensByID(int id)
{
return Lens.CreateLens(0, string.Empty, string.Empty, string.Empty, string.Empty, 0.0);
}
public void UpdateLens(Lens order)
{
}
}
}

View File

@ -14,7 +14,7 @@ namespace ProjectOptika.Scripts.Repositories.Implementations
public Order GetOrderByID(int id)
{
return Order.CreateOrder(0, 0);
return Order.CreateOrder(0, 0, 0.0, null);
}
public IEnumerable<Order> GetOrders()

View File

@ -0,0 +1,29 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class SpecificationsRepositories : ISpecificationsRepositories
{
public void CreateSpecifications(Specifications order)
{
}
public void DeleteSpecifications(int id)
{
}
public IEnumerable<Specifications> GetSpecifications()
{
return [];
}
public Specifications GetSpecificationsByID(int id)
{
return Specifications.CreateSpecifications(0, 0, string.Empty, string.Empty, string.Empty, string.Empty, 0.0);
}
public void UpdateSpecifications(Specifications order)
{
}
}
}