public ActionResult Edit(SupplierType obj)
        {

            try
            {
                List<SuppliersProductType> list1 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SuppliersProductType>>(obj.rows);
                NSession.Update(obj);
                NSession.Flush();
                NSession.Delete("from SuppliersProductType where SId='" + obj.Id + "'");
                NSession.Flush();
                NSession.Clear();
                foreach (SuppliersProductType product in list1)
                {
                    product.SId = obj.Id;
                    NSession.Save(product);
                    NSession.Flush();
                }
            }
            catch (Exception ee)
            {
                return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
            }
            return Json(new { IsSuccess = true });

        }
 private void SaveSupplier(PurchasePlanType obj)
 {
     object exit = NSession.CreateQuery("from SupplierType where SuppliersName='"+obj.Suppliers+"'").UniqueResult();
     if (exit==null)
     {
         SupplierType super = new SupplierType
         {
             SuppliersName = obj.Suppliers
         };
         NSession.Save(super);
         NSession.Flush();
         SuppliersProductType product = new SuppliersProductType
         {
             SId = super.Id,
             SKU = obj.SKU,
             Price = obj.Price,
             Web = obj.ProductUrl
         };
         NSession.Save(product);
         NSession.Flush();
     }
     else
     {
         IList<SupplierType> list = NSession.CreateQuery("from SupplierType where SuppliersName='" + obj.Suppliers + "'").List<SupplierType>();
         object productexit = NSession.CreateQuery("from SuppliersProductType where SId='" +list[0].Id+ "' and SKU='"+obj.SKU+"' ").UniqueResult();
         if (productexit == null)
         {
             SuppliersProductType product = new SuppliersProductType
             {
                 SId = list[0].Id,
                 SKU = obj.SKU,
                 Price = obj.Price,
                 Web = obj.ProductUrl
             };
             NSession.Save(product);
             NSession.Flush();
         }
     }
 }