Пример #1
0
 public ActionResult Filed(string code)
 {
     return(new JsonNetResult()
     {
         Data = _dynamicDataservices.GetDyncFieldByFormCode(code)
     });
 }
Пример #2
0
        public ActionResult Save()
        {
            var code      = Request.Form["code"];
            var value     = Request.Form["value"];
            var dataId    = Convert.ToInt32(Request.Form["dataId"]);
            var form      = _dynamicDataservices.GetDyncFormByCode(code);
            var filed     = _dynamicDataservices.GetDyncFieldByFormCode(code);
            var saveModel = value.DeserializeObject <SQLDynamicRow>();

            foreach (var item in saveModel.Row)
            {
                var filedItem = filed.Where(t => t.Name == item.Name).FirstOrDefault();
                item.Type = filedItem.Type;

                if (filedItem.IsNull())
                {
                    throw new FormatException("未能找到对应的字段!!!");
                }

                if (filedItem.Type == "html")
                {
                    item.Value = Request.Form[item.Name];
                }
                //if (filedItem.Fldsz) {
                //	item.Value.Length
                //}
                if (filedItem.Reqd == "1" && item.Value.IsNotNullOrEmpty())
                {
                    throw new FormatException($"{filedItem.Lbl}不能为空!!!");
                }

                if (filedItem.Uuiq == "1" && _dynamicDataservices.ValidateDyncForm(form.Name, filedItem.Name, item.Value, dataId) > 1)
                {
                    throw new FormatException($"{filedItem.Lbl}值已经存在!!!");
                }
            }
            if (dataId == -1)
            {
                _dynamicDataservices.AddDyncTableData(saveModel, form.Name);
            }
            else
            {
                _dynamicDataservices.UpdateDyncTableData(saveModel, form.Name, dataId);
            }

            if (form.Cfmurl.IsNotNullOrEmpty())
            {
                Response.Redirect(form.Cfmurl, true);
            }

            SetMessage(form.Cfmmsg);
            return(Redirect($"~/DyncForm/FormTable?code={code}"));
        }