You are on page 1of 13

Shop

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


{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

if ((Session["cust_num"]) != null)
{
txtcno.Text = Session["cust_num"].ToString();
}
if ((Session["cust_name"]) != null)
{
txtcustomername.Text =
Session["cust_name"].ToString();
}
if ((Session["address"]) != null)
{
txtadd.Text = Session["address"].ToString();
}
}
}
protected void btnpurchase_Click(object sender, EventArgs e)
{

Session["cust_num"] = txtcno.Text;
Session["cust_name"] = txtcustomername.Text;
Session["address"] = txtadd.Text;

string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();


SqlCommand objcmd = new SqlCommand("insert into
purchase_details(Customer_No,Customer_Name,Customer_Add,item_name,Pric
e,Quantity,Amount)values('" + txtcno.Text + "','" +
txtcustomername.Text + "','" + txtadd.Text + "','" +
ddlitemname.SelectedItem.Text + "','" + txtprice.Text + "','" +
txtquantity.Text +
"','"+float.Parse(txtquantity.Text)*float.Parse(txtprice.Text)+"')",
objsqlconn);
objcmd.ExecuteNonQuery();
objsqlconn.Close();
Response.Redirect("PurchasedItem.aspx");



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

}
protected void ddlitemname_SelectedIndexChanged(object sender,
EventArgs e)
{
//txtprice is ReadOny
txtprice.Enabled = false;
if (ddlitemname.SelectedItem.Text == "TV")
txtprice.Text = "40000";
else if (ddlitemname.SelectedItem.Text == "Mobile")
txtprice.Text = "10000";
else if (ddlitemname.SelectedItem.Text == "Laptop")
txtprice.Text = "50000";
else if(ddlitemname.SelectedItem.Text=="KeyBoard")
txtprice.Text="1000";
else
txtprice.Text="700";
}
}




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



string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();
DataSet ds = new DataSet();

SqlCommand objcmd = new SqlCommand("Select TOP 1* from
purchase_details order by purchas_id desc ", objsqlconn);
SqlDataAdapter da = new SqlDataAdapter(objcmd);
// SqlDataReader reader = objcmd.ExecuteReader();
da.Fill(ds);
lblIno.Text =
ds.Tables[0].Rows[0]["Customer_No"].ToString();
lbliname.Text =
ds.Tables[0].Rows[0]["item_Name"].ToString();
lblrate.Text = ds.Tables[0].Rows[0]["Price"].ToString();
lblqty.Text = ds.Tables[0].Rows[0]["Quantity"].ToString();
objsqlconn.Close();





}

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Customer_Details.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
Session["cust_num"] = null;
Session["cust_name"] = null;
Session["address"] = null;
Response.Redirect("ShowBillList.aspx");
}
}



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

string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();
DataSet ds = new DataSet();

SqlCommand objcmd1 = new SqlCommand("Select TOP 1* from
purchase_details order by purchas_id desc ", objsqlconn);
SqlDataAdapter da = new SqlDataAdapter(objcmd1);
// SqlDataReader reader = objcmd.ExecuteReader();
da.Fill(ds);
string cno=
ds.Tables[0].Rows[0]["Customer_No"].ToString();

lblcustno.Text =
ds.Tables[0].Rows[0]["Customer_No"].ToString();
lblcustname.Text =
ds.Tables[0].Rows[0]["Customer_Name"].ToString();
lblcustadd.Text =
ds.Tables[0].Rows[0]["Customer_Add"].ToString();





SqlCommand objcmd = new SqlCommand("Select
item_name,Price,Quantity,Amount from purchase_details where
Customer_No='"+cno+"'", objsqlconn);
GridView1.DataSource = objcmd.ExecuteReader();
GridView1.DataBind();
float amt = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{

amt=amt+float.Parse(GridView1.Rows[i].Cells[3].Text);
lbltotamt.Text = amt.ToString();
}

objsqlconn.Close();
}

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Customer_Details.aspx");
}
}


<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>


</system.web>
<connectionStrings>
<add name="Conn"
connectionString="Data Source=.;Initial Catalog=Labpgm1;Integrated
Security=True"></add>
</connectionStrings>
</configuration>


Employee
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;

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

string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();


SqlCommand objcmd = new SqlCommand("Select
Employee_Number,Employee_Name,Salary,Department from Employee",
objsqlconn);
GridView1.DataSource = objcmd.ExecuteReader();
GridView1.DataBind();

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

}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

public partial class DisplayDeptwise : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string dept=Request.QueryString["dname"];
string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();

