Beispiel #1
0
        public LoaiCauHoi GetLoaiCauHoi(int Id)
        {
            string     cacheKey;
            LoaiCauHoi objLoaiCauHoi = new LoaiCauHoi();

            cacheKey = "nuce_web_thi_loaicauhoi_" + Id.ToString();
            if (Cache[cacheKey] == null)
            {
                DataTable objTable = InitCacheLoaiCauHoi();
                DataRow[] drs      = objTable.Select(string.Format("ID = {0}", Id));
                if (drs.Length > 0)
                {
                    objLoaiCauHoi.ID          = Id;
                    objLoaiCauHoi.Description = drs[0]["Description"].ToString();
                    objLoaiCauHoi.Name        = drs[0]["Name"].ToString();
                }
                else
                {
                    objLoaiCauHoi.ID          = Id;
                    objLoaiCauHoi.Description = "";
                    objLoaiCauHoi.Name        = "";
                }
                Cache.Insert(cacheKey, objLoaiCauHoi);
            }
            else
            {
                objLoaiCauHoi = (LoaiCauHoi)Cache[cacheKey];
            }
            return(objLoaiCauHoi);
        }
Beispiel #2
0
        public LoaiCauHoi GetLoaiCauHoi(string Name)
        {
            DataTable objTable = InitCacheLoaiCauHoi();

            DataRow[]  drs           = objTable.Select(string.Format("Name = '{0}'", Name));
            LoaiCauHoi objLoaiCauHoi = new LoaiCauHoi();

            if (drs.Length > 0)
            {
                objLoaiCauHoi.ID          = int.Parse(drs[0]["ID"].ToString());
                objLoaiCauHoi.Description = drs[0]["Description"].ToString();
                objLoaiCauHoi.Name        = Name;
            }
            else
            {
                objLoaiCauHoi.ID          = -1;
                objLoaiCauHoi.Description = "";
                objLoaiCauHoi.Name        = Name;
            }
            return(objLoaiCauHoi);
        }