Net Practicals Manthan
Net Practicals Manthan
Aim: Design forms and write , test and debug programs to test its various
properties, methods , events.
-Choose Windows Forms App (.NET Framework) for C# and click Next.
-Name the project - MainForm and Create.(code following) .
-Double click at any point on left side of the code to Debug.
Page-1 2101202030-IT
Output:
Page-2 2101202030-IT
PRACTICAL-2
Aim: Write, test and debug applications to use textbox, label, button.
-Choose Windows Forms App (.NET Framework) for C# and click Next.
-Name the project - MainForm and Create.(code following) .
-Double click at any point on left side of the code to Debug.
Page-3 2101202030-IT
Output: Before writing text
Page-4 2101202030-IT
PRACTICAL-3
Aim: Write, test and debug application using rich text box, progress bar,
masked text box, link label.
Code:
Page-5 2101202030-IT
Output:
Initial-
Page-6 2101202030-IT
After editing:
LinkLabel: “Visit OpenAi” When clicked, it opens the OpenAI website in the
default browser.
Page-7 2101202030-IT
PRACTICAL-4
Page-8 2101202030-IT
This application will:
Display a MessageBox when a button is clicked.
Use an OpenFileDialog to let the user select a file.
Use a ColorDialog to let the user pick a color, which will then change the
form’s background color.
Output:
Initial-
Page-9 2101202030-IT
Clicked on “show” button-
Clicking on “Open File” button lets you choose file from computer.
Clicked on “select” button -lets you choose color and applies it to form
background.
Page-10 2101202030-IT
PRACTICAL-5
Aim: Write, test and debug applications using math and string
manipulation functions
The application will:
Accept two numbers and perform basic math operations (addition,
subtraction, multiplication, division).
Take a text input and allow users to apply various string
manipulations (e.g., converting to uppercase, reversing text, counting
words).
Code:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); SetupForm();
}
// Method to set up form components
private void SetupForm()
{
// Set form properties
this.Text = "Math and String Manipulation";
this.Size = new System.Drawing.Size(400, 400);
// Label for number input
Label numberLabel = new Label { Text = "Enter two numbers:",
Location = new System.Drawing.Point(20, 20) };
this.Controls.Add(numberLabel);
Page-11 2101202030-IT
// TextBoxes for numbers
TextBox number1TextBox = new TextBox { Location = new
System.Drawing.Point(20, 50), Width = 100 };
TextBox number2TextBox = new TextBox { Location = new
System.Drawing.Point(130, 50), Width = 100 };
this.Controls.Add(number1TextBox);
this.Controls.Add(number2TextBox);
// Button to calculate
Button calculateButton = new Button { Text = "Calculate",
Location = new System.Drawing.Point(20, 90) };
calculateButton.Click += (sender, e) => {
double num1, num2;
if (double.TryParse(number1TextBox.Text, out num1) &&
double.TryParse(number2TextBox.Text, out num2))
{ PerformMathOperations(num1, num2); }
else { MessageBox.Show("Please enter valid numbers."); } };
this.Controls.Add(calculateButton);
// TextBox for string input
Label stringLabel = new Label { Text = "Enter text:", Location =
new System.Drawing.Point(20, 140) };
TextBox inputTextBox = new TextBox { Location = new
System.Drawing.Point(20, 170), Width = 200 };
this.Controls.Add(stringLabel);
this.Controls.Add(inputTextBox);
// Button to perform string manipulations Button
Page-12 2101202030-IT
stringManipulateButton = new Button { Text = "Manipulate
Text", Location = new System.Drawing.Point(20, 200) };
stringManipulateButton.Click += (sender, e) => {
PerformStringManipulations(inputTextBox.Text);
};
this.Controls.Add(stringManipulateButton);
}
// Method to perform basic math operations
private void PerformMathOperations(double num1, double num2) {
double sum = num1 + num2;
double difference = num1 - num2;
double product = num1 * num2;
double quotient = num2 != 0 ? num1 / num2 : double.NaN;
// Handle division by zero
MessageBox.Show($"Sum: {sum}\nDifference:
{difference}\nProduct: {product}\nQuotient: {(num2 != 0 ?
quotient.ToString() : "undefined")}");
}
// Method to perform string manipulations
private void PerformStringManipulations(string text) {
string upperCase = text.ToUpper();
string lowerCase = text.ToLower();
string reversed = new string(text.Reverse().ToArray());
int wordCount = text.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries).Length;
Page-13 2101202030-IT
MessageBox.Show($"Uppercase: {upperCase}\nLowercase:
{lowerCase}\nReversed: {reversed}\nWord Count: {wordCount}");
}
}
}
The application will:
Accept two numbers and perform basic math operations (addition,
subtraction, multiplication, division).
Take a text input and allow users to apply various string
manipulations (e.g., converting to uppercase, reversing text, counting
words).
Output:
Page-14 2101202030-IT
Entering strings and clicked on “Manipulate”
Page-15 2101202030-IT
PRACTICAL-6
Aim: Create and test connection using ado.net to view SQL express
server/Microsoft Access data in textbox etc controls
Creating Database:
Create a new database –“TestDatabase” in SQL Server
Management Studio.
Create a sample table -Employees with a few columns
Drag and Drop four textboxes from toolbox at left into the form.
->Name the 1st box –“ textBoxID” ,2nd box- “textBoxFirstName”, 3rd box –
“textBoxLastName” , 4rth box- “textBoxPosition”, and the button –
“btnLoadData”.
Page-16 2101202030-IT
Output: After clicking the button
Page-17 2101202030-IT
PRACTICAL-7
Aim: Write, test and debug small application to add, edit, search, delete
record in database in bounded mode.
Creating Database:
Create a new database –“TestDatabase” in SQL Server
Management Studio.
Create a sample table -Employees with a few columns
Page-18 2101202030-IT
Page-19 2101202030-IT
Page-20 2101202030-IT
Output:
Page-21 2101202030-IT
PRACTICAL-8
-Code:
Page-22 2101202030-IT
Output: Initial
Page-23 2101202030-IT
PRACTICAL-9
Aim: Write, test and debug small application to add, edit, search, delete
record in database in bounded mode.
Creating Database:
Create a new database –“TestDatabase” in SQL Server
Management Studio.
Create a sample table -Employees with a few columns
Page-24 2101202030-IT
Page-25 2101202030-IT
Page-26 2101202030-IT
Output:
Page-27 2101202030-IT
PRACTICAL-10
Aim: Write, test and debug small application to add, edit, search, delete
record in database in unbounded mode i.e. through coding
-Create a new Windows Forms App (.NET Framework) project.
-Design the form: Drag and Drop the following:
TextBox controls for FirstName, LastName, and Position.
Button controls: btnAdd, btnEdit, btnDelete, btnSearch, and btnLoad.
a ListBox to display search results (listBoxResults).
Code:
Page-28 2101202030-IT
Page-29 2101202030-IT
Page-30 2101202030-IT
Output: Clicked on Load Data button
-Enter data in the text fields and click Add to insert a new record.
-Enter an EmployeeID and updated data, then click Edit to update an
existing record.
Page-31 2101202030-IT
-Enter an EmployeeID and click Delete to remove a record.
-Enter a name (or partial name) in FirstName or LastName and click Search
to find matching records.
Page-32 2101202030-IT