public JsonResult Create(CountryType obj)
 {
     try
     {
         if(IsCreateOk(obj.ECountry))
         return Json(new { errorMsg = "编号已经存在" });
         NSession.SaveOrUpdate(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
     }
     return Json(new { IsSuccess = true  });
 }
        public JsonResult GetUnCountryByAreaCode(string sort, string order, int id, string s)
        {
            string orderby = " order by Id desc ";
            if (!string.IsNullOrEmpty(sort) && !string.IsNullOrEmpty(order))
            {
                orderby = "order by " + sort + " " + order;
            }
            IList<object[]> list = NSession.CreateSQLQuery("select Id,CCountry,ECountry,CountryCode,(select AreaName from LogisticsArea where ID=(select top 1 AreaCode from LogisticsAreaCountry la where c.Id= la.CountryCode and la.AreaCode in (select ID from LogisticsArea where LId =(select LId from LogisticsArea where LogisticsArea.Id=:cid)))) as AreaNane from Country c where c.Id not in (select CountryCode from LogisticsAreaCountry where AreaCode=:cid ) and (CCountry like'%" + s + "%' or ECountry like '%" + s + "%')" + orderby)
              .SetInt32("cid", id)
              .List<object[]>();
            List<CountryType> l = new List<CountryType>();

            foreach (object[] foo in list)
            {
                CountryType c = new CountryType();
                c.Id = Utilities.ToInt(foo[0]);
                c.CCountry = foo[1].ToStr();
                c.ECountry = foo[2].ToStr();
                c.CountryCode = foo[3].ToStr();
                c.AreaName = foo[4].ToStr();
                l.Add(c);
            }

            return Json(new { total = l.Count, rows = l });

        }
 public ActionResult Edit(CountryType obj)
 {
     try
     {
         if (IsOk(obj.Id,obj.ECountry))
             return Json(new { errorMsg = "编号已经存在" });
         NSession.Update(obj);
         NSession.Flush();
     }
     catch (Exception ee)
     {
         return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
     }
     return Json(new { IsSuccess = true  });
 }