/// <summary> /// Converter DataRow sang Object. /// </summary> /// <returns></returns> public static Cls_ShopsOrders converDataRow_To_Object(DataRow dr) { Cls_ShopsOrders _Object = new Cls_ShopsOrders(); //ID_Order if (dr.Table.Columns.Contains(fn_ID_Order)) { if (dr[fn_ID_Order] != DBNull.Value) { _Object.ID_Order = (int)dr[fn_ID_Order]; } } //ID_Product if (dr.Table.Columns.Contains(fn_ID_Product)) { if (dr[fn_ID_Product] != DBNull.Value) { _Object.ID_Product = (int)dr[fn_ID_Product]; } } //ID_OrderProduct if (dr.Table.Columns.Contains(fn_ID_OrderProduct)) { if (dr[fn_ID_OrderProduct] != DBNull.Value) { _Object.ID_OrderProduct = (int)dr[fn_ID_OrderProduct]; } } //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); }
/// <summary> /// Get Array object class có parameter. /// </summary> /// <returns></returns> public static Cls_ShopsOrders[] getArrayObject(DataTable dt) { if (dt.Rows.Count == 0) { return(null); } Cls_ShopsOrders[] arr = new Cls_ShopsOrders[dt.Rows.Count]; int i = 0; foreach (DataRow dr in dt.Rows) { arr[i] = converDataRow_To_Object(dr); i++; } return(arr); }