Example #1
0
        //to check if some information user put is empty or invalid.
        bool IsItemDataValid()
        {
            //Check if an user input empty information
            if (ItemNameTxtbox.Text == "" || ItemPriceTxtbox.Text == "" || ItemQuantTxtbox.Text == "")
            {
                //Place the focus on the first invalid textbox
                if (ItemNameTxtbox.Text == "")
                {
                    ItemNameTxtbox.Focus();
                }
                if (ItemPriceTxtbox.Text == "")
                {
                    ItemPriceTxtbox.Focus();
                }
                if (ItemQuantTxtbox.Text == "")
                {
                    ItemQuantTxtbox.Focus();
                }
                return(false);
            }

            //Check if the number an user input is negative
            else if (Convert.ToDecimal(ItemPriceTxtbox.Text) <= 0 || (Convert.ToInt32(ItemQuantTxtbox.Text) <= 0))
            {
                //Place the focus on the first invalid textbox
                if (ItemPriceTxtbox.Text == "")
                {
                    ItemPriceTxtbox.Focus();
                }
                if (ItemQuantTxtbox.Text == "")
                {
                    ItemQuantTxtbox.Focus();
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }