-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewebooks.ascx.cs
107 lines (103 loc) · 3.93 KB
/
viewebooks.ascx.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;
public partial class viewebooks : System.Web.UI.UserControl
{
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.Items.Add("--Select--");
DropDownList2.Items.Add("--Select--");
dbconnection db = new dbconnection();
cmd.CommandText = "select distinct category from tb_ebook";
SqlDataReader dr = db.executeread(cmd);
while (dr.Read())
{
String s = dr[0].ToString();
DropDownList1.Items.Add(s);
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Enabled = false;
Panel1.Visible = true;
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if(e.CommandName=="Request")
{
String ebkid = e.CommandArgument.ToString();
dbconnection db = new dbconnection();
cmd.CommandText = "select status from tb_ebook where ebk_id=@d";
cmd.Parameters.AddWithValue("@d", ebkid);
SqlDataReader dr = db.executeread(cmd);
dr.Read();
string status = dr.GetString(0);
dbconnection db1 = new dbconnection();
cmd.CommandText = "select req_id from tb_id";
SqlDataReader dr1 = db1.executeread(cmd);
dr1.Read();
int id = dr1.GetInt32(0);
id++;
String reqid = "REQID" + id.ToString();
String sid = Session["uid"].ToString();
DateTime date = DateTime.Today;
dbconnection db7 = new dbconnection();
SqlCommand cmd7 = new SqlCommand();
cmd7.CommandText = "insert into tblRequest values(@rno,@sid,@bid,@date,@status)";
cmd7.Parameters.AddWithValue("@rno", reqid);
cmd7.Parameters.AddWithValue("@sid", sid);
cmd7.Parameters.AddWithValue("@bid", ebkid);
cmd7.Parameters.AddWithValue("@date", date);
cmd7.Parameters.AddWithValue("@status", status);
db7.execute(cmd7);
dbconnection db8 = new dbconnection();
SqlCommand cmd8 = new SqlCommand();
cmd8.CommandText = "update tb_id set req_id=@idd";
cmd8.Parameters.AddWithValue("@idd", id);
db8.execute(cmd8);
}
}
protected void Button1_Click(object sender, EventArgs e)
{
String str = TextBox1.Text;
dbconnection db = new dbconnection();
cmd.CommandText = "select * from tb_ebook where bkname=@n";
cmd.Parameters.AddWithValue("@n", str);
DataList1.DataSource = db.executeread(cmd);
DataList1.DataBind();
}
protected void Button3_Click(object sender, EventArgs e)
{
dbconnection db = new dbconnection();
cmd.CommandText = "select * from tb_ebook where category=@a and subject=@b";
cmd.Parameters.AddWithValue("@a", DropDownList1.SelectedItem.Text);
cmd.Parameters.AddWithValue("@b", DropDownList2.SelectedItem.Text);
DataList1.DataSource = db.executeread(cmd);
DataList1.DataBind();
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
String s = DropDownList1.SelectedItem.Text;
DropDownList2.Items.Add("--Select--");
dbconnection db1 = new dbconnection();
cmd.CommandText = "select subject from tb_ebook where category=@d";
cmd.Parameters.AddWithValue("@d", s);
SqlDataReader dr = db1.executeread(cmd);
while (dr.Read())
{
String st = dr[0].ToString();
DropDownList2.Items.Add(st);
}
}
}