0% found this document useful (0 votes)
72 views6 pages

Assignment 3 With Solution

This document contains code for a C# Windows Forms application that allows a user to select a department and program from dropdown lists. Based on these selections, it enables and disables different text boxes for entering academic marks like matriculation, FSC, and BSc. It also contains code to calculate and display a merit percentage based on the entered marks, and clear or exit the form.

Uploaded by

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

Assignment 3 With Solution

This document contains code for a C# Windows Forms application that allows a user to select a department and program from dropdown lists. Based on these selections, it enables and disables different text boxes for entering academic marks like matriculation, FSC, and BSc. It also contains code to calculate and display a merit percentage based on the entered marks, and clear or exit the form.

Uploaded by

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

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 AdmissionForm
{
public partial class Form1 : Form
{
public Form1()
{ InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e)


{
listDepart.Items.Add("Computer Science");
listDepart.Items.Add("Information Technology");
listDepart.Items.Add("TeleCommunication");

listProg.Items.Add("BSCS");
listProg.Items.Add("MCS");
listProg.Items.Add("MIT");
listProg.Items.Add("BS(TS)");

applicationNo.Enabled = false;
name.Enabled = false;
matricObMarks.Enabled = false;
matricToMarks.Enabled = false;
fscObMarks.Enabled = false;
fscToMarks.Enabled = false;
bscObMarks.Enabled = false;
bscToMarks.Enabled = false;
}

Page | 1
private void listProg_SelectedIndexChanged(object sender, EventArgs e)
{
if (listDepart.SelectedIndex == -1)
{
MessageBox.Show("Please First Select The Department");
}
else if (listDepart.SelectedIndex == 0 && listProg.SelectedIndex == 0)
{
MessageBox.Show("Enter The Data");
applicationNo.Enabled = true;
name.Enabled = true;
fscObMarks.Enabled = true;
fscToMarks.Enabled = true;
bscObMarks.Enabled = false;
bscToMarks.Enabled = false;
matricObMarks.Enabled = false;
matricToMarks.Enabled = false;
}
else if (listDepart.SelectedIndex == 0 && listProg.SelectedIndex == 1)
{
MessageBox.Show("Enter The Data");
applicationNo.Enabled = true;
name.Enabled = true;
matricObMarks.Enabled = true;
matricToMarks.Enabled = true;
fscObMarks.Enabled = true;
fscToMarks.Enabled = true;
bscObMarks.Enabled = true;
bscToMarks.Enabled = true;
}
else if (listDepart.SelectedIndex == 1 && listProg.SelectedIndex == 2)
{
MessageBox.Show("Enter The Data");
applicationNo.Enabled = true; name.Enabled = true;
matricObMarks.Enabled = true;
matricToMarks.Enabled = true;
fscObMarks.Enabled = true;
fscToMarks.Enabled = true;
bscObMarks.Enabled = true; bscToMarks.Enabled = true;
}

Page | 2
else if (listDepart.SelectedIndex == 2 && listProg.SelectedIndex == 3)
{
MessageBox.Show("Enter The Data");
applicationNo.Enabled = true;
name.Enabled = true;
fscObMarks.Enabled = true;
fscToMarks.Enabled = true;
bscObMarks.Enabled = false;
bscToMarks.Enabled = false;
matricObMarks.Enabled = false;
matricToMarks.Enabled = false;
}
else
{
MessageBox.Show("Invalid Selection:Please Select Again");
}
}

private void btbDisplay_Click(object sender, EventArgs e)


{
if ((listDepart.SelectedIndex == 0 && listProg.SelectedIndex == 0) ||
(listDepart.SelectedIndex == 2 && listProg.SelectedIndex == 3))
{
double fscObtainMarks, fscTotalMarks;
fscObtainMarks = Convert.ToDouble(fscObMarks.Text);
fscTotalMarks = Convert.ToDouble(fscToMarks.Text);
if (fscObtainMarks <= fscTotalMarks)
{
double meritPer;
meritPer = (fscObtainMarks / fscTotalMarks)*100;
merit.Text = meritPer.ToString("#.0");
if (meritPer >= 80)
{ remarks.Text = "Congratulation...!"; }
else { remarks.Text = "See Next Merit list"; }
}
else
{
MessageBox.Show("ERROR:Obtain marks are greater then Total
Marks");

Page | 3
}
}
else if ((listDepart.SelectedIndex == 0 && listProg.SelectedIndex == 1) ||
(listDepart.SelectedIndex == 1 && listProg.SelectedIndex == 2))
{
double matricObtainMarks, matricTotalMarks, fscObtainMarks,
fscTotalMarks, bscObtainMarks, bscTotalMarks,totalobtain;

matricObtainMarks = Convert.ToDouble(matricObMarks.Text);
matricTotalMarks = Convert.ToDouble(matricToMarks.Text);
fscObtainMarks = Convert.ToDouble(fscObMarks.Text);
fscTotalMarks = Convert.ToDouble(fscToMarks.Text);
bscObtainMarks = Convert.ToDouble(bscObMarks.Text);
bscTotalMarks = Convert.ToDouble(bscToMarks.Text);

totalobtain = matricObtainMarks + fscObtainMarks + bscObtainMarks;


double total = matricTotalMarks + fscTotalMarks + bscTotalMarks;
if ((matricObtainMarks <= matricTotalMarks) &&
(fscObtainMarks <= fscTotalMarks) &&
(bscObtainMarks <= bscTotalMarks))
{
double meritPer;
meritPer = (totalobtain / total) * 100;
merit.Text = meritPer.ToString("#.0");
if (meritPer >= 80)
{
remarks.Text = "Congratulation...!";
}
else { remarks.Text = "See Next Merit list"; }
}
else
{
MessageBox.Show("ERROR:Obtain marks are greater then Total
Marks");
}
}
}

private void btnClear_Click(object sender, EventArgs e)


{

Page | 4
applicationNo.Clear();
name.Clear();
matricObMarks.Clear();
matricToMarks.Clear();
fscObMarks.Clear();
fscToMarks.Clear();
bscObMarks.Clear();
bscToMarks.Clear();
merit.Clear();
remarks.Clear();
listDepart.SelectedIndex = -1;
listProg.SelectedIndex = -1;
applicationNo.Enabled = false;
name.Enabled = false;
matricObMarks.Enabled = false;
matricToMarks.Enabled = false;
fscObMarks.Enabled = false;
fscToMarks.Enabled = false;
bscObMarks.Enabled = false;
bscToMarks.Enabled = false;
}

private void btnExit_Click(object sender, EventArgs e)


{
Application.Exit();
}
}
}

Page | 5
Page | 6

You might also like