-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateWorkOrder.cs
More file actions
112 lines (97 loc) · 4.26 KB
/
Copy pathUpdateWorkOrder.cs
File metadata and controls
112 lines (97 loc) · 4.26 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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;
//This form is used to update a work order. It allows the user to search for a work order by job number, and then update the work order details.
namespace AviationMaintenanceManagementSystem
{
public partial class UpdateWorkOrder : Form
{
private readonly IWorkOrderFeature _workOrderFeature;
private WorkOrderTemplate _currentWorkOrder;
public UpdateWorkOrder(IWorkOrderFeature workOrderFeature)
{
_workOrderFeature = workOrderFeature;
InitializeComponent();
btnSearch.Click += btnSearch_Click;
btnSave.Click += btnSave_Click;
btnDelete.Click += btnDelete_Click;
btnCancel.Click += btnCancel_Click;
}
private void btnSearch_Click(object sender, EventArgs e)
{
string jobNumber = txtJobNumber.Text;
_currentWorkOrder = _workOrderFeature.GetWorkOrderById(jobNumber);
if (_currentWorkOrder != null)
{
//Populate the form with the work order details
txtDiscrepancy.Text = _currentWorkOrder.Discrepancy;
txtNotes.Text = _currentWorkOrder.Notes;
txtWorkCenterId.Text = _currentWorkOrder.WorkCenter.Name;
txtCorrectiveAction.Text = _currentWorkOrder.CorrectiveAction;
txtEquipmentStatus.Text = _currentWorkOrder.EquipmentStatus;
txtDate.Text = _currentWorkOrder.Date.ToString();
txtTime.Text = _currentWorkOrder.Time.ToString();
txtSerialNo.Text = _currentWorkOrder.SerialNumber;
}
else
{
MessageBox.Show("Invalid Job Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnSave_Click(object sender, EventArgs e)
{
if (_currentWorkOrder != null)
{
_currentWorkOrder.Discrepancy = txtDiscrepancy.Text;
_currentWorkOrder.Notes = txtNotes.Text;
_currentWorkOrder.CorrectiveAction = txtCorrectiveAction.Text;
_currentWorkOrder.EquipmentStatus = txtEquipmentStatus.Text;
_currentWorkOrder.Date = DateTime.Parse(txtDate.Text);
_currentWorkOrder.Time = DateTime.Parse(txtTime.Text);
_currentWorkOrder.SerialNumber = txtSerialNo.Text;
_workOrderFeature.UpdateWorkOrder(_currentWorkOrder);
MessageBox.Show("Work Order Updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("No Work Order to update", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (_currentWorkOrder != null)
{
var confirmDelete = MessageBox.Show("Are you sure you want to delete this Work Order?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (confirmDelete == DialogResult.Yes)
{
_workOrderFeature.DeleteWorkOrder(_currentWorkOrder.JobNumber);
txtDiscrepancy.Text = "";
txtNotes.Text = "";
txtWorkCenterId.Text = "";
txtCorrectiveAction.Text = "";
txtEquipmentStatus.Text = "";
txtDate.Text = "";
txtTime.Text = "";
txtSerialNo.Text = "";
}
MessageBox.Show("Work Order Deleted", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("No Work Order to delete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}