/// <summary> /// 删除新区数据 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Delete(HttpContext context, bool isRoot) { int ID; try { if (context.Request.Params["ID"] != null) { ID = Convert.ToInt32(context.Request.Params["ID"]); DISTRICT_CONTRAST dc = new DISTRICT_CONTRAST() { ID = ID }; ArrayList list = new ArrayList(); if (isRoot) { DISTRICT_CONTRAST dcSon = new DISTRICT_CONTRAST() { SUPERID = ID }; list.Add(dcm.GetDeleteSql(dcSon)); } list.Add(dcm.GetDeleteSql(dc)); return(dcm.ExecuteSqlTran(list).ToString()); } } catch (Exception ex) { LogHelper.WriteLog(ex); } return("-1"); }
/// <summary> /// 修改新区数据 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Update(HttpContext context) { ArrayList list = new ArrayList(); try { string name = context.Request.Params["NAME"]; int id; if (context.Request.Params["ID"] != null) { id = Convert.ToInt32(context.Request.Params["ID"]); //获取更新对象以及其更新语句 DISTRICT_CONTRAST fatherDC = new DISTRICT_CONTRAST() { ID = id, NAME = name }; list.Add(dcm.GetUpdateSql(fatherDC)); //获取更新对象的原来子集对象,及其删除语句 DISTRICT_CONTRAST dcOldSon = new DISTRICT_CONTRAST() { SUPERID = id }; list.Add(dcm.GetDeleteSql(dcOldSon)); //获取更新对象的新子集对象,及其插入语句 string childrenName = context.Request.Params["childrenName"]; string childrenId = context.Request.Params["childrenId"]; string[] arrayName = childrenName.Substring(1).Split(','); string[] arrayId = childrenId.Substring(1).Split(','); for (int i = 0; i < arrayName.Length; i++) { DISTRICT_CONTRAST dc = new DISTRICT_CONTRAST() { ID = dcm.GetSequence(), SUPERID = fatherDC.ID, NAME = arrayName[i], SUPERNAME = fatherDC.NAME, OLDID = Convert.ToInt32(arrayId[i]) }; list.Add(dcm.GetInsertSql(dc)); } return(dcm.ExecuteSqlTran(list).ToString()); } } catch (Exception ex) { LogHelper.WriteLog(ex); } return("-1"); }
/// <summary> /// 增加新区数据 /// </summary> /// <param name="context"></param> /// <returns></returns> public string Insert(HttpContext context) { try { ArrayList list = new ArrayList(); string name = context.Request.Params["NAME"]; //获取新区对象 DISTRICT_CONTRAST fatherDC = new DISTRICT_CONTRAST() { ID = dcm.GetSequence(), NAME = name, state = "closed", SUPERID = 0 }; list.Add(dcm.GetInsertSql(fatherDC)); string childrenName = context.Request.Params["childrenName"]; string childrenId = context.Request.Params["childrenId"]; string[] arrayName = childrenName.Substring(1).Split(','); string[] arrayId = childrenId.Substring(1).Split(','); for (int i = 0; i < arrayName.Length; i++) { DISTRICT_CONTRAST dc = new DISTRICT_CONTRAST() { ID = dcm.GetSequence(), SUPERID = fatherDC.ID, NAME = arrayName[i], SUPERNAME = fatherDC.NAME, OLDID = Convert.ToInt32(arrayId[i]) }; list.Add(dcm.GetInsertSql(dc)); } return(dcm.ExecuteSqlTran(list).ToString()); } catch (Exception ex) { LogHelper.WriteLog(ex); return("-1"); } }