aspc 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aspc-1.0.0/PKG-INFO +15 -0
- aspc-1.0.0/README.md +8 -0
- aspc-1.0.0/pyproject.toml +24 -0
- aspc-1.0.0/setup.cfg +4 -0
- aspc-1.0.0/src/aspc/__init__.py +1 -0
- aspc-1.0.0/src/aspc/__main__.py +3 -0
- aspc-1.0.0/src/aspc/cli.py +58 -0
- aspc-1.0.0/src/aspc/practicals/p1/WebForm1.aspx +48 -0
- aspc-1.0.0/src/aspc/practicals/p1/WebForm1.aspx.cs +64 -0
- aspc-1.0.0/src/aspc/practicals/p10/WebForm1.aspx +21 -0
- aspc-1.0.0/src/aspc/practicals/p10/WebForm1.aspx.cs +29 -0
- aspc-1.0.0/src/aspc/practicals/p12/WebForm1.aspx +46 -0
- aspc-1.0.0/src/aspc/practicals/p12/WebForm1.aspx.cs +56 -0
- aspc-1.0.0/src/aspc/practicals/p13/WebForm1.aspx +50 -0
- aspc-1.0.0/src/aspc/practicals/p13/WebForm1.aspx.cs +101 -0
- aspc-1.0.0/src/aspc/practicals/p14/WebForm1.aspx +46 -0
- aspc-1.0.0/src/aspc/practicals/p14/WebForm1.aspx.cs +78 -0
- aspc-1.0.0/src/aspc/practicals/p15/WebForm1.aspx +29 -0
- aspc-1.0.0/src/aspc/practicals/p15/WebForm1.aspx.cs +49 -0
- aspc-1.0.0/src/aspc/practicals/p17/WebForm1.aspx +20 -0
- aspc-1.0.0/src/aspc/practicals/p17/WebForm1.aspx.cs +56 -0
- aspc-1.0.0/src/aspc/practicals/p17/XMLFile1.xml +12 -0
- aspc-1.0.0/src/aspc/practicals/p18/WebForm1.aspx +63 -0
- aspc-1.0.0/src/aspc/practicals/p18/WebForm1.aspx.cs +32 -0
- aspc-1.0.0/src/aspc/practicals/p19/WebForm1.aspx +28 -0
- aspc-1.0.0/src/aspc/practicals/p19/WebForm1.aspx.cs +38 -0
- aspc-1.0.0/src/aspc/practicals/p2/WebForm1.aspx +27 -0
- aspc-1.0.0/src/aspc/practicals/p2/WebForm1.aspx.cs +52 -0
- aspc-1.0.0/src/aspc/practicals/p22/WebForm1.aspx +30 -0
- aspc-1.0.0/src/aspc/practicals/p22/WebForm1.aspx.cs +36 -0
- aspc-1.0.0/src/aspc/practicals/p3/WebForm1.aspx +40 -0
- aspc-1.0.0/src/aspc/practicals/p3/WebForm1.aspx.cs +36 -0
- aspc-1.0.0/src/aspc/practicals/p4/WebForm1.aspx +41 -0
- aspc-1.0.0/src/aspc/practicals/p4/WebForm1.aspx.cs +33 -0
- aspc-1.0.0/src/aspc/practicals/p5/WebForm1.aspx +18 -0
- aspc-1.0.0/src/aspc/practicals/p5/WebForm1.aspx.cs +17 -0
- aspc-1.0.0/src/aspc/practicals/p5/XMLFile1.xml +10 -0
- aspc-1.0.0/src/aspc/practicals/p6/WebUserControl1.ascx +9 -0
- aspc-1.0.0/src/aspc/practicals/p7/Web.sitemap +14 -0
- aspc-1.0.0/src/aspc/practicals/p7/WebForm1.aspx +30 -0
- aspc-1.0.0/src/aspc/practicals/p8/Site1.Master +62 -0
- aspc-1.0.0/src/aspc/practicals/p8/Skin1.Skin +20 -0
- aspc-1.0.0/src/aspc/practicals/p8/WebForm1.aspx +12 -0
- aspc-1.0.0/src/aspc/practicals/p9/WebForm1.aspx +30 -0
- aspc-1.0.0/src/aspc/practicals/p9/WebForm1.aspx.cs +34 -0
- aspc-1.0.0/src/aspc.egg-info/PKG-INFO +15 -0
- aspc-1.0.0/src/aspc.egg-info/SOURCES.txt +48 -0
- aspc-1.0.0/src/aspc.egg-info/dependency_links.txt +1 -0
- aspc-1.0.0/src/aspc.egg-info/entry_points.txt +2 -0
- aspc-1.0.0/src/aspc.egg-info/top_level.txt +1 -0
aspc-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aspc
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: ASP.NET practical installer
|
|
5
|
+
Requires-Python: >=3.9
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
|
|
8
|
+
# aspc
|
|
9
|
+
|
|
10
|
+
practice make man perfect
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install aspc
|
aspc-1.0.0/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "aspc"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "ASP.NET practical installer"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
|
|
12
|
+
[project.scripts]
|
|
13
|
+
aspc = "aspc.cli:main"
|
|
14
|
+
|
|
15
|
+
[tool.setuptools]
|
|
16
|
+
include-package-data = true
|
|
17
|
+
|
|
18
|
+
[tool.setuptools.packages.find]
|
|
19
|
+
where = ["src"]
|
|
20
|
+
|
|
21
|
+
[tool.setuptools.package-data]
|
|
22
|
+
aspc = [
|
|
23
|
+
"practicals/**/*"
|
|
24
|
+
]
|
aspc-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import shutil
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def install_practical(practical):
|
|
7
|
+
|
|
8
|
+
package_dir = Path(__file__).resolve().parent
|
|
9
|
+
source = package_dir / "practicals" / practical
|
|
10
|
+
|
|
11
|
+
# If practical doesn't exist, silently do nothing
|
|
12
|
+
if not source.exists():
|
|
13
|
+
return
|
|
14
|
+
|
|
15
|
+
destination = Path.cwd()
|
|
16
|
+
|
|
17
|
+
# Copy everything inside the practical folder
|
|
18
|
+
for item in source.rglob("*"):
|
|
19
|
+
|
|
20
|
+
if item.is_file():
|
|
21
|
+
|
|
22
|
+
relative_path = item.relative_to(source)
|
|
23
|
+
target = destination / relative_path
|
|
24
|
+
|
|
25
|
+
target.parent.mkdir(
|
|
26
|
+
parents=True,
|
|
27
|
+
exist_ok=True
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
shutil.copy2(item, target)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def main():
|
|
34
|
+
|
|
35
|
+
# No argument → do nothing
|
|
36
|
+
if len(sys.argv) != 2:
|
|
37
|
+
return
|
|
38
|
+
|
|
39
|
+
practical = sys.argv[1].lower()
|
|
40
|
+
|
|
41
|
+
# Only p1 through p22 are allowed
|
|
42
|
+
if not practical.startswith("p"):
|
|
43
|
+
return
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
number = int(practical[1:])
|
|
47
|
+
except ValueError:
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
# p23, p33, p100 etc. → do nothing
|
|
51
|
+
if number < 1 or number > 22:
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
install_practical(practical)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == "__main__":
|
|
58
|
+
main()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="practical1.WebForm1" %>
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
6
|
+
<head runat="server">
|
|
7
|
+
<title></title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<form id="form1" runat="server">
|
|
11
|
+
<div>
|
|
12
|
+
</div>
|
|
13
|
+
<asp:Label ID="Label1" runat="server" Text="student from"></asp:Label>
|
|
14
|
+
<p>
|
|
15
|
+
Name:-<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
|
|
16
|
+
</p>
|
|
17
|
+
<p>
|
|
18
|
+
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
|
|
19
|
+
</p>
|
|
20
|
+
<p>
|
|
21
|
+
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="n" Text="TY" />
|
|
22
|
+
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="n" Text="SY" />
|
|
23
|
+
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="n" Text="FY" />
|
|
24
|
+
</p>
|
|
25
|
+
<p>
|
|
26
|
+
Course:-
|
|
27
|
+
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
|
|
28
|
+
<asp:ListItem>IT</asp:ListItem>
|
|
29
|
+
<asp:ListItem>BT</asp:ListItem>
|
|
30
|
+
</asp:DropDownList>
|
|
31
|
+
</p>
|
|
32
|
+
<p>
|
|
33
|
+
subject:-<asp:DropDownList ID="DropDownList2" runat="server">
|
|
34
|
+
<asp:ListItem>Webdev</asp:ListItem>
|
|
35
|
+
<asp:ListItem>DSA</asp:ListItem>
|
|
36
|
+
</asp:DropDownList>
|
|
37
|
+
<asp:DropDownList ID="DropDownList3" runat="server">
|
|
38
|
+
<asp:ListItem>BR</asp:ListItem>
|
|
39
|
+
<asp:ListItem>BT</asp:ListItem>
|
|
40
|
+
</asp:DropDownList>
|
|
41
|
+
</p>
|
|
42
|
+
<p>
|
|
43
|
+
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
|
|
44
|
+
</p>
|
|
45
|
+
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
|
|
46
|
+
</form>
|
|
47
|
+
</body>
|
|
48
|
+
</html>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Web;
|
|
5
|
+
using System.Web.UI;
|
|
6
|
+
using System.Web.UI.WebControls;
|
|
7
|
+
|
|
8
|
+
namespace practical1
|
|
9
|
+
{
|
|
10
|
+
public partial class WebForm1 : System.Web.UI.Page
|
|
11
|
+
{
|
|
12
|
+
protected void Page_Load(object sender, EventArgs e)
|
|
13
|
+
{
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
protected void Button1_Click(object sender, EventArgs e)
|
|
18
|
+
{
|
|
19
|
+
String name = TextBox1.Text;
|
|
20
|
+
String csel = "";
|
|
21
|
+
|
|
22
|
+
if (RadioButton1.Checked)
|
|
23
|
+
{
|
|
24
|
+
csel = RadioButton1.Text;
|
|
25
|
+
}
|
|
26
|
+
else if (RadioButton2.Checked) {
|
|
27
|
+
csel = RadioButton2.Text;
|
|
28
|
+
}
|
|
29
|
+
else if(RadioButton3.Checked)
|
|
30
|
+
{
|
|
31
|
+
csel= RadioButton3.Text;
|
|
32
|
+
}
|
|
33
|
+
String co=DropDownList1.SelectedValue;
|
|
34
|
+
String sub = "";
|
|
35
|
+
if (DropDownList2.Visible)
|
|
36
|
+
{
|
|
37
|
+
sub = DropDownList2.SelectedValue;
|
|
38
|
+
}
|
|
39
|
+
else if(DropDownList3.Visible)
|
|
40
|
+
{
|
|
41
|
+
sub=DropDownList3.SelectedValue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Label3.Text = $"Name:{name}<br>"+$"course:{co}<br>"+$"subject:{sub}<br>"+$"class:{csel}";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
|
|
48
|
+
{
|
|
49
|
+
DropDownList2.Visible = false;
|
|
50
|
+
DropDownList3.Visible = false;
|
|
51
|
+
switch (DropDownList1.SelectedValue){
|
|
52
|
+
case "IT":
|
|
53
|
+
DropDownList2.Visible =true;
|
|
54
|
+
break;
|
|
55
|
+
case "BT":
|
|
56
|
+
DropDownList3.Visible =true;
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
DropDownList2.Visible =true;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="prac10ex.WebForm1" %>
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
6
|
+
<head runat="server">
|
|
7
|
+
<title></title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<form id="form1" runat="server">
|
|
11
|
+
<div>
|
|
12
|
+
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
|
|
13
|
+
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
|
|
14
|
+
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
|
|
15
|
+
<br />
|
|
16
|
+
<br />
|
|
17
|
+
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
|
|
18
|
+
</div>
|
|
19
|
+
</form>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Data.SqlClient;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using System.Web;
|
|
6
|
+
using System.Web.UI;
|
|
7
|
+
using System.Web.UI.WebControls;
|
|
8
|
+
|
|
9
|
+
namespace prac10ex
|
|
10
|
+
{
|
|
11
|
+
public partial class WebForm1 : System.Web.UI.Page
|
|
12
|
+
{
|
|
13
|
+
SqlConnection con=new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=exam;Integrated Security=True;TrustServerCertificate=True;");
|
|
14
|
+
SqlCommand cmd=new SqlCommand();
|
|
15
|
+
protected void Page_Load(object sender, EventArgs e)
|
|
16
|
+
{
|
|
17
|
+
con.Open();
|
|
18
|
+
cmd.Connection=con;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
protected void Button1_Click(object sender, EventArgs e)
|
|
22
|
+
{
|
|
23
|
+
String sql="Select * from exam where name='"+TextBox1.Text+"'"+"and pass='"+TextBox2.Text+"'";
|
|
24
|
+
cmd.CommandText = sql;
|
|
25
|
+
Label1.Text= cmd.ExecuteScalar().ToString();
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="prac12.WebForm1" %>
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
6
|
+
<head runat="server">
|
|
7
|
+
<title></title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<form id="form1" runat="server">
|
|
11
|
+
<div>
|
|
12
|
+
<asp:Label ID="Label1" runat="server" Text="Enter id:"></asp:Label>
|
|
13
|
+
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
|
|
14
|
+
<br />
|
|
15
|
+
<asp:Label ID="Label2" runat="server" Text="Enter Name:"></asp:Label>
|
|
16
|
+
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
|
|
17
|
+
<br />
|
|
18
|
+
<asp:Label ID="Label3" runat="server" Text="Enter Salary:"></asp:Label>
|
|
19
|
+
<asp:TextBox ID="TextBox3" runat="server" Height="16px"></asp:TextBox>
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
22
|
+
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="insert" />
|
|
23
|
+
|
|
24
|
+
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="view" />
|
|
25
|
+
|
|
26
|
+
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="update" />
|
|
27
|
+
|
|
28
|
+
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="delete" />
|
|
29
|
+
<br />
|
|
30
|
+
<br />
|
|
31
|
+
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
|
|
32
|
+
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
|
|
33
|
+
<Columns>
|
|
34
|
+
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
|
|
35
|
+
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
|
|
36
|
+
<asp:BoundField DataField="salary" HeaderText="salary" SortExpression="salary" />
|
|
37
|
+
</Columns>
|
|
38
|
+
</asp:GridView>
|
|
39
|
+
<br />
|
|
40
|
+
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sem5ConnectionString %>" SelectCommand="SELECT * FROM [emp]"></asp:SqlDataSource>
|
|
41
|
+
<br />
|
|
42
|
+
<br />
|
|
43
|
+
</div>
|
|
44
|
+
</form>
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Data.SqlClient;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using System.Web;
|
|
6
|
+
using System.Web.UI;
|
|
7
|
+
using System.Web.UI.WebControls;
|
|
8
|
+
|
|
9
|
+
namespace prac12
|
|
10
|
+
{
|
|
11
|
+
public partial class WebForm1 : System.Web.UI.Page
|
|
12
|
+
{
|
|
13
|
+
SqlConnection cn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=sem5;Integrated Security=True;TrustServerCertificate=True");
|
|
14
|
+
SqlCommand co = new SqlCommand();
|
|
15
|
+
SqlDataReader ds;
|
|
16
|
+
protected void Page_Load(object sender, EventArgs e)
|
|
17
|
+
{
|
|
18
|
+
cn.Open();
|
|
19
|
+
co.Connection = cn;
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
protected void Button1_Click(object sender, EventArgs e)
|
|
24
|
+
{
|
|
25
|
+
String sql = "insert into emp values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "')";
|
|
26
|
+
co.CommandText = sql;
|
|
27
|
+
co.ExecuteNonQuery();
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
protected void Button2_Click(object sender, EventArgs e)
|
|
33
|
+
{
|
|
34
|
+
co.CommandText = "select * from emp";
|
|
35
|
+
ds = co.ExecuteReader();
|
|
36
|
+
GridView1.DataSourceID = null;
|
|
37
|
+
GridView1.DataSource = ds; // Fixed: assigned DataSource
|
|
38
|
+
GridView1.DataBind();
|
|
39
|
+
ds.Close();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected void Button3_Click(object sender, EventArgs e)
|
|
43
|
+
{
|
|
44
|
+
String sql = "update emp set name='" + TextBox2.Text + "', salary=" + TextBox3.Text + " where id=" + TextBox1.Text;
|
|
45
|
+
co.CommandText = sql;
|
|
46
|
+
co.ExecuteNonQuery();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected void Button4_Click(object sender, EventArgs e)
|
|
50
|
+
{
|
|
51
|
+
String sql = "delete from emp where id=" + TextBox1.Text;
|
|
52
|
+
co.CommandText = sql;
|
|
53
|
+
co.ExecuteNonQuery();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="prac13.WebForm1" %>
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
6
|
+
<head runat="server">
|
|
7
|
+
<title></title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<form id="form1" runat="server">
|
|
11
|
+
<div>
|
|
12
|
+
<asp:Label ID="Label1" runat="server" Text="id:"></asp:Label>
|
|
13
|
+
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
|
|
14
|
+
<br />
|
|
15
|
+
<asp:Label ID="Label2" runat="server" Text="Name:"></asp:Label>
|
|
16
|
+
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
|
|
17
|
+
<br />
|
|
18
|
+
<asp:Label ID="Label3" runat="server" Text="salary"></asp:Label>
|
|
19
|
+
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
22
|
+
<br />
|
|
23
|
+
<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label>
|
|
24
|
+
<br />
|
|
25
|
+
<br />
|
|
26
|
+
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="insert" />
|
|
27
|
+
|
|
28
|
+
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="update" />
|
|
29
|
+
|
|
30
|
+
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="delete" />
|
|
31
|
+
|
|
32
|
+
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="view" />
|
|
33
|
+
<br />
|
|
34
|
+
<br />
|
|
35
|
+
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
|
|
36
|
+
<Columns>
|
|
37
|
+
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
|
|
38
|
+
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
|
|
39
|
+
<asp:BoundField DataField="salary" HeaderText="salary" SortExpression="salary" />
|
|
40
|
+
</Columns>
|
|
41
|
+
</asp:GridView>
|
|
42
|
+
<br />
|
|
43
|
+
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sem5ConnectionString %>" ProviderName="<%$ ConnectionStrings:sem5ConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [emp]"></asp:SqlDataSource>
|
|
44
|
+
<br />
|
|
45
|
+
<br />
|
|
46
|
+
<br />
|
|
47
|
+
</div>
|
|
48
|
+
</form>
|
|
49
|
+
</body>
|
|
50
|
+
</html>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Data.SqlClient;
|
|
4
|
+
using System.Linq;
|
|
5
|
+
using System.Web;
|
|
6
|
+
using System.Web.UI;
|
|
7
|
+
using System.Web.UI.WebControls;
|
|
8
|
+
|
|
9
|
+
namespace prac13
|
|
10
|
+
{
|
|
11
|
+
public partial class WebForm1 : System.Web.UI.Page
|
|
12
|
+
{
|
|
13
|
+
SqlConnection cn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=sem5;Integrated Security=True;TrustServerCertificate=True");
|
|
14
|
+
SqlCommand co = new SqlCommand();
|
|
15
|
+
SqlDataReader ds;
|
|
16
|
+
SqlParameter @p1,@p2,@p3;
|
|
17
|
+
|
|
18
|
+
protected void Page_Load(object sender, EventArgs e)
|
|
19
|
+
{
|
|
20
|
+
cn.Open();
|
|
21
|
+
co.Connection= cn;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected void Button1_Click(object sender, EventArgs e)
|
|
25
|
+
{
|
|
26
|
+
@p1 = new SqlParameter();
|
|
27
|
+
@p2 = new SqlParameter();
|
|
28
|
+
@p3 = new SqlParameter();
|
|
29
|
+
@p1.ParameterName = "id";
|
|
30
|
+
@p1.ParameterName = "name";
|
|
31
|
+
@p1.ParameterName = "salary";
|
|
32
|
+
|
|
33
|
+
@p1.DbType=System.Data.DbType.Int32;
|
|
34
|
+
@p2.DbType = System.Data.DbType.String;
|
|
35
|
+
@p3.DbType = System.Data.DbType.Int32;
|
|
36
|
+
|
|
37
|
+
co.Parameters.AddWithValue("@p1", TextBox1.Text);
|
|
38
|
+
co.Parameters.AddWithValue("@p2", TextBox2.Text);
|
|
39
|
+
co.Parameters.AddWithValue("@p3", TextBox3.Text);
|
|
40
|
+
|
|
41
|
+
co.CommandText = "insert into emp(id,name,salary)values(@p1,@p2,@p3);";
|
|
42
|
+
co.ExecuteNonQuery();
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected void Button2_Click(object sender, EventArgs e)
|
|
47
|
+
{
|
|
48
|
+
@p1 = new SqlParameter();
|
|
49
|
+
@p2 = new SqlParameter();
|
|
50
|
+
@p3 = new SqlParameter();
|
|
51
|
+
@p1.ParameterName = "id";
|
|
52
|
+
@p1.ParameterName = "name";
|
|
53
|
+
@p1.ParameterName = "salary";
|
|
54
|
+
|
|
55
|
+
@p1.DbType = System.Data.DbType.Int32;
|
|
56
|
+
@p2.DbType = System.Data.DbType.String;
|
|
57
|
+
@p3.DbType = System.Data.DbType.Int32;
|
|
58
|
+
|
|
59
|
+
co.Parameters.AddWithValue("@p1", TextBox1.Text);
|
|
60
|
+
co.Parameters.AddWithValue("@p2", TextBox2.Text);
|
|
61
|
+
co.Parameters.AddWithValue("@p3", TextBox3.Text);
|
|
62
|
+
|
|
63
|
+
co.CommandText = "update emp set id=@p1,name=@p2,salary=@p3 where id=@p1;";
|
|
64
|
+
co.ExecuteNonQuery();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected void Button3_Click(object sender, EventArgs e)
|
|
68
|
+
{
|
|
69
|
+
@p1 = new SqlParameter();
|
|
70
|
+
@p2 = new SqlParameter();
|
|
71
|
+
@p3 = new SqlParameter();
|
|
72
|
+
@p1.ParameterName = "id";
|
|
73
|
+
@p1.ParameterName = "name";
|
|
74
|
+
@p1.ParameterName = "salary";
|
|
75
|
+
|
|
76
|
+
@p1.DbType = System.Data.DbType.Int32;
|
|
77
|
+
@p2.DbType = System.Data.DbType.String;
|
|
78
|
+
@p3.DbType = System.Data.DbType.Int32;
|
|
79
|
+
|
|
80
|
+
co.Parameters.AddWithValue("@p1", TextBox1.Text);
|
|
81
|
+
co.Parameters.AddWithValue("@p2", TextBox2.Text);
|
|
82
|
+
co.Parameters.AddWithValue("@p3", TextBox3.Text);
|
|
83
|
+
|
|
84
|
+
co.CommandText = "delete from emp where id=@p1";
|
|
85
|
+
co.ExecuteNonQuery();
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
protected void Button4_Click(object sender, EventArgs e)
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
GridView1.DataSourceID = null;
|
|
94
|
+
co.CommandText = "Select * from emp";
|
|
95
|
+
ds=co.ExecuteReader();
|
|
96
|
+
GridView1.DataSource = ds;
|
|
97
|
+
GridView1.DataBind();
|
|
98
|
+
ds.Close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="prac14.WebForm1" %>
|
|
2
|
+
|
|
3
|
+
<!DOCTYPE html>
|
|
4
|
+
|
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
6
|
+
<head runat="server">
|
|
7
|
+
<title></title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<form id="form1" runat="server">
|
|
11
|
+
<div>
|
|
12
|
+
<asp:Label ID="Label1" runat="server" Text="id"></asp:Label>
|
|
13
|
+
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
|
|
14
|
+
<br />
|
|
15
|
+
<asp:Label ID="Label2" runat="server" Text="name:"></asp:Label>
|
|
16
|
+
<asp:TextBox ID="TextBox2" runat="server" OnTextChanged="TextBox2_TextChanged"></asp:TextBox>
|
|
17
|
+
<br />
|
|
18
|
+
<asp:Label ID="Label3" runat="server" Text="team:"></asp:Label>
|
|
19
|
+
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
22
|
+
<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label>
|
|
23
|
+
<br />
|
|
24
|
+
<br />
|
|
25
|
+
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="insert" />
|
|
26
|
+
|
|
27
|
+
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="view" />
|
|
28
|
+
|
|
29
|
+
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click" style="height: 26px" Text="Update" />
|
|
30
|
+
|
|
31
|
+
<asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="delete" />
|
|
32
|
+
<br />
|
|
33
|
+
<br />
|
|
34
|
+
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
|
|
35
|
+
<Columns>
|
|
36
|
+
<asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
|
|
37
|
+
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
|
|
38
|
+
<asp:BoundField DataField="team" HeaderText="team" SortExpression="team" />
|
|
39
|
+
</Columns>
|
|
40
|
+
</asp:GridView>
|
|
41
|
+
<br />
|
|
42
|
+
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:sem5ConnectionString %>" ProviderName="<%$ ConnectionStrings:sem5ConnectionString.ProviderName %>" SelectCommand="SELECT * FROM [player]"></asp:SqlDataSource>
|
|
43
|
+
</div>
|
|
44
|
+
</form>
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Data;
|
|
3
|
+
using System.Data.SqlClient;
|
|
4
|
+
using System.Web.UI;
|
|
5
|
+
using System.Web.UI.WebControls;
|
|
6
|
+
|
|
7
|
+
namespace prac14
|
|
8
|
+
{
|
|
9
|
+
public partial class WebForm1 : System.Web.UI.Page
|
|
10
|
+
{
|
|
11
|
+
// Only SqlDataSource is needed!
|
|
12
|
+
SqlDataSource ds = new SqlDataSource();
|
|
13
|
+
|
|
14
|
+
protected void Page_Load(object sender, EventArgs e)
|
|
15
|
+
{
|
|
16
|
+
// SqlDataSource handles database connections automatically behind the scenes
|
|
17
|
+
ds.ConnectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=sem5;Integrated Security=True;Encrypt=False;TrustServerCertificate=True";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected void TextBox2_TextChanged(object sender, EventArgs e)
|
|
21
|
+
{
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// INSERT
|
|
26
|
+
protected void Button1_Click(object sender, EventArgs e)
|
|
27
|
+
{
|
|
28
|
+
ds.InsertParameters.Clear();
|
|
29
|
+
SqlParameter @p1 = new SqlParameter();
|
|
30
|
+
SqlParameter @p2 = new SqlParameter();
|
|
31
|
+
SqlParameter @p3 = new SqlParameter();
|
|
32
|
+
// Removed System.Data.DbType to avoid C# parsing errors
|
|
33
|
+
ds.InsertParameters.Add("p1", TextBox1.Text);
|
|
34
|
+
ds.InsertParameters.Add("p2", TextBox2.Text);
|
|
35
|
+
ds.InsertParameters.Add("p3", TextBox3.Text);
|
|
36
|
+
|
|
37
|
+
ds.InsertCommand = "insert into player values(@p1, @p2, @p3)";
|
|
38
|
+
ds.Insert();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// DISPLAY / SELECT
|
|
42
|
+
protected void Button2_Click(object sender, EventArgs e)
|
|
43
|
+
{
|
|
44
|
+
GridView1.DataSourceID = null;
|
|
45
|
+
ds.SelectCommand = "select * from player";
|
|
46
|
+
GridView1.DataSource = ds;
|
|
47
|
+
GridView1.DataBind(); // Displays data directly through SqlDataSource
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// UPDATE
|
|
51
|
+
protected void Button3_Click(object sender, EventArgs e)
|
|
52
|
+
{
|
|
53
|
+
SqlParameter @p1 = new SqlParameter();
|
|
54
|
+
SqlParameter @p2 = new SqlParameter();
|
|
55
|
+
SqlParameter @p3 = new SqlParameter();
|
|
56
|
+
ds.UpdateParameters.Clear();
|
|
57
|
+
ds.UpdateParameters.Add("p1", TextBox1.Text);
|
|
58
|
+
ds.UpdateParameters.Add("p2", TextBox2.Text);
|
|
59
|
+
ds.UpdateParameters.Add("p3", TextBox3.Text);
|
|
60
|
+
|
|
61
|
+
ds.UpdateCommand = "update player set name=@p2, team=@p3 where id=@p1";
|
|
62
|
+
ds.Update(); // Automatically executes update
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// DELETE
|
|
66
|
+
protected void Button4_Click(object sender, EventArgs e)
|
|
67
|
+
{
|
|
68
|
+
SqlParameter @p1 = new SqlParameter();
|
|
69
|
+
SqlParameter @p2 = new SqlParameter();
|
|
70
|
+
SqlParameter @p3 = new SqlParameter();
|
|
71
|
+
ds.DeleteParameters.Clear();
|
|
72
|
+
ds.DeleteParameters.Add("p1", TextBox1.Text);
|
|
73
|
+
|
|
74
|
+
ds.DeleteCommand = "delete from player where id=@p1";
|
|
75
|
+
ds.Delete(); // Automatically executes delete
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|