Esempio n. 1
0
        public static bool SaveCatalog(F_CATALOG entity)
        {
            using (MainDataContext dbContext = new MainDataContext())
            {
                if (entity.ID == 0)
                {
                    var list = from a in dbContext.F_CATALOG select a.ID;

                    long total = list.LongCount();

                    if (total == 0)
                    {
                        entity.ID = 1;
                    }
                    else
                    {
                        entity.ID = dbContext.F_CATALOG.Max(a => a.ID) + 1;
                    }

                    dbContext.F_CATALOG.InsertOnSubmit(entity);
                }
                else
                {
                    var model = dbContext.F_CATALOG.FirstOrDefault(t => t.ID == entity.ID);

                    model.Name = entity.Name;
                }
                dbContext.SubmitChanges();
                return(true);
            }
        }
Esempio n. 2
0
        public ActionResult FlowCatalogSave(int id, string name)
        {
            Flow      flow   = new Flow();
            F_CATALOG entity = new F_CATALOG();

            entity.ID   = id;
            entity.Name = name;

            if (ModelState.IsValid)
            {
                bool save;

                try
                {
                    save = flow.SaveCatalog(entity);
                }
                catch (Exception)
                {
                    save = false;
                }

                if (save)
                {
                    return(Json(new { IsSuccess = true, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { IsSuccess = false, Message = "保存失败" }, "text/html", JsonRequestBehavior.AllowGet));
                }
            }

            return(View());
        }
Esempio n. 3
0
 public bool SaveCatalog(F_CATALOG entity)
 {
     return(DAL.WorkFlow.Flow.SaveCatalog(entity));
 }