/// <summary> /// 提交单据 /// </summary> /// <param name="billNo">单号</param> /// <param name="listInfo">明细信息</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,否则False</returns> public bool SubmitInfo(string billNo, System.Collections.Generic.List <View_S_GoodsEnteringBill> listInfo, out string error) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; ctx.Connection.Open(); ctx.Transaction = ctx.Connection.BeginTransaction(); IFlowServer serverFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); string billStatus = serverFlow.GetNextBillStatus(billNo); if (billStatus == null) { throw new Exception("单据状态为空,请重新确认"); } error = null; try { EditListInfo(ctx, billNo, listInfo); if (billStatus == GoodsEnteringBillStatus.单据完成.ToString()) { foreach (View_S_GoodsEnteringBill item in listInfo) { F_GoodsPlanCost tempGoodsInfo = new F_GoodsPlanCost(); tempGoodsInfo.Date = ServerTime.Time; tempGoodsInfo.GoodsCode = item.图号型号; tempGoodsInfo.GoodsName = item.物品名称; if (item.材料类别编码 == null || item.材料类别编码.Trim().Length == 0) { throw new Exception("材料类别不能为空"); } tempGoodsInfo.GoodsType = item.材料类别编码; tempGoodsInfo.GoodsUnitPrice = 0; tempGoodsInfo.IsDisable = false; tempGoodsInfo.PY = ctx.Fun_get_bm(item.物品名称, 1); tempGoodsInfo.WB = ctx.Fun_get_bm(item.物品名称, 0); tempGoodsInfo.Remark = item.备注; tempGoodsInfo.Spec = item.规格; tempGoodsInfo.UnitID = item.单位 == "" ? 1 : Convert.ToInt32(UniversalFunction.GetUnitID(item.单位)); List <Flow_FlowData> tempList = serverFlow.GetBusinessOperationInfo(billNo, GoodsEnteringBillStatus.新建单据.ToString()); if (tempList == null) { throw new Exception("获取操作人员失败"); } tempGoodsInfo.UserCode = tempList[0].OperationPersonnel; ctx.F_GoodsPlanCost.InsertOnSubmit(tempGoodsInfo); } } ctx.SubmitChanges(); ctx.Transaction.Commit(); return(true); } catch (Exception ex) { error = ex.Message; ctx.Transaction.Rollback(); return(false); } }