-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddInventory.cs
More file actions
76 lines (68 loc) · 2.41 KB
/
Copy pathAddInventory.cs
File metadata and controls
76 lines (68 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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 AviationMaintenanceManagementSystem.Features;
using AviationMaintenanceManagementSystem.ModelClasses;
namespace AviationMaintenanceManagementSystem
{
public partial class AddInventory : Form
{
private readonly IInventoryFeature _inventoryFeature;
public AddInventory(IInventoryFeature inventoryFeature)
{
_inventoryFeature = inventoryFeature;
InitializeComponent();
btnCancel.Click += btnCancel_Click;
btnSave.Click += btnSave_Click;
}
private void btnSave_Click(object sender, EventArgs e)
{
if(int.TryParse(txtQuantity.Text, out int quantity) &&
decimal.TryParse(txtPrice.Text, out decimal pricPerUnit))
{
MessageBox.Show("Quantity must be an Integer");
return;
}
var inventory = new Inventory
{
PartNumber = txtPartNumber.Text,
Nomenclature = txtNomenclature.Text,
Quantity = Convert.ToInt32(txtQuantity.Text),
PricePerUnit = Convert.ToDecimal(txtPrice.Text),
Manufacturer = txtManufacturer.Text,
DeliveryStatus = txtDelivery.Text,
AssignedJobNumber = txtAssignedJobNumber.Text,
AssignedWorkCenter = txtWorkCenter.Text,
RecievedDate = Convert.ToDateTime(txtDateReceived.Text),
ReceivedBy = txtReceivedBy.Text
};
_inventoryFeature.CreateInventory(inventory);
MessageBox.Show("Inventory Added Successfully");
ClearForm();
this.Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void ClearForm()
{
txtPartNumber.Text = "";
txtNomenclature.Text = "";
txtQuantity.Text = "";
txtPrice.Text = "";
txtManufacturer.Text = "";
txtDelivery.Text = "";
txtAssignedJobNumber.Text = "";
txtWorkCenter.Text = "";
txtDateReceived.Text = "";
txtReceivedBy.Text = "";
}
}
}