Beispiel #1
0
        private bool ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(cmbNames.Text))
            {
                cmbNames.Focus();
                return(false);
            }

            if (!EditMode)
            {
                if (MaterialsService.Exist(cmbNames.Text))
                {
                    Global.ValidationFailed(this, MaterialsResources.NameDuplicate);
                    cmbNames.Focus();
                    return(false);
                }
            }
            else if (MaterialsService.Exist(cmbNames.Text, _current))
            {
                Global.ValidationFailed(this, MaterialsResources.NameDuplicate);
                cmbNames.Focus();
                return(false);
            }

            if (cmbMesureUnit.SelectedIndex == -1)
            {
                cmbMesureUnit.Focus();
                return(false);
            }

            int temp;

            if (!int.TryParse(tbLowestAmount.Text, out temp))
            {
                Global.ValidationFailed(this, InputResources.Invalid);
                tbLowestAmount.FocusAndSelect();
                return(false);
            }

            return(true);
        }