Exemplo n.º 1
0
        private void GetList(HttpContext context, string btn)
        {
            if (btn != "show")
            {
                context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}");
                return;
            }
            try
            {
                BLL.sys_Bulletin bll = new BLL.sys_Bulletin();

                string strWhere = "";

                DataTable     dt      = bll.GetList(strWhere).Tables[0];
                string        rowsStr = Utils.ToJson(dt);
                StringBuilder jsonStr = new StringBuilder();
                jsonStr.Append("{\"status\":\"1\",\"msg\":\"数据获取成功!\",\"info\":");
                jsonStr.Append("{\"total\":" + dt.Rows.Count + ",\"rows\":");
                jsonStr.Append(rowsStr);
                jsonStr.Append("}}");
                context.Response.Write(jsonStr);
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
                return;
            }
        }
Exemplo n.º 2
0
        private void GetData(HttpContext context, string btn)
        {
            if (btn != "show")
            {
                context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}");
                return;
            }
            try
            {
                int bulletinId       = RequestHelper.GetInt("id", 0);
                BLL.sys_Bulletin bll = new BLL.sys_Bulletin();


                DataTable dt = bll.GetList(bulletinId).Tables[0];
                if (dt.Rows.Count == 0)
                {
                    context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,该条数据已被其他人删除!\"}");
                    return;
                }
                string rowsStr = Utils.ToJson(dt);

                string attachStr = "";
                string attachId  = Utils.ObjectToStr(dt.Rows[0]["Attachment"]);
                if (attachId != "" && attachId != "0")
                {
                    DataTable attachDT = new BLL.System.sys_Attachment().GetList("ID in(" + attachId + ")").Tables[0];
                    attachStr = Utils.ToJson(attachDT);
                }

                StringBuilder jsonStr = new StringBuilder();
                jsonStr.Append("{\"status\":\"1\",\"msg\":\"数据获取成功!\",\"info\":");
                jsonStr.Append(rowsStr);
                if (attachStr == "")
                {
                    jsonStr.Append(",\"attachinfo\":\"\"");
                }
                else
                {
                    jsonStr.Append(",\"attachinfo\":" + attachStr);
                }
                jsonStr.Append("}");
                context.Response.Write(jsonStr);
            }
            catch (Exception e)
            {
                context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}");
                return;
            }
        }