-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminProductDetails.aspx.cs
87 lines (68 loc) · 3.19 KB
/
AdminProductDetails.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
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DB_Prpject
{
public partial class AdminProductDetails : System.Web.UI.Page
{
string strconnect = "Data Source=AKKHAN;Initial Catalog=dbproject;Integrated Security=True";
protected void Page_Load(object sender, EventArgs e)
{
Admin_product_GridView1.DataBind();
}
protected void Admin_Prod_details_remove_btn_Click(object sender, EventArgs e)
{
try
{
//string seller = Admin_Seller_name_text.Text.Trim();
string productid = Admin_Prod_ID_text.Text.Trim();
if (productid == "")
Response.Write("<script>alert('Product ID field is empty')</script>");
else
{
string strconnect = "Data Source=AKKHAN;Initial Catalog=dbproject;Integrated Security=True";
SqlConnection con = new SqlConnection(strconnect);
con.Open();
//SqlCommand cmd = new SqlCommand("declare @flag int; execute delete_item_by_admin '" + product + "', '" + seller + "', '" + productid + "', @flag output select @flag as flag", con);
SqlCommand cmd = new SqlCommand("select * from inventory where productID= ' " + Admin_Prod_ID_text.Text.Trim() + " ' ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count >= 1)
{
// string strconnect = "Data Source=AKKHAN;Initial Catalog=dbproject;Integrated Security=True";
SqlConnection conn = new SqlConnection(strconnect);
conn.Open();
SqlCommand cmmd = new SqlCommand("Delete from inventory where productID= ' " + Admin_Prod_ID_text.Text.Trim() + " ' ", conn);
//SqlCommand cmmd = new SqlCommand("Delete from inventory where productID= ' " + Admin_Prod_ID_text.Text.Trim() + " ' ", conn);
cmmd.ExecuteNonQuery();
Response.Write("<script>alert('Deleted Successfully')</script>");
conn.Close();
}
else
{
Response.Write("<script>alert('Not Delete')</script>");
}
//int val = (int)cmd.ExecuteScalar();
//if (val == 0)
//{
// Response.Write("<script>alert('Invalid Input')</script>");
//}
//else
//{
//}
con.Close();
}
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "')</script>");
}
}
}
}