/// <summary>
    /// 提交排托单
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCommit_Click(object sender, EventArgs e)
    {
        BArriveBillBB arriveBillBB = new BArriveBillBB();
        BArrangeBillBC arrangeBillBC = new BArrangeBillBC();

        try
        {
            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    string strBillNo = "", strSate = "";
                    DataSet ds = new DataSet();

                    strBillNo = chkId.ValidationGroup;

                    //实时获取到货单状态
                    ds = arriveBillBB.GetList(" billNo='" + strBillNo + "'");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        strSate = ds.Tables[0].Rows[0]["instantState"].ToString();
                    }

                    if (strSate != "02")//当前到货单状态必须为“已生成排托单”
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前到货单未生成排托单、排托单已提交或已开始收货,不允许提交!\");", true);
                        return;
                    }
                    else
                    {
                        arrangeBillBC.CommitArrangeBill(strBillNo);//提交排托单
                        this.BindGrid();//重新绑定到货单列表
                        return;
                    }
                }
            }

            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true);
            return;
        }
        finally
        {
            arriveBillBB.Dispose();
            arrangeBillBC.Dispose();
        }
    }
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        BArriveBillBB arriveBillBB = new BArriveBillBB();

        try
        {
            string strWhere = this.StrWhere;
            DataSet ds = new DataSet();

            //到货通知单编号
            if (txtBillNo.Text.Trim() != "")
            {
                strWhere += " and  billNo like '%" + txtBillNo.Text.Replace("'", "''") + "%'";
            }

            //供应商
            if (txtSupple.Text.Trim() != "")
            {
                strWhere += " and  (custNo='" + txtSupple.Text.Replace("'", "''")
                    + "' or custNm like '%" + txtSupple.Text.Replace("'", "''") + "%')";
            }

            //到货通知单状态
            if (ddlState.SelectedValue.Trim() != "")
            {
                strWhere += " and instantState = '" + ddlState.SelectedValue.Replace("'", "''") + "'";
            }

            //到货日期
            if (this.beginDt.Text != "")
            {
                strWhere += " and arriveDt >='" + this.beginDt.Text.Trim() + "'";
            }

            if (this.endDt.Text != "")
            {
                strWhere += " and arriveDt <'" + Convert.ToDateTime(this.endDt.Text).AddDays(1).ToShortDateString() + "'";
            }

            //是否收货完成
            if (this.ddlIsFinishReceive.SelectedValue != "")
            {
                if (this.ddlIsFinishReceive.SelectedValue == "1")//收货完成
                {
                    strWhere += " and not exists(select 1 from dbo.BArriveDetail as t where t.arriveBillNo=dbo.vBArriveBill.billNo and t.isFinishReceive=0)";
                }
                else//未收货完成
                {
                    strWhere += " and exists(select 1 from dbo.BArriveDetail as t where t.arriveBillNo=dbo.vBArriveBill.billNo and t.isFinishReceive=0)";
                }
            }

            ds = arriveBillBB.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
        {
            arriveBillBB.Dispose();
        }
    }
Ejemplo n.º 3
0
    public DataTable GetArriveBillList()
    {
        BArriveBillBB arriveBillBB = new BArriveBillBB();

        try
        {
            DataTable dt = new DataTable();

            dt = arriveBillBB.GetVList("instantState in ('03','04')").Tables[0];
            return dt;
        }
        finally
        {
            arriveBillBB.Dispose();
        }
    }