Exemple #1
0
        //checks for a valid quantity
        private int CheckForValidQuantity()
        {
            int result = 1;

            //foreach (DataGridItem dItem in grdItems.Items)
            foreach (GridViewRow dItem in grdViewItems.Rows)
            {
                TextBox     txtQty             = (TextBox)dItem.FindControl("txtQty");
                Label       lblLimit           = (Label)dItem.FindControl("lblQty");
                PlaceHolder MessagePlaceHolder = (PlaceHolder)dItem.FindControl("MessagePlaceHolder");

                GlobalUtils.Utils UtilityMethods = new GlobalUtils.Utils();
                bool returnvalue = UtilityMethods.IsQtyValueValid(txtQty.Text, lblLimit.Text);
                if (returnvalue == false)
                {
                    GlobalUtils.Utils.DisplayMessage(ref MessagePlaceHolder, 2);
                    result = -1;
                    break;
                }
                else
                {
                    GlobalUtils.Utils.DisplayMessage(ref MessagePlaceHolder, 99);
                }
            }
            return(result);
        }
Exemple #2
0
        //checks for a valid quantity
        private int CheckForValidQuantity()
        {
            int  result      = 1;
            int  Counter     = 0;
            bool returnvalue = true;

            //Loop through the grid rows
            foreach (GridViewRow dItem in grdViewItems.Rows)
            {
                Label       lblQty       = (Label)dItem.FindControl("lblQty");
                HiddenField hdnQty       = (HiddenField)dItem.FindControl("hdnQty");
                LinkButton  lnkBtnItem   = (LinkButton)dItem.FindControl("lnkBtnItem");
                HiddenField hdnPubLimit  = (HiddenField)dItem.FindControl("hdnPubLimit");
                Label       lblEmailOnly = (Label)dItem.FindControl("lblEmailOnly");
                if (!lblEmailOnly.Visible)  //***EAC dirty hack to tell if the line item is physical/virtual
                {
                    lblQty.Text = hdnQty.Value;
                    int valQty = Int32.Parse(hdnQty.Value);
                    if (valQty > 0 && returnvalue == true)
                    {
                        Counter += Int32.Parse(hdnQty.Value);
                        GlobalUtils.Utils UtilityMethods = new GlobalUtils.Utils();

                        returnvalue = UtilityMethods.IsQtyValueValid(hdnQty.Value, hdnPubLimit.Value);
                        if (returnvalue == false)
                        {
                            result = -1;
                            if (string.Compare(hdnPubLimit.Value, "1") == 0)
                            {
                                lblMessage.Text = "Sorry, you cannot order more than " + hdnPubLimit.Value + " copy of " + lnkBtnItem.Text + ".";
                            }
                            else
                            {
                                lblMessage.Text = "Sorry, you cannot order more than " + hdnPubLimit.Value + " copies of " + lnkBtnItem.Text + ".";
                            }
                        }
                    }
                }
            }

            //Check for max order limit
            if (Counter > Int32.Parse(hdnTotalLimit.Value) && result == 1)
            {
                result          = -1;
                lblMessage.Text = "Sorry, you cannot order more than " + hdnTotalLimit.Value + " items.";
            }

            return(result);
        }