-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllocateItem.xaml.cs
130 lines (109 loc) · 4.24 KB
/
AllocateItem.xaml.cs
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Equipment_Manager
{
/// <summary>
/// Interaction logic for AllocateItem.xaml
/// </summary>
public partial class AllocateItem : Window
{
DataTable values = DBManager.SelectFromAlocationRequests();
DataTable eqAll;
string selectedEqID="", selected_allocation_id="",fromSiteID="",toSiteID="";
public AllocateItem()
{
InitializeComponent();
try
{
allocation_request.ItemsSource = values.AsDataView();
}
catch (Exception ex)
{
}
}
private void alllocateButton_Click(object sender, RoutedEventArgs e)
{
try
{
if(selectedEqID!="" && selected_allocation_id != "")
{
string transportCost = "";
EnterTransportationCost nn = new EnterTransportationCost();
nn.ShowDialog();
if (nn.DialogResult.Value)
{
transportCost = nn.trCost;
}
string resp = DBManager.InsertIntoAllocationTable("('" + selected_allocation_id + "','" + selectedEqID + "','" + fromSiteID + "','" + toSiteID + "','"+transportCost+ "')");
if (resp.Contains("Success"))
{
myMessageBox mm = new myMessageBox("Successfully allocated. Waiting for OM approval", "Success", "OK", 0);
mm.ShowDialog();
// MessageBox.Show("Successfully Allocated waiting for OM approval", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
eqAll.Clear();
}
else
{
myMessageBox mm = new myMessageBox("Allocation Failed!\n Maybe the selected equipment id was already allocated to this project", "Error", "OK", 1);
mm.ShowDialog();
// MessageBox.Show("", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
eqAll.Clear();
}
}
}
catch
{
}
}
private void cancelRequest_Click(object sender, RoutedEventArgs e)
{
try
{
if (selected_allocation_id != "")
{
string query = "UPDATE `allocation_request` SET `request_status`='4' WHERE id='" + selected_allocation_id + "'";
DBManager.UpdateDatabaseQuery(query);
}
}
catch (Exception ex)
{
}
}
private void equipment_list_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
selectedEqID = eqAll.Rows[equipment_list.SelectedIndex][0].ToString();
fromSiteID=eqAll.Rows[equipment_list.SelectedIndex][1].ToString();
}
catch
{
}
}
private void allocation_request_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
toSiteID = values.Rows[allocation_request.SelectedIndex][3].ToString();
eqAll = DBManager.SelectEquipmentForAlocation(values.Rows[allocation_request.SelectedIndex][1].ToString(),toSiteID);
equipment_list.ItemsSource = eqAll.AsDataView();
selected_allocation_id = values.Rows[allocation_request.SelectedIndex][0].ToString();
}
catch
{
}
}
}
}