/// <summary> /// 插入领料单明细信息 /// </summary> /// <param name="ctx">LINQ数据上下文</param> /// <param name="goodsTable">售后服务配件申请单分解的零件清单</param> /// <param name="storageID">库房ID</param> /// <param name="materialBillID">领料单单号</param> /// <param name="error">失败时返回的错误信息</param> /// <returns>返回TRUE表示成功,返回FALSE表示插入失败</returns> private bool InsertMaterialRequisitionList(DepotManagementDataContext ctx, ref DataTable goodsTable, string storageID, string materialBillID, out string error) { error = null; string strOutMessage = ""; try { for (int i = 0; i < goodsTable.Rows.Count; i++) { List <View_S_Stock> lstStock = m_storeServer.GetGoodsStoreOnlyForSBW(goodsTable.Rows[i]["GoodsCode"].ToString(), goodsTable.Rows[i]["GoodsName"].ToString(), goodsTable.Rows[i]["Spec"].ToString(), storageID).ToList(); if (lstStock.Count > 0) { foreach (View_S_Stock item in lstStock) { S_MaterialRequisitionGoods lnqMaterialList = new S_MaterialRequisitionGoods(); lnqMaterialList.BasicCount = 0; lnqMaterialList.BatchNo = item.批次号; lnqMaterialList.Bill_ID = materialBillID; lnqMaterialList.GoodsID = item.物品ID; lnqMaterialList.ProviderCode = item.供货单位; if (Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) > item.库存数量) { lnqMaterialList.RequestCount = Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]); lnqMaterialList.RealCount = item.库存数量; } else { lnqMaterialList.RequestCount = Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]); lnqMaterialList.RealCount = Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]); } lnqMaterialList.Remark = ""; lnqMaterialList.ShowPosition = 1; MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer(); if (!serverMaterialGoods.AutoCreateGoods(ctx, lnqMaterialList, out error)) { throw new Exception(error); } goodsTable.Rows[i]["RequestCount"] = Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) - lnqMaterialList.RealCount; if (Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) == 0) { break; } } } if (Convert.ToDecimal(goodsTable.Rows[i]["RequestCount"]) > 0) { strOutMessage = strOutMessage + "【图号型号】:" + goodsTable.Rows[i]["GoodsCode"].ToString() + " 【物品名称】:" + goodsTable.Rows[i]["GoodsName"].ToString() + " 【规格】:" + goodsTable.Rows[i]["Spec"].ToString() + " 【数量】:" + goodsTable.Rows[i]["RequestCount"].ToString() + "\r\n"; } } error = strOutMessage; return(true); } catch (Exception ex) { error = ex.Message; return(false); } }