C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Project on students mark using C# syntax


Posted Date: 27 Dec 2007    Resource Type: Code Snippets    Category: C# Syntax

Posted By: C.V.Nisha Angeline       Member Level: Bronze
Rating:     Points: 10



details:
the project basically has a front page which has the options to
1. enter scholastic marks( marks got in the particular test )
2. enter non-scholastic marks( marks in the continuous assesment )
3.view the scholastic marks of all the students along with the calculated paramters like grade,percentage, total, and points are displayed in the data grid
4.view the non-scholastic marks of all the students along with the calculated paramters like grade,percentage, total, and points are displayed in the data grid

database design:
1. two tables
a.mark (columns-sno,admnno,name,lang,eng,math,sci,soc,points,grade,total,percent)
b.nonmarks are created (columns-sno,lang,eng,math,sci,soc,comp,gk,art,games,points,grade)

major screens:
1. first page with options as noted above
2.clicking on each optoin goes to a form to enter the marks of students
3.datagrid view that shows the parameters calculated




This code is used to enter the marks of students into a database and view the marks along with the calculated paramaters.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication1
{
public partial class vthIterm : Form
{
SqlConnection conn;
SqlCommand cmd;
SqlDataAdapter da;
DataTable dt;
DataSet ds;
DataRow[] dr;
SqlCommandBuilder cb;

public vthIterm()
{
InitializeComponent();
String s = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + @"D:\Visual Studio 2005\Projects\Promotion db\Promotion db\marks.mdf" + @";Integrated Security=True;Connect Timeout=30;User Instance=True";
conn = new SqlConnection(s);
}

private void button1_Click(object sender, EventArgs e)
{
Form1 f = new Form1();
f.Show();
}

private void button2_Click(object sender, EventArgs e)
{
nonscholastic n = new nonscholastic();
n.Show();
}

private void button3_Click(object sender, EventArgs e)
{
conn.Open();
string sql = "select sno as 'Sno',admno as 'Admnno',name as 'Name',lang as 'IIlang',eng as 'English',math as 'Maths',sci as 'Science',soc as 'social',points as 'Points',grade as 'Grade',[percent] as 'Percent',total as 'Total' from mark";
cmd = new SqlCommand(sql, conn);
int d = cmd.ExecuteNonQuery();
dataGridView1.Visible = true;
da = new SqlDataAdapter(cmd);
cb = new SqlCommandBuilder(da);
ds = new DataSet();
da.Fill(ds, "person,details");
dt = ds.Tables[0];
dr = dt.Select();
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "person,details";
conn.Close();

}

private void button4_Click(object sender, EventArgs e)
{

conn.Open();
string sql = "select name as 'Name', nonmarks.sno as 'Sno',nonmarks.lang as 'IIlang',nonmarks.eng as 'English',nonmarks.math as 'Maths',nonmarks.sci as 'Science',nonmarks.soc as 'social',nonmarks.comp as 'CompSci',nonmarks.gk as 'Gk',nonmarks.art as 'Art/Craft',games as 'Games',nonmarks.points as 'Points',nonmarks.grade as 'Grade' from nonmarks,mark where mark.sno=nonmarks.sno";
cmd = new SqlCommand(sql, conn);
int d = cmd.ExecuteNonQuery();
dataGridView1.Visible = true;
da = new SqlDataAdapter(cmd);
cb = new SqlCommandBuilder(da);
ds = new DataSet();
da.Fill(ds, "person,details");
dt = ds.Tables[0];
dr = dt.Select();
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "person,details";
dataGridView1.SelectAll();
conn.Close();
}
}

}



This code part actually calculates the total ,points are assigned to each subject and then grades are assigned and finally percentage calulated
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
SqlConnection conn;
SqlCommand cmd;
float totm,ll,en1,m1,sc1,so1,tot;
string grade;
float a;

public Form1()
{
InitializeComponent();
String s = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + @"D:\Visual Studio 2005\Projects\Promotion db\Promotion db\marks.mdf" + @";Integrated Security=True;Connect Timeout=30;User Instance=True";
conn = new SqlConnection(s);

}

private void button1_Click(object sender, EventArgs e)
{
conn.Open();
float l = System.Convert.ToInt16(textBox4.Text);
float en = System.Convert.ToInt16(textBox5.Text);
float m = System.Convert.ToInt16(textBox6.Text);
float sc = System.Convert.ToInt16(textBox7.Text);
float so = System.Convert.ToInt16(textBox8.Text);
//marks
totm = l + en + m + sc + so;
//percentage
a = 20*(l / 100)+ 20 * (en / 100) + 20 * (m / 100) + 20 * (sc / 100) + 20 * (so / 100);
//point check
if (l==100)
{
ll = 1;
}
else if (l >=90 & l<=99 )
{
ll = 2;
}
else if (l >=80 & l <=89)
{
ll = 3;
}

else if (l >= 70 & l <= 79)
{
ll = 4;
}
else if (l >= 60 & l <= 69)
{
ll = 5;
}

else if (l >= 50 & l <= 59)
{
ll = 6;
}

else if (l >= 40 & l <= 49)
{
ll = 7;
}
else if (l >= 1 & l <= 39)
{
ll = 8;
}
//////////////////////////////
if (en == 100)
{
en1 = 1;
}
else if (en >= 90 & en <= 99)
{
en1 = 2;
}
else if (en >= 80 & en <= 89)
{
en1 = 3;
}

else if (en >= 70 & en <= 79)
{
en1 = 4;
}
else if (en >= 60 & en <= 69)
{
en1 = 5;
}

else if (en >= 50 & en <= 59)
{
en1 = 6;
}

else if (en >= 40 & en <= 49)
{
en1 = 7;
}
else if (en >= 1 & en <= 39)
{
en1 = 8;
}
///////////////////////

if (m == 100)
{
m1 = 1;
}
else if (m >= 90 & m <= 99)
{
m1 = 2;
}
else if (m >= 80 & m <= 89)
{
m1 = 3;
}

else if (m >= 70 & m <= 79)
{
m1 = 4;
}
else if (m >= 60 & m <= 69)
{
m1 = 5;
}

else if (m >= 50 & m <= 59)
{
m1 = 6;
}

else if (m >= 40 & m <= 49)
{
m1 = 7;
}
else if (m >= 1 & m <= 39)
{
m1 = 8;
}

//////////////////////////////

if (sc == 100)
{
sc1 = 1;
}
else if (sc >= 90 & sc <= 99)
{
sc1 = 2;
}
else if (sc >= 80 & sc <= 89)
{
sc1 = 3;
}

else if (sc >= 70 & sc <= 79)
{
sc1 = 4;
}
else if (sc >= 60 & sc <= 69)
{
sc1 = 5;
}

else if (sc >= 50 & sc <= 59)
{
sc1 = 6;
}

else if (sc >= 40 & sc <= 49)
{
sc1 = 7;
}
else if (sc >= 1 & sc <= 39)
{
sc1 = 8;
}

///////////////////

if (so == 100)
{
so1 = 1;
}
else if (so >= 90 & so <= 99)
{
so1 = 2;
}
else if (so >= 80 & so <= 89)
{
so1 = 3;
}

else if (so >= 70 & so <= 79)
{
so1 = 4;
}
else if (so >= 60 & so <= 69)
{
so1 = 5;
}

else if (so >= 50 & so <= 59)
{
so1 = 6;
}

else if (so >= 40 & so <= 49)
{
so1 = 7;
}
else if (so >= 1 & so <= 39)
{
so1 = 8;
}
// total cal

tot=ll+en1+m1+sc1+so1;
//grade
if (tot >= 1 & tot <= 5)
{ grade = "O"; }
else if (tot >= 6 & tot <= 10)
{ grade = "A"; }
else if (tot >= 11 & tot <= 15)
{ grade = "B"; }
else if (tot >= 16 & tot <= 20)
{ grade = "C"; }
else if (tot >= 21 & tot <= 25)
{ grade = "D"; }
else if (tot >= 26 & tot <= 30)
{ grade = "E"; }
else if (tot >= 30 & tot <= 40)
{ grade = "F"; }
//insert
string sql = "insert into mark values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + tot + "','" + grade + "','" + totm + "','" + a + "')";
cmd = new SqlCommand(sql, conn);
int c = cmd.ExecuteNonQuery();
if (c == 1)
{
MessageBox.Show("" + textBox3.Text + "'s marks entered enter next students marks");
}
else
{
MessageBox.Show("check if all enteries are done correctly");
}

conn.Close();
}

}
}




