Saturday, 13 June 2015

How to Develop Online Examination System in Asp.net and C# Part 1( ERD Diagram)


Online Examination system Final Year Project University of Wah  2015

Report 

Written by 
Sheharyar khan
Zohaib Ali
Irum Nisa

Erd Diagram:
Before we look at how to create and use a database we’ll look at how to
design one  Need to consider What tables, keys,and constraints are needed?What is the database going to be used for?
Conceptual design
• Build a model independent of the choice of DBMS
Logical design
• Create the database in a given DBMS
Physical design
• How the database is stored in hardware
 E/R Modelling is used for conceptual design
 Entities - objects or items of interest
 Attributes - facts about, or properties of, an entity
 Relationships - links between entities
OEDB ERD :


List of entities

Name
Primary key constraint name
Number of columns
Comment
AddSubjects
PK_AddSubjects
8

Question

13

Quiz
PK_Quiz
11

Students
PK_Students
15

Teachers
PK_Teachers
8

Users
PK_Users
7



Entity details:



Entity: AddSubjects
Primary key constraint name
PK_AddSubjects
Comment

Table options


Attributes:
Column name
Primary key
Data type
Not NULL
Comment
SubID
Yes
INTEGER
Yes

Name
No
NVARCHAR(250)
No

PassingMarks
No
INTEGER
No

ObtMarks
No
INTEGER
No

Status
No
BIT
No

refTeacherID
Yes
INTEGER
Yes

Code
No
NVARCHAR(100)
No

UserID
Yes
INTEGER
Yes




User Interface:


ONLINE EXAMINATION SYSTEM

SQL CONNECTION Class1:


First You have to create  Folder in Your Project then Write SQL Connection Class 
Then Change Web.config as below 

Class1.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace WebApplication3.DB_Logic
{
    public class Class1
    {
        
        SqlConnection conn;
        private DataSet sqldataset = new DataSet();
        private DataTable sqldatatable = new DataTable();
        public void ConnectToDb()
        {

            conn = new SqlConnection(ConfigurationManager.AppSettings["sqlconnstr"].ToString());
        }

        //open the db connection
        public SqlConnection Openconn()
        {
            ConnectToDb();
            if (conn.State == ConnectionState.Closed || conn.State == ConnectionState.Broken)
            {
                conn.Open();
            }
            return conn;
        }

        //close the db connection
        public SqlConnection Closeconn()
        {
            ConnectToDb();
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
            return conn;
        }
        //to execute a nonquery
        public void ExecuteQuery(SqlCommand Execcmd)
        {
            try
            {
                Execcmd.Connection = Openconn();
                int abc = Execcmd.ExecuteNonQuery();
            }
            catch (Exception Ex)
            {
                Ex.Message.ToString();
            }
            finally
            {
                Execcmd.Connection = Closeconn();
            }
        }

        //returns a dataset
        public DataSet returnDataSet(SqlCommand DScmd)
        {
            SqlDataAdapter DSadapater;
            try
            {
                sqldataset.Clear();
                DScmd.Connection = Openconn();
                DSadapater = new SqlDataAdapter(DScmd);
                DSadapater.Fill(sqldataset);
            }
            catch (Exception Ex)
            {
                Ex.Message.ToString();
            }
            finally
            {
                DScmd.Connection = Closeconn();
            }
            return sqldataset;
        }

        //returns a datatable
        public DataTable returnDataTable(SqlCommand DTcmd)
        {
            SqlDataAdapter DTadapter;
            try
            {
                sqldatatable.Clear();
                DTcmd.Connection = Openconn();
                DTadapter = new SqlDataAdapter(DTcmd);
                DTadapter.Fill(sqldatatable);
            }
            catch (Exception Ex)
            {
                Ex.Message.ToString();
            }
            finally
            {
                DTcmd.Connection = Closeconn();
            }
            return sqldatatable;
        }


    }
}

WEB.CONFIG:


USAGE IN PAGES :

SqlCommand insertentrycmd = new SqlCommand();
 DB_Logic.Class1 insertentry = new DB_Logic.Class1();

Here DB_Logic is My Folder Name and Class1 is my SQL Connection Class 


Thanks 




SHEHARYAR KHAN