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

        try
        {
            string strWhere = this.StrWhere;

            //托盘类型编码
            if (this.tbPalletSortNo.Text.Trim() != "")
            {
                strWhere += " and palletSortNo like '%" + this.tbPalletSortNo.Text.Trim().Replace("'", "''") + "%'";
            }

            //托盘类型名称
            if (this.tbPalletSortNm.Text.Trim() != "")
            {
                strWhere += " and palletSortNm like '%" + this.tbPalletSortNm.Text.Trim().Replace("'", "''") + "%'";
            }

            ds = palletSortBB.GetVList(strWhere);
            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
        {
            palletSortBB.Dispose();
        }
    }
    /// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strInfo = "";

        if (!this.ValidateData(out strInfo))
        {
            strInfo = strInfo.Replace("\"", "'").Replace("\n", "");
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true);
            return;
        }

        LPalletSortData model = new LPalletSortData();
        LPalletSortBB palletSortBB = new LPalletSortBB();

        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                this.IdValue = palletSortBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = palletSortBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                model.updtDt = DateTime.Now.ToString();
                model.updtEmpId = this.currentUser.empId;
                palletSortBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            palletSortBB.Dispose();
        }

        Response.Redirect("LPalletSortList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
    }
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        LPalletSortBB palletSortBB = new LPalletSortBB();
        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);
                    LPalletSortData palletSortModel = new LPalletSortData();

                    palletSortModel = palletSortBB.GetModel(id);
                    palletSortModel.isDel = true;
                    palletSortModel.updtDt = System.DateTime.Now.ToString();
                    palletSortModel.updtEmpId = this.currentUser.empId;
                    palletSortBB.ModifyRecord(palletSortModel);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            palletSortBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
    /// <summary>
    /// 展示数据
    /// </summary>
    /// <param name="id">记录Id</param>
    private void ShowInfo(int id)
    {
        LPalletSortBB palletSortBB = new LPalletSortBB();
        vLPalletSortData model = new vLPalletSortData();

        try
        {
            model = palletSortBB.GetVModel(id);
            this.tbPalletSortNo.Text = model.palletSortNo;
            this.tbPalletSortNm.Text = model.palletSortNm;
        }
        finally
        {
            palletSortBB.Dispose();
        }
    }