-
Notifications
You must be signed in to change notification settings - Fork 1
/
Admin.aspx.cs
78 lines (62 loc) · 2.55 KB
/
Admin.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace FoodFest
{
public partial class Admin : System.Web.UI.Page
{
DBConnect resConn = new DBConnect();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if ((Session["LoggedInUserName"] != null))
{
LinkButton LinkButton1 = (LinkButton)Master.FindControl("LinkButton1");
LinkButton1.Visible = false;
LinkButton LinkButton2 = (LinkButton)Master.FindControl("LinkButton2");
LinkButton2.Visible = true;
Label Welcome_label = (Label)Master.FindControl("Welcome_label");
Welcome_label.Text = "Welcome " + Session["LoggedInUserName"];
Welcome_label.Visible = true;
}
else
{
LinkButton LinkButton1 = (LinkButton)Master.FindControl("LinkButton1");
LinkButton1.Visible = true;
LinkButton LinkButton2 = (LinkButton)Master.FindControl("LinkButton2");
LinkButton2.Visible = false;
}
try
{
resConn.SqlConnectionObj.Open();
string query = "";
query = String.Format("select COUNT(*) from Order_tbl where DeliveryStatus is null");
resConn.SqlCommandObj.CommandText = query;
SqlDataReader reader = resConn.SqlCommandObj.ExecuteReader();
while (reader.Read())
{
Label1.Text = "You have "+ reader.GetInt32(0).ToString() + " new orders.";
}
resConn.SqlConnectionObj.Close();
}
catch (Exception ex)
{
throw new Exception("Error occurred during DB operation. Try again", ex);
}
finally
{
if (resConn.SqlConnectionObj != null && resConn.SqlConnectionObj.State == ConnectionState.Open)
{
resConn.SqlConnectionObj.Close();
}
}
}
}
}
}