/// <summary>
    /// 删除排拖单明细
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gridDetail_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        BArrangeBillBB arrangeBillBB = new BArrangeBillBB();

        try
        {
            string rowid = this.gridDetail.DataKeys[e.RowIndex].Values["rowId"].ToString();//标志
            string arrangeBillNo = this.gridDetail.DataKeys[e.RowIndex].Values["arrangeBillNo"].ToString();//标志
            BArrangeBillData arrangeBillModel = new BArrangeBillData();
            DataRow[] myDataRowArray_Result = null;

            //根据rowid查找排托明细
            myDataRowArray_Result = this.DtResult.Select("rowid='" + rowid + "'");

            if (myDataRowArray_Result.Length > 0)
            {
                //更改删除标志
                myDataRowArray_Result[0]["isdel"] = "1";//删除
                myDataRowArray_Result[0]["boxNum"] = 0;

                //判断排托单是否已经提交
                arrangeBillModel = arrangeBillBB.GetModel(arrangeBillNo);

                if (arrangeBillModel != null && arrangeBillModel.instantState != "01")
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('已提交数据不允许删除!');", true);
                    return;
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            this.BindDetailTable();//绑定排托明细列表
            this.SaveStencilDetailViewState();//保存
            this.BindGrid();//绑定到货明细列表
            arrangeBillBB.Dispose();
        }
    }
    /// <summary>
    /// 保存或保存并提交公共方法
    /// </summary>
    /// <param name="isSubmit"></param>
    protected void SubmitArrangeBill(bool isSubmit)
    {
        this.SaveStencilDetailViewState();//保存

        if (this.ValidateArrangeDetail())
        {
            BArrangeBillBC arrangeBillBC = new BArrangeBillBC();
            BArrangeBillBB arrangeBillBB = new BArrangeBillBB();

            try
            {
                BArrangeBillData data = arrangeBillBB.GetModel("PT" + this.ArriveBillNo);

                if (data == null)
                {
                    data = new BArrangeBillData();

                    data.arrangeBillNo = "PT" + this.ArriveBillNo;
                    data.id = 0;
                    data.isrtDt = DateTime.Now.ToString();
                    data.isrtEmpId = this.currentUser.empId;
                    data.arriveBillNo = this.ArriveBillNo;

                    if (isSubmit)
                    {
                        data.instantState = "02";
                        data.commitDt = DateTime.Now.ToString();
                        data.commitEmpId = this.currentUser.empId;
                    }
                    else
                    {
                        data.instantState = "01";
                        data.updtDt = DateTime.Now.ToString();
                        data.updtEmpId = this.currentUser.empId;
                    }
                }
                else
                {
                    if (data.instantState != "01")
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert9", "alert(\"当前排拖单已经提交,无法修改!\");", true);
                        return;
                    }

                    data.updtDt = DateTime.Now.ToString();
                    data.updtEmpId = this.currentUser.empId;

                    if (isSubmit)
                    {
                        data.instantState = "02";
                        data.commitDt = DateTime.Now.ToString();
                        data.commitEmpId = this.currentUser.empId;
                    }
                    else
                    {
                        data.instantState = "01";
                        data.updtDt = DateTime.Now.ToString();
                        data.updtEmpId = this.currentUser.empId;
                    }
                }

                if (arrangeBillBC.SaveBArrangeBill(data, this.DtResult, isSubmit))
                {
                    this.DtResult = null;
                    this.InitData();
                    this.BindDetailTable();//绑定排托明细列表
                    this.BindGrid();//绑定到货明细列表

                    if (isSubmit)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"排拖单提交成功!\");" + (isSubmit ? "location.replace('../BArriveBill/BArriveBillList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main');" : ""), true);
                    }
                    else
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"排拖单维护成功!\");", true);
                    }
                }
                else
                {
                    this.BindDetailTable();//绑定排托明细列表
                    this.BindGrid();//绑定到货明细列表
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"排拖单维护失败!\");", true);
                }
            }
            catch (Exception ex)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
                return;
            }
            finally
            {
                arrangeBillBB.Dispose();
                arrangeBillBC.Dispose();
            }
        }
    }