/// <summary> /// 判断是否允许往订单中增加此物品 /// </summary> /// <param name="operation">操作方式, 添加或更新</param> /// <param name="bargainNumber">合同号</param> /// <param name="goods">要增加或更新的物品信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>允许返回true, 否则返回false</returns> private bool AllowGoods(string operation, string bargainNumber, B_OrderFormGoods goods, out string error) { IQueryable <View_B_OrderFormInfo> orderFormGroup = m_orderFormServer.GetOrderFormCollection(bargainNumber); error = null; IQueryable <View_B_OrderFormGoods> goodsGroup = m_serverOrderFormGoods.GetOrderFormGoods(bargainNumber); if (goodsGroup == null || goodsGroup.Count() == 0) { return(true); } List <View_B_OrderFormGoods> lstGoods = goodsGroup.ToList(); View_B_OrderFormGoods findResult = lstGoods.Find(p => p.物品ID == goods.GoodsID); if (findResult == null) { return(true); } if (operation == "更新" && findResult.订单号 == goods.OrderFormNumber) { return(true); } error = string.Format("{0} 订单已经存在物品:{1},{2},{3},不允许再重复!", findResult.订单号, findResult.图号型号, findResult.物品名称, findResult.规格); return(false); }
/// <summary> /// 删除合同信息 /// </summary> /// <param name="bargainNumber">合同编号</param> /// <param name="returnBargainInfo">返回查询到的合同信息</param> /// <param name="error">错误信息, 没有则为null</param> /// <returns>操作是否成功的标志</returns> public bool DeleteBargainInfo(string bargainNumber, out IQueryResult returnBargainInfo, out string error) { error = null; returnBargainInfo = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; IBargainGoodsServer goodsServer = ServerModuleFactory.GetServerModule <IBargainGoodsServer>(); IQueryable <View_B_BargainGoods> returnBargainGoods; if (!goodsServer.GetBargainGoods(bargainNumber, out returnBargainGoods, out error)) { return(false); } #region 检查此合同的订单信息 IOrderFormInfoServer orderFormServer = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>(); if (orderFormServer.GetOrderFormCollection(bargainNumber).Count() > 0) { error = string.Format("合同 [{0}] 还包含有订单信息无法进行删除,请将所有此合同包含的订单信息全部删除后才能进行此操作!", bargainNumber); return(false); } #endregion if (returnBargainGoods != null && returnBargainGoods.Count() > 0) { error = string.Format("合同 [{0}] 还包含有零件信息无法进行删除,请将所有此合同包含的零件信息全部删除后才能进行此操作!", bargainNumber); return(false); } Table <B_BargainInfo> table = dataContxt.GetTable <B_BargainInfo>(); var delRow = from c in table where c.BargainNumber == bargainNumber select c; table.DeleteAllOnSubmit(delRow); dataContxt.SubmitChanges(); return(GetAllBargainInfo(out returnBargainInfo, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }