CBT Manual N-Scheme
CBT Manual N-Scheme
III-YEAR / V- SEM
4052561
PRACTICAL
PART-A
Date:
Aim:
To Accept a Character from console and check the case of the character
Procedure:
2. Select project type as Visual c# -> windows and template type as Console application, then
click ok.
Program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
char c;
Console.WriteLine("enter character");
c = (char)Console.Read();
if (char.IsLower(c))
{
Console.WriteLine("lowercase");
}
else if (char.IsUpper(c))
{
Console.WriteLine("uppercase");
}
else
Console.WriteLine("others");
}
}
}
OUTPUT
Result:
Thus the program for accepting a character from console and checking case of the Character was
completed and output verified successfully.
Ex no:2 VOWEL CHECKING
Date:
Aim:
To Write a program to accept any character from keyboard and display whether vowel or not.
Procedure:
2. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK and Design a Form as shown in Figure
Program
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 vowel_check
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
private void button1_Click(object sender, EventArgs e)
{
String c,d;
c = textBox1.Text;
d = c.ToUpper();
if ((d== "A")||(d== "E")||(d== "I")||(d== "O")||(d == "U"))
textBox2.Text = "VOWEL";
else
textBox2.Text = "NOT VOWEL";
}
}
}
Output
Result:
Thus the C# program for accepting any character from keyboard and display whether vowel or
not was completed and output verified successfully.
Ex no :3 CALCULATOR
Date :
Aim:
Procedure:
2. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
Program
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 calc1
{
public partial class Form1 : Form
{
int p;
string m,op;
public Form1()
{
InitializeComponent();
}
Result:
Thus the C# program for implementing calculator was completed and output verified
successfully.
Ex no :4 CALENDAR APPLICATION
Date :
Aim:
Develop a form in to pick a date from Calendar control and display the day, month, year details
in separate text boxes.
Procedure:
2. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
Program
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 calaender
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
int a, b, c;
a = dateTimePicker1.Value.Day;
b = dateTimePicker1.Value.Month;
c = dateTimePicker1.Value.Year;
textBox1.Text = a.ToString();
textBox2.Text = b.ToString();
textBox3.Text = c.ToString();
}
}
}
OUTPUT
Result:
Thus the C# program for implementing calculator was completed and output verified
successfully.
Ex no : 5 FILE AND FOLDER CONTROL
Date :
Aim:
Develop a application using the File and Directory controls to implement a common dialog box
Procedure:
2. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
Program
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 file_and_folder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Result:
Thus the C# program for developing an application using the File and Directory controls to
implement a common dialog box was completed and output verified successfully.
Ex.No : 6 DATABASE CREATION USING ADO.NET
Date :
Aim:
Procedure:
1.Open Microsoft SQL Server and Create a table stud in student database by using the following
commands
3. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
Program
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;
using System.Data.SqlClient;
namespace EX6
{
public partial class Form1 : Form
{
public SqlConnection con;
public SqlCommand com;
public Form1()
{
InitializeComponent();
}
6. For Database connectivity click data menu -> Add new DataSource->New Connection-
>select Server name and database name.
7. Check Test Connection and copy the link. Assign it in the Sql Connection.
8. Run the Program.
OUTPUT:
Result:
Thus the C# program for Database application to store details of students using ADO.NET was
completed and output verified successfully
Ex.No : 7 ASP.NET PAGE CREATION
Date :
Aim:
Create a simple ASP.NET page to output text with a form, two HTML text boxes, an
HTML button, and an HTML<span> element. Create an event procedure for the button.
Procedure:
2. Select templates as Visual c# -> ASP.NET Empty web site, then click OK.
Program
Default.aspx:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
span {
color: brown;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="CLICK"
Width="103px" />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
Output:
Result:
Thus the C# program for creating ASP.NET page, web based application was completed and
output verified successfully.
PART-B
Date :
Aim:
Develop a menu based application to implement a text editor with cut, copy, paste, save and
close operations with accessing key and shortcut keys.
Procedure:
2. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
Program
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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
OUTPUT:
Result:
Thus the C# program for Developing Menu based application was completed and output verified
successfully.
Ex.No : 9 QUIZ CREATION
Date :
Aim:
Procedure:
2. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK. 3. Design a form as shown in figure
Program:
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 Quiz
{
public partial class Form1 : Form
{
String[,] Quest = new String[6, 5];
String[,] Answer = new String[6, 2];
int i = -1;
public Form1()
{
InitializeComponent();
}
}
}
Output:
Result:
Thus the C# program for developing an application to Perform timer based Quiz of 5 Questions
was completed and output verified successfully.
Ex.No : 10 DATABASE UPDATION USING ADO.NET
Date :
Aim:
Develop a application using ADO.NET to insert, modify, update and delete operations.
Procedure:
1. Open Microsoft SQL Server and Create a table stud in student database by using the following
commands
use student 2
create table stud(regno varchar(10), sname varchar(15), dept varchar(15)) insert into stud
values(‘115526’,’Robert’,’Civil’)
3. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
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;
using System.Data.SqlClient;
namespace EX10
{
public partial class Form1 : Form
{
public SqlConnection con;
public SqlCommand com;
public SqlDataReader rd;
public Form1()
{
InitializeComponent();
}
}
}
}
Output:
Result:
Thus the C# program for Database application to insert, modify, update and delete operations
using ADO.NET was completed and output verified successfully.
Ex.No : 11 DATABASE UPDATION USING DATAGRID
Date :
Aim:
Procedure:
1. Open Microsoft SQL Server and Create a table stud in student database by using the following
commands
use student 3
3. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
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;
using System.Data.SqlClient;
namespace EX11
{
public partial class Form1 : Form
{
public SqlConnection con=new SqlConnection("Data Source=CT-
37\\SQLEXPRESS;Initial Catalog=student3;Integrated Security=True");
public SqlCommand com=new SqlCommand();
public SqlDataReader rd;
int n;
public Form1()
{
InitializeComponent();
}
Output:
Result:
Thus the application using DataGrid to add, edit and modify records was completed and
output verified successfully.
Ex.No : 12 REQUIRED FIELD VALIDATOR AND RANGE VALIDATOR
Date :
Aim:
Develop a web application to input data through a web form to a database and validate the
data. use the required filed validator and range validator controls.
Procedure:
2. Select templates as Visual c# -> ASP.NET Empty web site, then click OK.
7. solution explorer ->website7->add->add new item->visual c#->web form->file name -> home-
> click add.
8.toolbox->data->sql data source->configure data source->select database1.mdf->next-> set
dbconnect ->test query -> finish.
Program:
Default .aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="NAME:"></asp:Label>
<asp:TextBox ID="TextBoxname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBoxname" Display="Dynamic" ErrorMessage="Enter name"
ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>
<br />
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="PWD:"></asp:Label>
<asp:TextBox ID="TextBoxpwd" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="TextBoxpwd" Display="Dynamic" ErrorMessage="enter pwd"
ForeColor="Red" SetFocusOnError="True"></asp:RequiredFieldValidator>
<br />
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="AGE:"></asp:Label>
<asp:TextBox ID="TextBoxage" runat="server" TextMode="Number"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBoxage" Display="Dynamic" ErrorMessage="Enter valid age"
ForeColor="Red" MaximumValue="60" MinimumValue="20" SetFocusOnError="True"
Type="Integer"></asp:RangeValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="submit"
Width="141px" />
<br />
<br />
</div>
</form>
</body>
</html>
Web.config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="dbconnect" connectionString="Data
Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated
Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
</configuration>
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try{
SqlConnection con=new
SqlConnection(ConfigurationManager.ConnectionStrings["dbconnect"].ConnectionString);
con.Open();
string insert ="insert into stud(name,pwd,age)values(@name,@pwd,@age)";
SqlCommand cmd = new SqlCommand(insert,con);
cmd.Parameters.AddWithValue("@name",TextBoxname.Text);
cmd.Parameters.AddWithValue("@pwd",TextBoxpwd.Text);
cmd.Parameters.AddWithValue("@age",TextBoxage.Text);
cmd.ExecuteNonQuery();
Response.Redirect("homepage.aspx");
con.Close();
}
catch(Exception ex)
{
Response.Write(ex);
}
}
}
Output:
Result:
Thus the web application to input data through a web form to a database and validate the data
was completed and output verified successfully.
Ex.No : 13 READING XML STUDENT DATABASE
Date :
Aim:
Develop a Windows application to read an XML document containing subject, marks scored,
year of passing into a dataSet.
Procedure:
1. Open Microsoft Visual Studio and create a new windows application with the name
StudentXml.
2. On the Project Menu click Add New Item and then click Xml File option.
3. Enter the filename as student.xml and click Add button. Now edit the following XML code.
5. On Form1 add one Button control and a DataGridView control from the toolbox.
6. Change the Text property of Button1 as Show Table
7. On Form1 add a DataSet control from the toolbox.In the AddDataSet dialogue box, select
Untyped Dataset option and then click OK. Now DataSet1 is added to the component tray.
String filePath="D:\\student.xml";
studentdataset.ReadXml(filePath);
dataGridView1.DataSource=studentdataset;
dataGridView1.DataMember="stud";
Output:
Result:
Thus the application to read an XML document containing subject, marks scored, year of
passing into a dataSet was completed and output verified successfully.
Ex.No : 14 GENERATING STUDENT XML DOCUMENT USING ADO.NET
Date :
Aim:
Develop a windows application to read students records from database using ADO.NET and
generate XML document containing students record.
Procedure:
1.Open Microsoft SQL Server and Create a table stud in student database by using the following
commands
use student4
3. Select project type as Visual c# -> Windows and Template type as Windows application, then
click OK.
Program
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;
using System.Xml;
using System.Data.SqlClient;
namespace EX14
{
public partial class Form1 : Form
{
public SqlConnection con;
public SqlDataReader rd;
public Form1()
{
InitializeComponent();
}
}
}
}
OUTPUT:
Result:
Thus the windows application to read students records from database using ADO.NET and
generating XML document containing students record was completed and output verified
successfully.