-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCalculator.aspx.cs
187 lines (158 loc) · 7.19 KB
/
Calculator.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using System.Data;
public partial class Calculator : System.Web.UI.Page
{
#region Variable
static ILog logger = LogManager.GetLogger(typeof(Calculator));
DataTable dt;
#endregion
protected void Page_Load(object sender, EventArgs e)
{
((Label)Master.FindControl("lblHeader")).Text = "Calculator";
if (!IsPostBack)
{
FillState();
}
}
public void FillState()
{
Cls_CompletedQuoatationReportHelper objReport = new Cls_CompletedQuoatationReportHelper();
try
{
dt = objReport.GetStates();
dt.Rows.RemoveAt(5);
ddlDeparture.DataSource = dt;
ddlDeparture.DataBind();
ddlDeparture.Items.Insert(0, new ListItem("-Select State-", "0"));
ddlArrival.DataSource = dt;
ddlArrival.DataBind();
ddlArrival.Items.Insert(0, new ListItem("-Select State-", "0"));
}
catch (Exception ex)
{
logger.Error("Fill State Err - " + ex.Message);
}
finally
{
objReport = null;
dt = null;
}
}
protected void ddlArrival_SelectedIndexChanged(object sender, EventArgs e)
{
if (Convert.ToString(ddlArrival.SelectedItem).ToUpper() == "QLD")
{
ddlCylinders.Visible = true;
ddlGreenStar.Visible = false;
ddlGreenStar.SelectedValue = "-1";
}
else if (Convert.ToString(ddlArrival.SelectedItem).ToUpper() == "ACT")
{
ddlGreenStar.Visible = true;
ddlCylinders.Visible = false;
ddlCylinders.SelectedValue = "-1";
}
else
{
ddlCylinders.SelectedValue = "-1";
ddlCylinders.Visible = false;
ddlGreenStar.SelectedValue = "-1";
ddlGreenStar.Visible = false;
}
}
protected void imgCalculate_Click(object sender, ImageClickEventArgs e)
{
pnlCalculator.Visible = true;
Cls_Calculator objCalculator = new Cls_Calculator();
string FromState = Convert.ToString(ddlDeparture.SelectedItem).ToUpper();
string ToState = Convert.ToString(ddlArrival.SelectedItem).ToUpper();
double PurchasePrice = Convert.ToDouble(txtPP.Text);
double OnRoadPrice = 0;
try
{
objCalculator.FromStateID = Convert.ToInt32(ddlDeparture.SelectedValue);
objCalculator.ToStateID = Convert.ToInt32(ddlArrival.SelectedValue);
dt = objCalculator.GetCharges();
// Switch used to calculate onroad price of vehicle for different state
switch (Convert.ToString(ddlArrival.SelectedItem).ToUpper())
{
case "NSW":
OnRoadPrice = (PurchasePrice * 0.03) + ((PurchasePrice - 45000) > 0 ? (PurchasePrice - 45000) * 0.015 : 0);
break;
case "VIC":
OnRoadPrice = (PurchasePrice * 0.03) + ((PurchasePrice - 57466) > 0 ? (PurchasePrice - 57466) * 0.02 : 0);
// Changed on 22 Jun 12 from 5% to 3%
// OnRoadPrice = (PurchasePrice * 0.03) + ((PurchasePrice - 57009) > 0 ? (PurchasePrice - 57009) * 0.03 : 0);
break;
case "ACT":
// OnRoadPrice = (PurchasePrice * 0.03) + ((PurchasePrice - 45000) > 0 ? (PurchasePrice - 45000) * 0.015 : 0);
int GreenStars = Convert.ToInt32(ddlGreenStar.SelectedValue);
if (GreenStars == 0)
OnRoadPrice = 0;
else if (GreenStars == 2)
OnRoadPrice = (PurchasePrice * 0.02) + ((PurchasePrice - 45000) > 0 ? (PurchasePrice - 45000) * 0.02 : 0);
else if (GreenStars == 3)
OnRoadPrice = (PurchasePrice * 0.03) + ((PurchasePrice - 45000) > 0 ? (PurchasePrice - 45000) * 0.02 : 0);
else if (GreenStars == 4)
OnRoadPrice = (PurchasePrice * 0.04) + ((PurchasePrice - 45000) > 0 ? (PurchasePrice - 45000) * 0.02 : 0);
break;
case "QLD":
int Cylinder = Convert.ToInt32(ddlCylinders.SelectedValue);
if (Cylinder == 0)
OnRoadPrice = PurchasePrice * 0.02;
else if (Cylinder == 4)
OnRoadPrice = PurchasePrice * 0.03;
else if (Cylinder == 6)
OnRoadPrice = PurchasePrice * 0.035;
else if (Cylinder == 8)
OnRoadPrice = PurchasePrice * 0.04;
break;
case "WA":
if (PurchasePrice <= 25000)
OnRoadPrice = PurchasePrice * 0.275;
else if (PurchasePrice <= 50000)
OnRoadPrice = ((((PurchasePrice - 25000) / 6666) + 2.75) / 100) * PurchasePrice;
else
OnRoadPrice = PurchasePrice * 0.065;
break;
case "TAS":
if (PurchasePrice > 40000)
OnRoadPrice = PurchasePrice * 0.04;
else
OnRoadPrice = PurchasePrice * 0.03;
if (PurchasePrice < 40000 && PurchasePrice > 35000)
OnRoadPrice = OnRoadPrice + ((PurchasePrice - 35000) * 0.11);
break;
case "SA":
OnRoadPrice = PurchasePrice * 0.04;
break;
default:
break;
}
lblRegoCTP_ans.Text = Convert.ToString(dt.Rows[0]["RegoCTP"]);
lblStampDuty_ans.Text = Convert.ToString(OnRoadPrice);
OnRoadPrice = OnRoadPrice + Convert.ToDouble(dt.Rows[0]["RegoCTP"]);
lblfCharges_ans.Text = Convert.ToString(dt.Rows[0]["FreightCost"]);
lblHandlingFees_ans.Text = Convert.ToString(dt.Rows[0]["HandlingFee"]);
lblTotal_ans.Text = string.Format("{0:N2}", (Convert.ToDouble(dt.Rows[0]["FreightCost"]) + Convert.ToDouble(dt.Rows[0]["HandlingFee"]) + OnRoadPrice));
}
catch (Exception ex)
{
}
finally
{
}
}
protected void btnPrint_Click(object sender, ImageClickEventArgs e)
{
string strWindowParams = "menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=yes,left=200,top=20,width=700,height=450";
string strSCRIPT = "window.open('PrintCalculator.aspx?Departure=" + ddlDeparture.SelectedItem + "&DepartureValue=" + ddlDeparture.SelectedValue + " &Arrival=" + ddlArrival.SelectedItem + "&ArrivalValue=" + ddlArrival.SelectedValue + " &Cylinder=" + ddlCylinders.SelectedItem + "&CylinderValue=" + ddlCylinders.SelectedValue + " &PP=" + txtPP.Text + " &Stars=" + ddlGreenStar.SelectedItem + " &StarValue=" + ddlGreenStar.SelectedValue + "','my_win','" + strWindowParams + "')";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "_deo", strSCRIPT, true);
}
}