public ApiMessage EnterStockFromBuy() { HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; HttpRequestBase request = context.Request; string user_id = User.Identity.Name; UserManager userMgr = new UserManager(int.Parse(user_id), null); BUser user = userMgr.CurrentUser; StockManager stockManager = new StockManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); BuyManager buyManager = new BuyManager(userMgr.CurrentUser, userMgr.Shop, userMgr.CurrentUserPermission); ApiMessage message = new ApiMessage(); int[] buy_ids = null; int updateStock = 0; int shouseId = 0; buy_ids = base.ConvertToIntArrar(request["buy_ids"]); int.TryParse(request["update_stock"], out updateStock); int.TryParse(request["house_id"], out shouseId); try { if (buy_ids != null) { foreach (int buy_id in buy_ids) { BEnterStock stock = new BEnterStock(); stock.BuyID = buy_id; stock.Created = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now); stock.StoreHouse = new BStoreHouse() { ID = shouseId, Shop = new BShop() { ID = stockManager.Shop.Shop_ID } }; if (updateStock == 1) { stock.UpdateStock = true; } stockManager.CreateEnterStock(stock); } } message.Status = "ok"; message.Message = ""; } catch (JXC.Common.KMException.KMJXCException kex) { message.Status = "failed"; message.Message = kex.Message; } catch (Exception ex) { message.Status = "failed"; message.Message = "未知错误"; } finally { } return(message); }