0% found this document useful (0 votes)
7 views

c# Final Record

This document is a record notebook for the C# and .NET Programming course for MCA students during the 2024-2025 academic year. It includes practical exercises, algorithms, and example programs demonstrating concepts such as multilevel inheritance, virtual methods, and basic calculator functionality using Windows Forms. Additionally, it outlines tasks related to database operations for student and course management applications.

Uploaded by

hitlerkomanam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

c# Final Record

This document is a record notebook for the C# and .NET Programming course for MCA students during the 2024-2025 academic year. It includes practical exercises, algorithms, and example programs demonstrating concepts such as multilevel inheritance, virtual methods, and basic calculator functionality using Windows Forms. Additionally, it outlines tasks related to database operations for student and course management applications.

Uploaded by

hitlerkomanam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

RECORD NOTEBOOK

DEPARTMENT OF COMPUTER APPLICATIONS

CMCA22L05 C# AND .NET PROGRAMMING

2024 –2025 (ODD SEMESTER)

NAME :

REGISTER NO :

COURSE : M.C.A

YEAR / SEM / SEC : II / III / H


BONAFIDE CERTIFICATE

Certified that this is a Bonafide Record of work done by


of (Reg No: ) MCA Il year in C# AND .NET PROGRAMMING
during the III semester in the year 2024-2025.

Submitted for the Practical Examination held on ……………..

Signature of Lab-in charge Signature of DEAN

INTERNAL EXAMINER EXTERNAL EXAMINER


CONTENTS

PAGE
S.NO DATE PROGRAM SIGNATURE
NO

1.

2.

3.

4.

5.

6.

7.

8.
Ex No: 01 Write a program to implement multilevel inheritance. Accept and display data for one
student.
Class: student Data Members: Roll_no, name
DATE: Class: Test Data Members: marks 1, marks 2
Class: Result Data Members: total

Aim:

Algorithm:

1
Program:

using System;
using System.Collections.Generic;using
System.Linq;
using System.Text;
namespace Ex1
{
public class student
{
protected int Roll_no;
protected string name;
}
public class Test : student
{
protected int marks1;
protected int marks2;
}

public class Result : Test


{
private int total;
public void getDetails()
{
Console.WriteLine("\n Enter the Student Details :");
Console.Write("=================================");
Console.Write("\n Enter the Student Roll number :");
base.Roll_no = int.Parse(Console.ReadLine());
Console.Write("\n Enter the Student Name :"); base.name =
Console.ReadLine();
Console.Write("\n Enter the Mark-1 :"); base.marks1
= int.Parse(Console.ReadLine());Console.Write("\n
Enter the Mark-2 :"); base.marks2 =
int.Parse(Console.ReadLine());
}
public void showDetails()
{
Console.WriteLine("\n\n Student Details :");
Console.Write("=================================");
Console.WriteLine("\n Student Roll number :" + base.Roll_no);
Console.WriteLine("\n Student Name :" + base.name);
Console.WriteLine("\n Mark-1 :" + base.marks1);

2
Console.WriteLine("\n Mark-2 :" + base.marks2);
this.total = base.marks1 + base.marks2;
Console.WriteLine("\n Total Marks obtained :" + this.total);
}
}

class Program
{
static void Main(string[] args)
{
Result s1 = new Result();
s1.getDetails();
s1.showDetails();
Console.ReadLine();
}
}
}

3
Output:

Result:

4
Ex No: 02 Demonstrate Use of Virtual and override keyword in C# with a simple Program.

DATE:

Aim:

Algorithm:

5
Program:

Program;
using System;
namespace VirtualExample
{
class Shape
{
public double length=0.0;
public double width =0.0;
public double radius =0.0;

public Shape(double length, double width)


{
this.length = length;
this.width = width;
}
public Shape(double radius)
{
this.radius = radius;
}
public virtual void Area()
{
double area = 0.0;
area = Math.PI * Math.Pow(radius, 2);
Console.WriteLine("Area of Shape is :{0:0.00} ", area);
}
}
class Rectangle : Shape
{
public Rectangle(double length, double width): base(length, width)
{
}
public override void Area()
{
double area = 0.0;
area = length * width;
Console.WriteLine("Area of Rectangle is :{0:0.00} ", area);
}
}
class Circle : Shape
{
public Circle(double radius)
: base(radius)
{
}
}

6
class Program
{
static void Main(string[] args)
{
double length,width,radius=0.0;
Console.WriteLine("Enter the Length");
length = Double.Parse(Console.ReadLine());
Console.WriteLine("Enter the Width");
width = Double.Parse(Console.ReadLine());
Rectangle objRectangle = new Rectangle(length, width);
objRectangle.Area();
Console.WriteLine("Enter the Radius");
radius = Double.Parse(Console.ReadLine());
Circle objCircle = new Circle(radius);
objCircle.Area();
Console.Read();
}
}
}

7
Output:

Result:

8
Ex NO: 03 Write a program to design a simple calculator using windows application.

DATE:

Aim:

Algorithm:

9
Form Design:

10
Program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace CalculatorApp
{
public partial class Form1 : Form
{
double FirstNumber;
string Operation;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "1";
}
else
{
textBox1.Text = textBox1.Text + "1";
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "2";
}
else
{
textBox1.Text = textBox1.Text + "2";
}
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "3";
}
else
{

11
textBox1.Text = textBox1.Text + "3";
}
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "4";
}
else
{
textBox1.Text = textBox1.Text + "4";
}
}
private void button5_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "5";
}
else
{
textBox1.Text = textBox1.Text + "5";
}
}
private void button6_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "5";
}
else
{
textBox1.Text = textBox1.Text + "5";
}
}
private void button7_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "7";
}
else
{
textBox1.Text = textBox1.Text + "7";
}
}
private void button8_Click(object sender, EventArgs e)
{

12
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "8";
}
else
{
textBox1.Text = textBox1.Text + "8";
}
}
private void button9_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" && textBox1.Text != null)
{
textBox1.Text = "9";
}
else
{
textBox1.Text = textBox1.Text + "9";
}
}
private void button10_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + "0";
}
private void bc_Click(object sender, EventArgs e)
{
textBox1.Text = "0";
}
private void ndot_Click(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text + ".";
}
private void bad_Click(object sender, EventArgs e)
{
FirstNumber = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
Operation = "+";
}
private void bsub_Click(object sender, EventArgs e)
{
FirstNumber = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
Operation = "-";
}
private void bmul_Click(object sender, EventArgs e)
{
FirstNumber = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
Operation = "*";
}

