コード例 #1
0
        /// <summary>
        /// Converter DataRow sang Object.
        /// </summary>
        /// <returns></returns>
        public static Cls_Logs converDataRow_To_Object(DataRow dr)
        {
            Cls_Logs _Object = new Cls_Logs();

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

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

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

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

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

            return(_Object);
        }
コード例 #2
0
        /// <summary>
        /// Get Array object class có parameter.
        /// </summary>
        /// <returns></returns>
        public static Cls_Logs[] getArrayObject(DataTable dt)
        {
            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            Cls_Logs[] arr = new Cls_Logs[dt.Rows.Count];
            int        i   = 0;

            foreach (DataRow dr in dt.Rows)
            {
                arr[i] = converDataRow_To_Object(dr);
                i++;
            }
            return(arr);
        }