public void AddAreaCountry(string id, int tid)
        {
            NSession.Delete("from LogisticsAreaCountryType where  CountryCode=" + id +
                            " and AreaCode in (select Id from LogisticsAreaType where LId =(select LId from LogisticsAreaType where Id=" +
                            tid + "))");
            NSession.Flush();
            LogisticsAreaCountryType logcountry = new LogisticsAreaCountryType {
                CountryCode = id, AreaCode = tid
            };

            NSession.Save(logcountry);
        }
 public ActionResult Edit(LogisticsAreaCountryType obj)
 {
     try
     {
         NSession.Update(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
        /// <summary>
        /// 根据Id获取
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public LogisticsAreaCountryType GetById(int Id)
        {
            LogisticsAreaCountryType obj = NSession.Get <LogisticsAreaCountryType>(Id);

            if (obj == null)
            {
                throw new Exception("返回实体为空");
            }
            else
            {
                return(obj);
            }
        }
 public JsonResult DeleteConfirmed(int id)
 {
     try
     {
         LogisticsAreaCountryType obj = GetById(id);
         NSession.Delete(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return(Json(new { IsSuccess = false, ErrorMsg = "出错了" }));
     }
     return(Json(new { IsSuccess = true }));
 }
        public void DelAreaCountry(string id, int tid)
        {
            LogisticsAreaCountryType logc = new LogisticsAreaCountryType {
                CountryCode = id.ToString(), AreaCode = tid
            };
            IList <LogisticsAreaCountryType> list = NSession.CreateCriteria(typeof(LogisticsAreaCountryType))
                                                    .Add(Example.Create(logc))
                                                    .List <LogisticsAreaCountryType>();

            foreach (LogisticsAreaCountryType item in list)
            {
                NSession.Delete(item);
                NSession.Flush();
            }
        }
        public ActionResult Edit(int id)
        {
            LogisticsAreaCountryType obj = GetById(id);

            return(View(obj));
        }