-
Notifications
You must be signed in to change notification settings - Fork 0
/
Delete_Concession_Request.aspx.cs
84 lines (72 loc) · 2.85 KB
/
Delete_Concession_Request.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
public partial class Delete_Concession_Request : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["admin"] == null)
Response.Redirect("Adminlogin.aspx");
else
{
Response.ClearHeaders();
Response.AddHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
Response.AddHeader("Pragma", "no-cache");
LblResult.Text = "Record Deleted Successfully";
LblResult.Visible = false;
}
}
}
protected bool verifysap()
{
LblResult.Visible = false ;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("select count(*) from railway_concession where SAP_n=@sapid", con);
con.Open();
cmd.Parameters.AddWithValue("@sapid", Txtsap.Text);
Int32 count = (Int32)cmd.ExecuteScalar();
if (count == 0)
{
Lbl3.Text = "Invalid Sap ID or No concession request from this Sap Id";
Lbl3.Visible = true;
return false;
}
return true;
}
protected void Btndelete_Click(object sender, EventArgs e)
{
LblResult.Visible = false;
if (verifysap())
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("delete from railway_concession where SAP_n=@sapid and status=@pending", con);
con.Open();
cmd.Parameters.AddWithValue("@sapid", Txtsap.Text);
cmd.Parameters.AddWithValue("@pending","Pending");
cmd.ExecuteNonQuery();
cmd = new SqlCommand("select count(*) from railway_concession where SAP_n=@sapid and status=@pending", con);
cmd.Parameters.AddWithValue("@sapid", Txtsap.Text);
cmd.Parameters.AddWithValue("@pending", "Pending");
Int32 count = (Int32)cmd.ExecuteScalar();
con.Close();
if(count==0)
LblResult.Text = "Pending Request Deleted sucessfully";
LblResult.Visible = true;
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Session["admin"] = null;
Session["admin_type"] = null;
Server.Transfer("Adminlogin.aspx");
}
}