Você está na página 1de 92

Project Report On Online Library Management System

DOEACC Society Chandigarh Center, Branch Office Lucknow Project Guide Submitted By

Mr. Sanyam Shailendra Pratap Singh

Acknowledgement
A successful completion of this project is attributed to the great and indispensable help received from different people. I would like my sincere thanks to my project guide Mr. Chandrabhushan Sir for their constant guidance and valuable support throughout the project work. And of course nothing could have been true without support of my family, friends and batchmates for their continuous encouragement and useful tips throughout my project.

Shailendra Pratap Singh

TABLE OF CONTENTS:
1. Introduction 4-8 Purpose Scope Technology Used Assumptions Overview Functionality 2. Data base description 09-11 3. User interface(snapshots) 12-31 4. Coding 32-71

5. Future scope 72-73 Future scope of application Software scope 6. Conclusion 74 7. Bibliography 75

Introduction:-

Purpose:-

The purpose of this application are as follows : 1. The software is for automation of library. 2. It provides following facilities to
4

USER : 1. Can view details related to a particular book. 2. Can request for membership or issue of a book. ADMIN : 1.Can read and write information about any member. 2. Can update, create, delete the record of membership as per requirement and implementation plans.

Scope :

The different areas where we can use this application


5

are : Any education institute can make use of it for providing information about author, content of the available books. It can be used in offices and modifications can be easily done according to requirements.

Technology Used :

Front End: ASP.NET Back End: SQL Server 2005

Assumptions

This application is used to convert the manual application to the online application. Customized data will be used in this application. User does not have right to enter information about books.

Overview :

Project is related to library management which provides reading services to its members. Any person can become a member of the library by filling a prescribed form. They can get the book issued, so that they cab take home and return them.

Functionality :

Online membership. Keeps the track of issues and submission of books .

Data base description:1. Author Table

10

2. Book Stock Table

3. Book Stock Bill Table

4. Issue Return Table

11

5. Publisher Table

6. Member Type Table

7. Member Table

12

8. Book Stock Detail Table

9. Faculty Table

10. Student Table

13

User interface(snapshots):1. Author Form

14

2. Book Stock Form

15

3. Book Stock Bill Form

16

4. Book Sock Detail Form


17

18

5. Faculty Form

19

20

6. Student Form

21

7. Member Form

22

8. Member Type

23

24

8. Publisher Form

25

26

9. Search Book By Author Id Form

27

28

10. Search Book By Book Id Form

29

11. Search Book By Author Name Form

30

31

12. Search Book By Book Name Form

32

13. Search Book By Publisher Name Form


33

34

14. Search Book By Publisher Id Form

35

15. Main Form

36

37

16. Login Form

38

17. Create User Form

39

18. Home Form

40

41

19. Default Form

42

43

Coding:1. Author Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Master_Author : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Author"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader();

44

GridView1.DataSource = rd; GridView1.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox1.Text).Trim().Length; int l = (TextBox2.Text).Trim().Length; int m = (TextBox3.Text).Trim().Length; int n = (TextBox4.Text).Trim().Length; int o= (TextBox5.Text).Trim().Length; if (k > 0 && l > 0&&m > 0&& n> 0&&o > 0) { int c1=0; SqlConnection cons1 = new SqlConnection(constr); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from Author where author_id=@p"; cmd1.Parameters.AddWithValue ("@p", Int32.Parse( TextBox1.Text).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <=0) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into Author(author_id,a_name,a_address,a_city,a_mob) values(@author_id,@a_name,@a_address,@a_city,@a_mob)"; cmd.Parameters.AddWithValue ("@author_id", Int32.Parse (TextBox1.Text).ToString ()); cmd.Parameters.AddWithValue("@a_name", TextBox2.Text.ToString ()); cmd.Parameters.AddWithValue("@a_address", TextBox3.Text.ToString ()); cmd.Parameters.AddWithValue("@a_city", TextBox4.Text.ToString ()); cmd.Parameters.AddWithValue("@a_mob", TextBox5.Text.ToString ()); cons.Open(); cmd.ExecuteNonQuery();

45

} else { TextBox6.Visible = true; TextBox6.Text = "Id Already exist"; TextBox1.Focus(); } } else {

SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind();

} public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Author"; cons.Open(); SqlDataReader rd= cmd.ExecuteReader() ; return rd; }

TextBox6.Visible = true; TextBox6.Text="Do Not leave textbox blank ";}

protected void Button2_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "Delete from Author where author_id=@author_id" ; cmd.Parameters.AddWithValue("@author_id", Int32.Parse(TextBox1.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = deldata(); GridView1.DataSource = rd; GridView1.DataBind(); // cmd.Parameters.Add("@a_name", TextBox2.Text); // cmd.Parameters.Add("@a_address", TextBox3.Text); //cmd.Parameters.Add("@a_city", TextBox4.Text); // cmd.Parameters.Add("@a_mob", TextBox5.Text);

46

} public SqlDataReader deldata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Author"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } { protected void Button3_Click(object sender, EventArgs e) SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "update Author set a_name=@a_name,a_address=@a_address,a_city=@a_city,a_mob=@a_mob where author_id=@p "; cmd.Parameters.AddWithValue("@p",Int32.Parse(TextBox1.Text).ToS tring()); cmd.Parameters.AddWithValue("@a_name", TextBox2.Text); cmd.Parameters.AddWithValue("@a_address", TextBox3.Text); cmd.Parameters.AddWithValue("@a_city", TextBox4.Text); cmd.Parameters.AddWithValue("@a_mob", Int32.Parse(TextBox5.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = updata(); GridView1.DataSource = rd; GridView1.DataBind(); } public SqlDataReader updata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Author"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader();

47

} }

return rd;

2. Book Stock Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Master_BookStock : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } //String obj; // TextBox1 .Text=Session .Keys[1].ToString (); /*if(!Session.IsNewSession. /* TextBox1.Text = User.Identity.Name; TextBox2.Text = Session["login"].ToString();*/ /* if (Session ["login"]==User .Identity.Name) */ // obj = Session["login"].ToString(); // if(obj=="admin") else {

48

constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStock"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind(); } // else //{ // Response.Redirect("~/login.aspx"); //} } protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox1.Text).Trim().Length; if (k > 0) { int c1 = 0; SqlConnection cons1 = new SqlConnection(constr); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from BookStock where bid=@p"; cmd1.Parameters.AddWithValue("@p", Int32.Parse(TextBox1.Text).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <= 0) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into BookStock values(@bid,@bname,@author_id,@publisher_id,@balance,@bissued,@ bwrittenoff) ";

49

cmd.Parameters.AddWithValue("@bid", Int32.Parse(TextBox1.Text).ToString ()); cmd.Parameters.AddWithValue ("@bname", TextBox2.Text); cmd.Parameters.AddWithValue("@author_id", Int32.Parse(DropDownList1.SelectedValue)); cmd.Parameters.AddWithValue("@publisher_id", Int32.Parse(DropDownList2.SelectedValue)); cmd.Parameters.AddWithValue("@balance", Int32.Parse(TextBox5.Text).ToString()); cmd.Parameters.AddWithValue("@bissued", Int32.Parse(TextBox6.Text).ToString()); cmd.Parameters.AddWithValue("@bwrittenoff", Int32.Parse(TextBox7.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } else { TextBox8.Visible = true; TextBox8.Text = "Id Already Exist"; TextBox1.Focus(); } } else { } TextBox8.Text = "Empty Error ";

} public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStock"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } protected void Button2_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand();

50

cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "Delete from BookStock where bid=@bid"; cmd.Parameters.AddWithValue("@bid", Int32.Parse(TextBox1.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = deldata(); GridView1.DataSource = rd; GridView1.DataBind(); // cmd.Parameters.Add("@a_name", TextBox2.Text); // cmd.Parameters.Add("@a_address", TextBox3.Text); //cmd.Parameters.Add("@a_city", TextBox4.Text); // cmd.Parameters.Add("@a_mob", TextBox5.Text); } public SqlDataReader deldata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStock"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } protected void Button3_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "update BookStock set bname=@bname,author_id=@author_id,publisher_id=@publisher_id,ba lance=@balance,bissued=@bissued,bwrittenoff=@bwrittenoff where bid=@p "; cmd.Parameters.AddWithValue("@p", Int32.Parse(TextBox1.Text).ToString()); cmd.Parameters.AddWithValue("@bname", TextBox2.Text); cmd.Parameters.AddWithValue("@author_id", Int32.Parse(DropDownList2.Text).ToString()); cmd.Parameters.AddWithValue("@publisher_id", Int32.Parse(DropDownList2.Text).ToString());

51

cmd.Parameters.AddWithValue("@balance", Int32.Parse(TextBox5.Text).ToString()); cmd.Parameters.AddWithValue("@bissued", Int32.Parse(TextBox6.Text).ToString()); cmd.Parameters.AddWithValue("@bwrittenoff", Int32.Parse(TextBox7.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = updata(); GridView1.DataSource = rd; GridView1.DataBind(); } public SqlDataReader updata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStock"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } }

3. Book Stock Bill Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Master_BookStockBill : System.Web.UI.Page { private string constr;

52

protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockBill"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox7.Text).Trim().Length; if (k > 0) { int c1=0; SqlConnection cons1 = new SqlConnection(constr); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from BookStockBill where bid=@p"; cmd1.Parameters.AddWithValue ("@p", Int32.Parse(TextBox7.Text).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <=0) {

53

SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into BookStockBill(bid,billno,quantity,rate,amt,date) values(@bid,@billno,@quantity,@rate,@amt,@date)"; cmd.Parameters.AddWithValue ("@bid",Int32 .Parse (TextBox7 .Text ).ToString ()); cmd.Parameters.AddWithValue("@billno", TextBox2.Text); cmd.Parameters.AddWithValue("@quantity", TextBox3.Text); cmd.Parameters.AddWithValue("@rate", TextBox4.Text); cmd.Parameters.AddWithValue("@amt", TextBox5.Text); cmd.Parameters.AddWithValue("@date", Convert.ToDateTime(TextBox6.Text)); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } else { TextBox8.Visible = true; TextBox8.Text = "Duplicate error"; TextBox7.Focus(); } } else { TextBox8.Visible = true; TextBox8.Text="Empty Error ";}

} public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockBill"; cons.Open(); SqlDataReader rd= cmd.ExecuteReader() ; return rd; } protected void Button2_Click(object sender, EventArgs e)

54

SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons;

cmd.CommandType = CommandType.Text; cmd.CommandText = "Delete from BookStockBill where bid=@bid"; cmd.Parameters.AddWithValue("@bid", Int32.Parse(TextBox7.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = deldata(); GridView1.DataSource = rd; GridView1.DataBind(); } public SqlDataReader deldata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockBill"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } protected void Button3_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "update Author set billno=@billno,quantity=@quantity,rate=@rate,amt=@amt,date=@dat e where bid=@p "; cmd.Parameters.AddWithValue("@p", Int32.Parse(TextBox7.Text).ToString()); cmd.Parameters.AddWithValue("@billno", TextBox2.Text); cmd.Parameters.AddWithValue("@quantity", TextBox3.Text); cmd.Parameters.AddWithValue("@rate", TextBox4.Text); cmd.Parameters.AddWithValue("@amt", Int32.Parse(TextBox5.Text).ToString());

55

cmd.Parameters.AddWithValue("@date", Convert.ToDateTime (TextBox6.Text )); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = updata(); GridView1.DataSource = rd; GridView1.DataBind(); } public SqlDataReader updata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockBill"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; }

4. Book Stock Detail Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Master_BookStockDetail : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e)

56

if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockDetail"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { int c1=0; SqlConnection cons1 = new SqlConnection(constr); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from BookStockDetail where bid=@p"; cmd1.Parameters.AddWithValue ("@p", Int32.Parse(DropDownList1 .Text ).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <=0) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text;

57

cmd.CommandText = "insert into BookStockDetail(bid,bookno,booksissued,issue_date,return_date) values(@bid,@bookno,@booksissued,@issue_date,@return_date)"; cmd.Parameters.AddWithValue("@bid", Int32.Parse(DropDownList1 .Text ).ToString()); cmd.Parameters.AddWithValue("@bookno", TextBox2.Text); cmd.Parameters.AddWithValue("@booksissued", TextBox3.Text); cmd.Parameters.AddWithValue("@issue_date", TextBox4.Text); cmd.Parameters.AddWithValue("@return_date", TextBox5.Text); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } else { TextBox6.Visible = true; TextBox6.Text = "Id already exist"; DropDownList1 .Focus(); } } public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockDetail"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } protected void Button2_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "Delete from BookStockDetail where bid=@bid"; cmd.Parameters.AddWithValue("@bid", Int32.Parse(DropDownList1.Text ).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = deldata(); GridView1.DataSource = rd; GridView1.DataBind();

58

} public SqlDataReader deldata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockDetail"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } protected void Button3_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "update BookStockDetail set bookno=@bookno,booksissued=@booksissued,issue_date=@issue_date, return_date= return_date where bid=@p "; cmd.Parameters.AddWithValue("@p", Int32.Parse(DropDownList1.Text).ToString()); cmd.Parameters.AddWithValue("@bookno", TextBox2.Text); cmd.Parameters.AddWithValue("@booksissued", TextBox3.Text); cmd.Parameters.AddWithValue("@issue_date", TextBox4.Text); cmd.Parameters.AddWithValue("@return_date",TextBox5.Text); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = updata(); GridView1.DataSource = rd; GridView1.DataBind();

} public SqlDataReader updata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from BookStockDetail"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader();

59

} }

return rd;

5. Create User Code


using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

public partial class CreateUser : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } }

6. Default Code
using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

60

public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Text = "You are not admin"; Session.Abandon(); } else //if(Session["login"].ToString() == User.Identity.Name.ToString()) { Response.Redirect("~/Home/Home.aspx"); } } }

7. Home Code
using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

public partial class Home : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } /* else //if (Session["login"].ToString() == User.Identity.Name.ToString()) { Response.Redirect("~/Home/Home.aspx");

61

} }

}*/

8. Issue Return Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Transaction_IssueReturn : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { // Label2.Visible = true; // Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { TextBox2.Text = System.DateTime.Now.ToString(); constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from IssueReturn"; cons.Open();

62

} } protected void Button1_Click(object sender, EventArgs e) { int kk = Int32.Parse(DropDownList1.Text); int bkn = checkbookbalance(kk); if (bkn == 0) { Label10.Visible = true; Label10.Text = "Book not available"; } else { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into IssueReturn(bid,bookno,issue_date,return_date,fine) values(@bid,@bookno,@issue_date,@return_date,@fine)"; cmd.Parameters.AddWithValue("@bid", Int32.Parse(DropDownList1.Text).ToString()); cmd.Parameters.AddWithValue("@bookno", TextBox1.Text); //cmd.Parameters.AddWithValue("@memid", Int32.Parse(DropDownList2.Text).ToString()); cmd.Parameters.AddWithValue("@issue_date", TextBox2.Text); cmd.Parameters.AddWithValue("@return_date", TextBox3.Text); cmd.Parameters.AddWithValue("@fine", TextBox4.Text); cons.Open(); cmd.ExecuteNonQuery(); updatestockbook(kk); } SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } /* void updateissuereturn(int bid,string bookno,int memid,string issue_date,string return_date,int fine) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text;

SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind();

63

cmd.CommandText = "insert into IssueReturn(bid,bookno,memid,issue_date,return_date,fine) values(@bid,@bookno,@memid,@issue_date,@return_date,@fine)"; cmd.Parameters.AddWithValue("@bid", Int32.Parse(DropDownList1.Text).ToString()); cmd.Parameters.AddWithValue("@bookno", TextBox1.Text); cmd.Parameters.AddWithValue("@memid", Int32.Parse(DropDownList2.Text).ToString()); cmd.Parameters.AddWithValue("@issue_date", TextBox2.Text); cmd.Parameters.AddWithValue("@return_date", TextBox3.Text); cmd.Parameters.AddWithValue("@fine", TextBox4.Text); cons.Open(); cmd.ExecuteNonQuery(); }*/ public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from IssueReturn"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } int checkbookbalance(int bid) { int nb=0; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select balance cc from BookStock where bid=@bid"; cmd.Parameters.AddWithValue("@bid", bid); cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) nb = (int)rd["cc"]; return nb; } void updatestockbook(int bid) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "update BookStock set balance=balance-1 where bid=@bid";

64

} protected void TextBox2_CalendarExtender_Load(object sender, EventArgs e) { } }

cmd.Parameters.AddWithValue("@bid",bid); cons.Open(); cmd.ExecuteNonQuery();

9. Login Code
using System; using System.Collections; using System.Configuration; using System.Data; 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; using System.Data.SqlClient; using System.Web.Configuration; using System.Data.SqlTypes; using System.Security.Authentication; public partial class login : System.Web.UI.Page { /* private string constr; protected void Page_Load(object sender, EventArgs e) { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer"].Con nectionString; } protected void Button1_Click(object sender, EventArgs e) { int c1=0; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand();

65

cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select count(*) c from login where login=@g and password=@h"; cmd.Parameters.Add("@g", TextBox1.Text); cmd.Parameters.Add("@h", TextBox2.Text); cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { c1 = (int)rd["c"]; } //DataTable dt = new DataTable(); if (c1 > 0) { Response.Redirect("~/Home/Home.aspx"); } else { Label4.Text = "You Are Not Admin"; } }*/ protected void Page_Load(object sender, EventArgs e) { } protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { //bool Authenticated = false; // Authenticated = FormsAuthentication.Authenticate(Login1.UserName, Login1.Password); // Session["loginname"] = Login1.UserName; //e.Authenticated = Authenticated; /* if (Authenticated == true) { Response.Redirect("~/Home/Home.aspx"); }*/ // } if(Membership.ValidateUser(Login1.UserName.ToString(),Login1.Pa ssword.ToString())) { Session["login1"] = Login1.UserName.ToString(); //Session["Password"] = Login1.Password.ToString();

66

FormsAuthentication.RedirectFromLoginPage(Login1.UserName.ToStr ing(), false ); } else { Label2.Visible = true; Label2.Text="you are not a registered user"; } } /*private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password) { bool boolReturnValue = false; // Insert code that implements a site-specific custom // authentication method here. // This example implementation always returns false. string strConnection = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\user\Documents\li brary.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; SqlConnection Connection = new SqlConnection(strConnection); String strSQL = "Select * From sp_validateuser"; SqlCommand command =new SqlCommand(strSQL, Connection); SqlDataReader Dr; Connection.Open(); Dr=command.ExecuteReader(); while (Dr.Read()) { if ((UserName == Dr["name"].ToString()) & (Password == Dr["Password"].ToString())) { boolReturnValue = true; } Dr.Close(); return boolReturnValue; } } */ }

10. Main Code


using using using using System; System.Collections; System.Configuration; System.Data;

67

using using using using using using using using

System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Web.UI.HtmlControls; System.Xml.Linq;

public partial class Main : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } }

11. Member Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Member_Member : System.Web.UI.Page { public string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); }

68

constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList1.SelectedValue .ToString() == "1") { DropDownList3.Visible = true; DropDownList2.Visible = false; GridView1.Visible = true; GridView2.Visible = true; } if (DropDownList1.SelectedValue .ToString() == "2") { DropDownList2.Visible = true; DropDownList3.Visible =false ; GridView1.Visible = true; GridView2.Visible = true; } } protected void Button1_Click(object sender, EventArgs e) { SqlConnection cons; SqlCommand cmd; cons = new SqlConnection(constr); cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into Member(memid,memtype_id)values(@memid,@memtype_id)"; cmd.Parameters.AddWithValue("@memid",decimal.Parse(DropDownList 1.SelectedValue.ToString())); cmd.Parameters.AddWithValue("@memtype_id",decimal.Parse(DropDow nList2.SelectedValue.ToString())); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = showdata(); GridView3.DataSource = rd; GridView3.DataBind(); } public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand();

69

cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Member"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } }

12. Member Type Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Member_MemberType : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { // Label2.Visible = true; // Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from MemberType";

70

cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind(); } }

protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox1.Text).Trim().Length; if (k > 0) { int c1 = 0; SqlConnection cons1 = new SqlConnection(constr); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from MemberType where memtype_id=@p"; cmd1.Parameters.AddWithValue("@p", Int32.Parse(TextBox2.Text).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <= 0) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into MemberType(memtype,memtype_id,memfee) values(@memtype,@memtype_id,@memfee)"; cmd.Parameters.AddWithValue("@memtype", TextBox1.Text); cmd.Parameters.AddWithValue("@memtype_id", TextBox2.Text); cmd.Parameters.AddWithValue("@memfee", TextBox3.Text); cons.Open(); cmd.ExecuteNonQuery();

71

} else { Label6.Visible = true; Label6.Text = "Id Already exist"; TextBox1.Focus(); } } else { } }

SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind();

Label6.Visible = true; Label6.Text = "Do Not leave textbox blank ";

public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from MemberType"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; }

13. Publisher Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

72

public partial class Master_Publisher : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Publisher"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox1.Text).Trim().Length; if (k > 0) { int c1=0; SqlConnection cons1 = new SqlConnection(constr); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from Publisher where publisher_id=@p"; cmd1.Parameters.AddWithValue ("@p", Int32.Parse( TextBox1.Text).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <=0)

73

SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into Publisher(publisher_id,p_name,p_address,p_city,p_mob) values(@publisher_id,@p_name,@p_address,@p_city,@p_mob)"; cmd.Parameters.AddWithValue ("@publisher_id", TextBox1.Text); cmd.Parameters.AddWithValue("@p_name", TextBox2.Text); cmd.Parameters.AddWithValue("@p_address", TextBox3.Text); cmd.Parameters.AddWithValue("@p_city", TextBox4.Text); cmd.Parameters.AddWithValue("@p_mob", TextBox5.Text); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } else { TextBox6.Visible = true; TextBox6.Text = "Id already exist"; TextBox1.Focus(); } } else { TextBox6.Visible = true; TextBox6.Text="Fill the text box "; } } public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Publisher"; cons.Open(); SqlDataReader rd= cmd.ExecuteReader() ; return rd; }

74

protected void Button2_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "Delete from Publisher where publisher_id=@publisher_id"; cmd.Parameters.AddWithValue("@publisher_id", Int32.Parse(TextBox1.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = deldata(); GridView1.DataSource = rd; GridView1.DataBind(); } public SqlDataReader deldata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Publisher"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } protected void Button3_Click(object sender, EventArgs e) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "update Publisher set p_name=@p_name,p_address=@p_address,p_city=@p_city,p_mob=@p_mob where publisher_id=@p "; cmd.Parameters.AddWithValue("@p",Int32.Parse(TextBox1.Text).ToS tring()); cmd.Parameters.AddWithValue("@p_name", TextBox2.Text); cmd.Parameters.AddWithValue("@p_address", TextBox3.Text); cmd.Parameters.AddWithValue("@p_city", TextBox4.Text);

75

cmd.Parameters.AddWithValue("@p_mob", Int32.Parse(TextBox5.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = updata(); GridView1.DataSource = rd; GridView1.DataBind(); } public SqlDataReader updata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Publisher"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } }

14. Search Book By Author Id Code


using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

public partial class Query_Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { // Label2.Visible = true; // Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx");

76

} }

15. Search Book By Author Name Code


using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

public partial class Query_Default2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Session.Abandon(); Response.Redirect("~/login.aspx"); } } }

