private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                return;
            }
            else
            {
                if (dataGridView1.CurrentRow.Cells["编制人"].Value.ToString() == BasicInfo.LoginName)
                {
                    提交最终确认ToolStripMenuItem.Visible = true;
                }
                else
                {
                    提交最终确认ToolStripMenuItem.Visible = false;
                }

                IQueryable <View_HR_Personnel> IQViewHrPersonnel = m_serverPersonnel.GetFuzzyDeptDirector(
                    m_serverDepartment.GetDeptInfoFromPersonnelInfo(
                        dataGridView1.CurrentRow.Cells["编制人"].Value.ToString()).Rows[0]["DepartmentCode"].ToString());

                确认发起单据ToolStripMenuItem.Visible = false;

                foreach (var item in IQViewHrPersonnel)
                {
                    if (item.工号 == BasicInfo.LoginID)
                    {
                        确认发起单据ToolStripMenuItem.Visible = true;
                    }
                }

                指定责任人ToolStripMenuItem.Visible    = false;
                提交整改措施信息ToolStripMenuItem.Visible = false;
                确认整改措施信息ToolStripMenuItem.Visible = false;

                if (dataGridView1.CurrentRow.Cells["责任人"].Value.ToString() == BasicInfo.LoginName)
                {
                    提交整改措施信息ToolStripMenuItem.Visible = true;
                }

                IQViewHrPersonnel = m_serverPersonnel.GetFuzzyDeptDirector(
                    m_serverDepartment.GetDepartmentCode(dataGridView1.CurrentRow.Cells["责任部门"].Value.ToString()));

                foreach (var item in IQViewHrPersonnel)
                {
                    if (item.工号 == BasicInfo.LoginID)
                    {
                        确认整改措施信息ToolStripMenuItem.Visible = true;
                        指定责任人ToolStripMenuItem.Visible    = true;
                    }
                }
            }
        }
        /// <summary>
        /// 插入营销出库业务
        /// </summary>
        /// <param name="contxt">数据上下文</param>
        /// <param name="threePacket">三包外售后返修单信息</param>
        /// <param name="dtListOfStorageID">库房信息</param>
        /// <param name="listTable">明细信息</param>
        /// <param name="error">出错时返回错误信息,无错时返回null</param>
        /// <returns>插入成功返回True,插入失败返回False</returns>
        bool InsertYXCK(DepotManagementDataContext contxt, YX_ThreePacketsOfTheRepairBill threePacket,
                        DataTable dtListOfStorageID, DataTable listTable, out string error)
        {
            error = null;
            int    intDJID      = 0;
            SellIn serverSellIn = new SellIn();

            try
            {
                if (dtListOfStorageID == null || dtListOfStorageID.Rows.Count == 0)
                {
                    return(true);
                }
                else
                {
                    for (int k = 0; k < dtListOfStorageID.Rows.Count; k++)
                    {
                        string strBillID = m_serverAssignBill.AssignNewNo(serverSellIn, CE_BillTypeEnum.营销出库单.ToString());

                        S_MarketingBill lnqMarketingBill = new S_MarketingBill();

                        lnqMarketingBill.AffirmDate = ServerTime.Time;
                        lnqMarketingBill.Date       = Convert.ToDateTime(threePacket.FoundDate);
                        lnqMarketingBill.DJH        = strBillID;
                        lnqMarketingBill.DJZT_FLAG  = "已确认";
                        lnqMarketingBill.KFRY       = BasicInfo.LoginID;

                        string strDepartment = m_serverDepartment.GetDeptInfoFromPersonnelInfo(threePacket.FoundPersonnel).Rows[0]["DepartmentCode"].ToString();

                        lnqMarketingBill.LRKS       = strDepartment;
                        lnqMarketingBill.LRRY       = UniversalFunction.GetPersonnelCode(threePacket.FoundPersonnel);
                        lnqMarketingBill.SHRY       = m_serverPersonnel.GetFuzzyDeptDirector(strDepartment).ToList()[0].工号.ToString();
                        lnqMarketingBill.ShDate     = ServerTime.Time;
                        lnqMarketingBill.ObjectDept = "QT";
                        lnqMarketingBill.Remark     = "由三包外返修处理单【" + threePacket.Bill_ID + "】自动生成";
                        lnqMarketingBill.StorageID  = dtListOfStorageID.Rows[k][0].ToString();
                        lnqMarketingBill.YWFS       = "三包外返修出库";
                        lnqMarketingBill.YWLX       = "出库";

                        contxt.S_MarketingBill.InsertOnSubmit(lnqMarketingBill);

                        contxt.SubmitChanges();

                        var varID = from a in contxt.S_MarketingBill
                                    where a.DJH == lnqMarketingBill.DJH
                                    select a;

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

                        for (int i = 0; i < listTable.Rows.Count; i++)
                        {
                            if (Convert.ToBoolean(listTable.Rows[i]["是否为客户责任"]) &&
                                listTable.Rows[i][13].ToString().Trim() == dtListOfStorageID.Rows[k][0].ToString().Trim())
                            {
                                var varStock = from a in contxt.S_Stock
                                               where a.StorageID == dtListOfStorageID.Rows[k][0].ToString() &&
                                               a.GoodsID == Convert.ToInt32(listTable.Rows[i]["物品ID"]) &&
                                               a.BatchNo == listTable.Rows[i]["批次号"].ToString() &&
                                               a.Provider == listTable.Rows[i][14].ToString()
                                               select a;

                                if (varStock.Count() != 1)
                                {
                                    error = "库存信息不唯一或者为空";
                                    return(false);
                                }
                                else
                                {
                                    if (varStock.Single().GoodsStatus == 3)
                                    {
                                        error = "【" + varStock.Single().GoodsCode + "】 【" + varStock.Single().GoodsName + "】 【"
                                                + varStock.Single().Spec + "】【"
                                                + listTable.Rows[i]["批次号"].ToString()
                                                + "】物品库存状态为“隔离”不允许出库";

                                        return(false);
                                    }
                                }

                                S_MarketingList lnqMarketingList = new S_MarketingList();

                                lnqMarketingList.BatchNo = listTable.Rows[i]["批次号"].ToString();
                                lnqMarketingList.Count   = Convert.ToDecimal(listTable.Rows[i]["领用数量"]);
                                lnqMarketingList.CPID    = listTable.Rows[i]["物品ID"].ToString();
                                lnqMarketingList.DJ_ID   = intDJID;
                                lnqMarketingList.ReMark  = listTable.Rows[i]["备注"].ToString();
                                lnqMarketingList.Price   = Math.Round(Convert.ToDecimal(listTable.Rows[i]["单价"]) *
                                                                      Convert.ToDecimal(listTable.Rows[i]["领用数量"]), 2);
                                lnqMarketingList.Provider  = listTable.Rows[i][14].ToString();
                                lnqMarketingList.UnitPrice = Convert.ToDecimal(listTable.Rows[i]["单价"]);

                                contxt.S_MarketingList.InsertOnSubmit(lnqMarketingList);
                            }
                        }

                        contxt.SubmitChanges();

                        serverSellIn.OperationDetailAndStock_Out(contxt, lnqMarketingBill);
                        contxt.SubmitChanges();
                    }
                }

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