コード例 #1
0
        // this method creates & returns a collection of question entries for a special form entry
        internal bool loadFormEntryQuestionEntries(cFormEntry formEntry)
        {
            SqlCommand cmd = new SqlCommand("SELECT ID, QuestionID, FormEntryID, AnswerText FROM questionEntries WHERE FormEntryID = @feid ORDER BY ID", cMain.getConnection());

            cmd.Parameters.Add(new SqlParameter("feid", formEntry.ID));
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    cQuestionEntry qe = new cQuestionEntry();
                    qe.ID          = reader.GetString(0);
                    qe.QuestionID  = reader.GetString(1);
                    qe.FormEntryID = reader.GetString(2);
                    qe.Text        = reader.GetString(3);

                    this.Add(qe);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        // this method get's the question answers and creates the full form entry
        public bool addFormEntry(List <string> list)
        {
            System.Diagnostics.Debug.WriteLine(list[0]);

            if (fID.Length == 0)
            {
                return(false);
            }
            else
            {
                // create the form entry and assign form id (FK) then persist
                cFormEntry fe = new cFormEntry();
                fe.FormID = fID;
                if (!fe.persist())
                {
                    return(false);
                }
                var j = 0;

                // now iterate the question answers
                foreach (var i in list)
                {
                    // create the question entry and assign form entry id and question id
                    cQuestionEntry qe = new cQuestionEntry();
                    qe.QuestionID  = Questions[j].ID;
                    qe.FormEntryID = fe.ID;
                    qe.Text        = i;
                    if (!qe.persist())
                    {
                        return(false);
                    }
                    j++;
                }
                return(true);
            }
        }
コード例 #3
0
ファイル: cForm.cs プロジェクト: codepushr/sharpforms
        // this method get's the question answers and creates the full form entry
        public bool addFormEntry(List<string> list)
        {
            System.Diagnostics.Debug.WriteLine(list[0]);

            if (fID.Length == 0) return false;
            else {
                // create the form entry and assign form id (FK) then persist
                cFormEntry fe = new cFormEntry();
                fe.FormID = fID;
                if (!fe.persist()) return false;
                var j = 0;

                // now iterate the question answers
                foreach (var i in list) {
                    // create the question entry and assign form entry id and question id
                    cQuestionEntry qe = new cQuestionEntry();
                    qe.QuestionID = Questions[j].ID;
                    qe.FormEntryID = fe.ID;
                    qe.Text = i;
                    if (!qe.persist()) return false;
                    j++;
                }
                return true;
            }
        }