/// <summary> /// 获取TownCode /// </summary> /// <param name="plotid"></param> /// <returns></returns> public static List <string> get_TownCode() { List <string> list = new List <string>(); string strsql = "select distinct GLQ from PLOT_DKINFO"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { list.Add(reader[0].ToString()); } con.Close(); return(list); }
/// <summary> /// 获取NutrientCode /// </summary> /// <param name="plotid"></param> /// <returns></returns> public static List <string> get_NutrientCode() { List <string> list = new List <string>(); string strsql = "select distinct NUTRIENT_CODE from SOILNUTRIENT_CODE where DELFLAG='1'"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { list.Add(reader[0].ToString()); } con.Close(); return(list); }
/// <summary> /// 根据作物名称获取Nutrient_code /// </summary> /// <param name="name"></param> /// <returns></returns> public static string get_NutrientCode(string name) { string value = ""; string strsql = "select NUTRIENT_CODE from SOILNUTRIENT_CODE where [NUTRIENT_NAME]='" + name + "'"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { value = reader[0].ToString(); } con.Close(); return(value); }
/// <summary> /// 根据作物名称获取crop_code /// </summary> /// <param name="name"></param> /// <returns></returns> public static string get_CropCode(string name) { string value = ""; string strsql = "select CropCode from CROPINFO where [CropName]='" + name + "'"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { value = reader[0].ToString(); } con.Close(); return(value); }
/// <summary> /// 获取CropCode /// </summary> /// <param name="plotid"></param> /// <returns></returns> public static List <string> get_CropCode() { List <string> list = new List <string>(); string strsql = "select distinct CropCode from CROPINFO where DELFLAG=1"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { list.Add(reader[0].ToString()); } con.Close(); return(list); }
/// <summary> /// 获取作物代码和名称,并绑定数据源 /// </summary> /// <returns></returns> public static Dictionary <string, string> setCropSource() { Dictionary <string, string> source = new Dictionary <string, string>(); string strsql = "select [CropCode],[CropName] from CROPINFO where DELFLAG=1"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { source.Add(reader["CropCode"].ToString(), reader["CropName"].ToString()); } con.Close(); return(source); }
/// <summary> /// 获取结果 /// </summary> /// <param name="strsql"></param> /// <param name="param"></param> /// <returns></returns> public static string getResult(string strsql, SqlParameter param) { string result = ""; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); cmd.Parameters.Add(param); SqlDataReader read = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (read.Read()) { result = read[0].ToString(); } con.Close(); return(result); }
/// <summary> /// 获取处在某一时间段内的具体时间,用于汇总传参 /// </summary> /// <param name="strsql"></param> /// <param name="param"></param> /// <returns></returns> public static List <string> getIncludeTime(string strsql, SqlParameter[] param) { List <string> list = new List <string>(); //string strsql = "select MONITORTIME from MONITORTIME between @time1 and @time2"; SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(strsql, con); cmd.Parameters.AddRange(param); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { list.Add(reader[0].ToString()); } con.Close(); cmd.Parameters.Clear(); return(list); }
/// <summary> /// 获取作物类型 /// </summary> /// <param name="tablename"></param> /// <param name="date1"></param> /// <param name="date2"></param> /// <returns></returns> public static List <string> Get_CropCount(string rank, string tablename, DateTime date1, DateTime date2) { List <string> list = new List <string>(); string sqlstr = ""; switch (tablename) { case "CHLOROPHYLLRETRIEVAL": sqlstr = "select distinct CROP_CODE FROM CHLOROPHYLLRETRIEVAL_" + rank + " where MONITORTIME between '" + date1 + "' and '" + date2 + "'"; break; case "CROPYIELD": sqlstr = "select distinct CROP_CODE FROM CROPYIELD_" + rank + " where MONITORTIME between '" + date1 + "' and '" + date2 + "'"; break; case "WATERRETRIEVAL": sqlstr = "select distinct CROP_CODE FROM WATERRETRIEVAL_" + rank + " where MONITORTIME between '" + date1 + "' and '" + date2 + "'"; break; case "MATUREPERIOD": sqlstr = "select distinct CROP_CODE FROM MATUREPERIOD_" + rank + " where MONITORTIME between '" + date1 + "' and '" + date2 + "'"; break; case "SOILNUTRIENT": sqlstr = "select distinct CROP_CODE FROM SOILNUTRIENT_" + rank + " where MONITORTIME between '" + date1 + "' and '" + date2 + "'"; break; } SqlConnection con = DataBaseOperate.getSqlCon(); SqlCommand cmd = DataBaseOperate.getSqlCmd(sqlstr, con); SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { list.Add(dr["CROP_CODE"].ToString()); } con.Close(); return(list); }