/// <summary> /// Get Array object class có parameter. /// </summary> /// <returns></returns> public static Cls_Slider[] getArrayObject(DataTable dt) { if (dt.Rows.Count == 0) { return(null); } Cls_Slider[] arr = new Cls_Slider[dt.Rows.Count]; int i = 0; foreach (DataRow dr in dt.Rows) { arr[i] = converDataRow_To_Object(dr); i++; } return(arr); }
/// <summary> /// Converter DataRow sang Object. /// </summary> /// <returns></returns> public static Cls_Slider converDataRow_To_Object(DataRow dr) { Cls_Slider _Object = new Cls_Slider(); //ID_Slider if (dr.Table.Columns.Contains(fn_ID_Slider)) { if (dr[fn_ID_Slider] != DBNull.Value) { _Object.ID_Slider = (int)dr[fn_ID_Slider]; } } //Title if (dr.Table.Columns.Contains(fn_Title)) { if (dr[fn_Title] != DBNull.Value) { _Object.Title = (string)dr[fn_Title]; } } //Image if (dr.Table.Columns.Contains(fn_Image)) { if (dr[fn_Image] != DBNull.Value) { _Object.Image = (string)dr[fn_Image]; } } //SummaryContent if (dr.Table.Columns.Contains(fn_SummaryContent)) { if (dr[fn_SummaryContent] != DBNull.Value) { _Object.SummaryContent = (string)dr[fn_SummaryContent]; } } //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]; } } //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); }