Esempio n. 1
0
    public Section GetSectionByOID(int SOID)
    {
        Section section = null;

        using (OdbcConnection connection = new OdbcConnection(connectionString))
        {
            using (OdbcCommand command = new OdbcCommand())
            {

                command.Connection = connection;
                command.CommandText = "{CALL Section_BySectionOID(?)}";
                command.CommandType = CommandType.StoredProcedure;

                //Set Parameter Value
                command.Parameters.AddWithValue("@SOID", SOID);
                //Open connection
                connection.Open();
                //Read using reader
                using (OdbcDataReader dataReader = command.ExecuteReader())
                {
                    Question q = new Question();
                    //Section section;
                    if (dataReader.Read())
                    {
                        section = new Section();
                        section.SectionOID = Convert.ToInt32(dataReader["SectionOID"]);
                        section.AssessmentOID = Convert.ToInt32(dataReader["AssessmentOID"]);
                        section.CreatedBy = Convert.ToInt32(dataReader["CreatedBy"]);
                        section.CreatedDate = Convert.ToDateTime(dataReader["CreatedDate"]);
                        section.FlagPointTotal = Convert.ToInt32(dataReader["FlagPointTotal"]);
                        section.LastModifiedBy = Convert.ToInt32(dataReader["LastModifiedBy"]);
                        section.LastModifiedDate = Convert.ToDateTime(dataReader["LastModifiedDate"]);
                        section.PassingTotal = Convert.ToInt32(dataReader["PassingTotal"]);
                        section.SectionName = Convert.ToString(dataReader["SectionName"]);
                        section.TotalFlag = Convert.ToInt32(dataReader["TotalFlag"]);
                        section.TotalQuestion = Convert.ToInt32(dataReader["TotalQuestion"]);
                        section.Flag = (dataReader["Flag"]==null)?0:Convert.ToInt32(dataReader["Flag"]);
                        section.Low = (dataReader["Low"] == null) ? 0 : Convert.ToInt32(dataReader["Low"]);
                        section.Medium = (dataReader["Medium"] == null) ? 0 : Convert.ToInt32(dataReader["Medium"]);
                        section.High = (dataReader["High"] == null) ? 0 : Convert.ToInt32(dataReader["High"]);

                        //Get Question By SectionOID
                        section.QuestionList = q.GetQuestionBySectionOID(section.SectionOID);
                    }
                }

            }
        }
        return section;
    }