软测单独项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

362 lines
14 KiB

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
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class ZYFireStationHandler : IHttpHandler
{
private FangYar.BLL.FIRE.FIRE_STATION bll = new FangYar.BLL.FIRE.FIRE_STATION();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "StationList":
returnstr = GetStationList(context);
break;
case "GetStation":
returnstr = GetStation(context);
break;
case "Add":
returnstr = AddStation(context);
break;
case "Edit":
returnstr = EditStation(context);
break;
case "Del":
returnstr = DelStation(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string GetStationList(HttpContext context)
{
string returnstr = "";
try
{
string OrgList = context.Request.Params["OrgList"];
string OrgId = context.Request.Params["OrgId"];
string keyword = context.Request.Params["keywords"];
string treeID = context.Request.Params["treeID"];
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 = null;
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
{
where += " ORG_ID = '" + treeID + "'";
}
else
{
string[] OrgArray = OrgList.Split(',');
string OrgListString = "";
for (int i = 0; i < OrgArray.Length; i++)
{
if (i == 0)
{
OrgListString = "'" + OrgArray[i] + "'";
}
else
{
OrgListString += ",'" + OrgArray[i] + "'";
}
}
where = " ORG_ID in (" + OrgListString + ") ";
}
if (!string.IsNullOrEmpty(keyword))
{
if (where != null)
{
where += " and ";
}
where += "( STA_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<FangYar.Model.FIRE.FIRE_STATION> 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 GetStation(HttpContext context)
{
string returnstr = "";
try
{
string staId = context.Request.Params["staId"];
returnstr = "{\"code\":0,\"msg\":\"\",\"Data\":";
FangYar.Model.FIRE.FIRE_STATION data = bll.getStation(staId);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
}
return returnstr;
}
//添加队站
private string AddStation(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string userId = context.Request.Params["userId"];
string STA_ID = Guid.NewGuid().ToString("N");
string STA_NO = context.Request.Params["STA_NO"];
string STA_NAME = context.Request.Params["STA_NAME"];
string ABB = context.Request.Params["ABB"];
string S_FORM = context.Request.Params["S_FORM"];
string STA_TYPE = context.Request.Params["STA_TYPE"];
string ADDR = context.Request.Params["ADDR"];
string STA_DES = context.Request.Params["STA_DES"];
string FOUND_DATE = context.Request.Params["FOUND_DATE"];
string UNIT = context.Request.Params["UNIT"];
string DUTIES = context.Request.Params["DUTIES"];
string CONT = context.Request.Params["CONT"];
string PHONE = context.Request.Params["PHONE"];
string PN = context.Request.Params["PN"];
string CN = context.Request.Params["CN"];
string IS_THE = context.Request.Params["IS_THE"];
string IS_DUTY = context.Request.Params["IS_DUTY"];
string THE_CN = context.Request.Params["THE_CN"];
string THE_SN = context.Request.Params["THE_SN"];
string ACT_CN = context.Request.Params["ACT_CN"];
string ACT_SN = context.Request.Params["ACT_SN"];
string SIT = context.Request.Params["SIT"];
string EQU_DES = context.Request.Params["EQU_DES"];
string LON = context.Request.Params["LON"];
string LAT = context.Request.Params["LAT"];
string ORG_ID = context.Request.Params["ORG_ID"];
string CITY = context.Request.Params["CITY"];
string STATE = context.Request.Params["STATE"];
//队站表
FangYar.Model.FIRE.FIRE_STATION model = new Model.FIRE.FIRE_STATION();
model.STA_ID = STA_ID;
model.STA_NO = STA_NO;
model.STA_NAME = STA_NAME;
model.ABB = ABB;
model.S_FORM = S_FORM;
model.STA_TYPE = STA_TYPE;
model.ADDR = ADDR;
model.STA_DES = STA_DES;
model.FOUND_DATE = FOUND_DATE;
model.UNIT = UNIT;
model.DUTIES = DUTIES;
model.CONT = CONT;
model.PHONE = PHONE;
model.PN = int.Parse(PN);
model.CN = int.Parse(CN);
model.IS_THE = IS_THE;
model.IS_DUTY = IS_DUTY;
model.THE_CN = int.Parse(THE_CN);
model.THE_SN = int.Parse(THE_SN);
model.ACT_CN = int.Parse(ACT_CN);
model.ACT_SN = int.Parse(ACT_SN);
model.SIT = SIT;
model.EQU_DES = EQU_DES;
model.LON = LON;
model.LAT = LAT;
model.ORG_ID = ORG_ID;
model.CITY = CITY;
model.STATE = STATE;
model.A_PER = userId;
if (bll.AddStation(model))
{
msg = "添加成功!";
code = 1;
}
else { msg = "添加失败!"; }
}
catch
{
msg = "添加失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//修改人员信息
private string EditStation(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string userId = context.Request.Params["userId"];
string STA_ID = context.Request.Params["ID"];
string STA_NO = context.Request.Params["STA_NO"];
string STA_NAME = context.Request.Params["STA_NAME"];
string ABB = context.Request.Params["ABB"];
string S_FORM = context.Request.Params["S_FORM"];
string STA_TYPE = context.Request.Params["STA_TYPE"];
string ADDR = context.Request.Params["ADDR"];
string STA_DES = context.Request.Params["STA_DES"];
string FOUND_DATE = context.Request.Params["FOUND_DATE"];
string UNIT = context.Request.Params["UNIT"];
string DUTIES = context.Request.Params["DUTIES"];
string CONT = context.Request.Params["CONT"];
string PHONE = context.Request.Params["PHONE"];
string PN = context.Request.Params["PN"];
string CN = context.Request.Params["CN"];
string IS_THE = context.Request.Params["IS_THE"];
string IS_DUTY = context.Request.Params["IS_DUTY"];
string THE_CN = context.Request.Params["THE_CN"];
string THE_SN = context.Request.Params["THE_SN"];
string ACT_CN = context.Request.Params["ACT_CN"];
string ACT_SN = context.Request.Params["ACT_SN"];
string SIT = context.Request.Params["SIT"];
string EQU_DES = context.Request.Params["EQU_DES"];
string LON = context.Request.Params["LON"];
string LAT = context.Request.Params["LAT"];
string ORG_ID = context.Request.Params["ORG_ID"];
string CITY = context.Request.Params["CITY"];
string STATE = context.Request.Params["STATE"];
//队站表
FangYar.Model.FIRE.FIRE_STATION model = new Model.FIRE.FIRE_STATION();
model.STA_ID = STA_ID;
model.STA_NO = STA_NO;
model.STA_NAME = STA_NAME;
model.ABB = ABB;
model.S_FORM = S_FORM;
model.STA_TYPE = STA_TYPE;
model.ADDR = ADDR;
model.STA_DES = STA_DES;
model.FOUND_DATE = FOUND_DATE;
model.UNIT = UNIT;
model.DUTIES = DUTIES;
model.CONT = CONT;
model.PHONE = PHONE;
model.PN = int.Parse(PN);
model.CN = int.Parse(CN);
model.IS_THE = IS_THE;
model.IS_DUTY = IS_DUTY;
model.THE_CN = int.Parse(THE_CN);
model.THE_SN = int.Parse(THE_SN);
model.ACT_CN = int.Parse(ACT_CN);
model.ACT_SN = int.Parse(ACT_SN);
model.SIT = SIT;
model.EQU_DES = EQU_DES;
model.LON = LON;
model.LAT = LAT;
model.ORG_ID = ORG_ID;
model.CITY = CITY;
model.STATE = STATE;
model.U_PER = userId;
if (bll.EditStation(model))
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
catch
{
msg = "修改失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//删除人员
private string DelStation(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string StaList = context.Request.Params["StaList"];
string[] StaArray = StaList.Split(',');
string StaListString = "";
for (int i = 0; i < StaArray.Length; i++)
{
if (i == 0)
{
StaListString = "'" + StaArray[i] + "'";
}
else
{
StaListString += ",'" + StaArray[i] + "'";
}
}
var rcode = bll.DelStation(StaListString);
if (rcode == 0)
{
msg = "删除成功!";
code = 1;
}
else if (rcode == 1)
{
msg = "所选队站还有人员关联,请移除人员后再删除当前所选队站!";
}
else if (rcode == 2)
{
msg = "删除失败!";
}
}
catch
{
msg = "删除失败!";
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}