Example #1
0
        /// <summary>
        /// Returns survey comments for the specified survey.
        /// </summary>
        /// <param name="SurvID"></param>
        /// <returns></returns>
        public static List <SurveyComment> GetSurvCommentsBySurvey(int SurvID)
        {
            List <SurveyComment> cs = new List <SurveyComment>();
            SurveyComment        c;
            string query = "SELECT * FROM Comments.FN_GetSurvCommentsBySurvID (@sid)";

            using (SqlDataAdapter sql = new SqlDataAdapter())
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ISISConnectionString"].ConnectionString))
                {
                    conn.Open();

                    sql.SelectCommand = new SqlCommand(query, conn);
                    sql.SelectCommand.Parameters.AddWithValue("@sid", SurvID);
                    try
                    {
                        using (SqlDataReader rdr = sql.SelectCommand.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                c = new SurveyComment
                                {
                                    Notes  = new Note((int)rdr["ID"], (string)rdr["Notes"]),
                                    SurvID = (int)rdr["SurvID"],
                                    Survey = (string)rdr["Survey"],
                                    CID    = (int)rdr["CID"],
                                };
                                if (!rdr.IsDBNull(rdr.GetOrdinal("NoteDate")))
                                {
                                    c.NoteDate = (DateTime)rdr["NoteDate"];
                                }
                                c.NoteInit = (int)rdr["NoteInit"];
                                c.Name     = (string)rdr["Name"];
                                if (!rdr.IsDBNull(rdr.GetOrdinal("SourceName")))
                                {
                                    c.SourceName = (string)rdr["SourceName"];
                                }
                                if (!rdr.IsDBNull(rdr.GetOrdinal("NoteType")))
                                {
                                    c.NoteType = (string)rdr["NoteType"];
                                }
                                if (!rdr.IsDBNull(rdr.GetOrdinal("Source")))
                                {
                                    c.Source = (string)rdr["Source"];
                                }



                                cs.Add(c);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }

            return(cs);
        }
Example #2
0
        //
        // Survey Comments
        //

        /// <summary>
        /// Returns all survey comments with the specified note.
        /// </summary>
        /// <param name="CID"></param>
        /// <returns></returns>
        public static List <SurveyComment> GetSurvCommentsByCID(int CID)
        {
            List <SurveyComment> cs = new List <SurveyComment>();
            SurveyComment        c;
            string query = "SELECT * FROM Comments.FN_GetSurvCommentsByID(@cid)";

            using (SqlDataAdapter sql = new SqlDataAdapter())
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ISISConnectionString"].ConnectionString))
                {
                    conn.Open();

                    sql.SelectCommand = new SqlCommand(query, conn);
                    sql.SelectCommand.Parameters.AddWithValue("@cid", CID);
                    try
                    {
                        using (SqlDataReader rdr = sql.SelectCommand.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                c = new SurveyComment
                                {
                                    Notes      = new Note((int)rdr["ID"], (string)rdr["Notes"]),
                                    SurvID     = (int)rdr["SurvID"],
                                    CID        = (int)rdr["CID"],
                                    Survey     = (string)rdr["Survey"],
                                    NoteDate   = (DateTime)rdr["NoteDate"],
                                    NoteInit   = (int)rdr["NoteInit"],
                                    Name       = (string)rdr["Name"],
                                    SourceName = (string)rdr["SourceName"],
                                    NoteType   = (string)rdr["NoteType"],
                                    Source     = (string)rdr["Source"],
                                };

                                cs.Add(c);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

            return(cs);
        }