/// <summary>
        /// 添加CVT出厂检验记录
        /// </summary>
        /// <param name="dataContext">数据上下文</param>
        /// <param name="djh">营销入库单据号</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>添加成功返回True,添加失败返回False</returns>
        private bool AddDeliveryInspection(DepotManagementDataContext dataContext, string djh, out string error)
        {
            error = null;

            try
            {
                var varData = from a in dataContext.ProductsCodes
                              where a.DJH == djh
                              select a;

                foreach (var item in varData)
                {
                    object goodsAttirbute = UniversalFunction.GetGoodsAttributeInfo(dataContext, item.GoodsID, CE_GoodsAttributeName.CVT);

                    if (goodsAttirbute == null || !Convert.ToBoolean(goodsAttirbute))
                    {
                        continue;
                    }

                    string strDJH = m_assignBill.AssignNewNo(dataContext, this, CE_BillTypeEnum.CVT出厂检验记录表.ToString());

                    P_DeliveryInspection lnqDelivery = new P_DeliveryInspection();

                    lnqDelivery.AssociatedBillNo = djh;
                    lnqDelivery.DJH         = strDJH;
                    lnqDelivery.DJZT        = "等待检验";
                    lnqDelivery.Date        = ServerTime.Time;
                    lnqDelivery.ProductCode = item.ProductCode;
                    lnqDelivery.ProductType = item.GoodsCode;

                    dataContext.P_DeliveryInspection.InsertOnSubmit(lnqDelivery);

                    DataTable dtNullList = GetEmptyTable(item.GoodsCode);

                    for (int i = 0; i < dtNullList.Rows.Count; i++)
                    {
                        P_DeliveryInspectionItems lnqItem = new P_DeliveryInspectionItems();

                        lnqItem.DJH          = strDJH;
                        lnqItem.TechnicalID  = Convert.ToInt32(dtNullList.Rows[i]["技术要求ID"]);
                        lnqItem.TestItemName = dtNullList.Rows[i]["检测项目"].ToString();
                        lnqItem.TechnicalRequirementsName = dtNullList.Rows[i]["技术要求"].ToString();

                        dataContext.P_DeliveryInspectionItems.InsertOnSubmit(lnqItem);
                    }
                }

                dataContext.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 更新出厂检验记录
        /// </summary>
        /// <param name="delivery">出厂检验记录表信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>更新成功返回True,更新失败返回False</returns>
        public bool UpdateDeliveryInspection(P_DeliveryInspection delivery, out string error)
        {
            error = null;

            DepotManagementDataContext dataContext = CommentParameter.DepotDataContext;

            dataContext.Connection.Open();
            dataContext.Transaction = dataContext.Connection.BeginTransaction();

            try
            {
                var varData = from a in dataContext.P_DeliveryInspection
                              where a.DJH == delivery.DJH
                              select a;

                if (varData.Count() != 1)
                {
                    error = "数据为空或者不唯一";
                    return(false);
                }
                else
                {
                    P_DeliveryInspection lnqDeliveryInspection = varData.Single();

                    lnqDeliveryInspection.Verdict  = delivery.Verdict;
                    lnqDeliveryInspection.Date     = ServerTime.Time;
                    lnqDeliveryInspection.Surveyor = BasicInfo.LoginName;
                    lnqDeliveryInspection.Remark   = delivery.Remark;

                    if (delivery.Verdict == "不合格")
                    {
                        lnqDeliveryInspection.DisqualificationCase = delivery.DisqualificationCase;
                        lnqDeliveryInspection.DisqualificationItem = delivery.DisqualificationItem;
                        lnqDeliveryInspection.DJZT = "等待最终判定";

                        var varList = from a in dataContext.P_DeliveryInspectionItems
                                      where a.DJH == lnqDeliveryInspection.DJH
                                      select a;

                        foreach (var item in varList)
                        {
                            P_DeliveryInspectionItems lnqList = item;

                            if (lnqList.TechnicalID == Convert.ToInt32(lnqDeliveryInspection.DisqualificationItem))
                            {
                                lnqList.Judge           = "不合格";
                                lnqList.DetectionResult = delivery.DisqualificationCase;
                            }
                            else
                            {
                                lnqList.Judge = "合格";
                            }
                        }
                    }
                    else
                    {
                        lnqDeliveryInspection.DJZT = "已完成";

                        var varList = from a in dataContext.P_DeliveryInspectionItems
                                      where a.DJH == lnqDeliveryInspection.DJH
                                      select a;

                        foreach (var item in varList)
                        {
                            P_DeliveryInspectionItems lnqList = item;

                            lnqList.Judge = "合格";
                        }
                    }

                    dataContext.SubmitChanges();

                    //修改营销业务单据状态

                    if (!UpdateMarketingBill(dataContext, lnqDeliveryInspection.AssociatedBillNo, out error))
                    {
                        return(false);
                    }
                }

                dataContext.Transaction.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                dataContext.Transaction.Rollback();
                error = ex.Message;
                return(false);
            }
        }