-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pick.cs
165 lines (140 loc) · 4.42 KB
/
Pick.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace LMSWarehouse
{
public partial class FrmPick : Form
{
private struct BinItem
{
public int BinID, BinQty;
public string ProductName, BinDescription;
}
private Wrapper WS = new Wrapper();
private int BinID;
private int ProductID;
private int OrderDetailID;
private int WarehouseID;
private int QTY;
private string ScanSKU;
private BinItem Item;
public FrmPick(int fOrderDetailID, int fBinID, int fProductID, int fWarehouseID, int fQty)
{
BinID = fBinID;
ProductID = fProductID;
OrderDetailID = fOrderDetailID;
WarehouseID = fWarehouseID;
QTY = fQty;
ScanSKU = "";
InitializeComponent();
}
private void toolStripButtonClose_Click(object sender, EventArgs e)
{
Close();
}
private void GetBinData(int fBinID)
{
try
{
int ItemIndex = -1;
for (int x = 0; x < dgBins.RowCount; x++)
{
if (BinID.ToString() == dgBins.Rows[x].Cells[0].Value.ToString().Trim())
{
ItemIndex = x;
}
Item.ProductName = dgBins.Rows[x].Cells[4].Value.ToString();
ScanSKU = dgBins.Rows[x].Cells[5].Value.ToString();
}
if (ItemIndex == -1)
{
BinID = 0;
Item.BinID = 0;
Item.BinDescription = "";
Item.BinQty = 0;
}
else
{
BinID = int.Parse(dgBins.Rows[ItemIndex].Cells[0].Value.ToString()); ;
Item.BinID = int.Parse(dgBins.Rows[ItemIndex].Cells[0].Value.ToString());
Item.BinDescription = dgBins.Rows[ItemIndex].Cells[2].Value.ToString();
Item.BinQty = int.Parse(dgBins.Rows[ItemIndex].Cells[1].Value.ToString());
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void LoadFrm()
{
try
{
DataSet ds = WS.GetBinList(ProductID, "", WarehouseID);
dgBins.DataSource = ds.Tables[0];
GetBinData(BinID);
lblBin.Text = Item.BinDescription;
lblProduct.Text = ScanSKU + ": " + Item.ProductName;
if (Item.BinQty < QTY)
{
txtQty.Text = Item.BinQty.ToString();
}
else
{
txtQty.Text = QTY.ToString();
}
}
catch
{
Item.BinID = 0;
BinID = 0;
}
}
private void toolStripButtonPick_Click(object sender, EventArgs e)
{
try
{
int QtyValid = 0;
if (Item.BinQty < QTY)
{
QtyValid = Item.BinQty;
}
else
{
QtyValid = QTY;
}
if (int.Parse(txtQty.Text) > QtyValid)
{
MessageBox.Show("Qty is more then Stock in Bin");
return;
}
else
{
if (BinID > 0)
{
OrderDetailID = WS.SetStockFromPick(WarehouseID, BinID, int.Parse(txtQty.Text), OrderDetailID);
}
else
if (int.Parse(txtQty.Text) > QtyValid)
{
MessageBox.Show("Bin Location is not valid");
return;
}
Close();
}
}
catch
{
MessageBox.Show("An error occured. Could not pick stock");
}
}
private void FrmPick_Load(object sender, EventArgs e)
{
LoadFrm();
}
}
}