Академический Документы
Профессиональный Документы
Культура Документы
Question # 01:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReverseArray
{
class Program
{
static void Main(string[] args)
{
int[] array = { 22, 50, 11, 2, 49 };
foreach (int a in array)
{
Console.WriteLine(a);
}
Array.Reverse(array);
Console.WriteLine("Reversed Array : ");
foreach (int value in array)
{
Console.WriteLine(value);
}
Console.ReadLine();
}
}
}
Page 1 of 38
LAB TASK # 01:
Question # 02:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReverseArray
{
class Program
{
static void Main(string[] args)
{
}
for (i = 0; i < 3; i++)
{
Console.Write("\n\nEnter author names: ");
authorname[i] = Console.ReadLine();
}
for (i = 0; i < 3; i++)
{
Console.Write("\n\nEnter publisher name:\t");
publishername[i] = Console.ReadLine();
j++;
}
}
if(j == 0)
Page 2 of 38
{
Console.WriteLine("Not Found!!!");
}
Console.ReadLine();
}
}
Page 3 of 38
LAB TASK # 02:
Class.txt:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication5
{
class Product
{
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Product p = new Product();
sum.Add(rate);
Page 5 of 38
total = sum.Sum();
if (total == null)
{
txttotal.Text = Convert.ToString(total);
}
else
{
txttotal.Text = "Total = \t\t"+Convert.ToString(total)+" Rs";
}
Page 6 of 38
}
Page 7 of 38
txttotal.Text = "Total = \t\t" + Convert.ToString(total) + " Rs";
}
}
Page 8 of 38
else
{
txttotal.Text = "Total = \t\t" + Convert.ToString(total) + " Rs";
}
}
sum.RemoveAt(count - 1);
list.RemoveAt(count - 1);
listView.Items.RemoveAt(count-1);
count--;
total = sum.Sum();
}
}
}
}
}
Page 9 of 38
Page 10 of 38
Page 11 of 38
LAB TASK # 03:
Library.txt:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsApplication5
{
class Product
{
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Product p = new Product();
count++;
listView.Items.Add(Convert.ToString(count - 1) + " Prod " + rate);
sum.Add(rate);
Page 13 of 38
total = sum.Sum();
if (total == null)
{
txttotal.Text = Convert.ToString(total);
}
else
{
txttotal.Text = "Total = \t\t" + Convert.ToString(total) + " Rs";
}
Page 14 of 38
}
Page 15 of 38
txttotal.Text = "Total = \t\t" + Convert.ToString(total) + " Rs";
}
}
Page 16 of 38
else
{
txttotal.Text = "Total = \t\t" + Convert.ToString(total) + " Rs";
}
}
list.RemoveAt(1);
sum.Reverse();
sum.RemoveAt(0);
listView.Items.RemoveAt(count - 1);
count--;
total = sum.Sum();
}
}
}
StreamWriter writer = new StreamWriter(path, append: true);
bill++;
MessageBox.Show("Bill Generated");
writer.Close();
Page 17 of 38
}
}
Page 18 of 38
Page 19 of 38
LAB TASK # 04:
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double hours, sal;
{
if (hours <= 8 && hours >= 21)
{
try
{
}
catch (FormatException ex)
{
MessageBox.Show("Not Possible");
}
}
}
}
}
Page 20 of 38
Page 21 of 38
LAB TASK # 05:
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.IO;
namespace Lab_task_5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
datagrid.DataSource = table;
table.Columns.Add("ID", typeof(int));
table.Columns.Add("Roll_No", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Address", typeof(string));
table.Columns.Add("Math", typeof(double));
table.Columns.Add("English", typeof(double));
table.Columns.Add("Urdu", typeof(double));
table.Columns.Add("islamiate", typeof(double));
table.Columns.Add("Pst", typeof(double));
table.Columns.Add("Total", typeof(double));
table.Columns.Add("Percentage", typeof(double));
Page 22 of 38
{
list.Add(counter + " " + txtRoll.Text + " " + txtName.Text + " " + datagrid.Text
+" " + txtMaths.Text + " " + txtEnglish.Text + " " + txtUrdu.Text + " "+
txtIslamiate.Text + " " + txtPST.Text + " " + txtTotal.Text + " " + txtPercentage.Text);
}catch(Exception ex)
{
MessageBox.Show(ex.Message,"Exception Error",MessageBoxButtons.OKCancel,MessageBoxIcon.Exclamation);
}
}
}
}
}
Page 23 of 38
private void txtSearchRoll_TextChanged(object sender, EventArgs e)
{
try
{
if (File.Exists(path) == true)
{
File.AppendAllLines(path, list);
}
else
{
MessageBox.Show("File Not Exist", "Exception Error", MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation);
}else
{
MessageBox.Show("List is Less Than 30", "Exception Error", MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception Error", MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation);
}
}
File.ReadAllLines(path);
while (!oStreamReader.EndOfStream)
{
if (oStreamRowData.Length > 0)
{
oStreamDataValues = oStreamRowData.Split(',');
else
{
MessageBox.Show("There is no text file to read from!");
}
row++;
}
}
}
}
}
Page 25 of 38
Page 26 of 38
Page 27 of 38
Page 28 of 38
LAB TASK # 06:
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.IO;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.FileIO;
namespace Lab_task_5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
datagrid.DataSource = table;
table.Columns.Add("ID", typeof(string));
table.Columns.Add("Roll_No", typeof(string));
table.Columns.Add("Name", typeof(string));
table.Columns.Add("Address", typeof(string));
table.Columns.Add("Math", typeof(double));
table.Columns.Add("English", typeof(double));
table.Columns.Add("Urdu", typeof(double));
table.Columns.Add("islamiate", typeof(double));
table.Columns.Add("Pst", typeof(double));
table.Columns.Add("Total", typeof(double));
table.Columns.Add("Percentage", typeof(double));
Page 29 of 38
Total = Convert.ToDouble(txtEnglish.Text) + Convert.ToDouble(txtIslamiate.Text) +
Convert.ToDouble(txtMaths.Text) + Convert.ToDouble(txtPST.Text) + Convert.ToDouble(txtUrdu.Text);
Percentage = (Total / 500) * 100;
txtPercentage.Text = Percentage.ToString();
txtTotal.Text = Total.ToString();
counter++;
table.Rows.Add(counter, txtRoll.Text, txtName.Text, textAddress.Text, txtMaths.Text, txtEnglish.Text,
txtUrdu.Text, txtIslamiate.Text, txtPST.Text, Total, Percentage);
list.Add(counter + " " + txtRoll.Text + " " + txtName.Text + " " + datagrid.Text
+" " + txtMaths.Text + " " + txtEnglish.Text + " " + txtUrdu.Text + " "+
txtIslamiate.Text + " " + txtPST.Text + " " + txtTotal.Text + " "+
txtPercentage.Text+",");
}catch(Exception ex)
{
MessageBox.Show(ex.Message,"Exception Error",MessageBoxButtons.OKCancel,MessageBoxIcon.Exclamation);
}
}
}
}
}
if (File.Exists(path) == true)
{
File.AppendAllLines(path, list);
}
else
{
MessageBox.Show("File Not Exist", "Exception Error", MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation);
}else
{
MessageBox.Show("List is Less Than 30", "Exception Error", MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception Error", MessageBoxButtons.OKCancel,
MessageBoxIcon.Exclamation);
}
}
int row = 0;
string line;
while ((line = reader.ReadLine()) != null)
{
string[] columns = line.Split(',');
table.Rows.Add();
}
row++;
datagrid.DataSource = table;
}
}
}
Page 32 of 38
Power Point Slide:
Page 33 of 38
Lab Task # 07:-
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 lab_task_7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string ApplForDesci, Gender;
bool Success = false;
private void Form1_Load(object sender, EventArgs e)
{
LoadAllRecordIntoDataGridView();
}
void Insert()
{
try
{
Page 34 of 38
if (radioMale.Checked)
{
Gender = "Male";
}
else if (radioFemale.Checked)
{
Gender = "Female";
}
cmd.Parameters.AddWithValue("@Name", txtName.Text);
cmd.Parameters.AddWithValue("@Gender", Gender);
cmd.Parameters.AddWithValue("@Pre_Quali", txtPre.Text);
cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
cmd.Parameters.AddWithValue("@ApplForDesci", ApplForDesci);
cmd.Parameters.AddWithValue("@StudentID", txtID.Text);
cmd.ExecuteNonQuery();
}
using (SqlCommand cmd = new SqlCommand("INSERT INTO stRecord
(CourseName,Grade,TeacherName,SemesterName,StudentID) VALUES
(@CourseName,@Grade,@TeacherName,@SemesterName,@StudentID)", conn))
{
cmd.Parameters.AddWithValue("@CourseName", txtCourse.Text);
cmd.Parameters.AddWithValue("@Grade", txtGrade.Text);
cmd.Parameters.AddWithValue("@TeacherName", txtTeacher.Text);
cmd.Parameters.AddWithValue("@SemesterName", txtSemester.Text);
cmd.Parameters.AddWithValue("@StudentID", txtID.Text);
cmd.ExecuteNonQuery();
conn.Close();
}
MessageBox.Show("Data Inserted Successfully", "Success", MessageBoxButtons.OK,
MessageBoxIcon.Information);
Success = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtID.Clear();
}
}
dtRecords.Load(reader);
dtRecords.Columns[4].ColumnName = "Apply For Descipline";
dtRecords.Columns[2].ColumnName = "Previous Qualification";
}
return dtRecords;
Page 36 of 38
Lab Task 8:-
Power Point Slide:-
Page 37 of 38
Page 38 of 38