Пример #1
0
        /// <summary>
        /// Get Array object class có parameter.
        /// </summary>
        /// <returns></returns>
        public static Cls_NewsCatalogs[] getArrayObject(DataTable dt)
        {
            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            Cls_NewsCatalogs[] arr = new Cls_NewsCatalogs[dt.Rows.Count];
            int i = 0;

            foreach (DataRow dr in dt.Rows)
            {
                arr[i] = converDataRow_To_Object(dr);
                i++;
            }
            return(arr);
        }
Пример #2
0
        /// <summary>
        /// Converter DataRow sang Object.
        /// </summary>
        /// <returns></returns>
        public static Cls_NewsCatalogs converDataRow_To_Object(DataRow dr)
        {
            Cls_NewsCatalogs _Object = new Cls_NewsCatalogs();

            //ID_Catalog
            if (dr.Table.Columns.Contains(fn_ID_Catalog))
            {
                if (dr[fn_ID_Catalog] != DBNull.Value)
                {
                    _Object.ID_Catalog = (int)dr[fn_ID_Catalog];
                }
            }

            //ID_Parent
            if (dr.Table.Columns.Contains(fn_ID_Parent))
            {
                if (dr[fn_ID_Parent] != DBNull.Value)
                {
                    _Object.ID_Parent = (int)dr[fn_ID_Parent];
                }
            }

            //CatalogName
            if (dr.Table.Columns.Contains(fn_CatalogName))
            {
                if (dr[fn_CatalogName] != DBNull.Value)
                {
                    _Object.CatalogName = (string)dr[fn_CatalogName];
                }
            }

            //Image
            if (dr.Table.Columns.Contains(fn_Image))
            {
                if (dr[fn_Image] != DBNull.Value)
                {
                    _Object.Image = (string)dr[fn_Image];
                }
            }

            //Description
            if (dr.Table.Columns.Contains(fn_Description))
            {
                if (dr[fn_Description] != DBNull.Value)
                {
                    _Object.Description = (string)dr[fn_Description];
                }
            }

            //TitleWeb
            if (dr.Table.Columns.Contains(fn_TitleWeb))
            {
                if (dr[fn_TitleWeb] != DBNull.Value)
                {
                    _Object.TitleWeb = (string)dr[fn_TitleWeb];
                }
            }

            //LinkSEO
            if (dr.Table.Columns.Contains(fn_LinkSEO))
            {
                if (dr[fn_LinkSEO] != DBNull.Value)
                {
                    _Object.LinkSEO = (string)dr[fn_LinkSEO];
                }
            }

            //H1SEO
            if (dr.Table.Columns.Contains(fn_H1SEO))
            {
                if (dr[fn_H1SEO] != DBNull.Value)
                {
                    _Object.H1SEO = (string)dr[fn_H1SEO];
                }
            }

            //KeywordSEO
            if (dr.Table.Columns.Contains(fn_KeywordSEO))
            {
                if (dr[fn_KeywordSEO] != DBNull.Value)
                {
                    _Object.KeywordSEO = (string)dr[fn_KeywordSEO];
                }
            }

            //AddTime
            if (dr.Table.Columns.Contains(fn_AddTime))
            {
                if (dr[fn_AddTime] != DBNull.Value)
                {
                    _Object.AddTime = (DateTime)dr[fn_AddTime];
                }
            }

            //EditTime
            if (dr.Table.Columns.Contains(fn_EditTime))
            {
                if (dr[fn_EditTime] != DBNull.Value)
                {
                    _Object.EditTime = (DateTime)dr[fn_EditTime];
                }
            }

            //Hidden
            if (dr.Table.Columns.Contains(fn_Hidden))
            {
                if (dr[fn_Hidden] != DBNull.Value)
                {
                    _Object.Hidden = (bool)dr[fn_Hidden];
                }
            }

            return(_Object);
        }