コード例 #1
0
        public ImgFileName RetrieveImgFileNameByCardID(int cardID)
        {
            ImgFileName imgFileName = null;

            // connection
            var conn = DBConnection.GetDBConnection();

            // command text
            var cmdText = @"sp_select_imgfilenameid_by_cardid";

            // command
            var cmd = new SqlCommand(cmdText, conn);

            // command type
            cmd.CommandType = CommandType.StoredProcedure;

            // parameters and values
            cmd.Parameters.AddWithValue("@CardID", cardID);

            // try-catch to make connection
            try
            {
                // open the connection
                conn.Open();

                // execute the command
                var reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();

                    imgFileName = new ImgFileName()
                    {
                        ImgFileNameID = reader.GetString(0)
                                        // CardID = reader.GetInt32(1)
                    };
                }
                else
                {
                    throw new ApplicationException("Record not found.");
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Data access error.", ex);
            }
            finally
            {
                conn.Close();
            }

            return(imgFileName);
        }
コード例 #2
0
        public CardDetail RetrieveCardDetail(Card cardItem)
        {
            CardDetail  cardDetail  = null;
            ImgFileName imgFileName = null;

            try
            {
                imgFileName = _cardAccessor.RetrieveImgFileNameByCardID(cardItem.CardID);

                cardDetail = new CardDetail()
                {
                    Card        = cardItem,
                    ImgFileName = imgFileName
                };
            }
            catch
            {
                throw;
            }

            return(cardDetail);
        }