/// <summary>
        /// 设置所有三包外返修零件单价
        /// </summary>
        /// <param name="flag">是否删除原有的记录 True:删除 False:不删除</param>
        /// <param name="goodSunitPrice">数据表</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool UpdateAllGoodsUnitPrice(bool flag, DataTable goodSunitPrice, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext contxt = CommentParameter.DepotDataContext;

                if (flag)
                {
                    var varData = from a in contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice
                                  select a;

                    contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice.DeleteAllOnSubmit(varData);
                }

                for (int i = 0; i < goodSunitPrice.Rows.Count; i++)
                {
                    YX_ThreePacketsOfTheRepairGoodsUnitPrice lnqThreePackets = new YX_ThreePacketsOfTheRepairGoodsUnitPrice();

                    lnqThreePackets.GoodsID   = Convert.ToInt32(goodSunitPrice.Rows[i]["物品ID"]);
                    lnqThreePackets.UnitPrice = Convert.ToDecimal(goodSunitPrice.Rows[i]["单价"]);

                    var varCheck = from a in contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice
                                   where a.GoodsID == lnqThreePackets.GoodsID
                                   select a;

                    if (varCheck.Count() == 0)
                    {
                        contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice.InsertOnSubmit(lnqThreePackets);
                    }
                }

                contxt.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }
        /// <summary>
        /// 对单条三包外返修零件信息的数据库操作
        /// </summary>
        /// <param name="flag">操作方式 0:添加,1:修改,2:删除</param>
        /// <param name="threePacket">数据集</param>
        /// <param name="oldGoodsID">老的物品ID</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>操作成功返回True,操作失败返回False</returns>
        public bool OperationGoodsUnitPrice(int flag, YX_ThreePacketsOfTheRepairGoodsUnitPrice threePacket,
                                            int oldGoodsID, out string error)
        {
            error = null;

            try
            {
                DepotManagementDataContext contxt = CommentParameter.DepotDataContext;

                switch (flag)
                {
                case 0:    //添加

                    var varInsert = from a in contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice
                                    where a.GoodsID == threePacket.GoodsID
                                    select a;

                    if (varInsert.Count() > 0)
                    {
                        error = "不能添加同一个物品信息";
                        return(false);
                    }
                    else
                    {
                        contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice.InsertOnSubmit(threePacket);
                    }

                    break;

                case 1:    //修改

                    if (threePacket.GoodsID == oldGoodsID)
                    {
                        var varUpdateSame = from a in contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice
                                            where a.GoodsID == threePacket.GoodsID
                                            select a;

                        YX_ThreePacketsOfTheRepairGoodsUnitPrice lnqThree = varUpdateSame.Single();

                        lnqThree.UnitPrice = threePacket.UnitPrice;
                    }
                    else
                    {
                        var varUpdateDif = from a in contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice
                                           where a.GoodsID == threePacket.GoodsID
                                           select a;

                        if (varUpdateDif.Count() > 0)
                        {
                            error = "不能修改成重复信息";
                            return(false);
                        }
                        else
                        {
                            varUpdateDif = from a in contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice
                                           where a.GoodsID == oldGoodsID
                                           select a;

                            YX_ThreePacketsOfTheRepairGoodsUnitPrice lnqThree = varUpdateDif.Single();

                            lnqThree.GoodsID   = threePacket.GoodsID;
                            lnqThree.UnitPrice = threePacket.UnitPrice;
                        }
                    }

                    break;

                case 2:    //删除

                    var varDelete = from a in contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice
                                    where a.GoodsID == oldGoodsID
                                    select a;

                    contxt.YX_ThreePacketsOfTheRepairGoodsUnitPrice.DeleteAllOnSubmit(varDelete);

                    break;

                default:
                    break;
                }

                contxt.SubmitChanges();

                return(true);
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
        }