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