-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchCriminal.aspx.cs
112 lines (97 loc) · 4.29 KB
/
SearchCriminal.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
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
namespace SmartSystems_NS
{
public partial class SearchCriminal : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
filldropdownitems();
}
}
protected void filldropdownitems()
{
string ConnectionString = ConfigurationManager.ConnectionStrings["Database_ConnectionString"].ConnectionString;
DropDownList4.DataValueField = "Crime_type";
DropDownList4.DataTextField = "Crime_type";
string strSQL;
strSQL = "SELECT distinct [Crime_type] FROM [dbo].[tbl_crimetype]";
SqlConnection conn = new SqlConnection(ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand(strSQL, conn);
SqlDataReader reader = cmd.ExecuteReader();
DropDownList4.DataTextField = "Crime_type";
DropDownList4.DataValueField = "Crime_type";
DropDownList4.DataSource = reader;
DropDownList4.DataBind();
DropDownList4.Items.Add("ALL");
DropDownList4.Items.FindByValue("ALL").Selected = true;
conn.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
string cname,age, gender, edu, region, ci, ct, cryear,caseno;
cname = TextBox1.Text.ToString();
age = TextBox2.Text.ToString();
gender = DropDownList1.SelectedValue.ToString();
region = DropDownList2.Text.ToString();
edu = DropDownList5.Text.ToString();
ci = DropDownList3.Text.ToString();
ct = DropDownList4.Text.ToString();
cryear = TextBox3.Text.ToString();
caseno = txt_Caseno.Text.ToString();
if (region =="Select")
region ="";
if(edu=="Select")
edu ="";
if (ci=="Select")
ci="";
if (ct=="ALL")
ct = "";
//a = "SP_Searchcrimedetails '" + cname + "','" + age + "','" + gender + "','" + region + "','" + edu + "','" + ci + "','" + ct + "','" + cryear + "'";
//Response.Write (a);
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Database_ConnectionString"].ConnectionString))
{
SqlDataAdapter adaptor = new SqlDataAdapter("SP_Searchcrimedetails '" + cname+ "','" + age + "','" + gender + "','" + region + "','" + edu + "','" + ci + "','" + ct + "','"+cryear+ "','" + caseno +"' ", connection);
DataSet ds = new DataSet();
adaptor.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
connection.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void OnSelectedIndexChanged(object sender, EventArgs e)
{
//Determine the RowIndex of the Row whose Button was clicked.
int rowIndex = ((sender as LinkButton).NamingContainer as GridViewRow).RowIndex;
//Get the value of column from the DataKeys using the RowIndex.
string caseno = GridView1.DataKeys[rowIndex].Values[0].ToString();
Response.Write(caseno);
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Database_ConnectionString"].ConnectionString))
{
SqlDataAdapter adaptor = new SqlDataAdapter("sp_ViewCriminalDetails '" + caseno + "'", connection);
DataSet ds = new DataSet();
adaptor.Fill(ds);
DetailsView1.DataSource = ds;
DetailsView1.DataBind();
connection.Close();
}
}
}
}