/// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        SCommBB commBB = new SCommBB();
        DataSet ds = new DataSet();

        try
        {
            string arriveBillNo = "", FinanceBillNo = "", Material = "", custno = "";
            arriveBillNo = this.tbArriveBillNo.Text.Trim();
            FinanceBillNo = this.tbFinanceBillNo.Text.Trim();
            Material = this.tbMaterial.Text.Trim();
            custno = this.tbCustNO.Text.Trim();
            if (!Checkbox.Checked)
            {
                ds = commBB.Query("exec Proc_GetSapInStockArriveBillListNew '" + arriveBillNo + "','" + FinanceBillNo + "','" + Material + "','" + custno + "'");//查询的是没有同步的
            }
            else
            {
                //[Proc_GetSapInStockArriveBillListNewAreadyInstocked] 这个是获取已经入库的
                ds = commBB.Query("exec Proc_GetSapInStockArriveBillListNewAreadyInstocked '" + arriveBillNo + "','" + FinanceBillNo + "','" + Material + "','" + custno + "'");//查询的是没有同步的
            }

            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();

            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            commBB.Dispose();
        }
    }
    /// <summary>
    /// 绑定库存汇总列表
    /// </summary>
    protected void BindGrid()
    {
        SCommBB commBB = new SCommBB();

        try
        {
            DataSet ds = new DataSet();

            ds = commBB.Query("exec proc_StockTotalReportNew '" + this.ddlWare.SelectedValue + "','"
                + this.ddlWareLocater.SelectedValue + "','" + this.tbFinanceBillNo.Text.Trim().Replace("'", "''").Trim() + "','"
                + this.tbMaterial.Text.Trim().Replace("'", "''").Trim() + "','" + this.ddlIsOutStocking.SelectedValue + "','" + this.ddlCheckResult.SelectedValue + "'");

            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();

            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            commBB.Dispose();
        }
    }
    protected void BindGrid()
    {
        SCommBB commBB = new SCommBB();
        DataSet ds = new DataSet();

        try
        {
            string arriveBillNo = "", FinanceBillNo = "", Material = "", custno = "";
            arriveBillNo = this.tbarrivebillNo.Text.ToString();
            FinanceBillNo = "";
            Material = this.tbMaterial.Text.Trim();

            ds = commBB.Query("exec [Proc_GetSapOtherInStockArriveBillListNew] '" + arriveBillNo + "','" + FinanceBillNo + "','" + Material + "','" + custno + "'");

            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();

            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            commBB.Dispose();
        }
    }
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        SCommBB commBB = new SCommBB();
        DataSet ds = new DataSet();

        try
        {
            //ds = commBB.Query("exec Proc_GetSapOutStockSaleBillList '" + this.tbAbsEntry.Text.Trim().Replace("'", "''")
            //    + "','" + this.tbSaleBillNo.Text.Trim().Replace("'", "''") + "','"
            //    + this.tbMaterial.Text.Trim().Replace("'", "''") + "'");
            string AbsEntry = "";
            string SaleBillNo = this.tbSaleBillNo.Text.Trim();
            string material = this.tbMaterial.Text.Trim();
            string invoiceNo = this.tbinvoiceNo.Text;
            string custNo = this.tbcustNo.Text;
            //ds = commBB.Query("exec [dbo].[Proc_ newGetSapOutStockSaleBillList] '" + this.tbAbsEntry.Text.Trim().Replace("'", "''")
            //    + "','" + this.tbSaleBillNo.Text.Trim().Replace("'", "''") + "','"
            //    + "','" + this.tbMaterial.Text.Trim().Replace("'", "''") + "','"
            //    + this.tbinvoiceNo.Text.Trim().Replace("'", "''") + "'");

            ds = commBB.Query("exec [dbo].[Proc_GetSapOutStockSaleBillListNew] '" + AbsEntry + "','" + SaleBillNo + "','" + material + "','" + invoiceNo + "','"+custNo+"'");
            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();

            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            commBB.Dispose();
        }
    }
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        //判断上传控件是否为空
        if (this.FileInsertImg.PostedFile.FileName == "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请首先选择一个图片文件!\");", true);
            return;
        }
        this.btnCommit.Enabled = false;

        //判断文件格式(0无限制、1图片)
        FileInfo file = new FileInfo(this.FileInsertImg.PostedFile.FileName);
        string extension = file.Extension;
        SCommBB commBB = new SCommBB();
        try
        {
            //查看文件格式是否存在与系统表“图片文件格式”中
            if (commBB.Query("select 1 from SImageFileType where fileExtension='" + extension + "'").Tables[0].Rows.Count == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"本次附件上传要求为图片格式文件,请重新选择!\");", true);
                this.btnCommit.Enabled = true;
                return;
            }
        }
        finally
        {
            commBB.Dispose();
        }

        string fileId = "";
        string insertImgPath = "";
        if (this.FileId == "")
        {
            //获取文件名称
            string fileNm = DateTime.Now.ToString("yyyyMMddHHmmss");
            Random ro = new Random();
            fileNm += ro.Next(1000, 9999).ToString() + extension;
            //上传文件到指定目录
            this.FileInsertImg.PostedFile.SaveAs(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Images\\UpImg\\" + fileNm);

            string level = "";
            for (int i = 0; i < Convert.ToInt32(DirectLevel); i++)
            {
                level += "../";
            }
            insertImgPath = level + "Images/UpImg/" + fileNm;
        }
        else
        {
            SFileData fileData = this.UpImg(this.FileInsertImg.PostedFile);
            fileId = fileData.fileId.ToString();
            insertImgPath = fileData.preFileNm;
        }

        this.btnCommit.Enabled = true;

        this.ClientScript.RegisterStartupScript(this.GetType(), "returnParent", "returnParent('" + fileId + "','" + insertImgPath + "');", true);
    }
    /// <summary>
    /// ���ͼƬ
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnInsertImg_Click(object sender, EventArgs e)
    {
        //�ж��ϴ��ؼ��Ƿ�Ϊ��
        if (this.FileInsertImg.PostedFile.FileName == "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"������ѡ��һ��ͼƬ�ļ�!\");", true);
            return;
        }
        this.btnInsertImg.Enabled = false;

        //�ж��ļ���ʽ��0�����ơ�1ͼƬ��
        FileInfo file = new FileInfo(this.FileInsertImg.PostedFile.FileName);
        string extension = file.Extension;
        SCommBB commBB = new SCommBB();
        try
        {
            //�鿴�ļ���ʽ�Ƿ������ϵͳ���ͼƬ�ļ���ʽ����
            if (commBB.Query("select 1 from SImageFileType where fileExtension='" + extension + "'").Tables[0].Rows.Count == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"���θ����ϴ�Ҫ��ΪͼƬ��ʽ�ļ���������ѡ��!\");", true);
                this.btnInsertImg.Enabled = true;
                return;
            }
        }
        finally
        {
            commBB.Dispose();
        }

        //��ȡ�ļ�����
        string fileNm = DateTime.Now.ToString("yyyyMMddHHmmss");
        Random ro = new Random();
        fileNm += ro.Next(1000, 9999).ToString() + extension;
        //�ϴ��ļ���ָ��Ŀ¼
        this.FileInsertImg.PostedFile.SaveAs(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Images\\UpImg\\" + fileNm);

        //�ж�ͼƬ�ߴ磬�����ʾΪ400/300
        System.Drawing.Image image = System.Drawing.Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\Images\\UpImg\\" + fileNm);

        if (image.Width > 400)
        {
            this.content.Value += "<img alt=\"\" src=\"../../../Images/UpImg/" + fileNm + "\" width=\"400\" height=\"" + 400 * image.Height / image.Width + "\" />";
        }
        else if (image.Height > 300)
        {
            this.content.Value += "<img alt=\"\" src=\"../../../Images/UpImg/" + fileNm + "\" width=\"" + 300 * image.Width / image.Height + "\" height=\"300\" />";
        }
        else
        {
            this.content.Value += "<img alt=\"\" src=\"../../../Images/UpImg/" + fileNm + "\" />";
        }

        this.btnInsertImg.Enabled = true;
    }
 private void BindGrid()
 {
     string billNo = this.tbBillNo.Text.ToString();
     string material = this.tbMaterial.Text.ToString();
     string saleBillNo = this.tbsaleBillNo.Text.ToString();
     SCommBB commBB = new SCommBB();
     try
     {
         this.gridSaleBill.DataSource = commBB.Query("exec [dbo].[pro_GetoutSaleDetailShow] '" + material + "','" + billNo + "','" + saleBillNo + "'").Tables[0];
         this.gridSaleBill.DataBind();
     }
     catch { }
     finally
     {
         commBB.Dispose();
     }
 }
 private void ShowInfo()
 {
     string id = Request.Params["id"];
     string sql = " select  stockUpBillNo,saleBillNo ,materialNo from vCStockUpDetail  where id ='"+id+"'";
     SCommBB commBB = new SCommBB();
     try
     {
         DataTable dt = commBB.Query(sql).Tables[0];
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             this.tbBillNo.Text = dt.Rows[i][0].ToString();
             this.tbsaleBillNo.Text = dt.Rows[i][1].ToString();
             this.tbMaterial.Text = dt.Rows[i][2].ToString();
         }
     }
     catch { }
     finally
     {
         commBB.Dispose();
     }
 }
    /// <summary>
    /// 绑定集货区库位使用情况列表
    /// </summary>
    protected void BindGrid()
    {
        SCommBB commBB = new SCommBB();

        try
        {
            DataSet ds = new DataSet();

            ds = commBB.Query("exec Proc_GetJHQWareInfo '" + this.tbCustNo.Text.Trim().Replace("'", "''") + "'");

            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();

            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            commBB.Dispose();
        }
    }
    protected void BindGrid()
    {
        SCommBB commBB = new SCommBB();
        try
        {
            string strStartDt = "";
            string strEndDt = "";
            //开始入库日期
            if (!string.IsNullOrEmpty(this.tbStartDt.Text.Trim()))
            {
                strStartDt = this.tbStartDt.Text.Trim().ToUpper();
            }

            //截止入库日期
            if (!string.IsNullOrEmpty(this.tbEndDt.Text.Trim()))
            {
                strEndDt = this.tbEndDt.Text.Trim().ToUpper();
            }

            string material = this.lblmaterialNo.Text.ToString();
            DataSet ds = new DataSet();

            ds = commBB.Query(" exec [dbo].[up_inventory_OutIn_list] '" + material + "','" + strStartDt + "','" + strEndDt + "'");

            this.gridSaleBill.DataSource = ds.Tables[0];
            this.gridSaleBill.DataBind();
            this.Label1.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label4.Text = this.gridSaleBill.PageCount.ToString();
            this.TextBox1.Text = (this.gridSaleBill.PageIndex + 1).ToString();
        }
        catch { }
        finally
        {
            commBB.Dispose();
        }
    }
    public DataTable GetAllowTallyStockPallet_DE()
    {
        SCommBB commBB = new SCommBB();

        try
        {
            DataTable dt = new DataTable();

            dt = commBB.Query("exec Proc_GetAllowTallyStockPallet_DE").Tables[0];
            return dt;
        }
        finally
        {
            commBB.Dispose();
        }
    }
    /// <summary>
    /// 展示数据
    /// </summary>
    /// <param name="id">记录Id</param>
    private void ShowInfo(int id)
    {
        BCheckBillBB checkBillBB = new BCheckBillBB();
        SCommBB commBB = new SCommBB();

        try
        {
            vBCheckBillData model = new vBCheckBillData();
            DataSet ds = new DataSet();
            string strSQL = "";

            model = checkBillBB.GetVModel(id);
            this.lbCheckBillNo.Text = model.checkBillNo;
            this.tbArriveBillNo.Text = model.arriveBillNo;
            this.tbFinanceBillNo.Text = model.financeBillNo;
            this.hidMaterialNo.Value = model.materialNo;
            this.tbMaterialDesc.Text = model.materialDesc;
            this.tbCheckMark.Text = model.checkMark;

            //查找到货单明细ID
            strSQL = "select id,num from BArriveDetail where arriveBillNo='" + model.arriveBillNo
                + "' and financeBillNo='" + model.financeBillNo + "' and materialNo='" + model.materialNo + "'";
            ds = commBB.Query(strSQL);
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                this.hidArriveDetailID.Value = ds.Tables[0].Rows[0]["id"].ToString();
                this.tbNum.Text = ds.Tables[0].Rows[0]["num"].ToString();
            }

            this.BindMateriel2();//绑定物料对应检测标准明细表
        }
        finally
        {
            checkBillBB.Dispose();
        }
    }
    /// <summary>
    /// 绑定检测明细
    /// </summary>
    /// <param name="NewOrOld">new/old 分别表示 走检验标准结构,走单据结构。如果传空值,请确认DtResult不为空</param>
    protected void BindDetailTable(string strNewOrOld)
    {
        #region 初始化检测明细

        if (this.DtResult == null)//第一次初始化模板,分两种情况。新增和修改。
        {
            SCommBB commBB = new SCommBB();
            try
            {
                string strSQL = "";

                if (strNewOrOld == "new")//以标准为模板,走结构。
                {
                    strSQL = "exec Proc_InitCheckDetailAdd '" + this.hidMaterialNo.Value + "','" + this.hidArriveDetailID.Value + "'";
                }
                else if (strNewOrOld == "old")//以订单内容为主,走结构。一般是修改状态进来的单据。
                {
                    strSQL = "exec Proc_InitCheckDetailModify '" + this.IdValue.ToString() + "'";
                }

                DataSet ds = commBB.Query(strSQL);
                if (ds != null && ds.Tables.Count > 0)
                {
                    this.DtResult = ds.Tables[0];
                    this.DtResult.Columns.Add(new DataColumn("rowId", typeof(string)));
                    this.DtResult.Columns.Add(new DataColumn("isdel", typeof(string)));

                    foreach (DataRow dr in this.DtResult.Rows)
                    {
                        dr["rowId"] = Guid.NewGuid().ToString();
                        dr["isdel"] = "0";
                    }
                }
            }
            catch (Exception ex)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",4);", true);
                return;
            }
            finally
            {
                commBB.Dispose();
            }
        }

        DataView dv = this.DtResult.DefaultView;
        dv.RowFilter = "isdel=0";
        this.grid.DataSource = dv;
        this.grid.DataBind();

        #endregion 初始化检测明细
    }
    public DataTable GetArrangeBillDetail_Group(string strArriveBillNo, string strFinanceBillNos, string strPalletIndexs)
    {
        SCommBB commBB = new SCommBB();

        try
        {
            DataTable dt = new DataTable();
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select arrangeBillNo,arriveBillNo,materialNo,materialDesc,");
            strSql.Append("sum(boxNum) as boxNum,sum(consignBoxNum) as consignBoxNum ");
            strSql.Append("from dbo.vBArrangeBillDetail ");

            if (strFinanceBillNos != "")
            {
                strSql.Append("where arriveBillNo='" + strArriveBillNo
                    + "' and '," + strFinanceBillNos + ",' like '%,'+financeBillNo+',%' and palletIndex in ("
                    + strPalletIndexs + ") ");
            }
            else
            {
                strSql.Append("where arriveBillNo='" + strArriveBillNo + "' and palletIndex in (" + strPalletIndexs + ") ");
            }

            strSql.Append("group by arrangeBillNo,arriveBillNo,materialNo,materialDesc");

            dt = commBB.Query(strSql.ToString()).Tables[0];
            return dt;
        }
        finally
        {
            commBB.Dispose();
        }
    }
    private SFileData UpImg(HttpPostedFile postedFile)
    {
        //判断上传控件是否为空
        if (postedFile.FileName == "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请首先选择一个图片文件!\");", true);
            return null;
        }
        SFileData model = new SFileData();
        SSpaceBC spaceBC = new SSpaceBC();
        try
        {
            //判断文件格式(0无限制、1图片)
            FileInfo file = new FileInfo(postedFile.FileName);
            string extension = file.Extension;
            SCommBB commBB = new SCommBB();
            try
            {
                //查看文件格式是否存在与系统表“图片文件格式”中
                if (commBB.Query("select 1 from SImageFileType where fileExtension='" + extension + "'").Tables[0].Rows.Count == 0)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"本次附件上传要求为图片格式文件,请重新选择!\");", true);
                    return null;
                }
            }
            finally
            {
                commBB.Dispose();
            }

            int fileId = spaceBC.UploadFile(model, postedFile, "upFile", this.currentUser.empId, false);
            model.fileId = fileId;

            return model;
        }
        finally
        {
            spaceBC.Dispose();
        }
    }
    /// <summary>
    /// 根据树列表绑定grid
    /// </summary>
    private void BindDataList(int empListIndex, int empListedIndex)
    {
        PUserRoleBB userRoleBB = new PUserRoleBB();
        DataSet ds = new DataSet();

        //绑定已有人员
        try
        {
            ds = userRoleBB.GetVList("roleId=" + this.RoleId.ToString());
            this.empListed.DataTextField = "empNm";
            this.empListed.DataValueField = "id";
            this.empListed.DataSource = ds;
            this.empListed.DataBind();

            if (this.empListed.Items.Count > empListedIndex)
            {
                this.empListed.SelectedIndex = empListedIndex;
            }
            else if (this.empListed.Items.Count > 0)
            {
                this.empListed.SelectedIndex = this.empListed.Items.Count - 1;
            }
        }
        finally
        {
            userRoleBB.Dispose();
        }

        //绑定未有人员
        SCommBB commBB = new SCommBB();
        try
        {
            string strSql = "select * from HEemployee where isDel=0 and isEffect=1 and not exists(select 1 from PUserRole where roleId="
                + this.RoleId.ToString() + " and empId=HEemployee.empId)";
            ds = commBB.Query(strSql);

            this.empList.DataTextField = "empNm";
            this.empList.DataValueField = "empId";
            this.empList.DataSource = ds;
            this.empList.DataBind();

            if (this.empList.Items.Count > empListIndex)
            {
                this.empList.SelectedIndex = empListIndex;
            }
            else if (this.empList.Items.Count > 0)
            {
                this.empList.SelectedIndex = this.empList.Items.Count - 1;
            }
        }
        finally
        {
            commBB.Dispose();
        }
    }
    /// <summary>
    /// 提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        BBackBillBB backBillBB = new BBackBillBB();

        try
        {
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    int id = int.Parse(chkId.ValidationGroup);
                    BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id));

                    if (backBillModel.instantState != "03")
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true);
                        return;
                    }
                    else
                    {
                        retChecked = true;
                        backBillModel.commitDt = System.DateTime.Now.ToString();
                        backBillModel.commitEmpId = this.currentUser.empId;
                        backBillModel.instantState = "02";
                        backBillBB.ModifyRecord(backBillModel);
                    }

                    DataTable dtDetail = new DataTable();
                    BBackDetailBB backDetailBB = new BBackDetailBB();
                    //获取退货明细数据源
                    dtDetail = backDetailBB.GetList("backBillNo='" + backBillModel.backBillNo + "'").Tables[0];
                    string commadPallet = "";
                    for (int i = 0; i < dtDetail.Rows.Count; i++)
                    {
                        if (i == dtDetail.Rows.Count - 1)
                        {
                            commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "'";
                        }
                        else
                        {
                            commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "' or ";
                        }
                    }
                    string command = "select distinct palletNo  from BArrangeBillBox where " + commadPallet;//获取订单下的托盘号码
                    SCommBB bb = new SCommBB();
                    DataTable dt = bb.Query(command).Tables[0];
                    bb.Dispose();
                    //BForkliftTaskBC bforkTaskBC = new BForkliftTaskBC();
                    //for (int j = 0; j < dt.Rows.Count; j++)
                    //{
                    //    bforkTaskBC.SaveForkliftTaskWithTHD(dt.Rows[j][0].ToString(), "YCQ", "N01.01", "30", this.currentUser.empId,backBillModel.backBillNo);
                    //}
                }

            }

        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            backBillBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        BCheckBillBB checkBillBB = new BCheckBillBB();
        SCommBB comBB = new SCommBB();

        try
        {
            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);
                    BCheckBillData model = checkBillBB.GetModel(id);

                    if (model.instantState == "01")//判断检测单是否已经提交,已经提交不允许删除
                    {
                        //删除主数据
                        checkBillBB.DeleteRecord(id);

                        //删除明细
                        string strsql = "delete  from BCheckDetail where checkBillId='" + id.ToString() + "'";
                        comBB.Query(strsql);
                    }
                    else
                    {
                        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
        {
            checkBillBB.Dispose();
            comBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
    /// <summary>
    /// 确认发货
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnConfirmSend_Click(object sender, EventArgs e)
    {
        bool isChecked = false;

        //获取选中的数据Id
        foreach (GridViewRow gvrow in this.grid.Rows)
        {
            CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");

            if (chkId.Checked == true)
            {
                isChecked = true;

                string id = this.grid.DataKeys[gvrow.RowIndex].Values["id"].ToString();
                string stockUpbillNo = this.grid.DataKeys[gvrow.RowIndex].Values["stockUpBillNo"].ToString();

                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"选择的备货单号是" + stockUpbillNo + "!\");", true);
                string command = "select distinct palletNo,wareNo,wareLocatorNo from BArrangeBillBox where stockUpBillNo = '" + stockUpbillNo + "' and isnull(palletNo,'')<>''";//获取订单下的托盘号码 2015-06-25增加限制条件 排除生成空托盘的时候的bug
                SCommBB bb = new SCommBB();
                DataTable dt = bb.Query(command).Tables[0];
                bb.Dispose();
                BForkliftTaskBC bforkTaskBC = new BForkliftTaskBC();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    bforkTaskBC.SaveForkliftTask(dt.Rows[i][0].ToString(), "CKQ", "CKQ01", "20", this.currentUser.empId);
                }

                SCommBB commBB = new SCommBB();
                string strSql = "update dbo.CStockUpDetail set instantState='04' where stockUpBillNO='" + stockUpbillNo + "'";
                commBB.ExecuteSql(strSql);

                //将备货单属性改为09出库中
                strSql = @"update dbo.CStockUpBill set instantState='09'  where stockUpBillNo = '" + stockUpbillNo + "'";
                commBB.ExecuteSql(strSql);
                //实时获取订单状态
                //using (CStockUpBillBB billBB = new CStockUpBillBB())
                //{
                //    CStockUpBillData data = billBB.GetModel(Convert.ToInt32(id));

                //    data.instantState = "11";//状态更改为“确认发货”

                //    billBB.ModifyRecord(data);
                //}
            }
        }

        if (isChecked)
        {
            this.BindGrid();
            return;
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true);
        return;
    }
    /// <summary>
    /// 根据当前人员绑定DataList
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB();
        STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        SCommBB commBB = new SCommBB();
        DataSet perDs = new DataSet();
        DataSet ds = new DataSet();
        try
        {
            HtmlInputHidden hid = (HtmlInputHidden)e.Item.FindControl("nodeId");
            string nodeId = hid.Value;

            Label label = (Label)e.Item.FindControl("itemNo");
            string itemNo = label.Text;
            if (itemNo.IndexOf('-') >= 0)
            {
                itemNo = itemNo.Substring(itemNo.LastIndexOf('-') + 1);
            }

            //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
            if (this.IsHaveRole(1))
            {
                ds = treeFunctionBB.GetList("nodeId=" + nodeId);
            }
            else
            {
                ds = commBB.Query("select distinct permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId="
                    + this.currentUser.empId.ToString() + " and nodeId=" + nodeId + " order by permissionsTypeId");
            }

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow row = ds.Tables[0].Rows[i];

                //添加文本“<TD></TD>"以控制格式
                HtmlGenericControl td = new HtmlGenericControl();
                td.InnerHtml = "</td><td>";
                e.Item.Controls.Add(td);

                CheckBox checkBox = new CheckBox();
                checkBox.ID = "checkBox" + i.ToString();
                checkBox.Text = row["functionNm"].ToString();
                checkBox.ToolTip = row["functionNo"].ToString();

                //给checkBox赋值
                if (eemployeeBB.HasPermissions(this.EmpId, itemNo, row["functionNo"].ToString()))
                {
                    checkBox.Checked = true;
                }
                e.Item.Controls.Add(checkBox);
            }
        }
        finally
        {
            empPermissionsBB.Dispose();
            treeFunctionBB.Dispose();
            eemployeeBB.Dispose();
            commBB.Dispose();
        }
    }
 /// <summary>
 /// 初始化默认权限数据
 /// </summary>
 private void InitPermissionData()
 {
     PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
     STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
     SCommBB commBB = new SCommBB();
     try
     {
         //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
         if (this.IsHaveRole(1))
         {
             this.treeFunctionDs = treeFunctionBB.GetList("");
         }
         else
         {
             this.treeFunctionDs = commBB.Query("select distinct nodeId,permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId="
                 + this.currentUser.empId.ToString() + " order by permissionsTypeId");
         }
         //获取岗位具体权限
         this.rolePermissionsDs = rolePermissionsBB.GetList("roleId=" + this.RoleId.ToString());
     }
     finally
     {
         rolePermissionsBB.Dispose();
         treeFunctionBB.Dispose();
         commBB.Dispose();
     }
 }
    protected void BindGrid()
    {
        SCommBB commBB = new SCommBB();
        try
        {
            string strStartDt = "";
            string strEndDt = "";
            //开始入库日期
            if (!string.IsNullOrEmpty(this.tbStartDt.Text.Trim()))
            {
                strStartDt = this.tbStartDt.Text.Trim().ToUpper();
            }

            //截止入库日期
            if (!string.IsNullOrEmpty(this.tbEndDt.Text.Trim()))
            {
                strEndDt = this.tbEndDt.Text.Trim().ToUpper();
            }

            string billNo = this.tbBillNo.Text.ToString();
            string material = this.tbMaterial.Text.ToString();
            DataSet ds = new DataSet();

            ds = commBB.Query(" exec [dbo].[Proc_GetArriveBillNew] '" + billNo + "','"+material+"','"+strStartDt+"','"+strEndDt+"'");

            this.gridSaleBill.DataSource = ds.Tables[0];
            this.gridSaleBill.DataBind();
        }
        catch { }
        finally
        {
            commBB.Dispose();
        }

        //SCommBB commBB = new SCommBB();
        //string material = this.tbMaterial.Text.ToString().Trim();
        //string pallet = this.tbPalletNo.Text.ToString().Trim();
        //string boxNo = this.tbBoxNo.Text.ToString().Trim();
        //string billNo = this.tbBillNo.Text.ToString().Trim();
        //string outBox = this.ddlIsOutStocking.SelectedValue.ToString();
        //string strEndDt = DateTime.Now.ToString("yyyy-MM-dd");

        ////截止入库日期
        //if (!string.IsNullOrEmpty(this.tbAcceptStartDt.Text.Trim()))
        //{
        //    strEndDt = this.tbAcceptStartDt.Text.Trim().ToUpper();
        //}

        //try
        //{
        //    DataSet ds = new DataSet();

        //    ds = commBB.Query(" exec [dbo].[Pro_UstockOutInDetail] '"+boxNo +"','"+pallet+"','"+material+"','"+billNo+"','"+outBox+"','"+Convert.ToDateTime(strEndDt)+"'");

        //    this.grid.DataSource = ds.Tables[0];
        //    this.grid.DataBind();

        //    //赋值记录条数、页面总数
        //    this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
        //    this.Label2.Text = this.grid.PageCount.ToString();
        //    this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        //}
        //finally
        //{
        //    commBB.Dispose();
        //}
    }
 protected void BindGridOut()
 {
     string material = this.tbMaterial.Text.ToString();
     string stockUpBillNo = this.tbStockUpBillNo.Text.ToString();
     SCommBB commBB = new SCommBB();
     try
     {
         DataSet ds = new DataSet();
         ds = commBB.Query("exec [dbo].[pro_GetoutSaleDetail] '"+material+"','"+stockUpBillNo+"'");
         this.gridStockUpDetail.DataSource = ds.Tables[0];
         this.gridStockUpDetail.DataBind();
     }
     catch { }
     finally
     {
         commBB.Dispose();
     }
 }
    private void ShowPullInfo(string functionNo)
    {
        StringBuilder vmlStr = new StringBuilder();
        SCommBB commBB = new SCommBB();
        WFunctionStepBB functionStepBB = new WFunctionStepBB();
        DataSet ds = new DataSet();
        try
        {
            //������ù�����������������ͬ�������������������
            int stepLevels = 0;
            int maxStepSeq = 0;
            int stepIntervalX = 0;
            int stepIntervalY = 0;

            ds = commBB.Query("select max(seq) from WFunctionStep where functionNo='" + functionNo + "'");
            if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0][0] != DBNull.Value)
            {
                maxStepSeq = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            }

            ds = commBB.Query("select distinct stepNo from WFunctionStep where functionNo='" + functionNo + "'");
            stepLevels = ds.Tables[0].Rows.Count;

            //����Y��������
            if (stepLevels > 1)
            {
                stepIntervalY = 400 / (stepLevels - 1);
            }

            int roundrectId = 1;
            int currCenterRoundrectId = 0;
            int preCenterRoundrectId = 0;

            //��ʼ��ͼ������
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow row = ds.Tables[0].Rows[i];

                DataSet levelDs = new DataSet();
                levelDs = functionStepBB.GetVList("functionNo='" + functionNo + "' and stepNo=" + row["stepNo"].ToString());

                for (int j = 0; j < levelDs.Tables[0].Rows.Count; j++)
                {
                    DataRow levelRow = levelDs.Tables[0].Rows[j];
                    string stepId = levelRow["id"].ToString();
                    string stepNm = levelRow["stepNm"].ToString();
                    string stepNo = levelRow["stepNo"].ToString();
                    string seq = levelRow["seq"].ToString();
                    string nodeType = "";
                    string fillcolor = "";
                    int coordinateX;
                    int coordinateY;
                    //��ǰ��������������
                    int currLevelSteps = levelDs.Tables[0].Rows.Count;

                    //���㵱ǰ������X������
                    if (currLevelSteps > 1)
                    {
                        stepIntervalX = 400 / (currLevelSteps - 1);
                    }

                    if (roundrectId == 1)
                    {
                        nodeType = "start";
                        fillcolor = "#00EE00";
                    }
                    else if (i == ds.Tables[0].Rows.Count - 1 && j == levelDs.Tables[0].Rows.Count - 1)
                    {
                        nodeType = "end";
                        fillcolor = "#F4A8BD";
                    }
                    else
                    {
                        fillcolor = "#EEEEEE";
                    }

                    //����X����
                    if (Convert.ToInt32(levelRow["coordinateX"]) != 0)
                    {
                        coordinateX = Convert.ToInt32(levelRow["coordinateX"]);
                    }
                    else
                    {
                        if (currLevelSteps > 1)
                        {
                            coordinateX = 30 + stepIntervalX * j;
                        }
                        else
                        {
                            coordinateX = 230;
                        }
                    }

                    //����Y����
                    if (Convert.ToInt32(levelRow["coordinateY"]) != 0)
                    {
                        coordinateY = Convert.ToInt32(levelRow["coordinateY"]);
                    }
                    else
                    {
                        if (stepLevels > 1)
                        {
                            coordinateY = 30 + stepIntervalY * i;
                        }
                        else
                        {
                            coordinateY = 230;
                        }
                    }

                    vmlStr.Append("        <vml:roundrect inset='2pt,2pt,2pt,2pt' id='" + roundrectId.ToString() + "' stepId='" + stepId + "' nodeType='" + nodeType + "'\r\n");
                    vmlStr.Append("            readonly='0' fillcolor='" + fillcolor + "' ondblclick='EditStep(" + stepId + ");' style='left: " + coordinateX.ToString() + ";\r\n");
                    vmlStr.Append("            top: " + coordinateY.ToString() + "; width: 100; position: absolute; height: 50; vertical-align: middle; cursor: hand; text-align: center;\r\n");
                    vmlStr.Append("            z-index: 1' arcsize='4321f' coordsize='21600,21600' title='��'>\r\n");
                    vmlStr.Append("            <vml:shadow on='T' type='single' color='#b3b3b3' offset='3px,3px' />\r\n");
                    vmlStr.Append("            <vml:textbox inset='1pt,2pt,1pt,1pt' onselectstart='return false;'><b>" + stepNo + "-" + seq + "</b><br />" + stepNm + "</vml:textbox>\r\n");
                    vmlStr.Append("        </vml:roundrect>\r\n");
                    vmlStr.Append("\r\n");

                    if (j > 0)
                    {
                        //��ͬ������֮������
                        vmlStr.Append("        <vml:line mfrid='1' title='' source='" + Convert.ToString(roundrectId - 1) + "' object='" + roundrectId.ToString() + "' from='0,0' to='0,0' style='position: absolute;\r\n");
                        vmlStr.Append("            display: none; z-index: 2' arcsize='4321f' coordsize='21600,21600'>\r\n");
                        vmlStr.Append("            <vml:shadow on='T' type='single' color='#b3b3b3' offset='1px,1px' />\r\n");
                        vmlStr.Append("        </vml:line>\r\n");
                        vmlStr.Append("\r\n");
                    }

                    if (j == currLevelSteps / 2)
                    {
                        currCenterRoundrectId = roundrectId;
                    }

                    roundrectId += 1;
                }

                if (i > 0)
                {
                    //����ͬ����֮������
                    vmlStr.Append("        <vml:line mfrid='1' title='' source='" + Convert.ToString(preCenterRoundrectId) + "' object='" + Convert.ToString(currCenterRoundrectId) + "' from='0,0' to='0,0' style='position: absolute;\r\n");
                    vmlStr.Append("            display: none; z-index: 2' arcsize='4321f' coordsize='21600,21600'>\r\n");
                    vmlStr.Append("            <vml:stroke endarrow='block'>\r\n");
                    vmlStr.Append("            </vml:stroke>\r\n");
                    vmlStr.Append("            <vml:shadow on='T' type='single' color='#b3b3b3' offset='1px,1px' />\r\n");
                    vmlStr.Append("        </vml:line>\r\n");
                    vmlStr.Append("\r\n");
                }

                preCenterRoundrectId = currCenterRoundrectId;
            }
        }
        finally
        {
            commBB.Dispose();
            functionStepBB.Dispose();
        }
        this.vmlStr = vmlStr;
    }
    protected void btnUp_Click(object sender, EventArgs e)
    {
        this.lblMsg.Text = "";
        this.isUpSucess = false;
        if (this.SingleLimit == "1" && this.selectedFiles.Items.Count > 0)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"本次文件上传只允许选择单个文件!\");", true);
            return;
        }

        int userId = this.currentUser.empId;
        int fileID = 0;
        string preFileNm = "";
        SFileData model = new SFileData();
        SSpaceBC spaceBC = new SSpaceBC();

        try
        {
            //判断文件格式(0无限制、1图片)
            switch (this.FileType)
            {
                case "0":
                    break;
                case "1":
                    FileInfo file = new FileInfo(this.File1.PostedFile.FileName);
                    string extension = file.Extension;
                    //查看文件格式是否存在与系统表“图片文件格式”中
                    SCommBB commBB = new SCommBB();
                    try
                    {
                        if (commBB.Query("select 1 from SImageFileType where fileExtension='" + extension + "'").Tables[0].Rows.Count == 0)
                        {
                            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"本次附件上传要求为图片格式文件,请重新选择!\");", true);
                            return;
                        }
                    }
                    finally
                    {
                        commBB.Dispose();
                    }
                    break;
                default:
                    break;
            }

            fileID = spaceBC.UploadFile(model, this.File1.PostedFile, userId, this.FileType == "1");

            if (fileID != 0)
            {
                preFileNm = model.preFileNm;
            }

            ListItem item = new ListItem();
            item.Text = preFileNm;
            item.Value = fileID.ToString();
            this.selectedFiles.Items.Add(item);

            this.isUpSucess = true;
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",1);", true);
            return;
        }
        finally
        {
            spaceBC.Dispose();
        }
    }
    /// <summary>
    /// 根据树列表绑定grid
    /// </summary>
    private void BindDataList(int roleListIndex, int roleListedIndex)
    {
        PUserRoleBB userRoleBB = new PUserRoleBB();
        DataSet ds = new DataSet();

        //绑定已有岗位
        try
        {
            ds = userRoleBB.GetVList("empId=" + this.EmpId.ToString());
            this.roleListed.DataTextField = "roleName";
            this.roleListed.DataValueField = "id";
            this.roleListed.DataSource = ds;
            this.roleListed.DataBind();

            if (this.roleListed.Items.Count > roleListedIndex)
            {
                this.roleListed.SelectedIndex = roleListedIndex;
            }
            else if (this.roleListed.Items.Count > 0)
            {
                this.roleListed.SelectedIndex = this.roleListed.Items.Count - 1;
            }
        }
        finally
        {
            userRoleBB.Dispose();
        }

        //绑定未有岗位
        SCommBB commBB = new SCommBB();
        try
        {
            string strSql = "select * from PRole where not exists(select 1 from PUserRole where empId="
                + this.EmpId.ToString() + " and roleId=PRole.id)";
            ds = commBB.Query(strSql);

            this.roleList.DataTextField = "roleName";
            this.roleList.DataValueField = "id";
            this.roleList.DataSource = ds;
            this.roleList.DataBind();

            if (this.roleList.Items.Count > roleListIndex)
            {
                this.roleList.SelectedIndex = roleListIndex;
            }
            else if (this.roleList.Items.Count > 0)
            {
                this.roleList.SelectedIndex = this.roleList.Items.Count - 1;
            }
        }
        finally
        {
            commBB.Dispose();
        }
    }
    public DataTable GetArrangeBoxAndBillFactDetail(string strArriveBillNo, string strFinanceBillNos,
        string strMaterialNo, string strPalletIndexs, string strPalletNos)
    {
        SCommBB commBB = new SCommBB();

        try
        {
            DataTable dt = new DataTable();

            dt = commBB.Query("exec Proc_GetArrangeBoxAndBillFactDetail '" + strArriveBillNo + "','" + strFinanceBillNos
                + "','" + strMaterialNo + "','" + strPalletIndexs + "','" + strPalletNos + "'").Tables[0];
            return dt;
        }
        finally
        {
            commBB.Dispose();
        }
    }
