private string FilterTheMainTable(DateTime?fromDay, DateTime?toDay, string dbName) { int allCount = SqlCommandRunner.GetTableRowCount(_MainTable, dbName); int delRowCount; string sqlCommand = DefineTheMainTableFilterCommand(fromDay, toDay); try { delRowCount = SqlCommandRunner.ExecuteNonQuery(new SqlCommand(sqlCommand), dbName); } catch (Exception e) { throw new ApplicationException(string.Format("{0}{1}", _Error_FilterTable, e.Message)); } return(string.Format("--表{0}共计:总行数{1},删减{2}行数据", _MainTable, allCount, delRowCount)); }
private string FilterTheOtherTable(List <int> theRemainedMainTablePkids, string dbName, Dictionary <string, List <int> > tablesAndIds) { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, string> theColumnn in DefineProtectedTableFkColumnName()) { int allCount = SqlCommandRunner.GetTableRowCount(theColumnn.Key, dbName); try { string theCommand = string.Format("delete from {0} where {1} not in({2})", theColumnn.Key, theColumnn.Value, MakePkidStrings(theRemainedMainTablePkids)); sb.AppendLine(string.Format("--表{0}共计:总行数{1},删减{2}行数据", theColumnn.Key, allCount, SqlCommandRunner.ExecuteNonQuery(new SqlCommand(theCommand), dbName))); tablesAndIds.Add(theColumnn.Key, FindAllPkids(theColumnn.Key, dbName)); } catch (Exception e) { throw new ApplicationException(string.Format("{0}{1}", _Error_FilterTable, e.Message)); } } return(sb.ToString()); }
public string FilterTableData(DateTime?fromDay, DateTime?toDay) { int allCount = SqlCommandRunner.GetTableRowCount(_MainTable, _OrginDbName); return(string.Format("--表{0}共计:总行数{1},删减0行数据", _MainTable, allCount)); }