private string validaction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); string flag = "1"; try { Business.Base.BusinessServiceType bc = new project.Business.Base.BusinessServiceType(); bc.load(jp.getValue("id")); bc.Entity.SRVStatus = !bc.Entity.SRVStatus; int r = bc.valid(); if (r <= 0) { flag = "2"; } if (bc.Entity.SRVStatus) { collection.Add(new JsonStringValue("stat", "<span class=\"label label-success radius\">有效</span>")); } else { collection.Add(new JsonStringValue("stat", "<span class=\"label radius\">已失效</span>")); } //collection.Add(new JsonStringValue("id", jp.getValue("id"))); } catch { flag = "2"; } collection.Add(new JsonStringValue("type", "valid")); collection.Add(new JsonStringValue("flag", flag)); collection.Add(new JsonStringValue("liststr", createList(jp.getValue("SRVTypeNameS"), jp.getValue("SRVSPNoS")))); return(collection.ToString()); }
private string updateaction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); string flag = "1"; try { Business.Base.BusinessServiceType bc = new project.Business.Base.BusinessServiceType(); bc.load(jp.getValue("id")); collection.Add(new JsonStringValue("SRVTypeNo", bc.Entity.SRVTypeNo)); collection.Add(new JsonStringValue("SRVTypeName", bc.Entity.SRVTypeName)); collection.Add(new JsonStringValue("ParentTypeNo", bc.Entity.ParentTypeNo)); collection.Add(new JsonStringValue("ParentTypeNoName", bc.Entity.ParentTypeName)); collection.Add(new JsonStringValue("SRVSPNo", bc.Entity.SRVSPNo)); collection.Add(new JsonStringValue("Remark", bc.Entity.Remark)); } catch { flag = "2"; } collection.Add(new JsonStringValue("type", "update")); collection.Add(new JsonStringValue("flag", flag)); return(collection.ToString()); }
private string deleteaction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); string flag = "1"; try { Business.Base.BusinessServiceType bc = new project.Business.Base.BusinessServiceType(); bc.load(jp.getValue("id")); if (obj.PopulateDataSet("select 1 from Mstr_ServiceType where ParentTypeNo='" + bc.Entity.SRVTypeNo + "'").Tables[0].Rows.Count > 0) { flag = "3"; } else { int r = bc.delete(); if (r <= 0) { flag = "2"; } } } catch { flag = "2"; } collection.Add(new JsonStringValue("type", "delete")); collection.Add(new JsonStringValue("flag", flag)); collection.Add(new JsonStringValue("liststr", createList(jp.getValue("SRVTypeNameS"), jp.getValue("SRVSPNoS")))); return(collection.ToString()); }
private string insertaction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); string flag = "1"; try { Business.Base.BusinessServiceType bc = new project.Business.Base.BusinessServiceType(); bc.load(jp.getValue("id")); if (bc.Entity.ParentTypeNo == "") { collection.Add(new JsonStringValue("SRVTypeNo", bc.Entity.SRVTypeNo)); collection.Add(new JsonStringValue("SRVTypeName", bc.Entity.SRVTypeName)); } else { collection.Add(new JsonStringValue("SRVTypeNo", bc.Entity.ParentTypeNo)); collection.Add(new JsonStringValue("SRVTypeName", bc.Entity.ParentTypeName)); } } catch { flag = "2"; } collection.Add(new JsonStringValue("type", "insert")); collection.Add(new JsonStringValue("flag", flag)); return(collection.ToString()); }
private string submitaction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); string flag = "1"; try { Business.Base.BusinessServiceType bc = new project.Business.Base.BusinessServiceType(); if (jp.getValue("tp") == "update") { bc.load(jp.getValue("id")); bc.Entity.SRVTypeName = jp.getValue("SRVTypeName"); bc.Entity.ParentTypeNo = jp.getValue("ParentTypeNo"); bc.Entity.SRVSPNo = jp.getValue("SRVSPNo"); bc.Entity.Remark = jp.getValue("Remark"); int r = bc.Save("update"); if (r <= 0) { flag = "2"; } } else { Data obj = new Data(); DataTable dt = obj.PopulateDataSet("select cnt=COUNT(*) from Mstr_ServiceType where SRVTypeNo='" + jp.getValue("SRVTypeNo") + "'").Tables[0]; if (int.Parse(dt.Rows[0]["cnt"].ToString()) > 0) { flag = "3"; } else { bc.Entity.SRVTypeNo = jp.getValue("SRVTypeNo"); bc.Entity.SRVTypeName = jp.getValue("SRVTypeName"); bc.Entity.ParentTypeNo = jp.getValue("ParentTypeNo"); bc.Entity.SRVSPNo = jp.getValue("SRVSPNo"); bc.Entity.Remark = jp.getValue("Remark"); int r = bc.Save("insert"); if (r <= 0) { flag = "2"; } } } } catch { flag = "2"; } collection.Add(new JsonStringValue("type", "submit")); collection.Add(new JsonStringValue("flag", flag)); collection.Add(new JsonStringValue("liststr", createList(jp.getValue("SRVTypeNameS"), jp.getValue("SRVSPNoS")))); return(collection.ToString()); }