Exemple #28
0
    /// <summary>
    /// 发送邮件
    /// </summary>
    /// <param name="to">接受人</param>
    /// <param name="subject">邮件主题</param>
    /// <param name="body">邮件内容</param>
    /// <param name="bobyType">发送的邮件样式:0:普通文本,1:html样式</param>
    /// <returns></returns>
    public bool SendEmail(string to, string subject, string body, int bobyType)
    {
        if (to == "")
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"邮件发送失败,收件人邮箱不能为空!\");", true);
            return false;
        }

        using (SCommBB commBB = new SCommBB())
        {
            try
            {
                string strSql = "DECLARE @sendState nvarchar(2); exec sys_SendMail @To,@Bcc,@BobyType,@Subject,@Body,@sendState output; SELECT @sendState";
                System.Data.SqlClient.SqlParameter[] paras =
                {
                    new System.Data.SqlClient.SqlParameter("@To",System.Data.SqlDbType.VarChar),
                    new System.Data.SqlClient.SqlParameter("@Bcc",System.Data.SqlDbType.VarChar),
                    new System.Data.SqlClient.SqlParameter("@BobyType",System.Data.SqlDbType.Int),
                    new System.Data.SqlClient.SqlParameter("@Subject",System.Data.SqlDbType.VarChar),
                    new System.Data.SqlClient.SqlParameter("@Body",System.Data.SqlDbType.NText)
                };
                paras[0].Value = to;
                paras[1].Value = "";
                paras[2].Value = bobyType;
                paras[3].Value = subject;
                paras[4].Value = body;

                DataSet ds = commBB.Query(strSql, paras);
                if (ds.Tables[0].Rows[0][0].ToString() == "OK")
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                if (!HS.Function.CommFunction.IsEmail(to))
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"邮件发送失败,收件人邮箱格式错误或不存在!\");", true);
                }
                else
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"邮件发送失败,请检查邮件服务器是否配置正确!\");", true);
                }
                return false;
            }
        }
    }
    /// <summary>
    /// 根据树列表绑定DataList
    /// </summary>
    private void BindDataList()
    {
        STreeBB treeBB = new STreeBB();
        SCommBB commBB = new SCommBB();
        DataSet ds = new DataSet();

        try
        {
            //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
            if (this.IsHaveRole(1))
            {
                ds = treeBB.GetList("");
            }
            else
            {
                ds = commBB.Query("select distinct nodeId,itemNo,nodeNm,orderId,parentId from vSTree where empId="
                    + this.currentUser.empId.ToString() + " order by itemNo");
            }
            DataTable dt = treeBB.ConvertTreeList(ds.Tables[0]);
            this.DataList1.DataSource = dt;
            this.DataList1.DataKeyField = "nodeId";
            this.DataList1.DataBind();
        }
        finally
        {
            treeBB.Dispose();
            commBB.Dispose();
        }
    }
    /// <summary>
    /// 提交
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        //bool retChecked = false;
        //BBackBillBB backBillBB = new BBackBillBB();

        //try
        //{
        //    foreach (GridViewRow gvrow in this.grid.Rows)
        //    {
        //        CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
        //        if (chkId.Checked == true)
        //        {
        //            int id = int.Parse(chkId.ValidationGroup);
        //            BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id));

        //            if (backBillModel.instantState != "01")
        //            {
        //                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true);
        //                return;
        //            }
        //            else
        //            {
        //                retChecked = true;
        //                backBillModel.commitDt = System.DateTime.Now.ToString();
        //                backBillModel.commitEmpId = this.currentUser.empId;
        //                backBillModel.instantState = "02";
        //                backBillBB.ModifyRecord(backBillModel);
        //            }

        //            DataTable dtDetail = new DataTable();
        //            BBackDetailBB backDetailBB = new BBackDetailBB();
        //            //获取退货明细数据源
        //            dtDetail = backDetailBB.GetList("backBillNo='" + backBillModel.backBillNo + "'").Tables[0];
        //            string commadPallet = "";
        //            for (int i = 0; i < dtDetail.Rows.Count; i++)
        //            {
        //                if (i == dtDetail.Rows.Count - 1)
        //                {
        //                    commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "'";
        //                }
        //                else
        //                {
        //                    commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "' or ";
        //                }
        //            }
        //            string command = "select distinct palletNo  from BArrangeBillBox where " + commadPallet;//获取订单下的托盘号码
        //            SCommBB bb = new SCommBB();
        //            DataTable dt = bb.Query(command).Tables[0];
        //            bb.Dispose();
        //            //BForkliftTaskBC bforkTaskBC = new BForkliftTaskBC();
        //            //for (int j = 0; j < dt.Rows.Count; j++)
        //            //{
        //            //    bforkTaskBC.SaveForkliftTaskWithTHD(dt.Rows[j][0].ToString(), "YCQ", "N01.01", "30", this.currentUser.empId,backBillModel.backBillNo);
        //            //}
        //        }

        //    }

        //}
        //catch (Exception ex)
        //{
        //    this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
        //    return;
        //}
        //finally
        //{
        //    backBillBB.Dispose();
        //}

        //if (retChecked)
        //{
        //    this.BindGrid();
        //}

        bool retChecked = false;
        BBackBillBB backBillBB = new BBackBillBB();

        try
        {
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    int id = int.Parse(chkId.ValidationGroup);
                    BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id));

                    if (backBillModel.instantState != "01")
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true);
                        return;
                    }
                    else
                    {
                        DataTable dtDetail = new DataTable();
                        BBackDetailBB backDetailBB = new BBackDetailBB();
                        //获取退货明细数据源
                        dtDetail = backDetailBB.GetList("backBillNo='" + backBillModel.backBillNo + "'").Tables[0];
                        string commadPallet = "";
                        for (int i = 0; i < dtDetail.Rows.Count; i++)
                        {
                            if (i == dtDetail.Rows.Count - 1)
                            {
                                commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "'";
                            }
                            else
                            {
                                commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "' or ";
                            }
                        }
                        string command = "select distinct palletNo  from BArrangeBillBox where " + commadPallet;//获取订单下的托盘号码
                        SCommBB bb = new SCommBB();
                        DataTable dt = bb.Query(command).Tables[0];
                        //发现即便是没有数据
                        if (dt.Rows.Count > 0)
                        {
                            if (string.IsNullOrEmpty(dt.Rows[0][0].ToString()))
                            {
                                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"箱没有在托盘上请确定!\");", true);
                                return;
                            }
                        }
                        if (dt.Rows.Count > 1)
                        {
                            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"托盘不唯一!\");", true);
                            return;
                        }
                        command = @"select checkResult from BArrangeBillBox where palletNo  in (
        select distinct palletNo from BArrangeBillBox where " + commadPallet + ") and checkResult = 1 ";
                        DataTable noPass = bb.Query(command).Tables[0];
                        bb.Dispose();
                        if (noPass.Rows.Count > 0)
                        {
                            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"托盘上有合格的产品需要不能进行退货!\");", true);
                            return;
                        }
                        //2015-08-07 修改到异常区的叉车任务的功能
                        BForkliftTaskBC bforkTaskBC = new BForkliftTaskBC();
                        if (
                        bforkTaskBC.SaveForkliftTaskWithTHD(dt.Rows[0][0].ToString(), "", "", "30", this.currentUser.empId, backBillModel.backBillNo))
                        {
                            retChecked = true;
                            backBillModel.commitDt = System.DateTime.Now.ToString();
                            backBillModel.commitEmpId = this.currentUser.empId;
                            backBillModel.instantState = "02";
                            backBillBB.ModifyRecord(backBillModel);
                        }
                        else
                        {
                            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
        {
            backBillBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }