project on dot net (online library management system)

Post on 11-Nov-2014

155 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

use of C#, asp and sql

TRANSCRIPT

Project ReportProject ReportOnOn

Online Library ManagementOnline Library Management SystemSystem

DOEACC Society Chandigarh Center, Branch Office Lucknow

Project Guide Submitted By

Mr. Sanyam Shailendra Pratap Singh

AcknowledgementAcknowledgement

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

2

TABLE OF CONTENTS: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

3

6. Conclusion 74

7. Bibliography 75

Introduction:-Introduction:-

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

USER :1. Can view details related to a particular book.2. Can request for membership or issue of a book.

4

ADMIN :1.Can read and write information about anymember.2. Can update, create, delete the record ofmembership as per requirement and implementationplans.

Scope :The different areas where we can use this applicationare :

• Any education institute can make use of it forproviding information about author, content of theavailable books.

5

• It can be used in offices and modifications can beeasily done according to requirements.

Technology Used :

Front End: ASP.NET

6

Back End: SQL Server 2005

Assumptions

• This application is used to convert the manualapplication to the online application.

7

• Customized data will be used in this application.

• User does not have right to enter informationabout books.

Overview :

8

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

Functionality :

• Online membership.

• Keeps the track of issues and submission of books .

9

Data base description:-Data base description:-

1. Author Table

2. Book Stock Table

3. Book Stock Bill Table

10

4. Issue Return Table

5. Publisher Table

6. Member Type Table

11

7. Member Table

8. Book Stock Detail Table

9. Faculty Table

10. Student Table

12

User interface(snapshots):-User interface(snapshots):-

1. Author Form

13

2. Book Stock Form

14

3. Book Stock Bill Form

15

4. Book Sock Detail Form

16

5. Faculty Form

17

6. Student Form

18

7. Member Form

19

8. Member Type

20

8. Publisher Form

21

9. Search Book By Author Id Form

22

23

10. Search Book By Book Id Form

11. Search Book By Author Name Form

24

25

12. Search Book By Book Name Form

26

13. Search Book By Publisher Name Form

27

14. Search Book By Publisher Id Form

28

15. Main Form

29

16. Login Form

30

17. Create User Form

31

18. Home Form

32

19. Default Form

33

Coding:-Coding:-

1. Author 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.Data.SqlTypes;using 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"].ConnectionString; 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();

34

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(); SqlDataReader rd = showdata(); GridView1.DataSource = rd;

35

GridView1.DataBind(); } else { TextBox6.Visible = true; TextBox6.Text = "Id Already exist"; TextBox1.Focus(); } } else { TextBox6.Visible = true; TextBox6.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 Author"; 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 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); } public SqlDataReader deldata() {

36

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).ToString()); 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(); return rd; }

}

37

2. Book Stock 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.Data.SqlTypes;using 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 { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString; 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();

38

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) "; 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());

39

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();

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);

40

// 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,balance=@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()); 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;

41

cmd.CommandText = "select * from BookStock"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; } }

3. Book Stock Bill Codeusing 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.Data.SqlTypes;using System.Web.Configuration;

public partial class Master_BookStockBill : 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"].ConnectionString; 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();

42

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) {

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(); }

43

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) { 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();

44

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=@date 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()); 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 Codeusing System;using System.Collections;

45

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.Data.SqlTypes;using System.Web.Configuration;

public partial class Master_BookStockDetail : 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"].ConnectionString; 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";

46

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; 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;

47

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(); } 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;

48

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

}

5. Create User Codeusing 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;

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

}}

6. Default Codeusing 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;

49

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 Codeusing 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;

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"); }*/ }

50

}

8. Issue Return Codeusing 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.Data.SqlTypes;using 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"].ConnectionString; 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(); GridView1.DataSource = rd; GridView1.DataBind(); } } protected void Button1_Click(object sender, EventArgs e)

51

{ 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; 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);

52

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"; cmd.Parameters.AddWithValue("@bid",bid); cons.Open(); cmd.ExecuteNonQuery(); } protected void TextBox2_CalendarExtender_Load(object sender, EventArgs e) { }}

53

9. Login Codeusing 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"].ConnectionString;

} protected void Button1_Click(object sender, EventArgs e) { int c1=0; SqlConnection cons = new SqlConnection(constr); SqlCommand cmd = new SqlCommand();

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");

54

} 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.Password.ToString())) { Session["login1"] = Login1.UserName.ToString(); //Session["Password"] = Login1.Password.ToString(); FormsAuthentication.RedirectFromLoginPage(Login1.UserName.ToString(), 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\library.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";

55

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 Codeusing 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.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Xml.Linq;

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

11. Member Codeusing System;using System.Collections;using System.Configuration;

56

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.Data.SqlTypes;using 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"); } constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString; } 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;

57

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(DropDownList1.SelectedValue.ToString())); cmd.Parameters.AddWithValue("@memtype_id",decimal.Parse(DropDownList2.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(); cmd.Connection = cons; cmd.CommandType = CommandType.Text; cmd.CommandText = "select * from Member"; cons.Open(); SqlDataReader rd = cmd.ExecuteReader(); return rd; }}

12. Member Type Codeusing 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.Data.SqlTypes;using System.Web.Configuration;

58

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"].ConnectionString; 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(); 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) {

59

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(); SqlDataReader rd = showdata(); GridView1.DataSource = rd; GridView1.DataBind(); } else { Label6.Visible = true; Label6.Text = "Id Already exist"; TextBox1.Focus(); } } else { 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

60

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.Data.SqlTypes;using System.Web.Configuration;

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"].ConnectionString; 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) {

61

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) { 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 "; } }

62

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; } 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 ";

63

cmd.Parameters.AddWithValue("@p",Int32.Parse(TextBox1.Text).ToString()); 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", 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 Codeusing 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;

public partial class Query_Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null)

64

{ // Label2.Visible = true; // Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } }}

15. Search Book By Author Name Codeusing 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;

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 Codeusing System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;

65

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.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"].ConnectionString; 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"].ConnectionString; } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { /* 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

66

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 Codeusing 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;

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"); } }}

18. Search Book By Publisher Id Codeusing System;using System.Collections;using System.Configuration;

67

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;

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

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;

public partial class Query_Searchbp : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { if (Session["login1"] == null) {

Session.Abandon(); Response.Redirect("~/login.aspx"); } }}

68

20. Faculty Codeusing 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.Data.SqlTypes;using 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"].ConnectionString; 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(); } } protected void Button1_Click(object sender, EventArgs e) { int k = (TextBox1.Text).Trim().Length;

69

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,memtype_id)values(@faculty_id,@f_name,@qualification,@dept,@mobile,@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); 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(); }

70

} 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;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.Data.SqlTypes;using 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)

71

{ Label2.Visible = true; Label2.Text = "You are not admin"; Session.Abandon(); Response.Redirect("~/login.aspx"); } else { constr = WebConfigurationManager.ConnectionStrings["LocalSqlServer1"].ConnectionString; 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); 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,@memtyp

72

e_id)values(@student_id,@name,@course,@city,@address,@mobile,@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(); } } 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; }

}

73

Future ScopeFuture 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

74

application. There is flexibility in all the modules.

SOFTWARE SCOPE:

• Extensibility: This software is extendable in ways that its original developers may not 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,

75

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 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 the

76

information and outputs expected from the system.

ConclusionConclusion

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

77

BibliographyBibliography

Books: C# with Asp.Net(Black Book) Programming in C# by E Balagurusamy

Websites: www.dotnetprojects.com www.daniweb.com

78

79

top related