DataSet ds = new DataSet();
SqlCommand objcmd = new SqlCommand("Select
Employee_Number,Employee_Name,Salary,Department from Employee where
Department='"+dept+"'", objsqlconn);
//GridView1.DataSource = objcmd.ExecuteReader();
SqlDataAdapter da = new SqlDataAdapter(objcmd);

da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
}
else
{
Label1.Visible = true;
Label1.Text = "No Records Found";
}


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

}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

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

}
protected void btnadd_Click(object sender, EventArgs e)
{
string dept = "";
if (RadioButton1.Checked == true)
{
dept = "Sales";
}
else if (RadioButton2.Checked == true)
{
dept = "Accounts";
}
else
dept = "IT";

string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();


SqlCommand objcmd = new SqlCommand("insert into
Employee(Employee_Number,Employee_Name,Salary,Department)values('" +
txtempno.Text + "','" + txtempname.Text + "','" + txtsalary.Text +
"','" + dept.ToString() + "')", objsqlconn);
objcmd.ExecuteNonQuery();
objsqlconn.Close();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class HomePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("EmployeeDetails");
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("DisplayAllEmpDetails.aspx");
}
protected void Button3_Click(object sender, EventArgs e)
{

}
}

Student
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

public partial class DisplayAll : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();


SqlCommand objcmd = new SqlCommand("Select
Student_Number,Student_Name,Marks1,Marks2,Marks3,Total,Percentage,Grad
e from Student", objsqlconn);
GridView1.DataSource = objcmd.ExecuteReader();
GridView1.DataBind();


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

}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("StudentDetails.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{

}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

public partial class StudentDetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void btnadd_Click(object sender, EventArgs e)
{
int total = 0;
total = int.Parse(txtmarks1.Text) + int.Parse(txtmarks2.Text)
+ int.Parse(txtmarks3.Text);
string percentage = "";

float percent = total / 3;
percentage = percent.ToString() + "%";
char grade;
if (percent >= 70)
grade = 'A';
else if (percent >= 60)
grade = 'B';
else
grade = 'C';
string conn = "";
conn =
ConfigurationManager.ConnectionStrings["Conn"].ToString();
SqlConnection objsqlconn = new SqlConnection(conn);
objsqlconn.Open();


SqlCommand objcmd = new SqlCommand("insert into
Student(Student_Number,Student_Name,Marks1,Marks2,Marks3,Total,Percent
age,Grade)values('" + txttudentno.Text + "','" + txtsname.Text + "','"
+ txtmarks1.Text + "','" + txtmarks2.Text +
"','"+txtmarks3.Text+"','"+total.ToString()+"','"+percentage.ToString(
)+"','"+grade.ToString()+"')", objsqlconn);

objcmd.ExecuteNonQuery();
objsqlconn.Close();
}
}


Book
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

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

}
protected void btnaddnew_Click(object sender, EventArgs e)
{
string con = "";
con =
ConfigurationManager.ConnectionStrings["conn"].ToString();
SqlConnection objconn = new SqlConnection(con);
objconn.Open();
SqlCommand objcmd = new SqlCommand("insert into
BookDetails(accession_no,Author,Title,Publication,Edition,Volume)value
s('"+txtaccno.Text+"','"+txtauthor.Text+"','"+txttitle.Text+"','"+txtp
ublication.Text+"','"+txtedition.Text+"','"+txtvolume.Text+"')",objcon
n);
objcmd.ExecuteNonQuery();
objconn.Close();
}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

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

}
protected void btndelete_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
string con = "";
con =
ConfigurationManager.ConnectionStrings["conn"].ToString();
SqlConnection objconn = new SqlConnection(con);
objconn.Open();
SqlCommand objcmd = new SqlCommand("select * from BookDetails
where accession_no='" + txtaccno.Text + "'",objconn);

DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(objcmd);

da.Fill(ds);
lblaccno.Text =
ds.Tables[0].Rows[0]["accession_no"].ToString();
lblauthor.Text = ds.Tables[0].Rows[0]["Author"].ToString();
lbltitle.Text = ds.Tables[0].Rows[0]["Title"].ToString();
lblpublication.Text =
ds.Tables[0].Rows[0]["Publication"].ToString();

objcmd.CommandText = "delete from BookDetails where
accession_no='" + txtaccno.Text + "'";
objcmd.ExecuteNonQuery();
objcmd.Clone();
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

public partial class DisplayAll : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string conn = "";
conn =
ConfigurationManager.ConnectionStrings["conn"].ToString();
SqlConnection objconn = new SqlConnection(conn);
objconn.Open();
SqlCommand objcmd = new SqlCommand("select
accession_no,Author,Title,Publication,Edition,Volume from
BookDetails", objconn);
//SqlDataAdapter da = new SqlDataAdapter(objcmd);
//DataSet ds = new DataSet();
//da.Fill(ds);
//GridView1.DataSource = ds;
GridView1.DataSource = objcmd.ExecuteReader();
GridView1.DataBind();
}
}
}

MENU sOURCE CODE
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Menus.aspx.cs" Inherits="Menus" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ul>
<li><a href="AddNewBookDetails.aspx" target="right">Add New Books</a></li>
<li><a href="DisplayAll.aspx" target="right">Display All Records</a></li>
<li><a href="Delete.aspx" target="right">Delete</a></li>
</ul>
</div>
</form>
</body>
</html>

You might also like