13
private void bdiv_Click(object sender, EventArgs e)
{
FirstNumber = Convert.ToDouble(textBox1.Text);
textBox1.Text = "0";
Operation = "/";
}
private void nequal_Click(object sender, EventArgs e)
{
double SecondNumber;
double Result;

SecondNumber = Convert.ToDouble(textBox1.Text);

if (Operation == "+")
{
Result = (FirstNumber + SecondNumber);
textBox1.Text = Convert.ToString(Result);
FirstNumber = Result;
}
if (Operation == "-")
{
Result = (FirstNumber - SecondNumber);
textBox1.Text = Convert.ToString(Result);
FirstNumber = Result;
}
if (Operation == "*")
{
Result = (FirstNumber * SecondNumber);
textBox1.Text = Convert.ToString(Result);
FirstNumber = Result;
}
if (Operation == "/")
{
if (SecondNumber == 0)
{
textBox1.Text = "Cannot divide by zero";

}
else
{
Result = (FirstNumber / SecondNumber);
textBox1.Text = Convert.ToString(Result);
FirstNumber = Result;
}
}
}
}
}

14
Output:

Result:

15
Ex No: 04 CONSIDER the dataset student consisting of following tables:
tbl_course (course ID: int, course name: string)
tbl_student(usn: string, stud name: String, Address: String , Course id: int,
DATE: yr of admsn: int)
Develop suitable windows applications using C#.Net having following options:
a) Entering New Course Details.
b) Display the Course details (in a grid)

Aim:

Algorithm:

16
Form Designs:

17
Program :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form {
SqlConnection con = new SqlConnection("Data Source=DESKTOPFOF4B0D\\SQLEXPRESS;Initial
Catalog=master;Integrated Security=True");
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd=new SqlCommand("insert into TBL_COURSE values(" +
textBox1.Text +",'"+ textBox2.Text + "')",con);
cmd.ExecuteNonQuery();
MessageBox.Show("New Course Entered");
con.Close();
}
private void button2_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter da=new SqlDataAdapter("select * from TBL_COURSE",con);
DataTable dt= new DataTable();
da.Fill(dt);
dataGridView1.DataSource=dt;
con.Close( );
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
}
}
}

