Example #1
0
 /// <summary>
 /// 排序
 /// </summary>
 /// <param name="ID"></param>
 /// <param name="IsUp"></param>
 public void Sort(int ID, bool IsUp)
 {
     using (var ct = new DS_SysProductCategoryDataContext(DbHelperSQL.Connection))
     {
         var md = ct.DS_SysProductCategory.Single(a => a.ID == ID);
         ct.ExecuteCommand("update DS_SysProductCategory  set px=(select RowNumber from (select (ROW_NUMBER() OVER (ORDER BY px)) AS RowNumber,id from DS_SysProductCategory where  parentid={0}) as p2 where id=DS_SysProductCategory.id) where parentid={0}", md.ParentID);
         if (IsUp)
         {
             DS_SysProductCategory p = ct.DS_SysProductCategory.Single(a => a.ID == ID);
             DS_SysProductCategory p1;
             if (p.Px > 1)
             {
                 p1 = ct.DS_SysProductCategory.Single(a => a.Px == (p.Px - 1) && a.ParentID == md.ParentID);
                 p.Px--;
                 p1.Px++;
             }
         }
         else
         {
             DS_SysProductCategory p = ct.DS_SysProductCategory.Single(a => a.ID == ID);
             DS_SysProductCategory p1;
             if (p.Px < ct.DS_SysProductCategory.Where(a => a.ParentID == md.ParentID).Count())
             {
                 p1 = ct.DS_SysProductCategory.Single(a => a.Px == (p.Px + 1) && a.ParentID == md.ParentID);
                 p.Px++;
                 p1.Px--;
             }
         }
         ct.SubmitChanges();
     }
 }
Example #2
0
 public void Update(DS_SysProductCategory SysProductCategory)
 {
     using (var ct = new DS_SysProductCategoryDataContext(DbHelperSQL.Connection))
     {
         ct.DS_SysProductCategory.Attach(SysProductCategory, true);
         ct.SubmitChanges();
     }
 }
Example #3
0
 public void Add(DS_SysProductCategory SysProductCategory)
 {
     using (var ct = new DS_SysProductCategoryDataContext(DbHelperSQL.Connection))
     {
         ct.DS_SysProductCategory.InsertOnSubmit(SysProductCategory);
         ct.SubmitChanges();
     }
 }
Example #4
0
 public void Delete(int ID)
 {
     using (var ct = new DS_SysProductCategoryDataContext(DbHelperSQL.Connection))
     {
         var st = ct.DS_SysProductCategory.Single(a => a.ID == ID);
         ct.DS_SysProductCategory.DeleteOnSubmit(st);
         ct.SubmitChanges();
     }
 }
Example #5
0
        public void Delete(string Ids)
        {
            using (var ct = new DS_SysProductCategoryDataContext(DbHelperSQL.Connection))
            {
                string[] idarray  = Ids.Split(',');
                int[]    intarray = new int[idarray.Length];
                for (int i = 0; i < idarray.Length; i++)
                {
                    intarray[i] = int.Parse(idarray[i]);
                    var list1 = ct.DS_SysProductCategory.Where(a => a.ParentID == intarray[i]);
                    foreach (var item in list1)
                    {
                        ct.DS_SysProductCategory.DeleteAllOnSubmit(ct.DS_SysProductCategory.Where(a => a.ParentID == item.ID));
                    }
                    ct.DS_SysProductCategory.DeleteAllOnSubmit(list1);
                }
                var list = ct.DS_SysProductCategory.Where(a => idarray.Contains(a.ID.ToString()));
                ct.DS_SysProductCategory.DeleteAllOnSubmit(list);

                ct.SubmitChanges();
            }
        }