-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy patheditscript.aspx.cs
More file actions
172 lines (156 loc) · 7 KB
/
editscript.aspx.cs
File metadata and controls
172 lines (156 loc) · 7 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
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
using DataAccessLayer;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Analytics
{
public partial class editscript : System.Web.UI.Page
{
public string Symbol
{
get
{
return textboxSymbol.Text.Trim();
}
}
public string CompanyName
{
get
{
return textboxCompaName.Text.Trim();
}
}
public string PurchasePrice
{
get
{
return textboxPurchasePrice.Text.Trim();
}
}
public string PurchaseDate
{
get
{
return System.Convert.ToDateTime(textboxPurchaseDate.Text.ToString()).ToString();
}
}
public string PurchaseQty
{
get
{
return textboxQuantity.Text.Trim();
}
}
public string CommissionPaid
{
get
{
return textboxCommission.Text.Trim();
}
}
public string TotalCost
{
get
{
return labelTotalCost.Text.Trim();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if ( (Session["STOCKPORTFOLIONAME"] != null) && (Session["STOCKPORTFOLIOROWID"] != null))
{
//Master.Portfolio = Session["STOCKPORTFOLIONAME"].ToString();
if (!IsPostBack)
{
if (Request.QueryString.Count > 0)
{
textboxSymbol.Text = Request.QueryString["symbol"].ToString();
textboxCompaName.Text = System.Web.HttpUtility.HtmlDecode(Request.QueryString["companyname"].ToString());
textboxPurchasePrice.Text = Request.QueryString["price"].ToString();
//textboxPurchaseDate.Text = System.Convert.ToDateTime(Request.QueryString["date"].ToString()).ToString("yyyy-MM-ddThh:mm:ss");
textboxPurchaseDate.Text = System.Convert.ToDateTime(Request.QueryString["date"].ToString()).ToString("yyyy-MM-dd");
textboxQuantity.Text = Request.QueryString["qty"].ToString();
textboxCommission.Text = Request.QueryString["comission"].ToString();
labelTotalCost.Text = Request.QueryString["cost"].ToString();
textboxExchDisp.Text = System.Web.HttpUtility.HtmlDecode(Request.QueryString["exch"].ToString());
//textboxExchDisp.Text = System.Web.HttpUtility.HtmlDecode(Request.QueryString["exchDisp"].ToString());
//textboxType.Text = System.Web.HttpUtility.HtmlDecode(Request.QueryString["type"].ToString());
//textboxTypeDisp.Text = System.Web.HttpUtility.HtmlDecode(Request.QueryString["typeDisp"].ToString());
}
}
}
else
{
//Response.Write("<script language=javascript>alert('" + common.noPortfolioName + "')</script>");
Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.noPortfolioName + "');", true);
//Response.Redirect(".\\Default.aspx");
Response.Redirect("~/Default.aspx");
}
}
protected void buttonSave_Click(object sender, EventArgs e)
{
bool breturn = false;
if (textboxSymbol.Text.Length > 0 && textboxPurchaseDate.Text.Length > 0 && textboxPurchasePrice.Text.Length > 0 &&
textboxQuantity.Text.Length > 0 && textboxCommission.Text.Length > 0 && labelTotalCost.Text.Length > 0 &&
textboxCompaName.Text.Length > 0)
{
buttonCalCost_Click(null, null);
//Server.Transfer("~/openportfolio.aspx");
try
{
StockManager stockManager = new StockManager();
breturn = stockManager.updateTransaction(Session["STOCKPORTFOLIOROWID"].ToString(), PurchasePrice, PurchaseDate, PurchaseQty, CommissionPaid, TotalCost);
}
catch (Exception ex)
{
//Response.Write("<script language=javascript>alert('" + msg + "')</script>");
Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + ex.Message + "');", true);
}
if (breturn)
{
if (this.MasterPageFile.Contains("Site.Master"))
Response.Redirect("~/openportfolio.aspx");
else if (this.MasterPageFile.Contains("Site.Mobile.Master"))
Response.Redirect("~/mopenportfolio.aspx");
else
Response.Redirect("~/mopenportfolio.aspx");
}
else
{
//Response.Write("<script language=javascript>alert('Error while updating the transaction. Please try again or hit back.')</script>");
Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.errorEditScript + "');", true);
}
}
else
{
//Response.Write("<script language=javascript>alert('All fields are mandatory.')</script>");
Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('" + common.errorAllFieldsMandatory + "');", true);
}
}
protected void buttonBack_Click(object sender, EventArgs e)
{
if (this.MasterPageFile.Contains("Site.Master"))
Response.Redirect("~/openportfolio.aspx");
else if (this.MasterPageFile.Contains("Site.Mobile.Master"))
Response.Redirect("~/mopenportfolio.aspx");
else
Response.Redirect("~/mopenportfolio.aspx");
}
protected void buttonCalCost_Click(object sender, EventArgs e)
{
if (textboxPurchasePrice.Text.Length > 0 && textboxQuantity.Text.Length > 0 && textboxCommission.Text.Length > 0)
{
double purchasePrice = (double)System.Convert.ToDouble(textboxPurchasePrice.Text);
int purchaseQty = (int)System.Convert.ToInt32(textboxQuantity.Text);
double commissionPaid = (double)System.Convert.ToDouble(textboxCommission.Text);
double totalCost = (purchasePrice + commissionPaid) * purchaseQty;
labelTotalCost.Text = System.Convert.ToString(totalCost);
}
else
labelTotalCost.Text = "0.00";
}
}
}