18
Output :

Result:

19
Ex No : 05 Consider the above dataset student. Develop suitable windows application using C#.Net
a) Enter he Student details.
DATE: b) Display the details the student who have taken admission in a particular year.

Aim:

Algorithm:

20
Form Design:

21
Program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection("Data Source=DESKTOPFOF4B0D\\SQLEXPRESS;Initial
Catalog=master;Integrated Security=True");
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("select COURSE_ID from
TBL_COURSE", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
con.Close();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd=new SqlCommand ("insert into TBL_STUDENT
values('"+textBox1.Text+ "','"+textBox2.Text +"','"+textBox3.Text+"',"+
comboBox1.Text+ ","+ textBox4.Text +")",con);
cmd.ExecuteNonQuery();
MessageBox.Show("New Student Entered");
con.Close();
}

22
private void button3_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
comboBox1.Text = "";
}
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
dis d = new dis();
d.Show();
}
}
}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class dis : Form
{
SqlConnection con = new SqlConnection("Data Source=DESKTOPFOF4B0D\\SQLEXPRESS;Initial
Catalog=master;Integrated Security=True");
public dis()
{
InitializeComponent();
}
private void dis_Load(object sender, EventArgs e)
{
con.Open();

23
SqlCommand cmd = new SqlCommand("select distinct(YR_OF_AD) from TBL_STUDENT", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
con.Close();
}
private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from TBL_STUDENT
whereyr_of_ad="+comboBox1.Text,con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
}
}
}

24
Output:

Result:

25
Ex No : 06 Create the application using ASP.Net server controls that accepts name,
Password, age, E-Mail id and User id. All the information entry is
compulsory. Password should be reconfirmed. Age should be within 21 to
DATE: 30. Email id should be valid. User should have at least a capital letter and
digit as well as length should be between 7 and 20 characters.

Aim:

Algorithm:

26
27
Program:
Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"


Inherits="_Default" %>

<!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>Untitled Page</title>
<style type="text/css">
.style1
{
font-size: xx-large;font-
weight: bold; color:
#FF66CC; text-align:
center;
}
.style2
{
width: 500px; text-align:
center;
}
.style5
{
font-size: x-large;text-
align: center;
}
.style6
{
font-size: x-large;text-
align: right;
}
</style>
</head>
<body>

<form id="form1" runat="server">


<div class="style1">
<br />

28
Web Application with Validation<br />
</div>
<div style="text-align:center">
<table class="style2">
<tr>
<td class="style6">
<asp:Label ID="lblUserID" runat="server" Text="Enter User ID"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="txtUID" runat="server"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtUID" ErrorMessage="Value Required" style="font-size:
x-small"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="txtUID"
ErrorMessage="Enter the valid UserName" style="font-size: x-small"
OnServerValidate="CustomValidator1_ServerValidate"
ClientValidationFunction="CustomValidator1_ServerValidate"></asp:CustomValidator>
</td>
</tr>
<tr>
<td class="style6">
<asp:Label ID="lblPassword" runat="server" Text="Enter Password"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="txtPWD" runat="server"
TextMode="Password"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtPWD" ErrorMessage="Value Required" style="font-
size: x-small"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style6">
<asp:Label ID="lblRpassword" runat="server" Text="Re-Type
Password"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="txtRpwd" runat="server"
TextMode="Password"></asp:TextBox>

29
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtRpwd" ErrorMessage="Value Required" style="font-size: x-
small"></asp:RequiredFieldValidator>
<asp:CompareValidatorID="CompareValidator1"runat="server"
ControlToCompare="txtPWD" ControlToValidate="txtRpwd" ErrorMessage="Check
Password" style="font-size: x-small"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="style6">
<asp:Label ID="lblUname" runat="server" Text="User Name"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="txtUname" runat="server"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtUname" ErrorMessage="Value Required" style="font-size: x-
small"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style6">
<asp:Label ID="lblAge" runat="server" Text="Age"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"
ControlToValidate="txtAge" ErrorMessage="Value Required" style="font-size: x-
small"></asp:RequiredFieldValidator>
&nbsp;<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="txtAge"
ErrorMessage="RangeValidator" MaximumValue="30" MinimumValue="21" style="font-size: x-
small"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style6">
<asp:Label ID="lblemailID" runat="server" Text="emailID"></asp:Label>
</td>
<td class="style5">
<asp:TextBox ID="txtEmailID" runat="server"></asp:TextBox>&nbsp;<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"

