/// <summary> /// Update a dataset from the supplierId /// </summary> /// <param name="queries">List of the queries to be used for updating.</param> /// <param name="set">Set to be used for the updating.</param> public void UpdateDataSet(IDictionary <string, string> queries, DataSet set) { var queryStringBuilder = new StringBuilder(); if (queries == null) { return; } if (set == null) { return; } foreach (DataTable table in set.Tables) { if (queries.ContainsKey(table.TableName)) { queryStringBuilder.Append(queries[table.TableName]); queryStringBuilder.Append(";"); } } SqlExecutor.BeginTransaction(); SqlExecutor.UpdateDataSet(queryStringBuilder.ToString(), ref set); SqlExecutor.Commit(); }
/// <summary> /// This update a set of dataset with batch of queries. /// </summary> /// <param name="queries">List of the queries to be updated</param> /// <param name="setList">DataSet to be updated.</param> public void UpdateDataSetList(IDictionary <string, string> queries, IList <DataSet> setList) { StringBuilder queryStringBuilder = new StringBuilder(); SqlExecutor.BeginTransaction(); if (queries == null) { return; } foreach (var set in setList) { var tmp = set; if (set == null) { continue; } foreach (DataTable table in set.Tables) { if (!queries.ContainsKey(table.TableName)) { continue; } queryStringBuilder.Append(queries[table.TableName]); queryStringBuilder.Append(";"); } SqlExecutor.UpdateDataSet(queryStringBuilder.ToString(), ref tmp); } SqlExecutor.Commit(); }
public bool DeleteSupplier(IDictionary <string, string> queries, DataSet supplierDataSet) { if (supplierDataSet == null) { return(false); } if (queries == null) { return(false); } StringBuilder queryStringBuilder = new StringBuilder(); foreach (DataTable table in supplierDataSet.Tables) { if (queries.ContainsKey(table.TableName)) { queryStringBuilder.Append(queries[table.TableName]); queryStringBuilder.Append(";"); } } foreach (DataTable table in supplierDataSet.Tables) { foreach (DataRow row in table.Rows) { row.Delete(); } } try { SqlExecutor.BeginTransaction(); SqlExecutor.UpdateDataSet(queryStringBuilder.ToString(), ref supplierDataSet); SqlExecutor.Commit(); } catch (System.Exception e) { SqlExecutor.Rollback(); _logger.Error("Error deleting a supplier"); throw new DataLayerExecutionException("Error deleting a supplier", e); } return(true); }