コード例 #1
0
        public IList<CY.CSTS.Core.Business.VoteAnswer> GetAllVoteAnswer()
        {
            IList<CY.CSTS.Core.Business.VoteAnswer> voteAnswerlist = new List<CY.CSTS.Core.Business.VoteAnswer>();
            SqlServerUtility sql = new SqlServerUtility();

            SqlDataReader reader = sql.ExecuteSqlReader(SqlGetAllVoteAnswer);

            if(reader != null)
            {
                while(reader.Read())
                {
                    CY.CSTS.Core.Business.VoteAnswer voteAnswer = new CY.CSTS.Core.Business.VoteAnswer();

                    if (!reader.IsDBNull(0)) voteAnswer.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) voteAnswer.VoteItemID = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) voteAnswer.VoteAnswerContent = reader.GetString(2);

                    voteAnswer.MarkOld();
                    voteAnswerlist.Add(voteAnswer);
                }
                reader.Close();
            }
            return voteAnswerlist;
        }
コード例 #2
0
        public CY.CSTS.Core.Business.VoteAnswer Select(int id)
        {
            SqlServerUtility sql = new SqlServerUtility();

            sql.AddParameter("@Key", SqlDbType.Int, id);
            SqlDataReader reader = sql.ExecuteSqlReader(SqlSelectVoteAnswer);

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                CY.CSTS.Core.Business.VoteAnswer voteAnswer = new CY.CSTS.Core.Business.VoteAnswer();

                if (!reader.IsDBNull(0)) voteAnswer.Id = reader.GetInt32(0);
                if (!reader.IsDBNull(1)) voteAnswer.VoteItemID = reader.GetInt32(1);
                if (!reader.IsDBNull(2)) voteAnswer.VoteAnswerContent = reader.GetString(2);

                return voteAnswer;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }