Beispiel #1
0
        protected void disburseItemGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row      = disburseItemGridView.Rows[e.RowIndex];
            int         actual   = Int32.Parse((row.FindControl("Actual") as TextBox).Text);
            int         expected = Int32.Parse((row.FindControl("Expected") as Label).Text);


            string itemID = (row.FindControl("itemIDLabel") as Label).Text;

            if (actual > expected)
            {
                disburseItemGridView.EditIndex  = -1;
                disburseItemGridView.DataSource = (List <DisbursementCart>)ViewState["list"];
                disburseItemGridView.DataBind();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('The quantity you entered cannot larger than needed amount!')", true);
                return;
            }

            if (Convert.ToInt32(ViewState["originQty"]) == actual)
            {
                disburseItemGridView.EditIndex  = -1;
                disburseItemGridView.DataSource = (List <DisbursementCart>)ViewState["list"];
                disburseItemGridView.DataBind();
            }
            else
            {
                DisbursementDAO disDAO = new DisbursementDAO();
                disDAO.savingActualQty(Convert.ToInt32(ViewState["disburseID"]), itemID, actual);
                disburseItemGridView.EditIndex = -1;
                List <DisbursementCart> ldc = (List <DisbursementCart>)ViewState["list"];
                foreach (var i in ldc)
                {
                    if (i.ID == itemID)
                    {
                        i.Actual = actual;
                        break;
                    }
                }
                disburseItemGridView.DataSource = (List <DisbursementCart>)ViewState["list"];
                disburseItemGridView.DataBind();
            }
        }