/// <summary> /// 查询所有的墒情站点信息 /// </summary> /// <returns></returns> public List <CEntitySoilStation> QueryAllSoilStation() { string sql = " select * from " + CT_TableName; SqlDataAdapter adapter = new SqlDataAdapter(sql, CDBManager.GetInstacne().GetConnection()); DataTable dataTableTmp = new DataTable(); adapter.Fill(dataTableTmp); // 构建结果集 List <CEntitySoilStation> results = new List <CEntitySoilStation>(); for (int rowid = 0; rowid < dataTableTmp.Rows.Count; ++rowid) { CEntitySoilStation soilStation = new CEntitySoilStation(); soilStation.StationID = dataTableTmp.Rows[rowid][CN_StationId].ToString(); soilStation.SubCenterID = int.Parse(dataTableTmp.Rows[rowid][CN_SubCenterID].ToString()); soilStation.StationName = dataTableTmp.Rows[rowid][CN_StationName].ToString(); soilStation.StationType = CEnumHelper.DBStrToStationType(dataTableTmp.Rows[rowid][CN_StationType].ToString()); // soilStation.StrDeviceNumber = dataTableTmp.Rows[rowid][CN_DeviceNumber].ToString(); soilStation.A10 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_A10]); soilStation.B10 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_B10]); soilStation.C10 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_C10]); soilStation.D10 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_D10]); soilStation.M10 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_M10]); soilStation.N10 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_N10]); soilStation.A20 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_A20]); soilStation.B20 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_B20]); soilStation.C20 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_C20]); soilStation.D20 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_D20]); soilStation.M20 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_M20]); soilStation.N20 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_N20]); soilStation.A30 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_A30]); soilStation.B30 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_B30]); soilStation.C30 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_C30]); soilStation.D30 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_D30]); soilStation.M30 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_M30]); soilStation.N30 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_N30]); soilStation.A40 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_A40]); soilStation.B40 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_B40]); soilStation.C40 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_C40]); soilStation.D40 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_D40]); soilStation.M40 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_M40]); soilStation.N40 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_N40]); soilStation.A60 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_A60]); soilStation.B60 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_B60]); soilStation.C60 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_C60]); soilStation.D60 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_D60]); soilStation.M60 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_M60]); soilStation.N60 = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_N60]); soilStation.VoltageMin = GetCellDecimalValue(dataTableTmp.Rows[rowid][CN_Voltagemin]); soilStation.GSM = dataTableTmp.Rows[rowid][CN_GSM].ToString(); soilStation.GPRS = dataTableTmp.Rows[rowid][CN_GPRS].ToString(); soilStation.BDSatellite = dataTableTmp.Rows[rowid][CN_BDSatellite].ToString(); soilStation.BDMemberSatellite = dataTableTmp.Rows[rowid][CN_BDMember].ToString(); soilStation.Maintran = dataTableTmp.Rows[rowid][CN_Maintran].ToString(); soilStation.Subtran = dataTableTmp.Rows[rowid][CN_Subtran].ToString(); soilStation.Datapotocol = dataTableTmp.Rows[rowid][CN_Dataprotocol].ToString(); soilStation.Reportinterval = dataTableTmp.Rows[rowid][CN_Reportinterval].ToString(); results.Add(soilStation); } return(results); }
public List <CEntityStation> QueryAll() { string sql = " select * from " + CT_TableName; SqlDataAdapter adapter = new SqlDataAdapter(sql, CDBManager.GetInstacne().GetConnection()); DataTable dataTableTmp = new DataTable(); adapter.Fill(dataTableTmp); // 构建结果集 List <CEntityStation> results = new List <CEntityStation>(); //dataTableTmp.Rows.Count for (int rowid = 0; rowid < dataTableTmp.Rows.Count; ++rowid) { CEntityStation station = new CEntityStation(); station.StationID = dataTableTmp.Rows[rowid][CN_StationID].ToString(); station.SubCenterID = int.Parse(dataTableTmp.Rows[rowid][CN_SubCenterID].ToString()); station.StationName = dataTableTmp.Rows[rowid][CN_StationName].ToString(); station.StationType = CEnumHelper.DBStrToStationType(dataTableTmp.Rows[rowid][CN_StationType].ToString()); if (!dataTableTmp.Rows[rowid][CN_WaterBase].ToString().Equals("")) { station.DWaterBase = Decimal.Parse(dataTableTmp.Rows[rowid][CN_WaterBase].ToString()); } if (!dataTableTmp.Rows[rowid][CN_WaterMax].ToString().Equals("")) { station.DWaterMax = Decimal.Parse(dataTableTmp.Rows[rowid][CN_WaterMax].ToString()); } if (!dataTableTmp.Rows[rowid][CN_WaterMin].ToString().Equals("")) { station.DWaterMin = Decimal.Parse(dataTableTmp.Rows[rowid][CN_WaterMin].ToString()); } if (!dataTableTmp.Rows[rowid][CN_WaterChange].ToString().Equals("")) { station.DWaterChange = Decimal.Parse(dataTableTmp.Rows[rowid][CN_WaterChange].ToString()); } if (!dataTableTmp.Rows[rowid][CN_RainAccuracy].ToString().Equals("")) { station.DRainAccuracy = float.Parse(dataTableTmp.Rows[rowid][CN_RainAccuracy].ToString()); } if (!dataTableTmp.Rows[rowid][CN_RainChange].ToString().Equals("")) { station.DRainChange = Decimal.Parse(dataTableTmp.Rows[rowid][CN_RainChange].ToString()); } if (!dataTableTmp.Rows[rowid][CN_VoltageMin].ToString().Equals("")) { station.DVoltageMin = float.Parse(dataTableTmp.Rows[rowid][CN_VoltageMin].ToString()); } station.GSM = dataTableTmp.Rows[rowid][CN_GSM].ToString(); station.GPRS = dataTableTmp.Rows[rowid][CN_GPRS].ToString(); station.BDMemberSatellite = dataTableTmp.Rows[rowid][CN_BDMember].ToString(); station.BDSatellite = dataTableTmp.Rows[rowid][CN_BDSatellite].ToString(); station.Maintran = dataTableTmp.Rows[rowid][CN_Maintran].ToString(); station.Subtran = dataTableTmp.Rows[rowid][CN_Subtran].ToString(); station.Datapotocol = dataTableTmp.Rows[rowid][CN_Dataprotocol].ToString(); station.Watersensor = dataTableTmp.Rows[rowid][CN_Watersensor].ToString(); station.Rainsensor = dataTableTmp.Rows[rowid][CN_Rainsensor].ToString(); station.Reportinterval = dataTableTmp.Rows[rowid][CN_Reportinterval].ToString(); results.Add(station); } return(results); }