辛苦的劳动,被遗弃的代码
public static DataTable GetDataTable(string TableName, IDbConnection dbConnection, List<District> pDistrictList) { if (string.IsNullOrEmpty(TableName)) { return null; } if(!GtMap.GxDBHelper.Database.IsExistsTable(dbConnection,DefinitionClass.STR_TABLE_NAME_DWXX)) { GxDlgHelper.DevMessageBox.ShowInformation("当前连接的数据库中不存在" + DefinitionClass.STR_TABLE_NAME_DWXX+ "表!"); } int iDilit = int.Parse(GtMap.GxLandHelper.RunParameter.GetAreaDeciHektare(dbConnection)); DataRow dr; DataTable pTBDLMJTable = new DataTable(); DataTable pKZMJTable=new DataTable(); DataTable pResultTable=new DataTable(); pResultTable.Columns.Add("Image", System.Type.GetType("System.Int32")); pResultTable.Columns.Add("Name", Type.GetType("System.String")); pResultTable.Columns.Add("TotalArea", Type.GetType("System.Double")); pResultTable.Columns.Add("LayerOut", Type.GetType("System.Double")); pResultTable.Columns.Add("Result", Type.GetType("System.Double")); foreach (District pDistrict in pDistrictList) { if (pDistrict.Level == 1) { string sDLTBMJSelSQL = string.Empty; string sKZMJSelSQL = string.Empty; dr = pResultTable.NewRow(); sDLTBMJSelSQL = "SELECT SUM(TBDLMJ) AS TBDL FROM " + TableName + " WHERE ZLCDM LIKE '" + pDistrict.Code + "%'"; sKZMJSelSQL = "SELECT SUM(KZMJ) AS KZ FROM " + DefinitionClass.STR_TABLE_NAME_DWXX + " WHERE DWDM LIKE '" + pDistrict.Code + "%'"; pTBDLMJTable = GtMap.GxDBHelper.SQL.ExecuteQuery(dbConnection, sDLTBMJSelSQL); pKZMJTable = GtMap.GxDBHelper.SQL.ExecuteQuery(dbConnection, sKZMJSelSQL); string sTBDLArea = pTBDLMJTable.Rows[0]["TBDL"] != null ? pTBDLMJTable.Rows[0]["TBDL"].ToString() : string.Empty; string sKZMJArea = pKZMJTable.Rows[0]["KZ"] != null ? pKZMJTable.Rows[0]["KZ"].ToString() : string.Empty; if (sTBDLArea != "" && sKZMJArea != "") { dr = pResultTable.NewRow(); dr["TotalArea"] = GtMap.GxComHelper.Math.Rounding(Convert.ToDouble(sTBDLArea) / 10000, iDilit); dr["Name"] = pDistrict.Name; dr["LayerOut"] = GtMap.GxComHelper.Math.Rounding(Convert.ToDouble(sKZMJArea) / 10000, iDilit); double dResultCZ = Convert.ToDouble(dr["TotalArea"]) - Convert.ToDouble(dr["LayerOut"]); dr["Result"] = dResultCZ.ToString(); if (dResultCZ >= 0) { dr["Image"] = 0; } else { dr["Image"] = 1; } pResultTable.Rows.Add(dr); } } } if (pResultTable != null) { return pResultTable; } else { return null; } }