public ActionResult DelData(List <bool> Check, List <int> ID, List <short> RowVersion, string PrimaryKeyName) { BannerService svBanner = new BannerService(); var banner = new b2bBanner(); List <b2bBanner> bannerAll = new List <b2bBanner>(); List <int> listID = new List <int>(); List <int> listListNo = new List <int>(); if (PrimaryKeyName == "BannerId") { if (Check.Count() == 1) { banner = svBanner.SelectData <b2bBanner>("BannerID, ListNo", " BannerID = " + ID[0] + " AND WebID = 1").First(); try { svBanner.DelData <b2bBanner>(Check, ID, RowVersion, PrimaryKeyName); } catch (Exception ex) { CreateLogFiles(ex); } bannerAll = svBanner.SelectData <b2bBanner>("BannerID, ListNo", "ListNo > " + banner.ListNo + " AND WebID = 1"); for (var i = 0; i < bannerAll.Count(); i++) { listID.Add(bannerAll[i].BannerID); listListNo.Add(bannerAll[i].ListNo - 1); } svBanner.UpdateBannerListNo(listID, listListNo); } else { //for (var a = 0; a < Check.Count(); a++) //{ var num = 1; for (var i = 0; i < ID.Count(); i++) { if (Check[i] == true) { BannerService svBanner1 = new BannerService(); banner = svBanner1.SelectData <b2bBanner>("BannerID, ListNo", " BannerID = " + ID[i] + " AND WebID = 1").First(); svBanner.UpdateByCondition <b2bBanner>("ListNo = 0 , IsDelete = 1", "BannerID = " + ID[i]); //svBanner.DelData<b2bBanner>(Check, ID, RowVersion, PrimaryKeyName); bannerAll = svBanner.SelectData <b2bBanner>("BannerID, ListNo", "ListNo > " + banner.ListNo + " AND WebID = 1"); for (var j = 0; j < bannerAll.Count(); j++) { listID.Add(bannerAll[j].BannerID); listListNo.Add(bannerAll[j].ListNo - num); } svBanner.UpdateBannerListNo(listID, listListNo); listID.Clear(); listListNo.Clear(); num++; } } //break; //} } } if (svBanner.IsResult) { return(Json(new { Result = true })); } else { return(Json(new { Result = false })); } }