示例#1
0
        public ViewResult Edit(string id)
        {
            var model = default(WarningCardEntity);

            ViewBag.id = id;
            if (string.IsNullOrEmpty(id))
            {
                Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                model = new WarningCardEntity()
                {
                    SubmitTime = DateTime.Now, SubmitUser = user.UserName, CheckContents = new List <CheckContentEntity>()
                };
            }
            else
            {
                var bll = new WarningCardBLL();
                model = bll.GetDetail(id);
            }

            ViewBag.json = Newtonsoft.Json.JsonConvert.SerializeObject(model.CheckContents);
            DataItemDetailBLL dataitembll = new DataItemDetailBLL();
            var list1 = dataitembll.GetDataItemListByItemCode("预警指标卡类别");
            var data1 = list1.Select(x => new SelectListItem()
            {
                Value = x.ItemValue, Text = x.ItemName
            });

            ViewData["Category"] = data1;
            return(View(model));
        }
示例#2
0
        public void Save(WarningCardEntity model)
        {
            IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();

            try
            {
                var entity = (from q in db.IQueryable <WarningCardEntity>()
                              where q.CardId == model.CardId
                              select q).FirstOrDefault();

                if (entity == null)
                {
                    db.Insert(model);
                    db.Insert(model.CheckContents);
                }
                else
                {
                    entity.CardName     = model.CardName;
                    entity.Category     = model.Category;
                    entity.ModifyTime   = model.ModifyTime;
                    entity.ModifyUserId = model.ModifyUserId;

                    db.Update(entity);

                    var contents = (from q in db.IQueryable <CheckContentEntity>()
                                    where q.CardId == model.CardId
                                    select q).ToList();
                    var deleteitems = contents.Where(x => !model.CheckContents.Any(y => y.CheckContentId == x.CheckContentId)).ToList();
                    db.Delete(deleteitems);

                    foreach (var item in model.CheckContents)
                    {
                        var ss = contents.Find(x => x.CheckContentId == item.CheckContentId);
                        if (ss == null)
                        {
                            db.Insert(item);
                        }
                        else
                        {
                            ss.Content      = item.Content;
                            ss.ModifyTime   = item.ModifyTime;
                            ss.ModifyUserId = item.ModifyUserId;
                            db.Update(ss);
                        }
                    }
                }

                db.Commit();
            }
            catch (Exception)
            {
                db.Rollback();
                throw;
            }
        }
示例#3
0
        public JsonResult Edit(string id, WarningCardEntity model)
        {
            Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();

            if (string.IsNullOrEmpty(id))
            {
                model.CardId = Guid.NewGuid().ToString();
            }
            else
            {
                model.CardId = id;
            }

            model.CreateUserId = model.ModifyUserId = user.UserId;
            model.CreateTime   = model.ModifyTime = DateTime.Now;
            model.DeptId       = user.DeptId;
            if (model.CheckContents == null)
            {
                model.CheckContents = new List <CheckContentEntity>();
            }
            foreach (var item in model.CheckContents)
            {
                if (string.IsNullOrEmpty(item.CheckContentId))
                {
                    item.CheckContentId = Guid.NewGuid().ToString();
                }
                item.CreateUserId = item.ModifyUserId = user.UserId;
                item.CreateTime   = item.ModifyTime = DateTime.Now;
                item.CardId       = model.CardId;
            }
            var success = true;
            var message = "保存成功!";
            var bll     = new WarningCardBLL();

            try
            {
                bll.Save(model);
            }
            catch (Exception e)
            {
                success = false;
                message = e.Message;
            }

            return(Json(new { success, message }));
        }
示例#4
0
 public void Save(WarningCardEntity model)
 {
     this.service.Save(model);
 }