Exemplo n.º 1
0
 public static string GetDataList(int PageIndex, int PageSize)
 {
     try
     {
         int               intRecordCount = 0;
         List <object>     listReturn     = new List <object>();
         BLL_CustomizeHtml bll            = new BLL_CustomizeHtml();
         DataTable         dt             = bll.GetListByPage("", "CreateTime desc", ((PageIndex - 1) * PageSize + 1), PageIndex * PageSize).Tables[0];
         intRecordCount = bll.GetRecordCount("");
         foreach (DataRow item in dt.Rows)
         {
             listReturn.Add(new
             {
                 CustomizeHtml_Id = item["CustomizeHtml_Id"].ToString(),
                 HtmlType         = item["HtmlType"].ToString(),
                 HtmlContent      = pfunction.GetSubstring(pfunction.DeleteHTML(item["HtmlContent"].ToString()), 200, true),
                 CreateTime       = pfunction.ConvertToLongDateTime(item["CreateTime"].ToString())
             });
         }
         if (dt.Rows.Count > 0)
         {
             return(JsonConvert.SerializeObject(new
             {
                 err = "null",
                 PageIndex = PageIndex,
                 PageSize = PageSize,
                 TotalCount = intRecordCount,
                 list = listReturn
             }));
         }
         else
         {
             return(JsonConvert.SerializeObject(new
             {
                 err = "暂无数据"
             }));
         }
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new
         {
             err = "error"
         }));
     }
 }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(tId))
                {
                    #region 添加
                    //验证该类型是否已添加数据
                    if (bll.GetRecordCount("HtmlType='" + ddlSType.SelectedValue + "'") > 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.ready(function(){layer.msg('该类型数据已添加。', { time: 2000, icon: 4})});</script>");
                        return;
                    }

                    model.CustomizeHtml_Id = Guid.NewGuid().ToString();
                    model.HtmlType         = ddlSType.SelectedValue;
                    model.HtmlContent      = txt_content.Value;
                    model.CreateTime       = DateTime.Now;
                    model.CreateUser       = loginUser.SysUser_ID;
                    if (bll.Add(model))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(function(){layer.msg('新增成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index)});});</script>");
                        return;
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(layer.msg('新增失败!',{ time: 2000,icon:2}););</script>");
                        return;
                    }
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "新增自定义html");
                    #endregion
                }
                else
                {
                    #region 修改
                    //验证该类型是否已添加数据
                    if (bll.GetRecordCount("CustomizeHtml_Id!='" + tId + "' and HtmlType='" + ddlSType.SelectedValue + "'") > 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.ready(function(){layer.msg('该类型数据已添加。', { time: 2000, icon: 4})});</script>");
                        return;
                    }
                    model             = bll.GetModel(tId);
                    model.HtmlType    = ddlSType.SelectedValue;
                    model.HtmlContent = txt_content.Value;
                    model.CreateTime  = DateTime.Now;
                    model.CreateUser  = loginUser.SysUser_ID;
                    if (bll.Update(model))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>layer.ready(function(){layer.msg('修改成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});});</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(function(){layer.msg('修改失败!',{ time: 2000,icon:2});});</script>");
                        return;
                    }
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(loginUser.SysUser_ID, "", "修改自定义html");
                    #endregion
                }
            }
            catch (Exception)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.ready(function(){layer.msg('操作失败!',{ time: 2000,icon:2});});</script>");
            }
        }