30
ControlToValidate="txtPWD" ErrorMessage="Value Required" style="font-size: x-
small"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtEmailID" ErrorMessage="Correct e-mail format" style="font-size: x-small"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td style="text-align: center" >
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</td>
<td style="text-align: center" >
<asp:Button ID="btnClose" runat="server" Text="Close" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls:
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Pa
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgsargs)
{
string tData = args.Value.ToString().Trim();
args.IsValid = false;
if (tData.Length < 7 || tData.Length > 20) return;

int charCnt = 0;int


numCnt = 0;

31
foreach (char x in tData)
{
if (x >= 'A' && x <= 'Z')
charCnt++;
if (x >= '0' && x <= '9')
numCnt++;
}
if (charCnt < 1 || numCnt < 1) return;
args.IsValid = true;
}
}

32
Output:

Result:

33
Ex No: 07 Develop a web application using C#.Net and ASP.Net for a Bank.
The bank database should consists of following tables:
DATE:

a) tbl_bank (bankid : int, bankname : string, branchname : string)


b) tbl_account (acctno : int , bankid : int, customername : string ,address : string, contactno : int,
balance : real)
(Note : Account number and bank id together is a composite primary key).
Master page of this web application should contain hyperlinks to new bank entry, new
customer entry, (based on branch and bank) and report generations.The hyperlinks should
navigate to respective content pages.These content pages provide the fields for respective data
entry. This report should be generated(display in grid)as below:
a) Display all the records of particular bank.
b) The balance should be displayed for the entered account number (bank and branch are
input through combo box controls. Account number is input through text box).

Aim:

Algorithm:

34
Form Designs.

Master page

New Bank Entry

New Branch Entry

35
Programs:
Master Page code Design code:

<%@MasterLanguage="C#"AutoEventWireup="true"CodeFile="MasterPage.master.cs"Inher
its="MasterPa ge"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0
Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<styletype="text/css">
.style1
{
text-align: center;
}
.style2
{
font-family: Arial,Helvetica,sans-serif;
}
.style3
{
font-family: Arial,Helvetica,sans-serif; color: #990000;
}
.style4
{
color: #990000;
}
</style>
</head>
<body>
<formid="form1"runat="server">
<divstyle="height: 79px; background-color: #FFCC00;">
</div>
<divstyle="width: 202px; height: 539px; float:left; background-color: #FF00FF;"
class="style1">
<strong>MENU<br/>
<br/>
</strong><spanclass="style2">

36
<ahref="NewBankEntry.aspx"><strong><spanclass="style4">NewBankEntry</span></strong></a>
</span><strong><br class="style3"/>
<br/>
<brclass="style2"/>
</strong><spanclass="style2">
<ahref="NewBranchEntry.aspx"><strong><spanclass="style4">NewBranchEntry</span></strong></a>
</ span><strong><br class="style3"/>
<br/>
<brclass="style2"/>
</strong><spanclass="style2"><strong><spanclass="style4"><ahref="NewCustomerEntry.as
px">NewCu stomerEntry</a></span></strong></span><br/>
<br/>
<a href="DisplayAllRecordOfBank.aspx"><strong>Display All Record Of
Bank</strong></a><strong><br/>
</strong>
<br/>
<strong>
<ahref="DisplayBranchDetails.aspx">DisplayBranchDetails</a></strong><br/>
<br/>
<ahref="DisplayBalance.aspx">Display Balance</a></div>
<divstyle="height: 542px">
<asp:ContentPlaceHolderid="head"runat="server">
</asp:ContentPlaceHolder>
</div>
<divstyle="height: 48px; background-color: #9933FF;">
</div>
</form>
</body>
</html>

New Book Entry Design Code:

<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup
="true"CodeFil e="NewBankEntry.aspx.cs"Inherits="NewBankEntry"%>

<asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server">
<h2class="style1"style="color: #FF0000">New Bank Entry</h2>
<fieldset>
<tablestyle="width: 59%; height: 96px;"border="0"align="center">
<tr>
<tdstyle="width: 810px; text-align: right"> Bank ID</td>
<tdstyle="width: 578px">

