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: WebForm1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<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:ConnectionString.ProviderName %>" 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 : WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5
,
public partial class WebForm1 : System.Web.UI.Page
,
protected void Page_Load(object sender, EventArgs e)
,
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs
e)
,
Label1.Text = "Record Entered";
GridView1.DataBind();
-
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
,
Label1.Text = "Record Deleted";
GridView1.DataBind();
-
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
,
Label1.Text = "Record Edited";
GridView1.DataBind();
-
-
-
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: Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
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();
f2.MdiParent = this;
f2.FormClosed += new FormClosedEventHandler(f2_FormClosed);
f2.Show();
}
else
{
f2.Activate();
}
}
void f2_FormClosed(object sender, FormClosedEventArgs e)
{
f2 = null;
}
private void form3ToolStripMenuItem1_Click(object sender, EventArgs e)
{
Form3 f3 = new Form3();
f3.MdiParent = this;
f3.Show();
}
}
}
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: WebForm1.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="Crud.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>CRUD in ASP.NET</title>
</head>
<body>
<form id="form1" runat="server">
<main>
<section class="row" aria-labelledby="aspnetTitle">
<h1 id="aspnetTitle">ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and
Web applications using HTML, CSS, and JavaScript.</p>
<p><a href="http://www.asp.net" 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 ASP.NET 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 System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Crud
{
public partial class WebForm1 : System.Web.UI.Page
{
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 = int.Parse(TextBox1.Text);
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
string empname = TextBox2.Text;
string city = DropDownList1.SelectedValue;
string gender = RadioButtonList1.SelectedValue;
string contact = TextBox5.Text;
double age = double.Parse(TextBox3.Text);
DateTime jdate = DateTime.Parse(TextBox4.Text);
connection.Open();
SqlCommand command = new SqlCommand(
"INSERT INTO EmployeeSetup_Tab VALUES (@EmpId, @EmpName, @City, @Age,
@Gender, @JoiningDate, @Contact)", connection);
command.Parameters.AddWithValue("@EmpId", empid);
command.Parameters.AddWithValue("@EmpName", empname);
command.Parameters.AddWithValue("@City", city);
command.Parameters.AddWithValue("@Age", age);
command.Parameters.AddWithValue("@Gender", gender);
command.Parameters.AddWithValue("@JoiningDate", jdate);
command.Parameters.AddWithValue("@Contact", contact);
command.ExecuteNonQuery();
connection.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "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();
sd.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e) // UPDATE
{
int empid = int.Parse(TextBox1.Text);
string empname = TextBox2.Text;
string city = DropDownList1.SelectedValue;
string gender = RadioButtonList1.SelectedValue;
string contact = TextBox5.Text;
double age = double.Parse(TextBox3.Text);
DateTime jdate = DateTime.Parse(TextBox4.Text);
connection.Open();
SqlCommand command = new SqlCommand(
"UPDATE EmployeeSetup_Tab SET EmpName = @EmpName, City = @City, Age =
@Age, Gendor = @Gender, JoiningDate = @JoiningDate, Contact = @Contact WHERE EMPId
= @EmpId", connection);
command.Parameters.AddWithValue("@EmpId", empid);
command.Parameters.AddWithValue("@EmpName", empname);
command.Parameters.AddWithValue("@City", city);
command.Parameters.AddWithValue("@Age", age);
command.Parameters.AddWithValue("@Gender", gender);
command.Parameters.AddWithValue("@JoiningDate", jdate);
command.Parameters.AddWithValue("@Contact", contact);
command.ExecuteNonQuery();
connection.Close();
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Successfully
Updated');", true);
GetEmployeeList();
}
protected void Button3_Click(object sender, EventArgs e) // DELETE
{
int empid = int.Parse(TextBox1.Text);
connection.Open();
SqlCommand command = new SqlCommand("DELETE FROM EmployeeSetup_Tab
WHERE EMPId = @EmpId", connection);
command.Parameters.AddWithValue("@EmpId", empid);
command.ExecuteNonQuery();
connection.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Successfully
Deleted');", true);
GetEmployeeList();
}
protected void Button4_Click(object sender, EventArgs e) // SELECT
{
int empid = int.Parse(TextBox1.Text);
SqlCommand command = new SqlCommand("SELECT * FROM EmployeeSetup_Tab
WHERE EMPId = @EmpId", connection);
command.Parameters.AddWithValue("@EmpId", empid);
SqlDataAdapter sd = new SqlDataAdapter(command);
DataTable dt = new DataTable();
sd.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
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: WebService1.asmx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace Webservices
,
/// <summary>
/// Summary description for Addition_service
/// </summary>
*WebService(Namespace = "http://tempuri.org/")+
*WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)+
*System.ComponentModel.ToolboxItem(false)+
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the
following line.
*System.Web.Script.Services.ScriptService+
public class WebService1 : System.Web.Services.WebService
,
*WebMethod(MessageName = "Addition_Of_Two_Numbers")+
public int sum(int x, int y)
,
return x + y;
-
-
-
IU2241230054 Advanced .Net Framework(CE0619) 6CSE-F1
Output