This code is same as the previous one except that it is for non scholastic marks
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace WindowsApplication1
{
public partial class nonscholastic : Form
{
SqlConnection conn;
SqlCommand cmd;
float ll, en1, m1, sc1, so1, tot,gk1,ar1,ga1,co1;
string grade;
// float a;

public nonscholastic()
{
InitializeComponent();
String s = @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + @"D:\Visual Studio 2005\Projects\Promotion db\Promotion db\marks.mdf" + @";Integrated Security=True;Connect Timeout=30;User Instance=True";
conn = new SqlConnection(s);
}

private void nonscholastic_Load(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{
conn.Open();
float l = System.Convert.ToInt16(textBox2.Text);
float en = System.Convert.ToInt16(textBox3.Text);
float m = System.Convert.ToInt16(textBox4.Text);
float sc = System.Convert.ToInt16(textBox5.Text);
float so = System.Convert.ToInt16(textBox6.Text);
float co = System.Convert.ToInt16(textBox7.Text);
float gk = System.Convert.ToInt16(textBox8.Text);
float ar = System.Convert.ToInt16(textBox9.Text);
float ga = System.Convert.ToInt16(textBox10.Text);

//point check
if (l == 100)
{
ll = 1;
}
else if (l >= 90 & l <= 99)
{
ll = 2;
}
else if (l >= 80 & l <= 89)
{
ll = 3;
}

else if (l >= 70 & l <= 79)
{
ll = 4;
}
else if (l >= 60 & l <= 69)
{
ll = 5;
}

else if (l >= 50 & l <= 59)
{
ll = 6;
}

else if (l >= 40 & l <= 49)
{
ll = 7;
}
else if (l >= 1 & l <= 39)
{
ll = 8;
}
//////////////////////////////
if (en == 100)
{
en1 = 1;
}
else if (en >= 90 & en <= 99)
{
en1 = 2;
}
else if (en >= 80 & en <= 89)
{
en1 = 3;
}

else if (en >= 70 & en <= 79)
{
en1 = 4;
}
else if (en >= 60 & en <= 69)
{
en1 = 5;
}

else if (en >= 50 & en <= 59)
{
en1 = 6;
}

else if (en >= 40 & en <= 49)
{
en1 = 7;
}
else if (en >= 1 & en <= 39)
{
en1 = 8;
}
///////////////////////

if (m == 100)
{
m1 = 1;
}
else if (m >= 90 & m <= 99)
{
m1 = 2;
}
else if (m >= 80 & m <= 89)
{
m1 = 3;
}

else if (m >= 70 & m <= 79)
{
m1 = 4;
}
else if (m >= 60 & m <= 69)
{
m1 = 5;
}

else if (m >= 50 & m <= 59)
{
m1 = 6;
}

else if (m >= 40 & m <= 49)
{
m1 = 7;
}
else if (m >= 1 & m <= 39)
{
m1 = 8;
}

//////////////////////////////

if (sc == 100)
{
sc1 = 1;
}
else if (sc >= 90 & sc <= 99)
{
sc1 = 2;
}
else if (sc >= 80 & sc <= 89)
{
sc1 = 3;
}

else if (sc >= 70 & sc <= 79)
{
sc1 = 4;
}
else if (sc >= 60 & sc <= 69)
{
sc1 = 5;
}

else if (sc >= 50 & sc <= 59)
{
sc1 = 6;
}

else if (sc >= 40 & sc <= 49)
{
sc1 = 7;
}
else if (sc >= 1 & sc <= 39)
{
sc1 = 8;
}

///////////////////

if (so == 100)
{
so1 = 1;
}
else if (so >= 90 & so <= 99)
{
so1 = 2;
}
else if (so >= 80 & so <= 89)
{
so1 = 3;
}

else if (so >= 70 & so <= 79)
{
so1 = 4;
}
else if (so >= 60 & so <= 69)
{
so1 = 5;
}

else if (so >= 50 & so <= 59)
{
so1 = 6;
}

else if (so >= 40 & so <= 49)
{
so1 = 7;
}
else if (so >= 1 & so <= 39)
{
so1 = 8;
}
////////////////

if (co == 100)
{
co1 = 1;
}
else if (co >= 90 & co <= 99)
{
co1 = 2;
}
else if (co >= 80 & co <= 89)
{
co1 = 3;
}

else if (co >= 70 & co <= 79)
{
co1 = 4;
}
else if (co >= 60 & co <= 69)
{
co1 = 5;
}

else if (co >= 50 & co <= 59)
{
co1 = 6;
}

else if (co >= 40 & co <= 49)
{
co1 = 7;
}
else if (co >= 1 & co <= 39)
{
co1 = 8;
}
//////////////////////
if (gk == 100)
{
gk1 = 1;
}
else if (gk >= 90 & gk <= 99)
{
gk1 = 2;
}
else if (gk >= 80 & gk <= 89)
{
gk1 = 3;
}

else if (gk >= 70 & gk <= 79)
{
gk1 = 4;
}
else if (gk >= 60 & gk <= 69)
{
gk1 = 5;
}

else if (gk >= 50 & gk <= 59)
{
gk1 = 6;
}

else if (gk >= 40 & gk <= 49)
{
gk1 = 7;
}
else if (gk >= 1 & gk <= 39)
{
gk1 = 8;
}
////////////////////
if (ar == 100)
{
ar1 = 1;
}
else if (ar >= 90 & ar <= 99)
{
ar1 = 2;
}
else if (ar >= 80 & ar <= 89)
{
ar1 = 3;
}

else if (ar >= 70 & ar <= 79)
{
ar1 = 4;
}
else if (ar >= 60 & ar <= 69)
{
ar1 = 5;
}

else if (ar >= 50 & ar <= 59)
{
ar1 = 6;
}

else if (ar >= 40 & ar <= 49)
{
ar1 = 7;
}
else if (ar >= 1 & ar <= 39)
{
ar1 = 8;
}
////////////////
if (ga == 100)
{
ga1 = 1;
}
else if (ga >= 90 & ga <= 99)
{
ga1 = 2;
}
else if (ga >= 80 & ga <= 89)
{
ga1 = 3;
}

else if (ga >= 70 & ga <= 79)
{
ga1 = 4;
}
else if (ga >= 60 & ga <= 69)
{
ga1 = 5;
}

else if (ga >= 50 & ga <= 59)
{
ga1 = 6;
}

else if (ga >= 40 & ga <= 49)
{
ga1 = 7;
}
else if (ga >= 1 & ga <= 39)
{
ga1 = 8;
}
// total cal

tot = ll + en1 + m1 + sc1 + so1+co1+gk1+ga1+ar1+1;
//grade
if (tot >= 1 & tot <= 10)
{ grade = "O"; }
else if (tot >= 11& tot <= 20)
{ grade = "A"; }
else if (tot >= 21 & tot <= 30)
{ grade = "B"; }
else if (tot >= 31 & tot <= 40)
{ grade = "C"; }

//insert
string sql = "insert into nonmarks values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "','" + textBox9.Text + "','" + textBox10.Text + "','" + tot + "','" + grade + "')";
cmd = new SqlCommand(sql, conn);
int c = cmd.ExecuteNonQuery();
if (c == 1)
{
MessageBox.Show("" + textBox3.Text + "'s marks entered enter next students marks");
}
else
{
MessageBox.Show("check if all enteries are done correctly");
}

conn.Close();
}
}
}






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Intersection of two arrays
Previous Resource: get values from database using session variables.
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use