Esempio n. 1
0
        /// <summary>
        /// 取得主檔資料列。
        /// </summary>
        /// <param name="dataSet">資料集。</param>
        public static DataRow GetMasterRow(DataSet dataSet)
        {
            DataTable oTable;

            if (DataFunc.IsEmpty(dataSet))
            {
                return(null);
            }

            oTable = dataSet.Tables[dataSet.DataSetName];
            if (!DataFunc.IsEmpty(oTable))
            {
                if (oTable.Rows.Count > 0)
                {
                    return(oTable.Rows[0]);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 對目的資料表新增來源資料表中的資料列,有相同欄位時才會塞值。
        /// </summary>
        /// <param name="destDataTable">目的資料表。</param>
        /// <param name="sourceTable">來源資料表。</param>
        /// <param name="allowNull">是否允許Null值</param>
        public static void AddTableRows(DataTable destDataTable, DataTable sourceTable, bool allowNull = true)
        {
            if (BaseFunc.IsNull(destDataTable))
            {
                return;
            }
            if (DataFunc.IsEmpty(sourceTable))
            {
                return;
            }

            foreach (DataRowView sourceRow in sourceTable.DefaultView)
            {
                AddRow(destDataTable, sourceRow.Row, allowNull);
            }
        }