-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDelete_Shop.aspx.cs
124 lines (117 loc) · 3.71 KB
/
Delete_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
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 Delete_Shop : System.Web.UI.Page
{
private OracleConnection oc;
private OracleCommand com;
private OracleDataAdapter adap;
private DataTable db;
int flag;
String shopid;
String shopname;
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) { }
String query = "select name,shop_id from shop where status='active' or status='inactive'";
try
{
com.CommandText = query;
com.CommandType = CommandType.Text;
adap = new OracleDataAdapter(com);
db = new DataTable();
adap.Fill(db);
}
catch (Exception ff) { }
if (!Page.IsPostBack)
{
foreach (DataRow row in this.db.Rows)
{
DropDownList1.Items.Add(row[0].ToString() + "(Shop ID: " + row[1].ToString() + ")");
}
}
}
protected void next_button_Click(object sender, EventArgs e)
{
String str = DropDownList1.SelectedValue;
foreach (DataRow row in this.db.Rows)
{
if (str.Equals(row[0].ToString() + "(Shop ID: " + row[1].ToString() + ")"))
{
shopname=row[0].ToString();
shopid = row[1].ToString();
break;
}
}
Session["deleteshopid"] = shopid;
Session["deleteshopname"]=shopname;
Response.Redirect("Admin_con_msg.aspx");
/* Label2.Text = "Are you sure to delete ";
Label4.Text = shopname;
Label5.Text = shopid;
Label6.Text=")?";
Label2.Visible = true;
Label4.Visible = true;
Label5.Visible = true;
Label6.Visible = true;
yes_button.Visible = true;
no_button.Visible = true;*/
}
protected void yes_button_Click(object sender, EventArgs e)
{
int i = 0;
try
{
com = oc.CreateCommand();
com.CommandText = "delete_shop";
com.CommandType = CommandType.StoredProcedure;
OracleParameter p1 = new OracleParameter("shid", OracleType.VarChar, 20);
com.Parameters.Add(p1);
p1.Direction = ParameterDirection.Input;
p1.Value = Label5.Text;
i = com.ExecuteNonQuery();
}
catch (Exception j) { }
if (i != 0)
{
Label3.Text = Label5.Text + " has been deleted successfully.";
DropDownList1.Items.Remove(shopname + "(Shop ID: " + Label5.Text + ")");
}
else
{
Label3.Text = "Error";
}
Label3.Visible = true;
}
private void Page_Unload()
{
if (flag == 1)
{
oc.Close();
}
}
}