public static int UpdateSurveyCheckRefRecord(SurveyCheckRefSurvey record)
        {
            using (SqlDataAdapter sql = new SqlDataAdapter())
                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ISISConnectionString"].ConnectionString))
                {
                    conn.Open();

                    sql.UpdateCommand = new SqlCommand("proc_updateSurveyCheckRef", conn)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    sql.UpdateCommand.Parameters.AddWithValue("@ID", record.ID);
                    sql.UpdateCommand.Parameters.AddWithValue("@checkID", record.CheckID);
                    sql.UpdateCommand.Parameters.AddWithValue("@survID", record.SID);
                    if (record.SurveyDate == null)
                    {
                        sql.UpdateCommand.Parameters.AddWithValue("@survDate", DBNull.Value);
                    }
                    else
                    {
                        sql.UpdateCommand.Parameters.AddWithValue("@survDate", record.SurveyDate);
                    }

                    try
                    {
                        sql.UpdateCommand.ExecuteNonQuery();
                    }
                    catch (Exception)
                    {
                        return(1);
                    }
                }
            return(0);
        }
Beispiel #2
0
        /// <summary>
        /// Returns the user profile for the specified username.
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        public static List <SurveyCheckRefSurvey> GetSurveyCheckRefSurveys(int checkID)
        {
            List <SurveyCheckRefSurvey> records = new List <SurveyCheckRefSurvey>();

            string query = "SELECT * FROM qrySurveyCheckRefSurvs WHERE CheckID = @checkID";

            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("@checkID", checkID);

                    try
                    {
                        using (SqlDataReader rdr = sql.SelectCommand.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                SurveyCheckRefSurvey r = new SurveyCheckRefSurvey();

                                r.ID      = (int)rdr["ID"];
                                r.CheckID = (int)rdr["CheckID"];
                                r.SID     = (int)rdr["SurvID"];

                                if (!rdr.IsDBNull(rdr.GetOrdinal("SurveyDate")))
                                {
                                    r.SurveyDate = (DateTime)rdr["SurveyDate"];
                                }



                                records.Add(r);
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

            return(records);
        }