//just a function for some testing public List<SectionRecords> test() { List<SectionRecords> test = new List<SectionRecords>(); string query = "select MarksDistribution.Title from MarksDistribution "; string connectionString = ConfigurationManager.AppSettings["SqlDBConn"].ToString(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value"); connection.Open(); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { SectionRecords yo = new SectionRecords(); yo.title_setter((reader.GetInt32(reader.GetOrdinal("Title")))); test.Add(yo); } } finally { reader.Close(); } } return test; }
//Given FSID this will fetch all the current mark progress of said section public List<SectionRecords> Get_Section_Records(int id) { //return teacher_id.ToString(); List<SectionRecords> records = new List<SectionRecords>(); string query = "select MarksDistribution.MDID,MarksDistribution.Weigtage,MarksDistribution.TotalMarks,MarksDistribution.Title " + "from MarksDistribution,FacultySections " + "where MarksDistribution.FSID = FacultySections.FSID and MarksDistribution.FSID = " + id; string connectionString = ConfigurationManager.AppSettings["SqlDBConn"].ToString(); using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value"); connection.Open(); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { SectionRecords temp = new SectionRecords(); temp.weightage = reader.GetDouble(reader.GetOrdinal("Weigtage")); temp.MDID = reader.GetInt32(reader.GetOrdinal("MDID")); temp.totalmarks = reader.GetDouble(reader.GetOrdinal("TotalMarks")); temp.title_setter(reader.GetInt32(reader.GetOrdinal("Title"))); /*query= "Student.SName,Student.StudentID,MarksRecord.ObtainedMarks "+ "from MarksDistribution,MarksRecord,Student "+ "where MarksDistribution.MDID=MarksRecord.MDID and MarksRecord.StudentID=Student.StudentID and MarksDistribution.MDID="+temp.MDID; */ /*string connectionString2 = ConfigurationManager.AppSettings["SqlDBConn"].ToString(); using (SqlConnection connection2 = new SqlConnection(connectionString2)) { SqlCommand command2 = new SqlCommand(query, connection2); command2.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value"); SqlDataReader reader2 = command2.ExecuteReader(); try { while (reader2.Read()) { StudentRecords temp2 = new StudentRecords(); temp2.ID = reader.GetInt32(reader.GetOrdinal("StudentID")); temp2.Name = reader.GetString(reader.GetOrdinal("SName")); temp2.obtained = reader.GetDouble(reader.GetOrdinal("ObtainedMarks")); temp.SRs.Add(temp2); } } finally { reader2.Close(); } }*/ records.Add(temp); } } finally { reader.Close(); } for(int i=0;i<records.Count;i++) { int count = 0; double max = 0,min= records[i].totalmarks, average=0;bool no_records_found = true; query = "Select Student.SName,Student.StudentID,MarksRecord.ObtainedMarks " + "from MarksDistribution,MarksRecord,Student " + "where MarksDistribution.MDID=MarksRecord.MDID and MarksRecord.StudentID=Student.StudentID and MarksDistribution.MDID=" + records[i].MDID; command = new SqlCommand(query, connection); command.Parameters.AddWithValue("@tPatSName", "Your-Parm-Value"); reader = command.ExecuteReader(); try { while(reader.Read()) { StudentRecords temp2 = new StudentRecords(); temp2.ID = reader.GetInt32(reader.GetOrdinal("StudentID")); temp2.Name = reader.GetString(reader.GetOrdinal("SName")); temp2.obtained = reader.GetDouble(reader.GetOrdinal("ObtainedMarks")); if (temp2.obtained > max) max = temp2.obtained; if (temp2.obtained < min) min = temp2.obtained; average += temp2.obtained; records[i].SRs.Add(temp2); count++; no_records_found = false; } if(no_records_found) { min = 0; average = 0; } } finally { reader.Close(); } records[i].max = max; records[i].min = min; records[i].average = average/count; } } SectionRecords.assign = 0; SectionRecords.quiz = 0; SectionRecords.pro = 0; SectionRecords.fyp = 0; SectionRecords.lab = 0; SectionRecords.pres = 0; return records; }