IU2241230054 Advanced .
Net Framework(CE0619) 6CSE-F1
Practical-12
Aim :- Create a website to retrieve data from the database and shown under the gridview
with edit/update operation.
Design
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Code: [Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Sitanshu DataSet<br />
<br />
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataKeyNames="Id" DataSourceID="SqlDataSource1"
DefaultMode="Insert" Height="50px" OnItemInserted="DetailsView1_ItemInserted"
Width="125px">
<EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True"
SortExpression="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"
/>
<asp:BoundField DataField="Branch" HeaderText="Branch"
SortExpression="Branch" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
</asp:DetailsView>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" DataKeyNames="Id" DataSourceID="SqlDataSource1"
OnRowDeleted="GridView1_RowDeleted" OnRowEditing="GridView1_RowEditing">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True"
SortExpression="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"
/>
<asp:BoundField DataField="Branch" HeaderText="Branch"
SortExpression="Branch" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM *Table+ WHERE
*Id+ = @Id" InsertCommand="INSERT INTO *Table+ (*Id+, *Name+, *Branch+) VALUES (@Id,
@Name, @Branch)" ProviderName="<%$
ConnectionStrings:[Link] %>" SelectCommand="SELECT * FROM
*Table+" UpdateCommand="UPDATE *Table+ SET *Name+ = @Name, *Branch+ = @Branch
WHERE *Id+ = @Id">
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Branch" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Branch" Type="String" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
Code : [Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace WebApplication5
,
public partial class WebForm1 : [Link]
,
protected void Page_Load(object sender, EventArgs e)
,
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs
e)
,
[Link] = "Record Entered";
[Link]();
-
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
,
[Link] = "Record Deleted";
[Link]();
-
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
,
[Link] = "Record Edited";
[Link]();
-
-
-
Output
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Practical-13
Aim :- Create a web page demonstrating the structure of MDI form.
Design
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Code: [Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
namespace mdi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Form2 f2;
private void form2ToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (f2 == null)
{
f2 = new Form2();
[Link] = this;
[Link] += new FormClosedEventHandler(f2_FormClosed);
[Link]();
}
else
{
[Link]();
}
}
void f2_FormClosed(object sender, FormClosedEventArgs e)
{
f2 = null;
}
private void form3ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Form3 f3 = new Form3();
[Link] = this;
[Link]();
}
}
}
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Output
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Practical-14
Aim :- Create a web page demonstrating the structure of MDI form.
Design
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Code: [Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="[Link]"
Inherits="Crud.WebForm1" %>
<!DOCTYPE html>
<html xmlns="[Link]
<head runat="server">
<title>CRUD in [Link]</title>
</head>
<body>
<form id="form1" runat="server">
<main>
<section class="row" aria-labelledby="aspnetTitle">
<h1 id="aspnetTitle">[Link]</h1>
<p class="lead">[Link] is a free web framework for building great Web sites and
Web applications using HTML, CSS, and JavaScript.</p>
<p><a href="[Link] class="btn btn-primary btn-md">Learn more
»</a></p>
</section>
<div style="padding:15px">
<table class="w-100">
<tr>
<td colspan="2" style="font-size: large; font-weight: bold; color: #6699FF">
Complete CRUD in [Link] with SQL
</td>
</tr>
<tr>
<td style="width: 463px;">
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
<asp:Label ID="Label1" runat="server" Text="Employee ID"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" CssClass="offset-sm-
0"></asp:TextBox>
<asp:Button ID="Button4" runat="server" Font-Bold="True"
OnClick="Button4_Click" Text="SELECT" />
</td>
</tr>
<tr>
<td style="width: 463px;">
<asp:Label ID="Label2" runat="server" Text="Employee Name"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 463px;">
<asp:Label ID="Label3" runat="server" Text="Employee City"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>New York</asp:ListItem>
<asp:ListItem>Chicago</asp:ListItem>
<asp:ListItem>Los Angeles</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
<td style="width: 463px;">
<asp:Label ID="Label4" runat="server" Text="Employee Age"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 463px;">
<asp:Label ID="Label5" runat="server" Text="Employee
Gender"></asp:Label>
</td>
<td>
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem>Male</asp:ListItem>
<asp:ListItem>Female</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td style="width: 463px;">
<asp:Label ID="Label6" runat="server" Text="Joining Date"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 463px;">
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
<asp:Label ID="Label7" runat="server" Text="Contact No"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 463px;"></td>
<td>
<asp:Button ID="Button1" runat="server" Font-Bold="True"
OnClick="Button1_Click" Text="Insert" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click"
Text="Update" />
<asp:Button ID="Button3" runat="server" OnClick="Button3_Click"
OnClientClick="return confirm('Are you sure to delete?');" Text="Delete" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="GridView1" runat="server"
Width="576px"></asp:GridView>
</td>
</tr>
</table>
</div>
</main>
</form>
</body>
</html>
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
C# Code:
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace Crud
{
public partial class WebForm1 : [Link]
{
SqlConnection connection = new SqlConnection(
@"Data Source=(LocalDB)\MSSQLLocalDB;
AttachDbFilename=D:\Users\IU2241230016\source\repos\Crud\Crud\App_Data\Database1.
mdf;
Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetEmployeeList();
}
}
protected void Button1_Click(object sender, EventArgs e) // INSERT
{
int empid = [Link]([Link]);
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
string empname = [Link];
string city = [Link];
string gender = [Link];
string contact = [Link];
double age = [Link]([Link]);
DateTime jdate = [Link]([Link]);
[Link]();
SqlCommand command = new SqlCommand(
"INSERT INTO EmployeeSetup_Tab VALUES (@EmpId, @EmpName, @City, @Age,
@Gender, @JoiningDate, @Contact)", connection);
[Link]("@EmpId", empid);
[Link]("@EmpName", empname);
[Link]("@City", city);
[Link]("@Age", age);
[Link]("@Gender", gender);
[Link]("@JoiningDate", jdate);
[Link]("@Contact", contact);
[Link]();
[Link]();
[Link](this, [Link](), "alert", "alert('Successfully
Saved');", true);
GetEmployeeList();
}
void GetEmployeeList()
{
SqlCommand command = new SqlCommand("SELECT * FROM EmployeeSetup_Tab",
connection);
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
SqlDataAdapter sd = new SqlDataAdapter(command);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
}
protected void Button2_Click(object sender, EventArgs e) // UPDATE
{
int empid = [Link]([Link]);
string empname = [Link];
string city = [Link];
string gender = [Link];
string contact = [Link];
double age = [Link]([Link]);
DateTime jdate = [Link]([Link]);
[Link]();
SqlCommand command = new SqlCommand(
"UPDATE EmployeeSetup_Tab SET EmpName = @EmpName, City = @City, Age =
@Age, Gendor = @Gender, JoiningDate = @JoiningDate, Contact = @Contact WHERE EMPId
= @EmpId", connection);
[Link]("@EmpId", empid);
[Link]("@EmpName", empname);
[Link]("@City", city);
[Link]("@Age", age);
[Link]("@Gender", gender);
[Link]("@JoiningDate", jdate);
[Link]("@Contact", contact);
[Link]();
[Link]();
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
[Link](this, [Link](), "alert", "alert('Successfully
Updated');", true);
GetEmployeeList();
}
protected void Button3_Click(object sender, EventArgs e) // DELETE
{
int empid = [Link]([Link]);
[Link]();
SqlCommand command = new SqlCommand("DELETE FROM EmployeeSetup_Tab
WHERE EMPId = @EmpId", connection);
[Link]("@EmpId", empid);
[Link]();
[Link]();
[Link](this, [Link](), "alert", "alert('Successfully
Deleted');", true);
GetEmployeeList();
}
protected void Button4_Click(object sender, EventArgs e) // SELECT
{
int empid = [Link]([Link]);
SqlCommand command = new SqlCommand("SELECT * FROM EmployeeSetup_Tab
WHERE EMPId = @EmpId", connection);
[Link]("@EmpId", empid);
SqlDataAdapter sd = new SqlDataAdapter(command);
DataTable dt = new DataTable();
[Link](dt);
[Link] = dt;
[Link]();
}
}
}
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Output
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Practical-15
Aim :- Create a web page demonstrating the structure of MDI form.
Code: [Link]
using System;
using [Link];
using [Link];
using [Link];
using [Link];
namespace Webservices
,
/// <summary>
/// Summary description for Addition_service
/// </summary>
*WebService(Namespace = "[Link]
*WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)+
*[Link](false)+
// To allow this Web Service to be called from script, using [Link] AJAX, uncomment the
following line.
*[Link]+
public class WebService1 : [Link]
,
*WebMethod(MessageName = "Addition_Of_Two_Numbers")+
public int sum(int x, int y)
,
return x + y;
-
-
-
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Output