Exemplo n.º 1
0
        public ActionResult AutoMerge(string IDs, string Value)
        {
            using (DicMainDb db = new DicMainDb())
            {
                string[] idarr = IDs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                List <int> idlist = new List <int>();

                foreach (var id in idarr)
                {
                    idlist.Add(Int32.Parse(id));
                }
                var list = db.RcsDic.Where(p => idlist.Contains(p.ID)).ToList();

                foreach (var t in list)
                {
                    db.RcsDic.Attach(t);
                    var entity = db.Entry(t);

                    entity.State = System.Data.Entity.EntityState.Deleted;
                }

                var defalutTable = db.RcsTable.Where(p => p.Name == "defaultdic").First();


                RcsDic newmodel = new RcsDic();

                newmodel.Name    = list[0].Name;
                newmodel.Value   = Value;
                newmodel.Type    = 1;
                newmodel.TableID = defalutTable.ID;

                db.RcsDic.Add(newmodel);

                db.SaveChanges();

                string sql = @"update [dbo].[RcsTable] set Count=(
select count(0) from [dbo].[RcsDic] t1
where t1.TableID=[RcsTable].ID
)";
                db.Database.ExecuteSqlCommand(sql);
            }

            return(Json(1));
        }
Exemplo n.º 2
0
 public ActionResult EditAciton(RcsTable t)
 {
     using (DicMainDb maindb = new DicMainDb())
     {
         if (t.ID == 0)
         {
             maindb.RcsTable.Add(t);
         }
         else
         {
             maindb.RcsTable.Attach(t);
             var entity = maindb.Entry(t);
             entity.State = System.Data.Entity.EntityState.Modified;
         }
         maindb.SaveChanges();
     }
     return(Json(new {
         success = true
     }));
 }
Exemplo n.º 3
0
 public ActionResult EditAciton(RcsDic t)
 {
     using (DicMainDb maindb = new DicMainDb())
     {
         if (t.ID == 0)
         {
             maindb.RcsDic.Add(t);
             var table = maindb.RcsTable.Where(p => p.ID == t.TableID).FirstOrDefault();
             table.Count = table.Count + 1;
         }
         else
         {
             maindb.RcsDic.Attach(t);
             var entity = maindb.Entry(t);
             entity.State = System.Data.Entity.EntityState.Modified;
         }
         maindb.SaveChanges();
     }
     return(Json(new
     {
         success = true
     }));
 }