コード例 #1
0
        /// <summary>
        /// Service callable code to delete GridSettings by UserName GridName
        /// </summary>
        public static bool ReplaceGridSettings(DataSet ds)
        {
            if (ds == null || ds.Tables["GridSettings"] == null)
            {
                throw new Exception("The DataSet and/or DataTable is null.");
            }

            var clientDataSet = new GridSettingsCD();

            clientDataSet.Merge(ds, false, MissingSchemaAction.Ignore);

            if (clientDataSet.GridSettings.Rows.Count > 0)
            {
                var userName = clientDataSet.GridSettings[0]["UserName"] as string;
                var gridName = clientDataSet.GridSettings[0]["GridName"] as string;

                var gridSettingsTD = new GridSettingsTD();
                gridSettingsTD.GridSettings.BeginLoadData();
                gridSettingsTD.GridSettings.Merge(clientDataSet.GridSettings, false, MissingSchemaAction.Ignore);

                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    GridSettingsTD.DeleteGridSettingsByUserNameGridName(userName, gridName);
                    GridSettingsTD.UpdateGridSettings(gridSettingsTD);
                    ts.Complete();
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
 /// <summary>
 /// Get all GridSettings
 /// </summary>
 /// <returns>A GridSettingsTD</returns>
 public static DataSet GetGridSettings()
 {
     using (new TransactionScope(TransactionScopeOption.Suppress))
     {
         var ds = new GridSettingsTD();
         var ta = new GridSettingsTDTableAdapters.GridSettingsTableAdapter();
         ta.Fill(ds.GridSettings);
         return(ds);
     }
 }
コード例 #3
0
        /// <summary>
        /// Service callable code to Delete/Insert/Update Grid Settings
        /// </summary>
        /// <param name="ds">A DataSet of type GridSettingsCD</param>
        /// <returns>A GridSettingsCD. If ALL updated OK contains updated data, if not contains the RowErrors</returns>
        public static GridSettingsCD UpdateGridSettings(DataSet ds)
        {
            if (ds == null || ds.Tables["GridSettings"] == null)
            {
                throw new Exception("The DataSet and/or DataTable is null.");
            }

            var clientDataSet = new GridSettingsCD();

            clientDataSet.Merge(ds, false, MissingSchemaAction.Ignore);

            #region Update GridSettings
            var tblDataSet = new GridSettingsTD.GridSettingsDataTable();

            if (clientDataSet.GridSettings.Select("", "", DataViewRowState.Deleted).Length > 0 ||
                clientDataSet.GridSettings.Select("", "", DataViewRowState.Added).Length > 0 ||
                clientDataSet.GridSettings.Select("", "", DataViewRowState.ModifiedCurrent).Length > 0)
            {
                if (clientDataSet.GridSettings.Select("", "", DataViewRowState.ModifiedCurrent).Length > 0)
                {
                    var modifiedGridSetting = new GridSettingsDataTable();

                    foreach (GridSettingsRow modifiedRow in clientDataSet.GridSettings.Select("", "", DataViewRowState.ModifiedCurrent))
                    {
                        modifiedGridSetting.Clear();
                        modifiedGridSetting.ImportRow(modifiedRow);

                        tblDataSet.Merge(GridSettingsTD.GetGridSetting(modifiedRow.GridName, modifiedRow.GridName, modifiedRow.ColumnName));
                        tblDataSet.Merge(modifiedGridSetting, false, MissingSchemaAction.Ignore);
                    }
                }

                var gridSettingsTD = new GridSettingsTD();
                gridSettingsTD.GridSettings.BeginLoadData();
                gridSettingsTD.GridSettings.Merge(clientDataSet.GridSettings, false, MissingSchemaAction.Ignore);
                gridSettingsTD.GridSettings.Merge(tblDataSet, false, MissingSchemaAction.Ignore);


                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    GridSettingsTD.UpdateGridSettings(gridSettingsTD);
                    ts.Complete();
                }
            }
            #endregion

            return(clientDataSet);
        }