16. Search Book By Book Id Code


using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI;

77

using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Data.SqlTypes; using System.Web.Configuration; using System.Collections.Generic; public partial class Query_Default : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Session.Abandon(); Response.Redirect("~/login.aspx"); } /* constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer"].Con nectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT BookStock.bname, Author.a_name, Publisher.p_name, Publisher.publisher_id, BookStock.publisher_id AS Expr1, BookStock.author_id, Author.author_id AS Expr2 FROM BookStock INNER JOIN Author ON BookStock.author_id = Author.author_id INNER JOIN Publisher ON BookStock.publisher_id = Publisher.publisher_id WHERE (BookStock.bid = @bid)"; cmd.Parameters .AddWithValue ("@bid",Int32 .Parse (DropDownList1 .Text).ToString ()); cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind(); */ constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer"].Con nectionString; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { /* SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text;

78

cmd.CommandText = "SELECT BookStock.bname, Author.a_name, Publisher.p_name, Publisher.publisher_id, BookStock.publisher_id AS Expr1, BookStock.author_id, Author.author_id AS Expr2 FROM BookStock INNER JOIN Author ON BookStock.author_id = Author.author_id INNER JOIN Publisher ON BookStock.publisher_id = Publisher.publisher_id WHERE (BookStock.bid = @bid)"; cmd.Parameters.AddWithValue("@bid", int.Parse(DropDownList1.Text.ToString())); cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); Gridview*/ } }

17. Search Book By Book Name Code


using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

public partial class Query_Searchbbn : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Session.Abandon(); Response.Redirect("~/login.aspx"); } } }

79

18. Search Book By Publisher Id Code


using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

public partial class Query_Searchpid : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Session.Abandon(); Response.Redirect("~/login.aspx"); } } }

19. Search Book By Publisher Name Code


System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq;

using using using using using using using using using using using using

public partial class Query_Searchbp : System.Web.UI.Page

80

protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Session.Abandon(); Response.Redirect("~/login.aspx"); } }

20. Faculty Code


using using using using using using using using using using using using using using using System; System.Collections; System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Master_Faculty : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString;

81

} } protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox1.Text).Trim().Length; if (k > 0) { int c1=0; SqlConnection cons1 = new SqlConnection(constr); SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from Faculty where faculty_id=@p"; cmd1.Parameters.AddWithValue ("@p", Int32.Parse( TextBox1.Text).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <=0) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd= new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into Faculty(faculty_id,f_name,qualification,dept,mobile,receiptno,m emtype_id)values(@faculty_id,@f_name,@qualification,@dept,@mobi le,@receiptno,@memtype_id)"; cmd.Parameters.AddWithValue("@faculty_id", Int32.Parse (TextBox1.Text).ToString ()); cmd.Parameters.AddWithValue("@f_name", TextBox2.Text); cmd.Parameters.AddWithValue("@qualification", TextBox3.Text); cmd.Parameters.AddWithValue("@dept", TextBox4.Text);

SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Faculty"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind();

82

cmd.Parameters.AddWithValue("@mobile", (TextBox5.Text)); cmd.Parameters.AddWithValue("@receiptno", TextBox6.Text); cmd.Parameters.AddWithValue("@memtype_id", Int32.Parse(DropDownList1.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } else { TextBox7.Visible = true; TextBox7.Text = "Id exists"; TextBox1.Focus(); } } else { TextBox7.Visible = true; TextBox7.Text = "Text Box Is Empty "; } } public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Faculty"; cons.Open(); SqlDataReader rd= cmd.ExecuteReader() ; return rd; } }

