Пример #1
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="context"></param>
 private void Upt(HttpContext context)
 {
     entity.ResponseResult result = new entity.ResponseResult();
     try
     {
         Models.CustomForm model = new Models.CustomForm();
         model.ID   = Convert.ToInt32(context.Request.Form["ID"]);
         model.Name = context.Request.Form["Name"];
         List <entity.Fields> fields = JsonConvert.DeserializeObject <List <entity.Fields> >(context.Request.Form["Fields"]);
         model.Fields   = JsonConvert.SerializeObject(fields);
         model.SQL      = context.Request.Form["SQL"];
         model.ModuleID = context.Request.Form["ModuleID"];
         if (string.IsNullOrWhiteSpace(model.Name) || fields.Count == 0 || string.IsNullOrWhiteSpace(model.SQL) || model.ID == 0)
         {
             result.IsSuccess = false;
             result.Message   = "自定义内容,全部都为必填项。";
         }
         else
         {
             if (model.SQL.ToLower().Trim().StartsWith("select") == false)
             {
                 result.IsSuccess = false;
                 result.Message   = "SQL语句只能为select语句。";
             }
             else
             {
                 string validSqlMsg = "";
                 bool   isValidSql  = ValidateSQL(model.SQL, fields, ref validSqlMsg);
                 if (!isValidSql)
                 {
                     result.IsSuccess = false;
                     result.Message   = validSqlMsg;
                 }
                 else
                 {
                     int flag = CustomFormDal.GetCustomFormDAL.UpdateCustomForm(model);
                     if (flag > 0)
                     {
                         result.IsSuccess = true;
                         result.Message   = "修改成功。";
                     }
                     else
                     {
                         result.IsSuccess = false;
                         result.Message   = "修改失败,请稍后重试。";
                     }
                 }
             }
         }
     }
     catch
     {
         result.IsSuccess = false;
         result.Message   = "修改失败,请稍后重试。";
     }
     context.Response.Write(JsonConvert.SerializeObject(result));
 }
Пример #2
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="context"></param>
        private void Det(HttpContext context)
        {
            entity.ResponseResult result = new entity.ResponseResult();
            int[] ids  = JsonConvert.DeserializeObject <int[]>(context.Request.Form["ids"]);
            bool  flag = DAL.CustomFormDal.GetCustomFormDAL.BatchDelete(ids);

            if (flag)
            {
                result.IsSuccess = true;
                result.Message   = "删除成功";
            }
            else
            {
                result.IsSuccess = false;
                result.Message   = "删除失败,请稍后重试";
            }
            context.Response.Write(JsonConvert.SerializeObject(result));
        }