public JsonResult Save(SuppliersProductType obj)
 {
     try
     {
         List<SuppliersProductType> list = Session["SupplierProducts"] as List<SuppliersProductType>;
         if (list == null)
             list = new List<SuppliersProductType>();
         SuppliersProductType findOne = list.Find(p => p.SKU == obj.SKU);
         if (findOne != null)
         {
             // findOne = obj;
             list.Remove(findOne);
             list.Add(obj);
         }
         else
         {
             list.Add(obj);
         }
         Session["SupplierProducts"] = list;
     }
     catch (Exception ee)
     {
         return Json(new { IsSuccess = false, ErrorMsg = "出错了" });
     }
     return Json(new { IsSuccess = true  });
 }
 public JsonResult Create(SuppliersProductType obj)
 {
     try
     {
        
         NSession.SaveOrUpdate(obj);
         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();
         }
     }
 }