-
Notifications
You must be signed in to change notification settings - Fork 0
/
MasterPage.master.cs
148 lines (126 loc) · 5.74 KB
/
MasterPage.master.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MainDataModuleTableAdapters;
public partial class MasterPage : System.Web.UI.MasterPage
{
public int GetUserNameAndPasswordAndReturnOwnerID(string username, string password)
{
int ownerid = -1;
/*string username = "guest";
string pass = "pRS+UaJqCcwAcBEcdkJ6UmEQwvtkSm4GGero4+PfWIUrC7XpxXsgxi9xr0ha6paZ";
if (Request.Cookies["username"] != null && Request.Cookies["password"] != null)
{
username = Request.Cookies["username"].Value.ToString();
pass = Request.Cookies["password"].Value.ToString();
}*/
tbl_usersTableAdapter tb = new tbl_usersTableAdapter();
int ownerID = (int)tb.GetOwnerIDfromUsername(username, password);
return ownerid;
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["owner"] == null)
{
Session["modulename"] = Request.Url.PathAndQuery;
Response.Redirect("login.aspx");
}
else
{
try
{
string username = Request.Cookies["username"].Value.ToString();
string pass = Request.Cookies["password"].Value.ToString();
string ownerid = Request.Cookies["owner"].Value.ToString();
string userWeight = Request.Cookies["userWeight"].Value.ToString();
string useridfromDB = new main_class().Encode(((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString());
if (ownerid != useridfromDB)
{
Session["modulename"] = Request.Url.PathAndQuery;
Response.Redirect("login.aspx");
}
else
{
Session["owner"] = ((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString();
Session["OwnerID"] = ((int)new tbl_usersTableAdapter().GetOwnerIDfromUsername(username, pass)).ToString();
Session["userWeight"] = new main_class().Decode(userWeight);
Session["username"] = username;
Session["password"] = pass;
}
}
catch (Exception __e)
{
Response.Redirect("login.aspx");
}
}
if (!IsPostBack)
{
Literal1.Text = new tbl_sms_recieved_formattedTableAdapter().GetUnreadSMSCount(Convert.ToInt32(Session["owner"].ToString())).Value.ToString();
lbl_OwnerName.Text = new MainDataModuleTableAdapters.tbl_ownerTableAdapter().GetOwnerNameFromOID(Convert.ToInt32(Session["owner"].ToString()));
lbl_today.Text = new main_class().Convert_to_Shamsi(DateTime.Now);
}
lbl_current_value.Text = new MainDataModuleTableAdapters.tbl_sms_billingTableAdapter().GetLastCredit(Convert.ToInt32(Session["owner"].ToString()) ).ToString();
}
protected void RightMenuClicked(object sender, EventArgs e)
{
// Remeber Caption of LinkButtons must be highlighted
LinkButton lb = sender as LinkButton;
switch (lb.Text)
{
case "ارسال پیام":
Response.Cookies.Add(new HttpCookie("linkname", "SendSMS"));
Response.Cookies.Add(new HttpCookie("titlename", "1"));
Response.Redirect("links.aspx?page_id=10");
break;
case "پیام های دریافتی":
Response.Cookies.Add(new HttpCookie("linkname", "RecievedSMS"));
Response.Cookies.Add(new HttpCookie("titlename", "2"));
Response.Redirect("links.aspx?page_id=11");
break;
case "پیام های ارسالی":
Response.Cookies.Add(new HttpCookie("linkname", "SentSMSList"));
Response.Cookies.Add(new HttpCookie("titlename", "3"));
Response.Redirect("links.aspx?page_id=12");
break;
case "صندوق پیشنهادات":
break;
case "نظرسنجی":
Response.Cookies.Add(new HttpCookie("linkname", "Openions"));
Response.Cookies.Add(new HttpCookie("titlename", "4"));
Response.Redirect("links.aspx?page_id=13");
break;
case "مدیریت گیرندگان":
Response.Cookies.Add(new HttpCookie("linkname", "CustomersAdmin"));
Response.Cookies.Add(new HttpCookie("titlename", "5"));
Response.Redirect("links.aspx?page_id=1");
break;
case "مدیریت نمرات":
Response.Cookies.Add(new HttpCookie("linkname", "ResultsAdmin"));
Response.Cookies.Add(new HttpCookie("titlename", "6"));
Response.Redirect("links.aspx?page_id=8");
break;
case "تنظیمات":
Response.Cookies.Add(new HttpCookie("linkname", "ُSettings"));
Response.Cookies.Add(new HttpCookie("titlename", "7"));
Response.Redirect("links.aspx?page_id=16");
break;
}
}
protected void lnk_SuggestionList_Click(object sender, EventArgs e)
{
}
protected void lnk_signout_Click(object sender, EventArgs e)
{
Response.Cookies.Add(new HttpCookie("username",""));
Response.Cookies.Add(new HttpCookie("password", ""));
Response.Cookies.Add(new HttpCookie("owner", ""));
Response.Redirect("login.aspx");
}
protected void lnk_charge_Click(object sender, EventArgs e)
{
Response.Redirect("links.aspx?page_id=15");
}
}