Пример #1
0
        public ActionResult CreateLine(string linecode)
        {
            var model = new TLineEntity();

            if (!string.IsNullOrWhiteSpace(linecode))
            {
                model = tLineRepository.GetSingle(linecode);
            }
            return(View(model));
        }
Пример #2
0
        public ActionResult CreateLine(TLineEntity lineInfoEntity)
        {
            var result            = false;
            ReturnJsonMessage msg = new ReturnJsonMessage();
            var lineLsit          = tLineRepository.GetList();

            if (lineInfoEntity != null)
            {
                #region 验证
                if (lineLsit != null && lineLsit.Count(l => l.LCode == lineInfoEntity.LCode && l.LId != lineInfoEntity.LId) > 0)
                {
                    msg.Text  = "编码已经存在";
                    msg.Value = "error";
                    return(Json(msg));
                }
                if (lineLsit != null && lineLsit.Count(l => l.LName == lineInfoEntity.LName && l.LId != lineInfoEntity.LId) > 0)
                {
                    msg.Text  = "名称已经存在";
                    msg.Value = "error";
                    return(Json(msg));
                }
                if (lineLsit != null && lineLsit.Count(l => l.LFullName == lineInfoEntity.LFullName && l.LId != lineInfoEntity.LId) > 0)
                {
                    msg.Text  = "全称已经存在";
                    msg.Value = "error";
                    return(Json(msg));
                }
                #endregion

                if (lineInfoEntity.LId == 0)
                {
                    result = tLineRepository.AddReturnInt(lineInfoEntity) > 0;
                }
                else
                {
                    var lineModel = lineLsit.FirstOrDefault(l => l.LCode == lineInfoEntity.LCode);
                    lineModel.LName     = lineInfoEntity.LName;
                    lineModel.LFullName = lineInfoEntity.LFullName;
                    lineModel.LType     = lineInfoEntity.LType;

                    result = tLineRepository.Update(lineModel);
                }
            }


            msg.Text  = result ? "保存成功" : "保存失败";
            msg.Value = result ? "success" : "error";

            return(Json(msg));
        }