Ejemplo n.º 1
0
 public ActionResult UpdateCost(string key)
 {
     try
     {
         if (key != Keyapi)
         {
             return(Json(0, JsonRequestBehavior.AllowGet));
         }
         var lst1  = Request["lstRet1"];
         var lst2  = Request["lstRet2"];
         var model = _da.GetById(ItemId);
         while (model.Cost_Product.Count > 0)
         {
             var item = model.Cost_Product.FirstOrDefault();
             _da.Delete(item);
         }
         while (model.Cost_Product_User.Count > 0)
         {
             var item = model.Cost_Product_User.FirstOrDefault();
             _da.Delete(item);
         }
         model.Cost_Product.Clear();
         model.Cost_Product_User.Clear();
         model.Cost_Product      = JsonConvert.DeserializeObject <List <Cost_Product> >(lst1);
         model.Cost_Product_User = JsonConvert.DeserializeObject <List <Cost_Product_User> >(lst2);
         _da.Save();
         return(Json(1, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(0, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 2
0
        //D
        public ResultMessage Delete(int id)
        {
            if (_da.IsInuse(id))
            {
                return(new ResultMessage(false, "\r\n已经在单据中使用,不能删除。\r\n可以设为'停用'"));
            }
            else if (_da.Delete(id) <= 0)
            {
                return(new ResultMessage(false, "记录不存在"));
            }

            return(new ResultMessage(true, string.Empty));
        }
 public ActionResult DeleteProduct(Product P)
 {
     ProductDA.Delete(P.ID);
     return(RedirectToAction("ManageProducts"));
 }