Beispiel #1
0
        public bool AddStudyPerson(AddStudyPerson smodel)
        {
            connection();

            string     message;
            SqlCommand cmd = new SqlCommand("Recruitment.AddStudyPerson", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@PSCID", smodel.PSCID);
            cmd.Parameters.AddWithValue("@StudyName", smodel.StudyName);
            cmd.Parameters.AddWithValue("@StudyID", smodel.StudyID);
            cmd.Parameters.AddWithValue("@ParticipantType", smodel.ParticipantType);
            cmd.Parameters.AddWithValue("@DateOfBirth", smodel.DateOfBirth);
            if (smodel.Sex != null)
            {
                cmd.Parameters.AddWithValue("@Sex", smodel.Sex);
            }
            else
            {
                cmd.Parameters.AddWithValue("@Sex", "");
            }

            cmd.Parameters.Add(new SqlParameter("@Message", SqlDbType.VarChar, 255, "message")).Direction = ParameterDirection.Output;
            if (smodel.StudyPersonID != null)
            {
                cmd.Parameters.AddWithValue("@StudyPersonID", smodel.StudyPersonID);
            }
            else
            {
                cmd.Parameters.AddWithValue("@StudyPersonID", DBNull.Value);
            }
            //cmd.Parameters["@Message"].Direction = ParameterDirection.Output;



            con.Open();
            //int i = cmd.ExecuteNonQuery();
            //con.Close();
            //if (i >= 1)
            //    return true;
            //else
            //    return false;

            int rows = 0;

            rows    = cmd.ExecuteNonQuery();
            message = Convert.ToString(cmd.Parameters["@Message"].Value);
            con.Close();
            smodel.Message = message;
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        public DataSet StudyPersonExists(AddStudyPerson smodel)
        {
            connection();
            SqlCommand cm = new SqlCommand("Recruitment.ExistsPersonByPSCIDandStudy", con);

            cm.CommandType = CommandType.StoredProcedure;
            cm.Parameters.AddWithValue("@PSCID", smodel.PSCID);
            cm.Parameters.AddWithValue("@StudyName", smodel.StudyName);
            SqlDataAdapter sd = new SqlDataAdapter(cm);
            DataSet        ds = new DataSet();

            con.Open();
            sd.Fill(ds);
            con.Close();

            return(ds);
        }