/
Purchases.aspx.cs
173 lines (142 loc) · 6.28 KB
/
Purchases.aspx.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
166
167
168
169
170
171
172
173
using System;
using System.Globalization;
public partial class Purchases : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if ((string)Session["StarID"] == null)
{
Response.Redirect("Login.aspx");
}
poDll.PurchaseOrder dll = new poDll.PurchaseOrder();
lblPoNumber.Text = dll.PURCHASE_GetNextPoNum();
btnSummate.Text = "Sum Totals";
btnSubmit.Visible = false;
}
protected void btnSummate_Click(object sender, EventArgs e)
{
poDll.PurchaseOrder dll = new poDll.PurchaseOrder();
if (btnSummate.Text == "Sum Totals" && tbUnitPrice1.Text != "")
{
float up1 = float.Parse(tbUnitPrice1.Text, CultureInfo.InvariantCulture);
int q1 = Int32.Parse(tbQuantity1.Text);
tbFinalAmount1.Text = (up1 * q1).ToString();
if (tbItem2.Text != "")
{
float up2 = float.Parse(tbUnitPrice2.Text, CultureInfo.InvariantCulture);
int q2 = Int32.Parse(tbQuantity2.Text);
tbFinalAmount2.Text = (up2 * q2).ToString();
}
if (tbItem3.Text != "")
{
float up3 = float.Parse(tbUnitPrice3.Text, CultureInfo.InvariantCulture);
int q3 = Int32.Parse(tbQuantity3.Text);
tbFinalAmount3.Text = (up3 * q3).ToString();
}
if (tbItem4.Text != "")
{
float up4 = float.Parse(tbUnitPrice4.Text, CultureInfo.InvariantCulture);
int q4 = Int32.Parse(tbQuantity4.Text);
tbFinalAmount4.Text = (up4 * q4).ToString();
}
if (tbItem5.Text != "")
{
float up5 = float.Parse(tbUnitPrice5.Text, CultureInfo.InvariantCulture);
int q5 = Int32.Parse(tbQuantity5.Text);
tbFinalAmount5.Text = (up5 * q5).ToString();
}
btnSummate.Visible = false;
btnSubmit.Visible = true;
btnSubmit.Text = "Submit Purchase Order";
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
poDll.PurchaseOrder dll = new poDll.PurchaseOrder();
if (tbItem1.Text != "")
{
string orderBy = Session["StarID"].ToString();
string vendor = dlVendor.Text;
int oNum = Int32.Parse(lblPoNumber.Text);
int lNum = Int32.Parse(lblLine1.Text);
string item = tbItem1.Text;
int qty = Int32.Parse(tbQuantity1.Text);
float uPrice = float.Parse(tbUnitPrice1.Text, CultureInfo.InvariantCulture);
float fPrice = float.Parse(tbFinalAmount1.Text, CultureInfo.InvariantCulture);
int iTotalRows;
iTotalRows = dll.PURCHASE_Insert(oNum, lNum, item, qty, uPrice, fPrice, orderBy, vendor);
if (iTotalRows > 0)
{
lblMessage.Text = "Your Order was recieved Succesfully";
}
}
if (tbItem2.Text != "")
{
string orderBy = Session["StarID"].ToString();
string vendor = dlVendor.Text;
int oNum = Int32.Parse(lblPoNumber.Text);
int lNum = Int32.Parse(lblLine2.Text);
string item = tbItem1.Text;
int qty = Int32.Parse(tbQuantity2.Text);
float uPrice = float.Parse(tbUnitPrice2.Text, CultureInfo.InvariantCulture);
float fPrice = float.Parse(tbFinalAmount2.Text, CultureInfo.InvariantCulture);
int iTotalRows;
iTotalRows = dll.PURCHASE_Insert(oNum, lNum, item, qty, uPrice, fPrice, orderBy, vendor);
if (iTotalRows > 0)
{
lblMessage.Text = "Your Order was recieved Succesfully";
}
}
if (tbItem3.Text != "")
{
string orderBy = Session["StarID"].ToString();
string vendor = dlVendor.Text;
int oNum = Int32.Parse(lblPoNumber.Text);
int lNum = Int32.Parse(lblLine3.Text);
string item = tbItem1.Text;
int qty = Int32.Parse(tbQuantity3.Text);
float uPrice = float.Parse(tbUnitPrice3.Text, CultureInfo.InvariantCulture);
float fPrice = float.Parse(tbFinalAmount3.Text, CultureInfo.InvariantCulture);
int iTotalRows;
iTotalRows = dll.PURCHASE_Insert(oNum, lNum, item, qty, uPrice, fPrice, orderBy, vendor);
if (iTotalRows > 0)
{
lblMessage.Text = "Your Order was recieved Succesfully";
}
}
if (tbItem4.Text != "")
{
string orderBy = Session["StarID"].ToString();
string vendor = dlVendor.Text;
int oNum = Int32.Parse(lblPoNumber.Text);
int lNum = Int32.Parse(lblLine4.Text);
string item = tbItem1.Text;
int qty = Int32.Parse(tbQuantity4.Text);
float uPrice = float.Parse(tbUnitPrice4.Text, CultureInfo.InvariantCulture);
float fPrice = float.Parse(tbFinalAmount4.Text, CultureInfo.InvariantCulture);
int iTotalRows;
iTotalRows = dll.PURCHASE_Insert(oNum, lNum, item, qty, uPrice, fPrice, orderBy, vendor);
if (iTotalRows > 0)
{
lblMessage.Text = "Your Order was recieved Succesfully";
}
}
if (tbItem5.Text != "")
{
string orderBy = Session["StarID"].ToString();
string vendor = dlVendor.Text;
int oNum = Int32.Parse(lblPoNumber.Text);
int lNum = Int32.Parse(lblLine5.Text);
string item = tbItem1.Text;
int qty = Int32.Parse(tbQuantity5.Text);
float uPrice = float.Parse(tbUnitPrice5.Text, CultureInfo.InvariantCulture);
float fPrice = float.Parse(tbFinalAmount5.Text, CultureInfo.InvariantCulture);
int iTotalRows;
iTotalRows = dll.PURCHASE_Insert(oNum, lNum, item, qty, uPrice, fPrice, orderBy, vendor);
if (iTotalRows > 0)
{
lblMessage.Text = "Your Order was recieved Succesfully";
}
}
}
}