>>>>>>>>>>>>>>>>>>>>>>>>>>>GETCoNneCTION.cs>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace ConnectionStringClass
{
public class GetConnection
{
public static string path;
static GetConnection()
{
path = ConfigurationManager.ConnectionStrings["RESERVATION"].ConnectionString;
}
}
}
<<<<<<<<<<<<<<<<<<<<<BE.cs>>>>>>>>>>>>>>>>>>>>>>>>>.......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BE_Reservation
{
public class BE
{
public int id { get; set; }
public string name { get; set; }
public string address { get; set; }
public string dis { get; set; }
}
}
>.>>>>>>>>>>>>>>>>>>DAL.cs>>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BE_Reservation;
using ConnectionStringClass;
namespace DAL_Reservation
{
public class DAL
{
private string connect = GetConnection.path;
public List<BE> show()
{
List<BE> list = new List<BE>();
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("pogo", con);
cmd.CommandType = CommandType.StoredProcedure;
try
{
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
while (sdr.Read())
{
BE be = new BE();
be.id = Convert.ToInt32(sdr["id"]);
be.name = Convert.ToString(sdr["name"]);
be.address = Convert.ToString(sdr["address"]);
be.dis = Convert.ToString(sdr["dis"]);
list.Add(be);
}
}
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
return list;
}
public void UpdateReserver(BE be)
{
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("spupdate", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", be.id);
cmd.Parameters.AddWithValue("@name", be.name);
cmd.Parameters.AddWithValue("@address", be.address);
cmd.Parameters.AddWithValue("@dis", be.dis);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
}
public void DeleteR(BE be)
{
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("spdelete ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", be.id);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
}
public void InsertR(BE be)
{
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("spInsert ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", be.name);
cmd.Parameters.AddWithValue("@address", be.address);
cmd.Parameters.AddWithValue("@dis", be.dis);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>BL.cs>>>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_Reservation;
using DAL_Reservation;
namespace BL_Reservation
{
public class BL
{
public List<BE> show()
{
return new DAL().show();
}
public void UpdateReserver(BE be)
{
new DAL().UpdateReserver(be);
}
public void DeleteR(BE be)
{
new DAL().DeleteR(be);
}
public void InsertR(BE be)
{
new DAL().InsertR(be);
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>WEBFoRm1.apx>>>>>>>>>>>>>>>>>>>>>>>>>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Sale.WebForm1" EnableEventValidation="false" %>
<!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>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="id" OnItemEditing="ListView1_ItemEditing" OnItemUpdating="ListView1_ItemUpdating"
OnItemDeleting="ListView1_ItemDeleting" OnItemCanceling="ListView1_Cancelling" InsertItemPosition="LastItem" OnItemInserting="ListView1_ItemInserting">
<LayoutTemplate>
<table border="1">
<tr>
<td style="width: 100px">
Id
</td>
<td style="width: 100px">
Name
</td>
<td style="width: 100px">
Address
</td>
<td style="width: 200px">
dis
</td>
<td style="width: 200px">
Actions
</td>
</tr>
</table>
<div id="ItemPlaceholder" runat="server">
</div>
</table>
</LayoutTemplate>
<ItemTemplate>
<table border="1">
<tr>
<td style="width: 100px">
<%#Eval("id") %>
</td>
<td style="width: 100px">
<%#Eval("name") %>
</td>
<td style="width: 100px">
<%#Eval("address") %>
</td>
<td style="width: 200px">
<%#Eval("dis") %>
</td>
<td style="width: 200px">
<asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" />
<asp:Button ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="1">
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("id") %>'></asp:TextBox>
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox2" runat="server" Text='<%#Eval("name") %>'></asp:TextBox>
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox3" runat="server" Text='<%#Eval("address") %>'></asp:TextBox>
</td>
<td style="width: 200px">
<asp:TextBox ID="TextBox4" runat="server" Text='<%#Eval("dis") %>'></asp:TextBox>
</td>
<td style="width: 200px">
<asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table border="1">
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</td>
<td style="width: 200px">
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</td>
<td style="width: 200px">
<asp:Button ID="btnInsert" runat="server" Text="Insert" CommandName="Insert" />
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>webform1.aspx.cs>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BE_Reservation;
using BL_Reservation;
namespace Sale
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
databind();
}
}
protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e)
{
ListView1.EditIndex = e.NewEditIndex;
databind();
}
protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
{
TextBox txtItems1 = (e.Item.FindControl("TextBox5")) as TextBox;
TextBox txtItems2 = (e.Item.FindControl("TextBox6")) as TextBox;
TextBox txtItems3 = (e.Item.FindControl("TextBox7")) as TextBox;
BE bem = new BE();
bem.name = txtItems1.Text;
bem.address = txtItems2.Text;
bem.dis = txtItems3.Text;
new BL().InsertR(bem);
txtItems1.Text = "";
databind();
}
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
string lId = ListView1.DataKeys[e.ItemIndex].Value.ToString();
TextBox detail2 = ListView1.Items[e.ItemIndex].FindControl("TextBox2") as TextBox;
TextBox detail3 = ListView1.Items[e.ItemIndex].FindControl("TextBox3") as TextBox;
TextBox detail4 = ListView1.Items[e.ItemIndex].FindControl("TextBox4") as TextBox;
BE bes = new BE();
bes.id = Convert.ToInt32(lId);
bes.name = detail2.Text;
bes.address = detail3.Text;
bes.dis = detail4.Text;
new BL().UpdateReserver(bes);
ListView1.EditIndex = -1;
databind();
}
protected void ListView1_ItemDeleting(object sender, ListViewDeleteEventArgs e)
{
string listId = ListView1.DataKeys[e.ItemIndex].Value.ToString();
BE bem = new BE();
bem.id = Convert.ToInt32(listId);
new BL().DeleteR(bem);
databind();
}
protected void ListView1_Cancelling(object sender, ListViewCancelEventArgs e)
{
ListView1.EditIndex = -1;
databind();
}
public void databind()
{
ListView1.DataSource = new BL().show();
ListView1.DataBind();
}
}
}
alter proc spGetValue
@Id nvarchar(50),
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
UPDATE Tbl_dis
SET [Education]=@Education,
[Institute]=@Institute,
[City]=@City,
[Job]=@Job
WHERE @Id=Id
end
>>>>>>>>>>>>>>>>>>>>>>>UPDATE >><<<<<<<<<<<<<<<
alter proc spGetValue 1,'dhsj','hjsajd','hgaj','hgsdhga'
@Id int,
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
UPDATE Tbl_dis
SET [Education]=@Education,
[Institute]=@Institute,
[City]=@City,
[Job]=@Job
WHERE @Id=Id
end
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>INSERT >>>>>>>>>>>>>>>>>>>>>>..
alter proc spGetValue2 'Bcom','national','toba','tch'
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
INSERT INTO Tbl_dis
([Education]
,[Institute]
,[City]
,[Job])
VALUES
(@Education
,@Institute
,@City
,@Job)
end
>>>>>>>>>>>>>>>>>>>>>>......delete>>>>>.................]
\
create proc spvalue '2'
@Id int
as
begin
DELETE FROM Tbl_dis
WHERE Id=@Id
end
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace ConnectionStringClass
{
public class GetConnection
{
public static string path;
static GetConnection()
{
path = ConfigurationManager.ConnectionStrings["RESERVATION"].ConnectionString;
}
}
}
<<<<<<<<<<<<<<<<<<<<<BE.cs>>>>>>>>>>>>>>>>>>>>>>>>>.......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BE_Reservation
{
public class BE
{
public int id { get; set; }
public string name { get; set; }
public string address { get; set; }
public string dis { get; set; }
}
}
>.>>>>>>>>>>>>>>>>>>DAL.cs>>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using BE_Reservation;
using ConnectionStringClass;
namespace DAL_Reservation
{
public class DAL
{
private string connect = GetConnection.path;
public List<BE> show()
{
List<BE> list = new List<BE>();
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("pogo", con);
cmd.CommandType = CommandType.StoredProcedure;
try
{
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.HasRows)
{
while (sdr.Read())
{
BE be = new BE();
be.id = Convert.ToInt32(sdr["id"]);
be.name = Convert.ToString(sdr["name"]);
be.address = Convert.ToString(sdr["address"]);
be.dis = Convert.ToString(sdr["dis"]);
list.Add(be);
}
}
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
return list;
}
public void UpdateReserver(BE be)
{
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("spupdate", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", be.id);
cmd.Parameters.AddWithValue("@name", be.name);
cmd.Parameters.AddWithValue("@address", be.address);
cmd.Parameters.AddWithValue("@dis", be.dis);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
}
public void DeleteR(BE be)
{
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("spdelete ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", be.id);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
}
public void InsertR(BE be)
{
SqlConnection con = new SqlConnection(connect);
SqlCommand cmd = new SqlCommand("spInsert ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@name", be.name);
cmd.Parameters.AddWithValue("@address", be.address);
cmd.Parameters.AddWithValue("@dis", be.dis);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
catch (Exception exe)
{
throw exe;
}
finally
{
con.Close();
}
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>BL.cs>>>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE_Reservation;
using DAL_Reservation;
namespace BL_Reservation
{
public class BL
{
public List<BE> show()
{
return new DAL().show();
}
public void UpdateReserver(BE be)
{
new DAL().UpdateReserver(be);
}
public void DeleteR(BE be)
{
new DAL().DeleteR(be);
}
public void InsertR(BE be)
{
new DAL().InsertR(be);
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>WEBFoRm1.apx>>>>>>>>>>>>>>>>>>>>>>>>>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Sale.WebForm1" EnableEventValidation="false" %>
<!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>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="id" OnItemEditing="ListView1_ItemEditing" OnItemUpdating="ListView1_ItemUpdating"
OnItemDeleting="ListView1_ItemDeleting" OnItemCanceling="ListView1_Cancelling" InsertItemPosition="LastItem" OnItemInserting="ListView1_ItemInserting">
<LayoutTemplate>
<table border="1">
<tr>
<td style="width: 100px">
Id
</td>
<td style="width: 100px">
Name
</td>
<td style="width: 100px">
Address
</td>
<td style="width: 200px">
dis
</td>
<td style="width: 200px">
Actions
</td>
</tr>
</table>
<div id="ItemPlaceholder" runat="server">
</div>
</table>
</LayoutTemplate>
<ItemTemplate>
<table border="1">
<tr>
<td style="width: 100px">
<%#Eval("id") %>
</td>
<td style="width: 100px">
<%#Eval("name") %>
</td>
<td style="width: 100px">
<%#Eval("address") %>
</td>
<td style="width: 200px">
<%#Eval("dis") %>
</td>
<td style="width: 200px">
<asp:Button ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" />
<asp:Button ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="1">
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server" Text='<%#Eval("id") %>'></asp:TextBox>
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox2" runat="server" Text='<%#Eval("name") %>'></asp:TextBox>
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox3" runat="server" Text='<%#Eval("address") %>'></asp:TextBox>
</td>
<td style="width: 200px">
<asp:TextBox ID="TextBox4" runat="server" Text='<%#Eval("dis") %>'></asp:TextBox>
</td>
<td style="width: 200px">
<asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" />
</td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table border="1">
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</td>
<td style="width: 200px">
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</td>
<td style="width: 200px">
<asp:Button ID="btnInsert" runat="server" Text="Insert" CommandName="Insert" />
</td>
</tr>
</table>
</InsertItemTemplate>
</asp:ListView>
</div>
</form>
</body>
</html>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>webform1.aspx.cs>>>>>>>>>>>>>>>>>>>>>>>>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BE_Reservation;
using BL_Reservation;
namespace Sale
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
databind();
}
}
protected void ListView1_ItemEditing(object sender, ListViewEditEventArgs e)
{
ListView1.EditIndex = e.NewEditIndex;
databind();
}
protected void ListView1_ItemInserting(object sender, ListViewInsertEventArgs e)
{
TextBox txtItems1 = (e.Item.FindControl("TextBox5")) as TextBox;
TextBox txtItems2 = (e.Item.FindControl("TextBox6")) as TextBox;
TextBox txtItems3 = (e.Item.FindControl("TextBox7")) as TextBox;
BE bem = new BE();
bem.name = txtItems1.Text;
bem.address = txtItems2.Text;
bem.dis = txtItems3.Text;
new BL().InsertR(bem);
txtItems1.Text = "";
databind();
}
protected void ListView1_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
string lId = ListView1.DataKeys[e.ItemIndex].Value.ToString();
TextBox detail2 = ListView1.Items[e.ItemIndex].FindControl("TextBox2") as TextBox;
TextBox detail3 = ListView1.Items[e.ItemIndex].FindControl("TextBox3") as TextBox;
TextBox detail4 = ListView1.Items[e.ItemIndex].FindControl("TextBox4") as TextBox;
BE bes = new BE();
bes.id = Convert.ToInt32(lId);
bes.name = detail2.Text;
bes.address = detail3.Text;
bes.dis = detail4.Text;
new BL().UpdateReserver(bes);
ListView1.EditIndex = -1;
databind();
}
protected void ListView1_ItemDeleting(object sender, ListViewDeleteEventArgs e)
{
string listId = ListView1.DataKeys[e.ItemIndex].Value.ToString();
BE bem = new BE();
bem.id = Convert.ToInt32(listId);
new BL().DeleteR(bem);
databind();
}
protected void ListView1_Cancelling(object sender, ListViewCancelEventArgs e)
{
ListView1.EditIndex = -1;
databind();
}
public void databind()
{
ListView1.DataSource = new BL().show();
ListView1.DataBind();
}
}
}
alter proc spGetValue
@Id nvarchar(50),
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
UPDATE Tbl_dis
SET [Education]=@Education,
[Institute]=@Institute,
[City]=@City,
[Job]=@Job
WHERE @Id=Id
end
>>>>>>>>>>>>>>>>>>>>>>>UPDATE >><<<<<<<<<<<<<<<
alter proc spGetValue 1,'dhsj','hjsajd','hgaj','hgsdhga'
@Id int,
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
UPDATE Tbl_dis
SET [Education]=@Education,
[Institute]=@Institute,
[City]=@City,
[Job]=@Job
WHERE @Id=Id
end
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>INSERT >>>>>>>>>>>>>>>>>>>>>>..
alter proc spGetValue2 'Bcom','national','toba','tch'
@Education varchar(50),
@Institute varchar(50),
@City varchar(20),
@Job nvarchar(50)
as
begin
INSERT INTO Tbl_dis
([Education]
,[Institute]
,[City]
,[Job])
VALUES
(@Education
,@Institute
,@City
,@Job)
end
>>>>>>>>>>>>>>>>>>>>>>......delete>>>>>.................]
\
create proc spvalue '2'
@Id int
as
begin
DELETE FROM Tbl_dis
WHERE Id=@Id
end
No comments :
Post a Comment