-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPending_Shop.aspx.cs
157 lines (150 loc) · 5.18 KB
/
Pending_Shop.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
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Data.OracleClient;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.SessionState;
public partial class Pending_Shop : System.Web.UI.Page
{
private OracleConnection oc;
private OracleCommand com;
private OracleDataAdapter adap;
private DataSet ds;
int flag;
protected void Page_Load(object sender, EventArgs e)
{
Session["backtoadmin"] = "flasebacktoadmin";
if (!Convert.ToString(Session["AdminLoggedin"]).Equals("TrueAdmin"))
{
flag = 0;
Session["backtoadmin"] = "truebacktoadmin";
Session["takemetoadmin"] = Request.CurrentExecutionFilePath.ToString();
Response.Redirect("Signin.aspx");
}
flag = 1;
try
{
oc = new OracleConnection("Data Source=MYDB; User ID=scott; Password=tiger");
oc.Open();
com = oc.CreateCommand();
}
catch (Exception ee) { }
int k = 0;
String query = "select name,shop_id,address,ph_no from shop where status='pending'";
try
{
com.CommandText = query;
com.CommandType = CommandType.Text;
adap = new OracleDataAdapter(com);
ds = new DataSet();
adap.Fill(ds);
k = ds.Tables[0].Rows.Count;
DataList1.DataSource = ds;
DataList1.DataBind();
}
catch (Exception ff) { }
if (k == 0)
Label9.Visible = true;
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
String s = "";
String sname = "";
int i = 0,j=0;
if (e.CommandName == "addshop")
{
DataSet ds1 = (DataSet)DataList1.DataSource;
s = ds1.Tables[0].Rows[e.Item.ItemIndex]["shop_id"].ToString();
sname = ds1.Tables[0].Rows[e.Item.ItemIndex]["name"].ToString();
String q = "update shop set status='active' where shop_id='"+s+"'";
try
{
this.com = oc.CreateCommand();
this.com.CommandText = q;
i = com.ExecuteNonQuery();
}
catch (Exception p) { }
int aa = 300;
String date = DateTime.Now.ToShortDateString();
try
{
this.com = oc.CreateCommand();
com.CommandText = "insert_payment";
com.CommandType = CommandType.StoredProcedure;
OracleParameter p1 = new OracleParameter("shid", OracleType.VarChar, 20);
com.Parameters.Add(p1);
p1.Direction = ParameterDirection.Input;
p1.Value = s;
OracleParameter p2 = new OracleParameter("amount", OracleType.Number);
com.Parameters.Add(p2);
p2.Direction = ParameterDirection.Input;
p2.Value = aa;
OracleParameter p3 = new OracleParameter("dates", OracleType.VarChar, 30);
com.Parameters.Add(p3);
p3.Direction = ParameterDirection.Input;
p3.Value = date;
j = com.ExecuteNonQuery();
}
catch (Exception p) { }
if (i!=0 && j!=0)
{
Label8.Text = sname + " is successfully added to the database.";
Label8.Visible = true;
}
else
{
Label8.Text = "An error has occurred";
Label8.Visible = true;
}
}
else if (e.CommandName == "deleteshop")
{
DataSet ds1 = (DataSet)DataList1.DataSource;
s = ds1.Tables[0].Rows[e.Item.ItemIndex]["shop_id"].ToString();
sname = ds1.Tables[0].Rows[e.Item.ItemIndex]["name"].ToString();
String q = "delete from shop where shop_id='"+s+"'";
try
{
this.com = oc.CreateCommand();
this.com.CommandText = q;
i = com.ExecuteNonQuery();
}
catch (Exception p) { }
if (i != 0)
{
Label8.Text = sname + " is successfully deleted from the database.";
}
else
{
Label8.Text = "An error has occurred";
}
Label8.Visible = true;
}
String query = "select name,shop_id,address,ph_no from shop where status='pending'";
try
{
this.com = oc.CreateCommand();
com.CommandText = query;
com.CommandType = CommandType.Text;
adap = new OracleDataAdapter(com);
ds = new DataSet();
adap.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
}
catch (Exception ff) { }
}
private void Page_Unload()
{
if (flag == 1)
{
oc.Close();
}
}
}