37
<asp:TextBoxID="TextBox1"runat="server"Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<tdstyle="width: 810px; text-align: right">Bank
Name</td>
<tdstyle="width: 578px">
<asp:TextBoxID="TextBox2"runat="server"Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<tdstyle="width: 810px"> &nbsp;</td>
<tdstyle="width: 578px"> &nbsp;</td>
</tr>
<tr>
<tdstyle="width: 810px"> &nbsp;</td>
<tdstyle="width: 578px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:ButtonID="Button1"runat="server"Text="Submit"Width="100px" style="color:
#FF0000"onclick="Button1_Click"/>
</td>
</tr>
</table>
</fieldset>
</asp:Content>

Aspx code:

using System;
using System.Collections.Generic;
using System.Linq;using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;publicpartialclassNewBankEntry :
System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
SqlConnection con = newSqlConnection("Data Source=DHANANJAY-PC;Initial
Catalog=bankDB;User ID=sa;Password=123;Pooling=False");
con.Open();

38
string query = "insert into tbl_Bank(BankID,BankName)
values("+TextBox1.Text+",'"+TextBox2.Text+"')"; SqlCommand cmd =
newSqlCommand(query,con);
int i = cmd.ExecuteNonQuery(); if (i > 0)
{
Response.Write("<script language='javascript'>alert('insertion successful')</script>");
}
else
{
Response.Write("<script language='javascript'>alert('insertion

failed')</script>");
}
TextBox1.Text = ""; TextBox2.Text = "";
}
}

New Branch Entry Design code

<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup
="true"CodeFil e="NewBranchEntry.aspx.cs"Inherits="NewBranchEntry"%>
<asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server">
<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;
<spanstyle="color: #FF0000">New Branch Entry</span></h1>
<fieldset>
<tablestyle="width: 75%"align="center">
<tr>
<tdstyle="width: 159px; text-align: right;"> Branch ID</td>
<tdstyle="width: 474px">
<asp:TextBoxID="TextBox1"runat="server"Width="200px"Height="25px"></asp:TextBox>
</td>
</tr>
<tr>
<tdstyle="width: 159px; text-align: right;"> Bank ID</td>
<tdstyle="width: 474px">
<asp:DropDownListID="DropDownList1"runat="server"Width="200px"Height="25px"
DataSourceID="SqlDataSource1"DataTextField="BankID"DataValueField="BankID">
<asp:ListItem>Select Bank ID</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSourceID="SqlDataSource1"runat="server" ConnectionString="<%$
ConnectionStrings:bankDBConnectionString %>" SelectCommand="SELECT [BankID]FROM
[tbl_Bank]"></asp:SqlDataSource>

39
</td>
</tr>
<tr>
<tdstyle="width: 159px; text-align: right;"> Branch Name</td>
<tdstyle="width: 474px">
<asp:TextBoxID="TextBox2"runat="server"Width="200px"Height="25px"></asp:TextBox>
</td>
</tr>
<tr>
<tdstyle="width: 159px; text-align: right;"> &nbsp;</td>
<tdstyle="width: 474px"> &nbsp;</td>
</tr>
<tr>
<tdstyle="width: 159px; text-align: right;"> &nbsp;</td>
<tdstyle="width: 474px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;
<asp:ButtonID="Button1"runat="server"Text="Submit"BackColor="Red"
Width="100px"onclick="Button1_Click"/>
</td>
</tr>
</table>
</fieldset>
</asp:Content>

Aspx code:

