/// <summary> /// Get all GridFilters /// </summary> /// <returns>A GridFiltersTD</returns> public static DataSet GetGridFilters() { using (new TransactionScope(TransactionScopeOption.Suppress)) { var ds = new GridFiltersTD(); var ta = new GridFiltersTDTableAdapters.GridFiltersTableAdapter(); ta.Fill(ds.GridFilters); return(ds); } }
/// <summary> /// Returns true or false if a GridFilters exists /// </summary> /// <param name="userName">The UserName to check existance</param> /// <param name="gridName">The GridName to check existance</param> /// <returns>true if GridFilters exists, false if not</returns> public static bool IsExistingGridFilters(string userName, string gridName) { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(gridName)) { throw new Exception("The UserName and/or GridName is null or empty."); } using (new TransactionScope(TransactionScopeOption.Suppress)) { var ta = new GridFiltersTDTableAdapters.GridFiltersTableAdapter(); return(ta.IsExistingGridFilters(userName, gridName) == 0 ? false : true); } }
/// <summary> /// Service callable code to Delete GridFilters /// </summary> /// <returns>A GridFiltersTD. If ALL updated OK contains updated data, if not contains the RowErrors</returns> public static void DeleteGridFiltersByUserNameGridName(string userName, string gridName) { if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(gridName)) { throw new Exception("The UserName and/or GridName is null or empty."); } using (var ts = new TransactionScope(TransactionScopeOption.Required)) { var taGridFilters = new GridFiltersTDTableAdapters.GridFiltersTableAdapter(); taGridFilters.DeleteByUserNameGridName(userName, gridName); ts.Complete(); } }
/// <summary> /// Service callable code to Delete/Insert/Update GridFilters /// </summary> /// <returns>A GridFiltersTD. If ALL updated OK contains updated data, if not contains the RowErrors</returns> public static DataSet UpdateGridFilters(DataSet gridFiltersDataSet) { if (gridFiltersDataSet == null || gridFiltersDataSet.Tables["GridFilters"] == null) { throw new Exception("The DataSet and/or DataTable is null."); } var dtGridFilters = new GridFiltersDataTable(); dtGridFilters.BeginLoadData(); dtGridFilters.Merge(gridFiltersDataSet.Tables["GridFilters"], false, MissingSchemaAction.Error); using (var ts = new TransactionScope(TransactionScopeOption.Required)) { var taGridFilters = new GridFiltersTDTableAdapters.GridFiltersTableAdapter(); // cannot do deletes by row #region do inserts (full replace) if (dtGridFilters.Select("", "", DataViewRowState.Added).Length > 0) { DeleteGridFiltersByUserNameGridName(dtGridFilters.Rows[0]["UserName"].ToString(), dtGridFilters.Rows[0]["GridName"].ToString()); } foreach (GridFiltersRow insertedRow in dtGridFilters.Select("", "", DataViewRowState.Added)) { insertedRow.SetDefaultValues(); if (insertedRow.IsValidRow()) { taGridFilters.Update(insertedRow); } else { throw new Exception("A row to be inserted contains invalid data. Entire transaction cancelled."); } } #endregion ts.Complete(); } dtGridFilters.AcceptChanges(); gridFiltersDataSet.Tables["GridFilters"].Merge(dtGridFilters, false, MissingSchemaAction.Ignore); return(gridFiltersDataSet); }