using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Text; using System.Collections; using System.Reflection; using System.Web.Script.Serialization; using FangYar.Model; using FangYar.BLL; namespace FangYar.WebUI.ashx { /// /// OaLeaveHandler 的摘要说明 /// public class ZYFireIntWharfHandler : IHttpHandler { private FangYar.BLL.FIRE.FIRE_INTAKE_WHARF bll = new FangYar.BLL.FIRE.FIRE_INTAKE_WHARF(); public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string action = context.Request.Params["Action"]; string returnstr = ""; switch (action) { case "IntWharfList": returnstr = GetIntWharfList(context); break; case "Add": returnstr = AddIntWharf(context); break; case "Edit": returnstr = EditIntWharf(context); break; case "Del": returnstr = DelIntWharf(context); break; } context.Response.Write(returnstr); } //查询 private string GetIntWharfList(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["OrgId"]; string keyword = context.Request.Params["keywords"]; string STATE = context.Request.Params["STATE"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; int pageIndex = 1; int pageSize = 10; if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); } if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); } string where = " 1=1 "; if (!string.IsNullOrEmpty(OrgId)) { where += " and (ORG_ID ='" + OrgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + OrgId + "') )"; } if (!string.IsNullOrEmpty(STATE)) { if (where != null) { where += " and "; } where += " STATE = '" + STATE + "' "; } if (!string.IsNullOrEmpty(keyword)) { if (where != null) { where += " and "; } where += "( name like '%" + keyword + "%' or ADDR like '%" + keyword + "%')"; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = bll.GetRecordCount(where); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List list = bll.QueryList(pageIndex, pageSize, where, ""); returnstr += FangYar.Common.JsonHelper.ToJson(list); } returnstr += "}"; } catch { returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]"; } return returnstr; } //添加消防装备 private string AddIntWharf(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string USER_ID = context.Request.Params["USER_ID"]; string ID = Guid.NewGuid().ToString("N"); string INT_NO = context.Request.Params["INT_NO"]; string NAME = context.Request.Params["NAME"]; string ADDR = context.Request.Params["ADDR"]; string LON = context.Request.Params["LON"]; string LAT = context.Request.Params["LAT"]; string A_STATE = context.Request.Params["A_STATE"]; string SOURCE = context.Request.Params["SOURCE"]; string SUB_ROAD = context.Request.Params["SUB_ROAD"]; string I_FORM = context.Request.Params["I_FORM"]; string I_HEIGHT = context.Request.Params["I_HEIGHT"]; string P_SPACE = context.Request.Params["P_SPACE"]; string P_NUM = context.Request.Params["P_NUM"]; string R_PHOTO = context.Request.Params["R_PHOTO"]; string P_PHOTO = context.Request.Params["P_PHOTO"]; string FOUND_DATE = context.Request.Params["FOUND_DATE"]; string I_RECORD = context.Request.Params["I_RECORD"]; string ORG_ID = context.Request.Params["ORG_ID"]; string CITY = context.Request.Params["CITY"]; string STATE = context.Request.Params["STATE"]; //取水码头表 FangYar.Model.FIRE.FIRE_INTAKE_WHARF model = new Model.FIRE.FIRE_INTAKE_WHARF(); model.ID = ID; model.INT_NO = INT_NO; model.NAME = NAME; model.ADDR = ADDR; model.LON = LON; model.LAT = LAT; model.A_STATE = A_STATE; model.SOURCE = SOURCE; model.SUB_ROAD = SUB_ROAD; model.I_FORM = I_FORM; model.I_HEIGHT = int.Parse(I_HEIGHT); model.P_SPACE = P_SPACE; model.P_NUM = int.Parse(P_NUM); model.R_PHOTO = R_PHOTO; model.P_PHOTO = P_PHOTO; model.FOUND_DATE = FOUND_DATE; model.I_RECORD = I_RECORD; model.ORG_ID = ORG_ID; model.CITY = CITY; model.STATE = STATE; model.A_PER = USER_ID; if (bll.Add(model)) { msg = "添加成功!"; code = 1; } else { msg = "添加失败!"; } } catch { msg = "添加失败"; } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; return returnstr; } //修改消防装备 private string EditIntWharf(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string USER_ID = context.Request.Params["USER_ID"]; string ID = context.Request.Params["ID"]; string INT_NO = context.Request.Params["INT_NO"]; string NAME = context.Request.Params["NAME"]; string ADDR = context.Request.Params["ADDR"]; string LON = context.Request.Params["LON"]; string LAT = context.Request.Params["LAT"]; string A_STATE = context.Request.Params["A_STATE"]; string SOURCE = context.Request.Params["SOURCE"]; string SUB_ROAD = context.Request.Params["SUB_ROAD"]; string I_FORM = context.Request.Params["I_FORM"]; string I_HEIGHT = context.Request.Params["I_HEIGHT"]; string P_SPACE = context.Request.Params["P_SPACE"]; string P_NUM = context.Request.Params["P_NUM"]; string R_PHOTO = context.Request.Params["R_PHOTO"]; string P_PHOTO = context.Request.Params["P_PHOTO"]; string FOUND_DATE = context.Request.Params["FOUND_DATE"]; string I_RECORD = context.Request.Params["I_RECORD"]; string ORG_ID = context.Request.Params["ORG_ID"]; string CITY = context.Request.Params["CITY"]; string STATE = context.Request.Params["STATE"]; //取水码头表 FangYar.Model.FIRE.FIRE_INTAKE_WHARF model = new Model.FIRE.FIRE_INTAKE_WHARF(); model.ID = ID; model.INT_NO = INT_NO; model.NAME = NAME; model.ADDR = ADDR; model.LON = LON; model.LAT = LAT; model.A_STATE = A_STATE; model.SOURCE = SOURCE; model.SUB_ROAD = SUB_ROAD; model.I_FORM = I_FORM; model.I_HEIGHT = int.Parse(I_HEIGHT); model.P_SPACE = P_SPACE; model.P_NUM = int.Parse(P_NUM); model.R_PHOTO = R_PHOTO; model.P_PHOTO = P_PHOTO; model.FOUND_DATE = FOUND_DATE; model.I_RECORD = I_RECORD; model.ORG_ID = ORG_ID; model.CITY = CITY; model.STATE = STATE; model.U_PER = USER_ID; if (bll.Update(model)) { msg = "修改成功!"; code = 1; } else { msg = "修改失败!"; } } catch { msg = "修改失败!"; } returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}"; return returnstr; } //删除消防装备 private string DelIntWharf(HttpContext context) { string returnstr = ""; int code = -1; string msg = ""; try { string IntWharfList = context.Request.Params["IntWharfList"]; string[] IntWharfArray = IntWharfList.Split(','); string IntWharfListString = ""; for (int i = 0; i < IntWharfArray.Length; i++) { if (i == 0) { IntWharfListString = "'" + IntWharfArray[i] + "'"; } else { IntWharfListString += ",'" + IntWharfArray[i] + "'"; } } if (bll.DeleteList(IntWharfListString)) { msg = "删除成功!"; code = 1; } else { msg = "删除失败!"; } } catch { msg = "删除失败!"; } returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}"; return returnstr; } public bool IsReusable { get { return false; } } } }