using System;
using System.Collections.Generic;
using System.Linq;using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;publicpartialclassNewBranchEntry :
System.Web.UI.Page
{
protectedvoid Page_Load(object sender, EventArgs e)
{
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
SqlConnection con = newSqlConnection("Data Source=DHANANJAY-PC;Initial
Catalog=bankDB;User ID=sa;Password=123;Pooling=False");
con.Open();
string query = "insert into tbl_Branch(BranchID,BankID,BranchName) values(" +

40
TextBox1.Text + ","+DropDownList1.SelectedValue+",'" + TextBox2.Text + "')";
SqlCommand cmd = newSqlCommand(query, con); int i = cmd.ExecuteNonQuery();if (i > 0)
{

Response.Write("<script language='javascript'>alert('insertion successful')</script>");


}
else
{
Response.Write("<script language='javascript'>alert('insertion

failed')</script>");
}
TextBox1.Text = ""; TextBox2.Text = "";
}
}
New Customer Entry Design code:

<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup
="true"CodeFil e="NewCustomerEntry.aspx.cs"Inherits="NewCustomerEntry"%>

<asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server">
<h1style="color:
#FF0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; New Customer
Entry</h1>
<fieldset>
<tablealign="center"style="width: 78%">
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;">
<b>Account Number:</b></td>
<tdstyle="width: 363px">
<asp:TextBoxID="TextBox_acc"runat="server"Width="200px"Height="25px"></asp:TextBo x>
</td>
</tr>
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;">
<b>Bank ID:</b></td>
<tdstyle="width: 363px">
<asp:DropDownListID="DropDownList_bid"runat="server"Width="200px"

41
Height="25px"DataSourceID="SqlDataSource1"DataTextField="BankID"
DataValueField="BankID">

</asp:DropDownList>
<asp:SqlDataSourceID="SqlDataSource1"runat="server" ConnectionString="<%$
ConnectionStrings:bankDBConnectionString %>" SelectCommand="SELECT [BankID] FROM
[tbl_Bank]"></asp:SqlDataSource>
</td>
</tr>
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;">
<b>Branch ID:</b></td>
<tdstyle="width: 363px">
<asp:DropDownListID="DropDownList_brachId"runat="server"Width="200px"

Height="25px"DataSourceID="SqlDataSource2"DataTextField="BranchID"
DataValueField="BranchID">
</asp:DropDownList>
<asp:SqlDataSourceID="SqlDataSource2"runat="server" ConnectionString="<%$
ConnectionStrings:bankDBConnectionString %>" SelectCommand="SELECT [BranchID]FROM
[tbl_Branch]"></asp:SqlDataSource>
</td>
</tr>
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;">
<b>Customer Name:</b></td>
<tdstyle="width: 363px">
<asp:TextBoxID="TextBox_custnm"runat="server"Width="200px"Height="25px"></asp:Tex tBox>
</td>
</tr>
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;">
<b>Address:</b></td>
<tdstyle="width: 363px">
<asp:TextBoxID="TextBox_add"runat="server"Width="200px"Height="25px"></asp:TextBo x>
</td>
</tr>
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;">
<b>Contact No:</b></td>
<tdstyle="width: 363px">
<asp:TextBoxID="TextBox_Con"runat="server"Width="200px"Height="25px"></asp:TextB ox>
</td>
</tr>

42
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;">
<b>Balance:</b></td>
<tdstyle="width: 363px">
<asp:TextBoxID="TextBox_bal"runat="server"Width="200px"Height="25px"></asp:TextBo x>
</td>
</tr>
<tr>
<tdstyle="width: 219px; text -align: right; color: #FF0000;"> &nbsp;</td>
<tdstyle="width: 363px"> &nbsp;</td>
</tr>
<tr>
<tdstyle="width: 219px; text-align: right; color: #FF0000;"> &nbsp;</td>
<tdstyle="width: 363px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;
<asp:ButtonID="Button1"runat="server"BackColor="Red"Text="Submit"
Width="100px"onclick="Button1_Click"/>
</td>
</tr>
</table>
</fieldset>
</asp:Content>

Aspx Code:
using System;
using System.Collections.Generic;
using System.Linq
;using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;publicpartialclassNewCustomerEntry :
System.Web.UI.Page
{
protectedvoid Button1_Click(object sender, EventArgs e)
{
SqlConnection con = newSqlConnection("Data Source=DHANANJAY-PC;Initial
Catalog=bankDB;User ID=sa;Password=123;Pooling=False");
con.Open();
string query = "insert into
tbl_Account(AccountNo,BankID,BranchID,CustomerName,Address,ContactNo,Balance)
values("+TextBox_acc.Text+","+DropDownList_bid.SelectedValue+","+DropDownList_brac hId.Selecte
dValue+",'"+TextBox_custnm.Text+"','"+TextBox_add.Text+"',"+TextBox_Con.Text+","+TextBox_bal.
Text+")";

43
SqlCommand cmd = newSqlCommand(query, con); int i = cmd.ExecuteNonQuery();if (i > 0)
{
Response.Write("<script language='javascript'>alert('insertion successful')</script>");
}
else
{
Response.Write("<script language='javascript'>alert('insertionfailed')</script>");
}
TextBox_acc.Text = ""; TextBox_custnm.Text = ""; TextBox_add.Text = "";TextBox_Con.Text =
""; TextBox_bal.Text = "";
}
}
Design code to Display all records of particular bank

<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup
="true"CodeFil e="DisplayAllRecordOfBank.aspx.cs"Inherits="DisplayAllRecordOfBank"%>
<asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server">
<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp
;&nbsp;&nbsp;&nbsp;&nbsp; Display All Record of Particular Bank</h1>
&nbsp;<asp:LabelID="Label1"runat="server"
style="font-weight: 700; text-align: right; color: #FF0000" Text="Select The
Bank"></asp:Label>
:<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"onselectedind
exchanged=" DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<br/>
<br/>
<br/>
<asp:GridViewID="GridView_details"runat="server"BackColor="White"
BorderColor="#CC9966"BorderStyle="None"BorderWidth="1px"CellPadding="4"
style="text-align: center"Width="380px">
<FooterStyleBackColor="#FFFFCC"ForeColor="#330099"/>
<HeaderStyleBackColor="#990000"Font-Bold="True"ForeColor="#FFFFCC"/>
<PagerStyleBackColor="#FFFFCC"ForeColor="#330099"HorizontalAlign="Center"/>

<RowStyleBackColor="White"ForeColor="#330099"/>
<SelectedRowStyleBackColor="#FFCC66"Font-Bold="True"ForeColor="#663399"/>
<SortedAscendingCellStyleBackColor="#FEFCEB"/>
<SortedAscendingHeaderStyleBackColor="#AF0101"/>
<SortedDescendingCellStyleBackColor="#F6F0C0"/>
<SortedDescendingHeaderStyleBackColor="#7E0000"/>

44
</asp:GridView>
<br/>
</asp:Content>

Aspx code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;publicpartialclassDisplayAllRecordOfBank : System.Web.UI.Page
{
SqlConnection con = newSqlConnection("Data Source=DHANANJAY-PC;Initial
Catalog=bankDB;User ID=sa;Password=123;Pooling=False");
SqlDataAdapter da;
SqlCommand cmd;
//string query;
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
con.Open();
string query = "select BankName from tbl_Bank "; cmd = newSqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read())
{
DropDownList1.Items.Add(dr[0].ToString());
}
con.Close(); gvBankDetail();
}
}
privatevoid gvBankDetail()
{
try{
con.Open();
string query = "select *from tbl_Bank";
cmd = newSqlCommand(query,con); da = newSqlDataAdapter(cmd);DataSet
ds = newDataSet();
da.Fill(ds); GridView_details.DataSource = ds; GridView_details.DataBind(); con.Close();
}

45
{
con.Open();
string query = "select *from tbl_Bank";
cmd = newSqlCommand(query,con); da = newSqlDataAdapter(cmd);DataSet
ds = newDataSet();
da.Fill(ds); GridView_details.DataSource = ds; GridView_details.DataBind(); con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}

protectedvoid DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


{
try
{
con.Open();

string query = "select *from tbl_Bank where BankName='"+DropDownList1.SelectedItem+"'";


cmd = newSqlCommand(query, con);da = newSqlDataAdapter(cmd); DataSet ds = newDataSet();
da.Fill(ds); GridView_details.DataSource = ds; GridView_details.DataBind(); con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}

Design code to Display all records of a branch of particular bank

<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup
="true"CodeFil e="DisplayBranchDetails.aspx.cs"Inherits="DisplayBranchDetails"%>

<asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server">
<h1>Display Branch Detail</h1>
<asp:LabelID="Label1"runat="server"Text="Select the BankName"></asp:Label>
:<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>

46
<br/>
<br/>
<asp:GridViewID="GridView1"runat="server">
</asp:GridView>
<br/>
</asp:Content>

Aspx code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;publicpartialclassDisplayBranchDetails : System.Web.UI.Page
{
SqlConnection con = newSqlConnection("Data Source=DHANANJAY-PC;Initial
Catalog=bankDB;User ID=sa;Password=123;Pooling=False");
SqlDataAdapter da;
SqlCommand cmd;
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
con.Open();
string query = "select BankName from tbl_Bank "; cmd = newSqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read())
{
DropDownList1.Items.Add(dr[0].ToString());
}
con.Close(); gvBankDetail();
}
}
privatevoid gvBankDetail()
{
try{
con.Open();
string query = "select *from tbl_Bank,tbl_Branch where
tbl_Bank.BankID=tbl_Branch.BankID"; cmd = newSqlCommand(query, con);da =

47
newSqlDataAdapter(cmd); DataSet ds = newDataSet();
da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
protectedvoid DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
con.Open();

string query = "select *from tbl_Bank,tbl_Branch where


tbl_Bank.BankID=tbl_Branch.BankID and tbl_Bank.BankName='" +
DropDownList1.SelectedItem + "'";
cmd = newSqlCommand(query, con); da = newSqlDataAdapter(cmd);DataSet
ds = newDataSet();
da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); con.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}

Design Code to display the balance for the entered account number

<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPage.master"AutoEventWireup
="true"CodeFil e="DisplayBalance.aspx.cs"Inherits="DisplayBalance"%>

<asp:ContentID="Content1"ContentPlaceHolderID="head"Runat="Server">
<tablestyle="width: 78%; height: 98px; vertical-align: middle; text-align: center;"
align="center">
<tr>
<tdstyle="width: 118px">
Account number </td>
<tdstyle="width: 155px">
<asp:TextBoxID="TextBox1"runat="server"Width="200px"></asp:TextBox>
</td>

48
<td> &nbsp;</td>
</tr>
<tr>
<tdstyle="width: 118px">
Bank ID</td>
<tdstyle="width: 155px">
<asp:DropDownListID="DropDownList1"runat="server"Width="200px">
</asp:DropDownList>
</td>
<td> &nbsp;</td>
</tr>
<tr>
<tdstyle="width: 118px">Branch
ID</td>
<tdstyle="width: 155px">
<asp:DropDownListID="DropDownList2"runat="server"Width="200px">
</asp:DropDownList>
</td>
<td> &nbsp;</td>
</tr>
<tr>
<tdstyle="width: 118px"> &nbsp;</td>
<tdstyle="width: 155px">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;
<asp:ButtonID="Button1"runat="server"Text="Display"Width="100px" onclick="Button1_Click"/>
</td>
<td> &nbsp;</td>
</tr>
</table>
<asp:GridViewID="GridView1"runat="server">
</asp:GridView>
</asp:Content>

Aspx code:

using System;
using System.Collections.Generic;
using System.Linq;using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

49
publicpartialclassDisplayBalance : System.Web.UI.Page
{
SqlConnection con = newSqlConnection("Data Source=DHANANJAY-PC;Initial
Catalog=bankDB;User ID=sa;Password=123;Pooling=False");
SqlDataAdapter da;
SqlCommand cmd;
protectedvoid Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
con.Open();
string query = "select BankID from tbl_Bank "; cmd = newSqlCommand(query, con);SqlDataReader
dr = cmd.ExecuteReader(); while (dr.Read())
{
DropDownList1.Items.Add(dr[0].ToString());
}
con.Close();
}
if (!IsPostBack)
{
con.Open();
string query = "select BranchID from tbl_Branch ";
cmd = newSqlCommand(query, con); SqlDataReader dr = cmd.ExecuteReader(); while(dr.Read())
{
DropDownList2.Items.Add(dr[0].ToString());
}
con.Close();
}
}
protectedvoid Button1_Click(object sender, EventArgs e)
{
con.Open();
string query = "select *from tbl_Account where BranchID=" + DropDownList2.SelectedValue
+ "and BankID=" + DropDownList1.SelectedItem + " and AccountNo=" +TextBox1.Text+"";
cmd = newSqlCommand(query, con); da = newSqlDataAdapter(cmd);DataSet
ds = newDataSet();
da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind();con.Close();

}
}

50
Output:

Reports:
Display all records of particular bank

Display all records of a branch of particular


bank.

51
The balance should be displayed for the entered account number.

Result

52
Ex No: 08 To calculate the interest for the Bank database using web services.

DATE:

Aim:

Algorithm:

53
FORM DESIGN:

54
WEB SERVICE :-

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

namespace Simpleinterestservice1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[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 Service1 : System.Web.Services.WebService

[WebMethod]
public int Simpleinterest(int P,int n,int r)
{
return (P *n *r)/100;
}
}
}

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

55
}
protected void Button1_Click(object sender, EventArgs e)
{
localhost.Service1 mys = new localhost.Service1();
int P = Convert .ToInt32 (TextBox1 .Text);
int n = Convert .ToInt32 (TextBox2 .Text);
int r = Convert .ToInt32 (TextBox3 .Text);
int interest= mys.Simpleinterest (P,n,r);
TextBox4 .Text = interest .ToString ();
}
}

56
OUTPUT:

Result:

57

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy