Ejemplo n.º 1
0
        //insert assignment
        public int insertAssignment(Assignments assignment, DateTime startdate, int schoolid, int id)
        {
            open();
            SqlCommand cmd = new SqlCommand("IDU_Assignment", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@Action", "INSERT");
            cmd.Parameters.AddWithValue("@name", assignment.name);
            cmd.Parameters.AddWithValue("@resources", assignment.resources);
            cmd.Parameters.AddWithValue("@description", assignment.description);
            cmd.Parameters.AddWithValue("@startdate", startdate);
            cmd.Parameters.AddWithValue("@enddate", assignment.enddate);
            cmd.Parameters.AddWithValue("@schoolid", schoolid);
            cmd.Parameters.AddWithValue("@teacherid", id);
            if (assignment.Question1 == null)
            {
                assignment.Question1 = "None";
            }
            if (assignment.Question2 == null)
            {
                assignment.Question2 = "None";
            }
            if (assignment.Question3 == null)
            {
                assignment.Question3 = "None";
            }
            if (assignment.Question4 == null)
            {
                assignment.Question4 = "None";
            }
            if (assignment.Question5 == null)
            {
                assignment.Question5 = "None";
            }
            cmd.Parameters.AddWithValue("@question1", assignment.Question1);
            cmd.Parameters.AddWithValue("@question2", assignment.Question2);
            cmd.Parameters.AddWithValue("@question3", assignment.Question3);
            cmd.Parameters.AddWithValue("@question4", assignment.Question4);
            cmd.Parameters.AddWithValue("@question5", assignment.Question5);
            int res = 0;

            res = cmd.ExecuteNonQuery();
            return(res);

            close();
        }
Ejemplo n.º 2
0
        // all assign assignment
        public IEnumerable <Assignments> Displayassignment(int schoolid, int userid)
        {
            open();
            string             query       = "select assignment.*,assignmentStd.* from assignments AS assignment inner join assignmentsStudentList as assignmentStd on assignment.id = assignmentStd.assignmentid where assignmentStd.studentid=" + userid;
            List <Assignments> assignments = new List <Assignments>();
            SqlCommand         cmd         = new SqlCommand(query, con);

            using (SqlDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    var assignment = new Assignments {
                        id = dr.GetInt32(0), name = dr.GetString(1), startdate = dr.GetDateTime(2), enddate = dr.GetDateTime(3), resources = dr.GetString(8), description = dr.GetString(6), Question1 = dr.GetString(9), Question2 = dr.GetString(10), Question3 = dr.GetString(11), Question4 = dr.GetString(12), Question5 = dr.GetString(13)
                    };
                    assignments.Add(assignment);
                }
            }
            return(assignments);

            close();
        }
Ejemplo n.º 3
0
        //get assignmnet
        public IEnumerable <Assignments> displayassignment(int schoolid, int id)
        {
            open();
            string query;

            query = "select * from assignments where schoolid=" + schoolid + " and teacherid=" + id;

            List <Assignments> lstassignment = new List <Assignments>();
            SqlCommand         cmd           = new SqlCommand(query, con);

            using (SqlDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    var assignment = new Assignments {
                        id = dr.GetInt32(0), name = dr.GetString(1), startdate = dr.GetDateTime(2), enddate = dr.GetDateTime(3), Question1 = dr.GetString(9), Question2 = dr.GetString(10), Question3 = dr.GetString(11), Question4 = dr.GetString(12), Question5 = dr.GetString(13)
                    };
                    lstassignment.Add(assignment);
                }
            }
            return(lstassignment);

            close();
        }