private string FindAction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); int flag = 0; try { BusinessFormula bc = new BusinessFormula(); bc.GetByID(jp.getValue("id")); if (!string.IsNullOrEmpty(bc.Entity.ID)) { collection.Add(new JsonStringValue("data", JsonConvert.SerializeObject(bc.Entity))); } else { flag = 1; collection.Add(new JsonStringValue("msg", "该数据不存在!")); } } catch (Exception ex) { flag = 2; collection.Add(new JsonStringValue("ex", ex.Message)); } collection.Add(new JsonStringValue("type", "find")); collection.Add(new JsonNumericValue("flag", flag)); return(collection.ToString()); }
private string ModifyAction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); int flag = 1; try { BusinessFormula bc = new BusinessFormula(); bc.GetByID(jp.getValue("id")); bc.Entity.Name = jp.getValue("name"); bc.Entity.Explanation = jp.getValue("explanation"); bc.Entity.Remark = jp.getValue("remark"); if (bc.Update() > 0) { flag = 0; collection.Add(new JsonStringValue("list", createList("", "", "", 1))); } } catch (Exception ex) { flag = 2; collection.Add(new JsonStringValue("ex", ex.Message)); } collection.Add(new JsonStringValue("type", "modify")); collection.Add(new JsonNumericValue("flag", flag)); return(collection.ToString()); }
private string JumpAction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); int flag = 0; try { BusinessFormula bc = new BusinessFormula(); collection.Add(new JsonStringValue("list", createList(jp.getValue("id"), jp.getValue("name"), jp.getValue("explanation"), ParseIntForString(jp.getValue("pageIndex"))))); } catch (Exception ex) { flag = 2; collection.Add(new JsonStringValue("ex", ex.Message)); } collection.Add(new JsonStringValue("type", "select")); collection.Add(new JsonNumericValue("flag", flag)); return(collection.ToString()); }
private string createList(string id, string name, string explanation, int pageIndex) { System.Text.StringBuilder sb = new System.Text.StringBuilder(""); sb.Append("<table class=\"table table-border table-bordered table-hover table-bg table-sort\" id=\"tablelist\">"); sb.Append("<thead>"); sb.Append("<tr class=\"text-c\">"); sb.Append("<th width=\"5%\">序号</th>"); sb.Append("<th width='10%'>编号</th>"); sb.Append("<th width='15%'>名称</th>"); sb.Append("<th width='30%'>描述</th>"); sb.Append("<th width='30%'>备注</th>"); sb.Append("</tr>"); sb.Append("</thead>"); int r = 1; sb.Append("<tbody>"); BusinessFormula bc = new BusinessFormula(); foreach (EntityFormula it in bc.GetList(id, name, explanation, pageIndex, pageSize)) { sb.Append("<tr class=\"text-c\" id=\"" + it.ID + "\">"); sb.Append("<td style=\"text-align:center;\">" + r.ToString() + "</td>"); sb.Append("<td>" + it.ID + "</td>"); sb.Append("<td>" + it.Name + "</td>"); sb.Append("<td>" + it.Explanation + "</td>"); sb.Append("<td>" + it.Remark + "</td>"); sb.Append("</tr>"); r++; } sb.Append("</tbody>"); sb.Append("</table>"); sb.Append(Paginat(bc.GetCount(id, name, explanation), pageSize, pageIndex, 7)); return(sb.ToString()); }
private string DeleteAction(JsonArrayParse jp) { JsonObjectCollection collection = new JsonObjectCollection(); int flag = 1; try { BusinessFormula bc = new BusinessFormula(); bc.GetByID(jp.getValue("id")); if (bc.Delete() > 0) { flag = 0; collection.Add(new JsonStringValue("list", createList("", "", "", 1))); } } catch (Exception ex) { flag = 2; collection.Add(new JsonStringValue("ex", ex.Message)); } collection.Add(new JsonStringValue("type", "delete")); collection.Add(new JsonNumericValue("flag", flag)); return(collection.ToString()); }