Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 38

Home Page

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs


e)
{
DateTime dt1 = DateTime.Parse("10/31/2013");
DateTime dt2 = DateTime.Now;
if (dt2 <= dt1)
{
Register a;
a = new Register();
Hide();
a.Show();
}
else
MessageBox.Show("Registration date is over!!");
}

private void pictureBox2_Click(object sender, EventArgs e)


{
Alogin a;
a = new Alogin();
Hide();
a.Show();
}

private void pictureBox4_Click(object sender, EventArgs e)


{
Slogin a;
a = new Slogin();
a.Show();
Hide();
}

}
}
Student Registration
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Register : Form
{
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");

public Register()
{
InitializeComponent();
}

private void Register_Load(object sender, EventArgs e)


{
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "dd-MMM-yyyy";

string query = null, ID = null;

//auto increment
query = "select max(reg_no) from student";
con1.Open();
OracleCommand cmd = new OracleCommand(query,con1);
cmd.CommandText = query;
ID = Convert.ToString(cmd.ExecuteScalar());

if((ID.Equals("")))
textBox1.Text = Convert.ToString(20140001);
else
{
long s = Convert.ToInt64(ID) + 1;
textBox1.Text = Convert.ToString(s);
}

con1.Close();
}

private void button1_Click(object sender, EventArgs e)


{
//insert
try
{
con1.Open();
string query = "insert into user_details values('" + textBox5.Text +
"','" + dateTimePicker1.Text + "','" + textBox2.Text +"','"+ textBox3.Text + "','" +
textBox4.Text +"', '"+ comboBox1.Text +"','"+ richTextBox1.Text +"')";
OracleCommand cmd = new OracleCommand(query, con1);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
con1.Close();

con1.Open();
query = "insert into student values('" + textBox1.Text + "','" +
textBox5.Text + "'," + comboBox2.Text + ")";
OracleCommand cmd1 = new OracleCommand(query, con1);
cmd1.CommandType = CommandType.Text;
cmd1.ExecuteNonQuery();
con1.Close();

con1.Open();
query = "insert into user_contact values('" + textBox5.Text + "','" +
textBox6.Text + "')";
OracleCommand cmd2 = new OracleCommand(query, con1);
cmd2.CommandType = CommandType.Text;
cmd2.ExecuteNonQuery();
con1.Close();

MessageBox.Show("You are registerd for GCET '14");

Form1 a;
a = new Form1();
a.Show();
Hide();

}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}

private void button2_Click(object sender, EventArgs e)


{
string query = null;

string c1 = null;
int flag = 0;

con1.Open();
query = "select uname from user_details where uname = '"+ textBox5.Text +"'";
OracleCommand cmd = new OracleCommand(query,con1);
OracleDataReader reader;
reader = cmd.ExecuteReader();

while (reader.Read())
{
c1 = (string)reader["uname"];
flag = 1;
}

reader.Close();

if (textBox5.Text == "")
{
MessageBox.Show("Fill the box!!");
}
else
{
if (flag == 1)
MessageBox.Show("Username not avaliable!!");
else
MessageBox.Show("Avaliable!!");
}
con1.Close();
}
}

Admin login
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Alogin : Form
{
OracleConnection con1 = new OracleConnection("Data source=xe;User
ID=gcet;password=gcet");

public Alogin()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
string query = null;

try
{
if ((textBox1.Text == "") || (maskedTextBox1.Text == ""))
{
MessageBox.Show("Enter empty block!!");
}
else
{
string c1, c2 = null;
int flag = 0;

con1.Open();
query = "select * from admin where username = '" + textBox1.Text +
"'";
OracleCommand cmd = new OracleCommand(query, con1);
OracleDataReader reader;
reader = cmd.ExecuteReader();

while (reader.Read())
{
c1 = (string)reader["username"];
c2 = (string)reader["pword"];
flag = 1;
}

reader.Close();

if (flag == 1)
{
if (c2 == maskedTextBox1.Text)
{
Amenu a;
a = new Amenu();
a.Show();
this.Close();
}
else
MessageBox.Show("Invalid password!!");
}
else
MessageBox.Show("Invalid username!!");

con1.Close();
}
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}
}
}

Admin menu
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GCET_14
{
public partial class Amenu : Form
{
public Amenu()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)


{
Form1 a;
a = new Form1();
a.Show();
Hide();
}

private void button1_Click(object sender, EventArgs e)


{
if (radioButton1.Checked)
{
setpaper a;
a = new setpaper();
a.Show();
Hide();
}

else
{
Adelete a;
a = new Adelete();
a.Show();
Hide();
}
}

}
}
View, Search And delete
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Adelete : Form
{
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");

public Adelete()
{
InitializeComponent();
}

private void pictureBox1_Click(object sender, EventArgs e)


{
Amenu a = new Amenu();
a.Show();
Hide();
}

private void button1_Click(object sender, EventArgs e)


{
//view all student details in dataset
String query = "SELECT student.reg_no, user_details.*, user_contact.phone_no
FROM user_details INNER JOIN user_contact ON user_details.uname = user_contact.uname
INNER JOIN student ON user_details.uname = student.u_id ORDER BY student.reg_no";
OracleCommand cmd = new OracleCommand(query, con1);
try
{
con1.Open();
OracleDataAdapter da = new OracleDataAdapter(query, con1);
DataSet d = new DataSet();
da.Fill(d);
dataGridView1.DataSource = d.Tables[0];
con1.Close();
}
catch(Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

private void button2_Click(object sender, EventArgs e)


{
//view selected student details in dataset
String query = "SELECT student.reg_no, user_details.*, user_contact.phone_no
FROM user_details INNER JOIN user_contact ON user_details.uname = user_contact.uname
INNER JOIN student ON user_details.uname = student.u_id where user_details.uname = '" +
textBox1.Text + "'";
OracleCommand cmd = new OracleCommand(query, con1);
try
{
con1.Open();
OracleDataAdapter da = new OracleDataAdapter(query, con1);
DataSet d = new DataSet();
da.Fill(d);
dataGridView1.DataSource = d.Tables[0];
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

private void button3_Click(object sender, EventArgs e)


{
try
{
//delete code
if (textBox1.Text == "")
{
MessageBox.Show("Enter uname!!");
}
else
{
con1.Open();
string query;

query = "delete from student where u_id= '" + textBox1.Text + "'";


OracleCommand cmd1 = new OracleCommand(query, con1);
cmd1.ExecuteNonQuery();

query = "delete from user_contact where uname= '" + textBox1.Text +


"'";
OracleCommand cmd2 = new OracleCommand(query, con1);
cmd2.ExecuteNonQuery();

query = "delete from user_details where uname= '" + textBox1.Text +


"'";
OracleCommand cmd3 = new OracleCommand(query, con1);
cmd3.ExecuteNonQuery();

MessageBox.Show("Student details deleted succesfully");


textBox1.Text = "";
con1.Close();
}
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}

}
}
}
Set question Papers
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class setpaper : Form
{
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");

public setpaper()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)


{
Smenu a;
a = new Smenu();
a.Show();
Hide();
}

private void button1_Click(object sender, EventArgs e)


{
try
{
con1.Open();
string query = "insert into paper values('" + comboBox1.Text + "','" +
textBox1.Text + "','" + 1 + "')";
OracleCommand cmd = new OracleCommand(query, con1);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
con1.Close();

con1.Open();
query = "insert into objective values('" + comboBox1.Text + "','" +
textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text +
"')";
OracleCommand cmd1 = new OracleCommand(query, con1);
cmd1.CommandType = CommandType.Text;
cmd1.ExecuteNonQuery();
con1.Close();
MessageBox.Show("Questions Inserted successfully!!");

textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
textBox5.Text = "";
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}
}
}
Student Login

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Slogin : Form
{
OracleConnection con1 = new OracleConnection("Data source =xe;User
ID=gcet;password=gcet");

public Slogin()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
try
{
string query = null, c1 = null, c2 = null;
int flag = 0;

con1.Open();
query = "select * from student where reg_no = '" + textBox1.Text + "'";
OracleCommand cmd = new OracleCommand(query, con1);
OracleDataReader reader;
reader = cmd.ExecuteReader();
while (reader.Read())
{
c1 = (string)reader["reg_no"];
c2 = (string)reader["u_id"];
flag = 1;
}

reader.Close();

if (flag == 1)
{
if (c2 == textBox2.Text)
{
MyGlobals.reg = textBox1.Text;
MyGlobals.uname = textBox2.Text;
Smenu a;
a = new Smenu();
a.Show();
this.Close();
}
else
MessageBox.Show("Invalid user ID!!");
}
else
MessageBox.Show("Invalid registration ID!!");

con1.Close();
}

catch (Exception er)


{
con1.Close();
MessageBox.Show(er.Message);
}
}

}
}
Student menu

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Smenu : Form
{
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");

public Smenu()
{
InitializeComponent();
}

private void button2_Click(object sender, EventArgs e)


{
Form1 a;
a = new Form1();
a.Show();
Hide();
}

private void button1_Click(object sender, EventArgs e)


{
if (radioButton1.Checked)
{
DateTime dt1 = DateTime.Parse("10/29/2013");
DateTime dt2 = DateTime.Now;
TimeSpan time = DateTime.Now.TimeOfDay;

if (dt1.Date == dt2.Date)
{
if (time > new TimeSpan(00, 00, 00) && time < new TimeSpan(23, 59,
00)) //Hours, Minutes, Seconds
{
string query2 = "Select score from result where reg_no = '" +
MyGlobals.reg + "'";
con1.Open();
OracleCommand cmd1 = new OracleCommand(query2, con1);
cmd1.CommandText = query2;
string ID = Convert.ToString(cmd1.ExecuteScalar());
con1.Close();
if ((ID.Equals("")))
{
Instructions a;
a = new Instructions();
a.Show();
Hide();
}
else
{
MessageBox.Show("You have answered exam!!");
}
}
else
MessageBox.Show("Examination Time over!!");
}
else
MessageBox.Show("You cannot answer now!!");
}
else if (radioButton2.Checked)
{
string query2 = "Select score from result where reg_no = '"+
MyGlobals.reg +"'";
con1.Open();
OracleCommand cmd1 = new OracleCommand(query2, con1);
cmd1.CommandText = query2;
string ID = Convert.ToString(cmd1.ExecuteScalar());
con1.Close();
if ((ID.Equals("")))
{
MessageBox.Show("You have not answered exam!!");
}
else
{
Result a;
a = new Result();
a.Show();
Hide();
}

con1.Close();
}
else if (radioButton3.Checked)
{
DateTime dt1 = DateTime.Parse("10/31/2013");
DateTime dt2 = DateTime.Now;
if (dt2 <= dt1)
{
UpdateRegister a;
a = new UpdateRegister();
a.Show();
Hide();
}
else
MessageBox.Show("Registration date is over!!");
}

}
}
Update Form

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class UpdateRegister : Form
{
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");

public UpdateRegister()
{
InitializeComponent();
}

private void UpdateRegister_Load(object sender, EventArgs e)


{
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "dd-MMM-yyyy";

textBox1.Text = MyGlobals.uname;
textBox2.Text = MyGlobals.reg;
}

private void button1_Click(object sender, EventArgs e)


{
//update code
try
{
string query = "Update user_details Set dob = '" + dateTimePicker1.Text +
"', fname = '" + textBox3.Text + "', minit = '" + textBox4.Text + "', lname = '" +
textBox5.Text + "', gender = '" + comboBox1.Text + "', location = '" + richTextBox1.Text
+ "' where uname = '" + textBox1.Text + "'";
OracleCommand cmd1 = new OracleCommand(query, con1);
cmd1.CommandType = CommandType.Text;
con1.Open();
cmd1.ExecuteNonQuery();
con1.Close();

string query1 = "Update user_contact Set phone_no = '" + textBox6.Text +


"' where uname = '" + textBox1.Text + "'";
OracleCommand cmd2 = new OracleCommand(query1, con1);
cmd2.CommandType = CommandType.Text;
con1.Open();
cmd2.ExecuteNonQuery();
con1.Close();

string query3 = "Update student Set year_admission = '"+ comboBox2.Text


+"' where u_id = '" + textBox1.Text + "'";
OracleCommand cmd3 = new OracleCommand(query3, con1);
cmd3.CommandType = CommandType.Text;
con1.Open();
cmd3.ExecuteNonQuery();
con1.Close();

MessageBox.Show("Record updated successfully");

Smenu a;
a = new Smenu();
a.Show();
Hide();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}

}
}
}

Instructions

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

namespace GCET_14
{
public partial class Instructions : Form
{
public Instructions()
{
InitializeComponent();
}

private void pictureBox1_Click(object sender, EventArgs e)


{
Physics a;
a = new Physics();
a.Show();
Hide();
}

}
}

Physics Paper

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Physics : Form
{
int flag = 0, count = 0;
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");
public Physics()
{
InitializeComponent();
}

public void insert()


{
//counting marks
if (radioButton2.Checked)
count++;
if (radioButton8.Checked)
count++;
if (radioButton11.Checked)
count++;
if (radioButton13.Checked)
count++;
if (radioButton17.Checked)
count++;
MyGlobals.score = count;
try
{
flag = 1;
con1.Open();
string query = "insert into result(c1,reg_no) values(" + count + ",'"+
MyGlobals.reg +"')";
OracleCommand cmd = new OracleCommand(query, con1);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

private void Physics_Load(object sender, EventArgs e)


{
//start of code for timer
timer1.Enabled = true;
timer1.Start();
timer1.Interval = 1000;
progressBar1.Maximum = 60; //seconds
timer1.Tick += new EventHandler(timer1_Tick);
//End of code for timer

//showing questions
try
{
string query = null;

con1.Open();
query = "SELECT question FROM paper WHERE q_no BETWEEN 1 AND 5 ORDER BY
q_no ASC";
OracleCommand cmd = new OracleCommand(query, con1);
cmd.CommandType = CommandType.Text;
OracleDataReader reader;
reader = cmd.ExecuteReader();

reader.Read();
label1.Text = (string)reader[0];
reader.Read();
label2.Text = (string)reader[0];
reader.Read();
label3.Text = (string)reader[0];
reader.Read();
label4.Text = (string)reader[0];
reader.Read();
label5.Text = (string)reader[0];

reader.Close();

//show options
query = "select * from objective where q_no BETWEEN 1 AND 5 ORDER BY q_no
ASC";
OracleCommand cmd1 = new OracleCommand(query, con1);
OracleDataReader reader1;
reader1 = cmd1.ExecuteReader();

//question 1
reader1.Read();
radioButton1.Text = (string)reader1["ob1"];
radioButton2.Text = (string)reader1["ob2"];
radioButton3.Text = (string)reader1["ob3"];
radioButton4.Text = (string)reader1["ob4"];

//question 2
reader1.Read();
radioButton5.Text = (string)reader1["ob1"];
radioButton6.Text = (string)reader1["ob2"];
radioButton7.Text = (string)reader1["ob3"];
radioButton8.Text = (string)reader1["ob4"];

//question 3
reader1.Read();
radioButton9.Text = (string)reader1["ob1"];
radioButton10.Text = (string)reader1["ob2"];
radioButton11.Text = (string)reader1["ob3"];
radioButton12.Text = (string)reader1["ob4"];

//question 4
reader1.Read();
radioButton13.Text = (string)reader1["ob1"];
radioButton14.Text = (string)reader1["ob2"];
radioButton15.Text = (string)reader1["ob3"];
radioButton16.Text = (string)reader1["ob4"];

//question 5
reader1.Read();
radioButton17.Text = (string)reader1["ob1"];
radioButton18.Text = (string)reader1["ob2"];
radioButton19.Text = (string)reader1["ob3"];
radioButton20.Text = (string)reader1["ob4"];

reader1.Close();
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

//function for timer


void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value != 60)
{
progressBar1.Value++;
}
else
{
timer1.Stop();

//Code to insert marks


if (flag == 0)
insert();

Maths a = new Maths();


a.Show();
Hide();
}
}

private void pictureBox1_Click(object sender, EventArgs e)


{
//Code to insert marks
if (flag == 0)
insert();

timer1.Stop();
Maths a = new Maths();
a.Show();
Hide();
}

}
}
Maths Paper

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Maths : Form
{
int flag = 0, count = 0;
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");

public Maths()
{
InitializeComponent();
}

public void insert()


{
//counting marks
if (radioButton3.Checked)
count++;
if (radioButton8.Checked)
count++;
if (radioButton11.Checked)
count++;
if (radioButton14.Checked)
count++;
if (radioButton15.Checked)
count++;

MyGlobals.score = MyGlobals.score + count;


try
{
flag = 1;
con1.Open();
string query = "update result set c2 =" + count + "WHERE reg_no ='" +
MyGlobals.reg + "'";
OracleCommand cmd = new OracleCommand(query, con1);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

private void Maths_Load(object sender, EventArgs e)


{
//start of code for timer
timer1.Enabled = true;
timer1.Start();
timer1.Interval = 1000;
progressBar1.Maximum = 60;
timer1.Tick += new EventHandler(timer1_Tick);
//End of code for timer

//showing questions
try
{
string query = null;

con1.Open();
query = "SELECT question FROM paper WHERE q_no BETWEEN 6 AND 10 ORDER BY
q_no ASC";
OracleCommand cmd = new OracleCommand(query, con1);
OracleDataReader reader;
reader = cmd.ExecuteReader();

reader.Read();
label1.Text = (string)reader["question"];
reader.Read();
label2.Text = (string)reader["question"];
reader.Read();
label3.Text = (string)reader["question"];
reader.Read();
label4.Text = (string)reader["question"];
reader.Read();
label5.Text = (string)reader["question"];

reader.Close();

//show options
query = "select * from objective where q_no BETWEEN 6 AND 10 ORDER BY
q_no ASC";
OracleCommand cmd1 = new OracleCommand(query, con1);
OracleDataReader reader1;
reader1 = cmd1.ExecuteReader();

//question 1
reader1.Read();
radioButton1.Text = (string)reader1["ob1"];
radioButton2.Text = (string)reader1["ob2"];
radioButton3.Text = (string)reader1["ob3"];
radioButton4.Text = (string)reader1["ob4"];

//question 2
reader1.Read();
radioButton5.Text = (string)reader1["ob1"];
radioButton6.Text = (string)reader1["ob2"];
radioButton7.Text = (string)reader1["ob3"];
radioButton8.Text = (string)reader1["ob4"];

//question 3
reader1.Read();
radioButton9.Text = (string)reader1["ob1"];
radioButton10.Text = (string)reader1["ob2"];
radioButton11.Text = (string)reader1["ob3"];
radioButton12.Text = (string)reader1["ob4"];

//question 4
reader1.Read();
radioButton13.Text = (string)reader1["ob1"];
radioButton14.Text = (string)reader1["ob2"];
radioButton15.Text = (string)reader1["ob3"];
radioButton16.Text = (string)reader1["ob4"];

//question 5
reader1.Read();
radioButton17.Text = (string)reader1["ob1"];
radioButton18.Text = (string)reader1["ob2"];
radioButton19.Text = (string)reader1["ob3"];
radioButton20.Text = (string)reader1["ob4"];

reader1.Close();
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

//function for timer


void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value != 60)
{
progressBar1.Value++;
}
else
{
timer1.Stop();

//Code to insert marks


if (flag == 0)
insert();

Chem a = new Chem();


a.Show();
Hide();
}
}

private void pictureBox1_Click(object sender, EventArgs e)


{
//Code to insert marks
if (flag == 0)
insert();

timer1.Stop();
Chem a = new Chem();
a.Show();
Hide();
}
}
}
Chemistry Paper

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Chem : Form
{
int flag = 0, count = 0;
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");

public Chem()
{
InitializeComponent();
}

public void insert()


{
//counting marks
if (radioButton2.Checked)
count++;
if (radioButton8.Checked)
count++;
if (radioButton11.Checked)
count++;
if (radioButton13.Checked)
count++;
if (radioButton19.Checked)
count++;

MyGlobals.score = MyGlobals.score + count;


try
{
flag = 1;
con1.Open();
string query = "update result set c3 =" + count + ",score = "+
MyGlobals.score + " WHERE reg_no ='"+ MyGlobals.reg +"'";
OracleCommand cmd = new OracleCommand(query, con1);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

private void Chem_Load(object sender, EventArgs e)


{
//start of code for timer
timer1.Enabled = true;
timer1.Start();
timer1.Interval = 1000;
progressBar1.Maximum = 60;
timer1.Tick += new EventHandler(timer1_Tick);
//End of code for timer

//showing questions
try
{
string query = null;

con1.Open();
query = "SELECT question FROM paper WHERE q_no BETWEEN 11 AND 15 ORDER BY
q_no ASC";
OracleCommand cmd = new OracleCommand(query, con1);
OracleDataReader reader;
reader = cmd.ExecuteReader();

reader.Read();
label1.Text = (string)reader["question"];
reader.Read();
label2.Text = (string)reader["question"];
reader.Read();
label3.Text = (string)reader["question"];
reader.Read();
label4.Text = (string)reader["question"];
reader.Read();
label5.Text = (string)reader["question"];

reader.Close();

//show options
query = "select * from objective where q_no BETWEEN 11 AND 15 ORDER BY
q_no ASC";
OracleCommand cmd1 = new OracleCommand(query, con1);
OracleDataReader reader1;
reader1 = cmd1.ExecuteReader();

//question 1
reader1.Read();
radioButton1.Text = (string)reader1["ob1"];
radioButton2.Text = (string)reader1["ob2"];
radioButton3.Text = (string)reader1["ob3"];
radioButton4.Text = (string)reader1["ob4"];

//question 2
reader1.Read();
radioButton5.Text = (string)reader1["ob1"];
radioButton6.Text = (string)reader1["ob2"];
radioButton7.Text = (string)reader1["ob3"];
radioButton8.Text = (string)reader1["ob4"];

//question 3
reader1.Read();
radioButton9.Text = (string)reader1["ob1"];
radioButton10.Text = (string)reader1["ob2"];
radioButton11.Text = (string)reader1["ob3"];
radioButton12.Text = (string)reader1["ob4"];

//question 4
reader1.Read();
radioButton13.Text = (string)reader1["ob1"];
radioButton14.Text = (string)reader1["ob2"];
radioButton15.Text = (string)reader1["ob3"];
radioButton16.Text = (string)reader1["ob4"];

//question 5
reader1.Read();
radioButton17.Text = (string)reader1["ob1"];
radioButton18.Text = (string)reader1["ob2"];
radioButton19.Text = (string)reader1["ob3"];
radioButton20.Text = (string)reader1["ob4"];

reader1.Close();
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

//function for timer


void timer1_Tick(object sender, EventArgs e)
{
if (progressBar1.Value != 60)
{
progressBar1.Value++;
}
else
{
timer1.Stop();

//Code to insert marks


if (flag == 0)
insert();

Smenu a = new Smenu();


a.Show();
Hide();
}
}

private void button1_Click(object sender, EventArgs e)


{
//Code to insert marks
if (flag == 0)
insert();

timer1.Stop();
Smenu a = new Smenu();
a.Show();
Hide();
}
}
}
Result

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
using System.IO;

namespace GCET_14
{
public partial class Result : Form
{
OracleConnection con1 = new OracleConnection("Data Source=xe;User
ID=gcet;password=gcet");
public Result()
{
InitializeComponent();
}

private void Result_Load(object sender, EventArgs e)


{
textBox1.Text = MyGlobals.reg;
}

private void button1_Click(object sender, EventArgs e)


{
//search code
String query = "SELECT reg_no, c1 as PHY, c2 as MAT, c3 as CHEM,SCORE from
result where reg_no = '" + textBox1.Text + "'";
OracleCommand cmd = new OracleCommand(query, con1);
try
{
con1.Open();
OracleDataAdapter da = new OracleDataAdapter(query, con1);
DataSet d = new DataSet();
da.Fill(d);
dataGridView1.DataSource = d.Tables[0];
con1.Close();
}
catch (Exception er)
{
con1.Close();
MessageBox.Show(er.Message);
}
}

private void pictureBox2_Click(object sender, EventArgs e)


{
Smenu a;
a = new Smenu();
Hide();
a.Show();
}
}
}

You might also like