21. Student Code


using System; using System.Collections;

83

using using using using using using using using using using using using using

System.Configuration; System.Data; System.Linq; System.Web; System.Web.Security; System.Web.UI; System.Web.UI.HtmlControls; System.Web.UI.WebControls; System.Web.UI.WebControls.WebParts; System.Xml.Linq; System.Data.SqlClient; System.Data.SqlTypes; System.Web.Configuration;

public partial class Master_Student : System.Web.UI.Page { private string constr; protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) { Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].Co nnectionString; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Student"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); GridView1.DataSource = rd; GridView1.DataBind(); } } protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox1.Text).Trim().Length; if (k > 0) { int c1 = 0; SqlConnection cons1 = new SqlConnection(constr);

84

SqlCommand cmd1 = new SqlCommand(); cmd1.Connection = cons1; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "Select count(*) c from Student where student_id=@p"; cmd1.Parameters.AddWithValue("@p", Int32.Parse(TextBox1.Text).ToString()); cons1.Open(); SqlDataReader rd1 = cmd1.ExecuteReader(); while (rd1.Read()) { c1 = (int)rd1["c"]; } if (c1 <= 0) { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into Student(student_id,name,course,city,address,mobile,receiptno,@m emtype_id)values(@student_id,@name,@course,@city,@address,@mobi le,@receiptno,@memtype_id)"; cmd.Parameters.AddWithValue("@student_id", Int32.Parse(TextBox1.Text).ToString()); cmd.Parameters.AddWithValue("@name", TextBox2.Text); cmd.Parameters.AddWithValue("@course", TextBox3.Text); cmd.Parameters.AddWithValue("@address", TextBox4.Text); cmd.Parameters.AddWithValue("@city", TextBox5.Text); cmd.Parameters.AddWithValue("@mobile", (TextBox6.Text)); cmd.Parameters.AddWithValue("@receiptno", TextBox7.Text); cmd.Parameters.AddWithValue("@memtype_id",Int32.Parse (DropDownList1.Text).ToString()); cons.Open(); cmd.ExecuteNonQuery(); SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } else { TextBox8.Visible = true; TextBox8.Text = "Duplicate error"; TextBox1.Focus();

85

} else {

TextBox8.Visible = true; TextBox8.Text = "Do not leave text box empty "; } } public SqlDataReader showdata() { SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Student"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } }

86

Future Scope
FUTURE SCOPE OF APPLICATION :

This application can be easily implemented under various situations. We can add new features as and when we require. Reusability is possible as and when require in this application. There is flexibility in all the modules.
SOFTWARE SCOPE:

Extensibility: This software is extendable in ways that its original developers may not
87

expect. The following principles enhances extensibility like hide data structure, avoid traversing multiple links or methods, avoid case statements on object type and distinguish public and private operations. Reusability: Reusability is possible as and when require in this application. We can update it next version. Reusable software reduces design, coding and testing cost by amortizing effort over several designs. Reducing the amount of code also simplifies understanding, which increases the likelihood that the code is correct. We follow up both types of reusability: Sharing of newly written code within a project and reuse of

88

previously written code on new projects. Understandability: A method is understandable if someone other than the creator of the method can understand the code (as well as the creator after a time lapse). We use the method, which small and coherent helps to accomplish this. Cost-effectiveness: Its cost is under the budget and make within given time period. It is desirable to aim for a system with a minimum cost subject to the condition that it must satisfy the entire requirement. Scope of this document is to put down the requirements, clearly identifying the information needed by the user, the source of

89

the information and outputs expected from the system.

Conclusion
From a proper analysis of positive points and constraints on the component, it can be safely concluded that the product is a highly efficient GUI based component. This application is working properly and meeting to all user requirements. This component can be easily plugged in many other system

90

Bibliography
Books: C# with Asp.Net(Black Book) Programming in C# by E Balagurusamy Websites: www.dotnetprojects.com www.daniweb.com

91

92

Você também pode gostar