vishu.net
vishu.net
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 1 Subject: Dot Net Technology Date:
Title: Write a C# Program to display information of student and compile it with
csc.exe. Remark:
using System;
using System.Data;
class Student
{
private string name;
private int age;
private string grade;
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 2 Subject: Dot Net Technology Date:
Title:Write C# program to pass command line argument Remark:
//pass command line argument:-
System.Console.WriteLine(), System.Console.Write(),
System.Console.ReadLine(),System.Console.Read(),
System.Console.ReadKey().
//
Program:-
using System;
class CommandLineArgsExample
{
static void Main(string[] args)
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 3 Subject: Dot Net Technology Date:
Title:Write a C# for implementation of multiple main.[int,void] Remark:
class StringConcatenation
{
static void Main()
{
Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 4 Subject: Dot Net Technology Date:
Title:Write a C# for implementation of multiple main.[int,void] Remark:
class Program
{
static int Main()
{
int number;
bool isValid = int.TryParse(Console.ReadLine(), out number);
if (!isValid)
{
Console.WriteLine("Invalid input! Please enter a valid integer.");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
return -1;
}
if (number % 2 == 0)
{
Console.WriteLine("The number " + number + " is Even.");
}
else
{
Console.WriteLine("The number " + number + " is Odd.");
}
return 0;
}
} Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 5 Subject: Dot Net Technology Date:
Title:Write a C# program to check given number is perfect or not, using ‘Using’
Keyword. Remark:
using System;
class PerfectNumberCheck
{
static void Main()
{
Console.WriteLine("Enter a number to check if it's a perfect number:");
using (var reader = Console.In)
{
string userInput = reader.ReadLine();
int number;
if (!int.TryParse(userInput, out number) || number <= 0)
{
Console.WriteLine("Please enter a valid positive integer.");
return;
}
bool isPerfect = IsPerfectNumber(number);
Console.WriteLine("The number " + number + " is " + (isPerfect ? "a
perfect number." : "not a perfect number."));
}
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
static bool IsPerfectNumber(int num)
{
int sum = 0;
for (int i = 1; i < num; i++)
{
if (num % i == 0)
{
sum += i;
}
}
return sum == num;
}
}
Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 6 Subject: Dot Net Technology Date:
Title: Write a C# program to implement boxing and unboxing Remark:
using System;
class BoxingUnboxing
{
static void Main()
{
int number = 35;
Console.WriteLine("Original value (int): " + number);
Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 7 Subject: Dot Net Technology Date:
Title: Write a C# program to display information of employee. Remark:
class Employee
{
public string Name { get; set; }
public string Address { get; set; }
public int Age { get; set; }
public DateTime DateOfBirth { get; set; }
public decimal BasicPay { get; set; }
public decimal HRA { get; set; }
public decimal DA { get; set; }
employee.Name = Console.ReadLine();
Console.Write("Enter Address: ");
employee.Address = Console.ReadLine();
Console.Write("Enter Age: ");
employee.Age = int.Parse(Console.ReadLine());
employee.HRA = decimal.Parse(Console.ReadLine());
Console.Write("Enter DA: ");
employee.DA = decimal.Parse(Console.ReadLine());
employee.DisplayInfo();
Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 8 Subject: Dot Net Technology Date:
Title: Write a C# program to implement C# Control Statements(if,for,for……each
etc). Remark:
A.]Input three number and find which is maximum
using System;
class ProgramA
{
static void Main(string[] args)
{
Console.WriteLine("Part A: Enter three numbers:");
Console.Write("Enter first number: ");
int num1 = int.Parse(Console.ReadLine());
using System;
class FactorialProgram
{
static void Main(string[] args)
{
Console.Write("Enter a number to find its factorial: ");
int number = int.Parse(Console.ReadLine());
int factorial = 1;
class DisplayArrayProgram
{
static void Main(string[] args)
{
Console.WriteLine("Array contents:");
Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 9 Subject: Dot Net Technology Date:
Title: Write a C# program to implement casting (implicit and explicit). Remark:
using System;
class CastingProgram
{
static void Main(string[] args)
{
int intNumber = 150;
double doubleNumber = intNumber;
Console.WriteLine("Implicit Casting:");
Console.WriteLine("Integer value: " + intNumber);
Console.WriteLine("Implicitly casted to double: " +
doubleNumber);
K. G. D. B. L. Mahavidyalaya, Kundal
B.C.A- III(2024-25) SEM:V
Name: Roll No.
Assignment no.: 10 Subject: Dot Net Technology Date:
Title: Write a C# program for swapping of two numbers by using pass by value
and pass by reference and out parameters. Remark:
using System;
class SwappingProgram
{
int x = 11;
int y = 22;
SwapByValue(x, y);
x = 11;
y = 22;
Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
height: 345px;
}
.auto-style2 {
width: 540px;
height: 599px;
margin-left: 167px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div></div>
<table class="auto-style1">
<tr> <td>
<asp:ImageMap ID="ImageMap1" runat="server"
ImageUrl="~/Immages/nature.jpg" Width="413px" Height="305px">
<asp:CircleHotSpot />
<asp:RectangleHotSpot Bottom="100" Left="200"
NavigateUrl="~/Employee.aspx" Right="100" Top="200" />
</asp:ImageMap>
</td>
</tr>
</table>
</form>
</body>
</html>
Output:-
K. G. D. B. L. Mahavidyalaya, Kundal
<!DOCTYPE html>
<script runat="server">
</script>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Industry Information</title>
<style>
body {
font-family: Arial, sans-
serif; background-color:
#f4f4f4; margin: 0;
padding: 20px;
text-align:
center;
}
.industry-container {
background: #fff;
padding: 20px;
border-radius:
8px;
border: solid
black; margin:
auto; width:
400px;
}
h2
{ color: #333;
}
.industry-image {
width: 80%;
height: auto;
border-radius: 8px;
}
.industry-link {
display: inline-
block; margin-top:
15px; padding: 10px
15px; background-
color: gray; color:
white;
text-
decoration:solid;
border-radius: 4px;
}
.industry-link:hover {
background-color:
gray;
}
.auto-style1 {
width: 357px;
height: 302px;
margin-top:
0px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="industry-container">
<h2>Tesla Industry</h2>
<br />
<asp:HyperLink ID="image1" runat="server"
NavigateUrl="https://www.tesla.com/" Target="_blank">
<asp:Image ID="image2" runat="server" ImageUrl="Immages/tesla2.jpg"
Width="400px" />
</asp:HyperLink>
Validation.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" UnobtrusiveValidationMode="None"
Debug="true" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Employee Management</title>
<style>
body {
font-family: Arial, sans-
serif; margin: 20px;
height: 414px;
}
label {
display:
block; margin:
5px 0;
}
.error-message {
color: red;
font-size:
12px; margin-
top: 5px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h2>Employee Management</h2>
<div>
<label for="txtName">Name:</label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvName" runat="server"
ControlToValidate="txtName"
ErrorMessage="Name is required." CssClass="error-message"
Display="Dynamic"></asp:RequiredFieldValidator>
</div>
<div>
<label for="txtAge">Age:</label>
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvAge" runat="server"
ControlToValidate="txtAge"
ErrorMessage="Age is required." CssClass="error-message"
Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revAge" runat="server"
ControlToValidate="txtAge"
ErrorMessage="Enter a valid age." CssClass="error-message"
Display="Dynamic"
ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
</div>
<div>
<label for="txtEmail">Email:</label>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server"
ControlToValidate="txtEmail"
ErrorMessage="Email is required." CssClass="error-message"
Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmail" runat="server"
ControlToValidate="txtEmail"
ErrorMessage="Enter a valid email." CssClass="error-message"
Display="Dynamic"
ValidationExpression="^[\w-\.]+@([\w-]+\.)+[\w-
]{2,4}$"></asp:RegularExpressionValidator>
</div>
<div>
<label for="txtPassword">Password:</label>
<asp:TextBox ID="txtPassword" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server"
ControlToValidate="txtPassword"
ErrorMessage="Password is required." CssClass="error-message"
Display="Dynamic"></asp:RequiredFieldValidator>
</div>
<div>
<label for="txtConfirmPassword">Confirm Password:</label>
<asp:TextBox ID="txtConfirmPassword" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvConfirmPassword" runat="server"
ControlToValidate="txtConfirmPassword"
ErrorMessage="Confirm Password is required." Display="Dynamic"
ForeColor="#FF6666"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvPassword" runat="server"
ControlToCompare="txtPassword"
ControlToValidate="txtConfirmPassword" ErrorMessage="Passwords do
not match." Display="Dynamic" ForeColor="#FF6600"></asp:CompareValidator>
</div>
<br />
<asp:Button ID="btnSave" runat="server" Text="Save"
OnClick="btnSave_Click" Width="153px" />
<asp:Label ID="lblMessage" runat="server" Visible="False"></asp:Label>
<script runat="server">
protected void btnSave_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
</script>
</form>
</body>
</html>
Output:-
K. G. D. B. L. Mahavidyalaya,
Kundal B.C.A- III(2024-25)
SEM:V
Employee.aspx:-
<%@ Page Language="C#" AutoEventWireup="true" UnobtrusiveValidationMode="None"
Debug="true" CodeFile="Employee.aspx.cs" Inherits="Employee" %>
<!DOCTYPE html>
<html lang="en">
<head id="Head1" runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Employee Management</title>
<style>
body {
font-family: Arial, sans-
serif; background-color:
#e9ecef; display: flex;
justify-content:
center; align-items:
center; height:
660px;
margin: 0;
}
.container {
background: #ffffff;
padding: 30px;
border: 2px solid
black; border-radius:
10px; width: 400px;
}
h2
{
text-align:
center; margin-
} bottom: 20px;
.form-group {
margin-bottom: 15px; /* Space between text boxes */
}
.error-message {
color: red;
font-size:
12px; margin-
top: 5px;
}
.auto-style1 {
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="container">
<h2>Employee Management</h2>
<div class="form-group">
<label for="Id">Id:</label>
<asp:TextBox ID="Id" runat="server" required></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvId" runat="server"
ControlToValidate="Id"
ErrorMessage="Please enter Id." CssClass="error-message"
Display="Dynamic" ValidationGroup="search"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="txtName">Name:</label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvName" runat="server"
ControlToValidate="txtName"
ErrorMessage="Name is required." CssClass="error-message"
Display="Dynamic" ValidationGroup="save"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="txtAge">Age:</label>
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvAge" runat="server"
ControlToValidate="txtAge"
ErrorMessage="Age is required." CssClass="error-message"
Display="Dynamic" ValidationGroup="save"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revAge" runat="server"
ControlToValidate="txtAge"
ErrorMessage="Enter a valid age." CssClass="error-message"
Display="Dynamic"
ValidationExpression="^\d+$"
ValidationGroup="save"></asp:RegularExpressionValidator>
</div>
<div class="form-group">
<label for="ddlGender">Gender:</label>
<asp:DropDownList ID="ddlGender" runat="server"
ValidationGroup="save">
<asp:ListItem Value="">Select Gender</asp:ListItem>
<asp:ListItem Value="Male">Male</asp:ListItem>
<asp:ListItem Value="Female">Female</asp:ListItem>
<asp:ListItem Value="Other">Other</asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvGender" runat="server"
ControlToValidate="ddlGender"
InitialValue="" ErrorMessage="Gender is
required." CssClass="error-message" Display="Dynamic"
ValidationGroup="save"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="txtCity">City:</label>
<asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCity" runat="server"
ControlToValidate="txtCity"
ErrorMessage="City is required." CssClass="error-message"
Display="Dynamic" ValidationGroup="save"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="txtEmail">Email:</label>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server"
ControlToValidate="txtEmail"
ErrorMessage="Email is required." CssClass="error-message"
Display="Dynamic" ValidationGroup="save"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmail" runat="server"
ControlToValidate="txtEmail"
ErrorMessage="Enter a valid email." CssClass="error-message"
Display="Dynamic"
ValidationExpression="^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$"
ValidationGroup="save"></asp:RegularExpressionValidator>
</div>
<div class="form-group">
<label for="txtPassword">Password:</label>
<asp:TextBox ID="txtPassword" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server"
ControlToValidate="txtPassword"
ErrorMessage="Password is required." CssClass="error-message"
Display="Dynamic" ValidationGroup="save"></asp:RequiredFieldValidator>
</div>
<div class="form-group">
<label for="txtConfirmPassword">Confirm Password:</label>
<asp:TextBox ID="txtConfirmPassword" runat="server"
TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvConfirmPassword"
runat="server" ControlToValidate="txtConfirmPassword"
ErrorMessage="Confirm Password is required." CssClass="error-
message" Display="Dynamic" ValidationGroup="save"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="cvPassword" runat="server"
ControlToCompare="txtPassword"
ControlToValidate="txtConfirmPassword"
ErrorMessage="Passwords do not match." CssClass="error-message"
Display="Dynamic" ValidationGroup="save"></asp:CompareValidator>
</div>
<div class="auto-style1">
<br />
<br />
<asp:Label ID="lblMessage" runat="server" ForeColor="Green"
Height="31px" style="margin-top: 0px" Width="82px"></asp:Label>
</div>
<div>
<asp:Button ID="btnSearch" runat="server" Text="Display"
OnClick="btnSearch_Click" ValidationGroup="search" Width="82px" />
&nb
sp;
<asp:Button ID="btnUpdate" runat="server" Text="Update"
OnClick="btnUpdate_Click" ValidationGroup="search" Width="85px" />
<asp:Button ID="btnDelete" runat="server" Text="Delete"
OnClick="btnDelete_Click" ValidationGroup="search" Width="90px" />
</div>
</div>
</form>
</body>
</html>
Employee.aspx.cs:-
using System;
using System.Data.SqlClient;
using System.Configuration;
string query = "INSERT INTO Employees (Id, Name, Age, Gender, City,
Email, Password) VALUES (@Id, @Name, @Age, @Gender, @City, @Email, @Password)";
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.AddWithValue("@Id", Id.Text);
cmd.Parameters.AddWithValue("@Name", txtName.Text);
cmd.Parameters.AddWithValue("@Age", txtAge.Text);
cmd.Parameters.AddWithValue("@Gender", ddlGender.SelectedValue);
cmd.Parameters.AddWithValue("@City", txtCity.Text);
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
txtName.Text =
reader["Name"].ToString(); txtAge.Text =
reader["Age"].ToString();
ddlGender.SelectedValue =
reader["Gender"].ToString(); txtCity.Text =
reader["City"].ToString(); txtEmail.Text =
reader["Email"].ToString();
}
els
e
{ ClearFields();
lblMessage.Text = "No employee found with this
ID."; lblMessage.ForeColor =
System.Drawing.Color.Red;
}
conn.Close();
}
Id.Text = "";
txtName.Text = "";
txtAge.Text = "";
ddlGender.SelectedIndex = 0;
txtCity.Text = "";
txtEmail.Text = "";
txtPassword.Text = "";
txtConfirmPassword.Text =
"";
}
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
conn.Open();
int rowsAffected = cmd.ExecuteNonQuery();
conn.Close();
if (rowsAffected > 0)
{
els
e lblMessage.Text = "Error: No record found with this ID.";
{ lblMessage.ForeColor = System.Drawing.Color.Red;
conn.Open();
int rowsAffected = cmd.ExecuteNonQuery();
conn.Close();
if (rowsAffected > 0)
{
ClearFields();
lblMessage.Text = "Employee deleted
successfully."; lblMessage.ForeColor =
} System.Drawing.Color.Green;
els
e
{ lblMessage.Text = "No employee found with this
ID."; lblMessage.ForeColor =
System.Drawing.Color.Red;
}
}
Output:-
Inserting Data:-
Updating Data:-
Deleting Data:-
Display Data:-