Ejemplo n.º 1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public int SaveForm(string keyValue, RiskPlanEntity entity)
 {
     try
     {
         return(service.SaveForm(keyValue, entity));
     }
     catch (Exception ex)
     {
         return(0);
         //throw;
     }
 }
Ejemplo n.º 2
0
        public ActionResult SaveForm(string keyValue, RiskPlanEntity entity, [System.Web.Http.FromBody] string dataJson)
        {
            StringBuilder sb      = new StringBuilder();
            List <string> listIds = new List <string>();

            string[] arr = entity.AreaId.Split(',');
            foreach (string str in arr)
            {
                if (!listIds.Contains(str))
                {
                    listIds.Add(str);
                }
            }
            foreach (string str in listIds)
            {
                sb.Append(str + ",");
            }
            entity.AreaId = sb.ToString().TrimEnd(',');

            if (riskplanbll.SaveForm(keyValue, entity) > 0)
            {
                //保存关联的从表记录
                if (dataJson.Length > 0)
                {
                    RiskPlanDataBLL riskplandatabll = new RiskPlanDataBLL();
                    if (riskplandatabll.Remove(entity.Id) > 0)
                    {
                        List <RiskPlanDataEntity> list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <RiskPlanDataEntity> >(dataJson);
                        foreach (RiskPlanDataEntity data in list)
                        {
                            riskplandatabll.SaveForm("", data);
                        }
                    }
                }
                entity.RiskNumbers = riskplanbll.GetRiskNumbers(entity.AreaId, entity.StartDate.ToString(), entity.Id);
                if (riskplanbll.SaveForm(entity.Id, entity) <= 0)
                {
                    return(Error("操作失败"));
                }
            }
            return(Success("操作成功。"));
        }