-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminCustomerDetails.aspx.cs
99 lines (74 loc) · 2.59 KB
/
AdminCustomerDetails.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DB_Prpject
{
public partial class AdminCustomerDetails : System.Web.UI.Page
{
string strconnect = "Data Source=AKKHAN;Initial Catalog=dbproject;Integrated Security=True";
protected void Page_Load(object sender, EventArgs e)
{
Admin_customer_GridView1.DataBind();
}
protected void Admin_Cust_details_remove_btn_Click(object sender, EventArgs e)
{
if (check_valid_Email())
{
Response.Write("<script>alert('Customer Not Exits')</script>");
}
else
{
delete_Customer();
}
}
bool check_valid_Email()
{
try
{
string strconnect = "Data Source=AKKHAN;Initial Catalog=dbproject;Integrated Security=True";
SqlConnection con = new SqlConnection(strconnect);
con.Open();
SqlCommand cmd = new SqlCommand("Select count(*) from customer where login_id = '" + Admin_Cust_details_user_text.Text.Trim() + "'", con);
int count = (int)cmd.ExecuteScalar();
con.Close();
if (count == 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "')</script>");
return false;
}
}
void delete_Customer()
{
try
{
string strconnect = "Data Source=AKKHAN;Initial Catalog=dbproject;Integrated Security=True";
SqlConnection con = new SqlConnection(strconnect);
con.Open();
SqlCommand cmd = new SqlCommand("DELETE from customer where login_id = '" + Admin_Cust_details_user_text.Text.Trim() + "'", con);
cmd.ExecuteNonQuery();
Response.Write("<script>alert('Deletion Successfull !!')</script>");
Admin_customer_GridView1.DataBind();
con.Close();
}
catch (Exception ex)
{
Response.Write("<script>alert('" + ex.Message + "')</script>");
}
}
}
}