Exemplo n.º 1
0
 /// <summary>
 /// 创建一个方案_规程
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个方案_规程</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, SCHEME_RULE entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public Common.ClientResult.Result Post([FromBody] SCHEME_RULE entity)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (entity != null && ModelState.IsValid)
            {
                string currentPerson = GetCurrentPerson();
                entity.CREATETIME   = DateTime.Now;
                entity.CREATEPERSON = currentPerson;

                entity.ID = Result.GetNewId();
                string returnValue = string.Empty;
                if (m_BLL.Create(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",方案_规程的信息的Id为" + entity.ID, "方案_规程"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.InsertSucceed;
                    return(result); //提示创建成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",方案_规程的信息," + returnValue, "方案_规程"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.InsertFail + returnValue;
                    return(result); //提示插入失败
                }
            }

            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            return(result);
        }
Exemplo n.º 3
0
        // PUT api/<controller>/5
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Common.ClientResult.Result Put([FromBody] SCHEME_RULE entity)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (entity != null && ModelState.IsValid)
            {   //数据校验
                string currentPerson = GetCurrentPerson();
                entity.UPDATETIME   = DateTime.Now;
                entity.UPDATEPERSON = currentPerson;

                string returnValue = string.Empty;
                if (m_BLL.Edit(ref validationErrors, entity))
                {
                    LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",方案_规程信息的Id为" + entity.ID, "方案_规程"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.UpdateSucceed;
                    return(result); //提示更新成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",方案_规程信息的Id为" + entity.ID + "," + returnValue, "方案_规程"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.UpdateFail + returnValue;
                    return(result); //提示更新失败
                }
            }
            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式";
            return(result); //提示输入的数据的格式不对
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="ID">方案编号</param>
        /// <param name="NAME">方案名称</param>
        /// <param name="UNDERTAKE_LABORATORYID">实验室编号</param>
        /// <param name="RULEIDs">检查项编号多个,分割例如(1,2)</param>
        /// <returns></returns>
        public ActionResult UpdateSave(string ID, string NAME, string UNDERTAKE_LABORATORYID, string RULEIDs)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (ID != null && ID.Trim() != "")
            {
                SCHEME entity = m_BLL.GetById(ID);


                if (entity != null && ModelState.IsValid)
                {   //数据校验
                    string currentPerson = GetCurrentPerson();
                    entity.UPDATEPERSON           = currentPerson;
                    entity.UPDATETIME             = DateTime.Now;
                    entity.NAME                   = NAME;
                    entity.UNDERTAKE_LABORATORYID = UNDERTAKE_LABORATORYID;

                    if (entity.SCHEME_RULE != null && entity.SCHEME_RULE.Count > 0)
                    {
                        SCHEME_RULEBLL rBll = new SCHEME_RULEBLL();
                        string[]       rIDs = new string[entity.SCHEME_RULE.Count];
                        int            i    = 0;
                        foreach (SCHEME_RULE r in entity.SCHEME_RULE.ToList())
                        {
                            rIDs[i] = r.ID;
                            i++;
                        }
                        rBll.DeleteCollection(ref validationErrors, rIDs);
                    }

                    if (RULEIDs != null && RULEIDs.Trim() != "")
                    {
                        int      i          = 1;
                        string[] RULEIDList = RULEIDs.Split(',');
                        foreach (string ruleID in RULEIDList)
                        {
                            if (ruleID != null && ruleID.Trim() != "")
                            {
                                SCHEME_RULE item = new SCHEME_RULE();
                                item.CREATEPERSON = currentPerson;
                                item.CREATETIME   = DateTime.Now;
                                item.RULEID       = ruleID;
                                item.SCHEMEID     = entity.ID;
                                item.ID           = Result.GetNewId();
                                item.SORT         = i;
                                entity.SCHEME_RULE.Add(item);
                                i++;
                            }
                        }
                    }

                    string returnValue = string.Empty;
                    if (m_BLL.Edit(ref validationErrors, entity))
                    {
                        LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",方案信息的Id为" + entity.ID, "方案"
                                                       );//写入日志
                        result.Code    = Common.ClientCode.Succeed;
                        result.Message = Suggestion.UpdateSucceed;
                        return(Json(result)); //提示更新成功
                    }
                    else
                    {
                        if (validationErrors != null && validationErrors.Count > 0)
                        {
                            validationErrors.All(a =>
                            {
                                returnValue += a.ErrorMessage;
                                return(true);
                            });
                        }
                        LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",方案信息的Id为" + entity.ID + "," + returnValue, "方案"
                                                       );//写入日志
                        result.Code    = Common.ClientCode.Fail;
                        result.Message = Suggestion.UpdateFail + returnValue;
                        return(Json(result)); //提示更新失败
                    }
                }
                result.Code    = Common.ClientCode.FindNull;
                result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式";
                return(Json(result)); //提示输入的数据的格式不对
            }
            else
            {
                //return CreateSave(NAME, UNDERTAKE_LABORATORYID, RULEIDs);
                result.Code    = Common.ClientCode.FindNull;
                result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式";
                return(Json(result)); //提示输入的数据的格式不对
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="NAME">方案名称</param>
        /// <param name="UNDERTAKE_LABORATORYID">实验室编号</param>
        /// <param name="RULEIDs">检查项编号多个,分割例如(1,2)</param>
        /// <param name="COPYID">复制方案ID</param>
        /// <returns></returns>
        public ActionResult CreateSave(string NAME, string UNDERTAKE_LABORATORYID, string RULEIDs, string COPYID)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            SCHEME entity        = new SCHEME();
            string currentPerson = GetCurrentPerson();

            entity.CREATETIME             = DateTime.Now;
            entity.CREATEPERSON           = currentPerson;
            entity.UNDERTAKE_LABORATORYID = UNDERTAKE_LABORATORYID;
            entity.ID     = Result.GetNewId();
            entity.STATUS = "未使用";
            entity.ISSTOP = "停用";
            entity.NAME   = NAME;
            entity.COPYID = COPYID;
            if (RULEIDs != null && RULEIDs.Trim() != "")
            {
                string[] RULEIDList = RULEIDs.Split(',');
                int      i          = 1;
                foreach (string ruleID in RULEIDList)
                {
                    if (ruleID != null && ruleID.Trim() != "")
                    {
                        SCHEME_RULE item = new SCHEME_RULE();
                        item.CREATEPERSON = currentPerson;
                        item.CREATETIME   = DateTime.Now;
                        item.RULEID       = ruleID;
                        item.SCHEMEID     = entity.ID;
                        item.ID           = Result.GetNewId();
                        item.SORT         = i;
                        entity.SCHEME_RULE.Add(item);
                        i++;
                    }
                }
            }

            string returnValue = string.Empty;

            if (m_BLL.Create(ref validationErrors, entity))
            {
                LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",方案的信息的Id为" + entity.ID, "方案"
                                               );//写入日志
                result.Code = Common.ClientCode.Succeed;
                //result.Message = Suggestion.InsertSucceed;
                result.Message = entity.ID;
                return(Json(result)); //提示创建成功
            }
            else
            {
                if (validationErrors != null && validationErrors.Count > 0)
                {
                    validationErrors.All(a =>
                    {
                        returnValue += a.ErrorMessage;
                        return(true);
                    });
                }
                LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",方案的信息," + returnValue, "方案"
                                               );//写入日志
                result.Code    = Common.ClientCode.Fail;
                result.Message = Suggestion.InsertFail + returnValue;
                return(Json(result)); //提示插入失败
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 根据ID获取数据模型
        /// </summary>
        /// <param name="id">编号</param>
        /// <returns></returns>
        public SCHEME_RULE Get(string id)
        {
            SCHEME_RULE item = m_BLL.GetById(id);

            return(item);
        }