コード例 #1
0
 internal SubSections GetSubSections(Section section, string response_id)
 {
     try
     {
         QuestionProvider provider = new QuestionProvider(DbInfo);
         string           query    = $"select * from dsto_subsections where yref_section='{section.Key}' and deleted=0";
         var table = DbInfo.ExecuteSelectQuery(query);
         if (table.Rows.Count > 0)
         {
             DataRow    row        = table.Rows[0];
             SubSection subsection = section.SubSections.Add();
             subsection.Key       = row["guid"].ToString();
             subsection.OID       = int.Parse(row["OID"].ToString());
             subsection.Name      = row["Name"].ToString();
             subsection.Deleted   = bool.Parse(row["deleted"].ToString());
             subsection.CreatedBy = row["created_by"].ToString();
             subsection.Questions = provider.GetQuestions(subsection, response_id);
         }
         return(section.SubSections);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
        internal Sections GetSections(string reference, string response_id = null)
        {
            try
            {
                QuestionProvider provider = new QuestionProvider(DbInfo);
                Sections         sections = new Sections();
                string           query    = $"select * from dsto_sections where (yref_questionaire='{reference}' or yref_field_inspection='{reference}' or yref_certification='{reference}' or yref_template='{reference}') and deleted=0 order by oid asc";

                var table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Section section = new Section(null);
                        section.Key         = row["guid"].ToString();
                        section.OID         = int.Parse(row["OID"].ToString());
                        section.Name        = row["Name"].ToString();
                        section.Description = row["Description"].ToString();
                        section.Deleted     = bool.Parse(row["deleted"].ToString());
                        section.CreatedBy   = row["created_by"].ToString();
                        section.Questions   = provider.GetQuestions(section, response_id);
                        section.SubSections = new SubSectionProvider(DbInfo).GetSubSections(section, response_id);
                        sections.Add(section);
                    }
                    return(sections);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }