/// <summary> /// 根据单位编码获取火险等级 /// </summary> /// <param name="sw">参见模型</param> /// <returns>火险等级</returns> public static string getLevelByOrgNo(YJ_DANGERCLASS_SW sw) { var DANGERCLASS = ""; if (!string.IsNullOrEmpty(sw.BYORGNO)) { DANGERCLASS = YJ_DANGERCLASSCls.getModel(new YJ_DANGERCLASS_SW { BYORGNO = sw.BYORGNO }).DANGERCLASS; if (string.IsNullOrEmpty(DANGERCLASS)) { sw.BYORGNO = sw.BYORGNO.Substring(0, 6) + "000000000";//如果乡镇没有,查市的 DANGERCLASS = YJ_DANGERCLASSCls.getModel(new YJ_DANGERCLASS_SW { BYORGNO = sw.BYORGNO }).DANGERCLASS; if (string.IsNullOrEmpty(DANGERCLASS)) { //BYORGNO = "532503000";//如果市没有,查州的 sw.BYORGNO = ConfigCls.getProvincialCapital();// ConfigurationManager.AppSettings["ProvincialCapital"].ToString();//如果市没有,查州的 DANGERCLASS = YJ_DANGERCLASSCls.getModel(new YJ_DANGERCLASS_SW { BYORGNO = sw.BYORGNO }).DANGERCLASS; if (string.IsNullOrEmpty(DANGERCLASS)) { DANGERCLASS = ""; return(DANGERCLASS); } } } } return(DANGERCLASS); }
/// <summary> /// 获取火险等级列表 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static IEnumerable <YJ_DANGERCLASS_Model> getListModel(YJ_DANGERCLASS_SW sw) { DataTable dt = BaseDT.YJ_DANGERCLASS.getDT(sw);//列表 var result = new List <YJ_DANGERCLASS_Model>(); for (int i = 0; i < dt.Rows.Count; i++) { YJ_DANGERCLASS_Model m = new YJ_DANGERCLASS_Model(); m.DANGERID = dt.Rows[i]["DANGERID"].ToString(); m.DCDATE = ClsSwitch.SwitTM(dt.Rows[i]["DCDATE"].ToString()); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.TOWNNAME = dt.Rows[i]["TOWNNAME"].ToString(); m.JD = dt.Rows[i]["JD"].ToString(); m.WD = dt.Rows[i]["WD"].ToString(); m.DANGERCLASS = dt.Rows[i]["DANGERCLASS"].ToString(); m.TOPTOWNNAME = dt.Rows[i]["TOPTOWNNAME"].ToString(); m.WEATHER = dt.Rows[i]["WEATHER"].ToString(); m.TEMPREATURE = dt.Rows[i]["TEMPREATURE"].ToString(); m.WINDYSPEED = dt.Rows[i]["WINDYSPEED"].ToString(); result.Add(m); } dt.Clear(); dt.Dispose(); return(result); }
/// <summary> /// 获取单条记录 /// </summary> /// <param name="sw">参见条件模型T_ALL_AREA_SW</param> /// <returns>参见模型T_ALL_AREA_Model</returns> public static YJ_DANGERCLASS_Model getModel(YJ_DANGERCLASS_SW sw) { DataTable dt = BaseDT.YJ_DANGERCLASS.getTopDT(sw); YJ_DANGERCLASS_Model m = new YJ_DANGERCLASS_Model(); if (dt.Rows.Count > 0) { m.DANGERID = dt.Rows[0]["DANGERID"].ToString(); m.DCDATE = dt.Rows[0]["DCDATE"].ToString(); m.BYORGNO = dt.Rows[0]["BYORGNO"].ToString(); m.TOWNNAME = dt.Rows[0]["TOWNNAME"].ToString(); m.JD = dt.Rows[0]["JD"].ToString(); m.WD = dt.Rows[0]["WD"].ToString(); m.DANGERCLASS = dt.Rows[0]["DANGERCLASS"].ToString() == "0" ? "" : dt.Rows[0]["DANGERCLASS"].ToString(); m.TOPTOWNNAME = dt.Rows[0]["TOPTOWNNAME"].ToString(); m.WEATHER = dt.Rows[0]["WEATHER"].ToString(); m.TEMPREATURE = dt.Rows[0]["TEMPREATURE"].ToString(); m.WINDYSPEED = dt.Rows[0]["WINDYSPEED"].ToString(); } //m.WEATHER =m.WEATHER!= null ? m.WEATHER :""; //m.TEMPREATURE = m.TEMPREATURE != null ? m.TEMPREATURE : ""; //m.WINDYSPEED = m.WINDYSPEED != null ? m.WINDYSPEED : ""; //m.DANGERCLASS = m.DANGERCLASS != null ? m.DANGERCLASS : ""; return(m); }
/// <summary> /// 获取火险等级 /// </summary> /// <returns></returns> public JsonResult GetFireLevelList() { MessageListObject msg = null; var sw = new YJ_DANGERCLASS_SW(); var list = YJ_DANGERCLASSCls.getListModelTop(sw).OrderByDescending(p => Convert.ToInt32(p.DANGERCLASS)); msg = new MessageListObject(true, list); return(Json(msg)); }
/// <summary> /// 判断记录是否存在 /// </summary> /// <param name="sw">参见模型</param> /// <returns>true存在 false不存在</returns> public static bool isExists(YJ_DANGERCLASS_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("select 1 from YJ_DANGERCLASS where 1=1"); sb.AppendFormat(" and DCDATE='{0}'", ClsSql.EncodeSql(sw.DCDATE)); sb.AppendFormat(" and TOWNNAME='{0}'", ClsSql.EncodeSql(sw.TOWNNAME)); sb.AppendFormat(" and BYORGNO='{0}'", ClsSql.EncodeSql(sw.BYORGNO)); return(DataBaseClass.JudgeRecordExists(sb.ToString())); }
/// <summary> /// 获取最新数据 /// </summary> /// <returns>参见模型</returns> public static DataTable getNewDT(YJ_DANGERCLASS_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" SELECT DANGERID, DCDATE, BYORGNO, TOWNNAME, JD, WD, DANGERCLASS, TOPTOWNNAME, WEATHER, TEMPREATURE, WINDYSPEED"); sb.AppendFormat(" FROM YJ_DANGERCLASS"); sb.AppendFormat(" where DCDATE=(select max( DCDATE) from YJ_DANGERCLASS)"); string sql = sb.ToString() + " order by BYORGNO DESC"; DataSet ds = DataBaseClass.FullDataSet(sql); return(ds.Tables[0]); }
/// <summary> /// json获取火险等级 /// </summary> /// <returns></returns> public JsonResult GetFireLevel() { var sw = new YJ_DANGERCLASS_SW(); string level = Request.Params["level"]; string dt = Request.Params["dt"]; sw.DANGERCLASS = level; sw.DCDATE = dt; var str = GetFireLevelHtml(sw); Message ms = new Message(true, str.ToString(), ""); return(Json(ms)); }
public string GetFireLevelHtml(YJ_DANGERCLASS_SW sw) { StringBuilder sb = new StringBuilder(); sb.Append("<table cellpadding=\"0\" cellspacing=\"0\" >"); sb.Append(" <thead>"); sb.Append("<tr><th>区域</th><th>等级</th><th>时间</th></tr>"); sb.Append("</thead>"); sb.Append("<tbody>"); var list = new List <YJ_DANGERCLASS_Model>(); if (string.IsNullOrEmpty(sw.DCDATE)) { list = YJ_DANGERCLASSCls.getListModelTop(new YJ_DANGERCLASS_SW() { }).ToList(); if (!string.IsNullOrEmpty(sw.DANGERCLASS) && sw.DANGERCLASS != "0") { list = list.Where(p => p.DANGERCLASS == sw.DANGERCLASS).ToList(); } } else { list = YJ_DANGERCLASSCls.getListModel(sw).ToList(); } if (list.Any()) { foreach (var item in list) { sb.Append("<tr>"); sb.AppendFormat("<td class=\"center\">{0}</td>", item.TOPTOWNNAME + "==>" + item.TOWNNAME); sb.AppendFormat("<td class=\"center\">{0}</td>", item.DANGERCLASS); sb.AppendFormat("<td class=\"center\">{0}</td>", ClsSwitch.SwitDate(item.DCDATE)); sb.Append("</tr>"); } } else { sb.Append("<tr>"); sb.Append("<td colspan=\"3\"><em>暂未查询到记录!</em></td>"); sb.Append("</tr>"); } sb.Append("</tbody>"); sb.Append("</table>"); return(sb.ToString()); }
/// <summary> /// 获取某一区域数据 /// </summary> /// <returns>参见模型</returns> public static DataTable getNewArea(YJ_DANGERCLASS_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" SELECT top 1 DANGERID, DCDATE, BYORGNO, TOWNNAME, JD, WD, DANGERCLASS, TOPTOWNNAME, WEATHER, TEMPREATURE, WINDYSPEED"); sb.AppendFormat(" FROM YJ_DANGERCLASS Where 1=1 "); if (!string.IsNullOrEmpty(sw.DCDATE) && !string.IsNullOrEmpty(sw.TOWNNAME)) { sb.AppendFormat(" AND DCDATE='" + sw.DCDATE + "' and (TOWNNAME='" + sw.TOWNNAME + "')"); } else { sb.AppendFormat(" AND TOWNNAME='" + sw.TOWNNAME + "'"); //sb.AppendFormat(" AND (DCDATE=(select max(DCDATE) from YJ_DANGERCLASS) or DCDATE=(select max(DCDATE) from YJ_DANGERCLASS where DCDATE!=(select max(DCDATE) from YJ_DANGERCLASS) and TOWNNAME!='" + sw.TOWNNAME + "')) and (TOWNNAME='" + sw.TOWNNAME + "')"); //sb.AppendFormat(" AND DCDATE=(select max( DCDATE) from YJ_DANGERCLASS) and (TOWNNAME='" + sw.TOWNNAME + "')"); } string sql = sb.ToString() + " order by DCDATE DESC"; DataSet ds = DataBaseClass.FullDataSet(sql); return(ds.Tables[0]); }
/// <summary> /// 获取数据库中最新的一条火险等级记录 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static DataTable getTopDT(YJ_DANGERCLASS_SW sw) { StringBuilder sb = new StringBuilder(); sb.AppendFormat(" SELECT top 1 DANGERID, DCDATE, BYORGNO, TOWNNAME, JD, WD, DANGERCLASS, TOPTOWNNAME, WEATHER, TEMPREATURE, WINDYSPEED"); sb.AppendFormat(" FROM YJ_DANGERCLASS Where 1=1 "); if (!string.IsNullOrEmpty(sw.BYORGNO)) { sb.AppendFormat(" And BYORGNO='{0}'", ClsSql.EncodeSql(sw.BYORGNO)); } if (!string.IsNullOrEmpty(sw.DANGERCLASS) && sw.DANGERCLASS != "0") { sb.AppendFormat(" And DANGERCLASS='{0}'", ClsSql.EncodeSql(sw.DANGERCLASS)); } if (!string.IsNullOrEmpty(sw.DCDATE)) { sb.AppendFormat(" And convert(char(10), DCDATE,120)='{0}'", ClsSwitch.SwitDate(sw.DCDATE)); } string sql = sb.ToString() + " order by DCDATE DESC"; DataSet ds = DataBaseClass.FullDataSet(sql); return(ds.Tables[0]); }