コード例 #1
0
        private bool ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(tbName.Text))
            {
                Global.ValidationFailed(this, LabsResources.NameNull);
                tbName.FocusAndSelect();
                return(false);
            }

            if (string.Compare(tbName.Text, "همه", true) == 0)
            {
                Global.ValidationFailed(this, SharedResources.SystemReserved);
                tbName.FocusAndSelect();
                return(false);
            }

            if (!EditMode)
            {
                if (LabsService.Exist(tbName.Text))
                {
                    Global.ValidationFailed(this, LabsResources.NameDuplicate);
                    tbName.FocusAndSelect();
                    return(false);
                }
            }
            else if (LabsService.Instanse.Exist(tbName.Text, _current))
            {
                Global.ValidationFailed(this, LabsResources.NameDuplicate);
                tbName.FocusAndSelect();
                return(false);
            }

            return(true);
        }
コード例 #2
0
        private bool ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(cmbNames.Text))
            {
                cmbNames.Focus();
                return(false);
            }

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

            int temp;

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

            return(true);
        }
コード例 #3
0
        private bool ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(tbName.Text))
            {
                Global.ValidationFailed(this, CategoriesResources.NameNull);
                tbName.FocusAndSelect();
                return(false);
            }

            if (!EditMode)
            {
                if (CategoriesService.Exist(tbName.Text))
                {
                    Global.ValidationFailed(this, CategoriesResources.NameDuplicate);
                    tbName.FocusAndSelect();
                    return(false);
                }
            }
            else if (CategoriesService.Exist(tbName.Text, _current))
            {
                Global.ValidationFailed(this, CategoriesResources.NameDuplicate);
                tbName.FocusAndSelect();
                return(false);
            }

            return(true);
        }
コード例 #4
0
        private bool ValidateFields()
        {
            if (string.IsNullOrEmpty(pbCurrentPassword.Password) && string.IsNullOrEmpty(pbNewPassword.Password) &&
                string.IsNullOrEmpty(pbConfirmNewPassword.Password))
            {
                return(true);
            }

            if (string.Compare(UsersService.EncodePassword(pbCurrentPassword.Password), _password, false) != 0)
            {
                Global.ValidationFailed(this, AccountResources.CurrentPasswordWrong);
                pbCurrentPassword.FocusAndSelect();
                return(false);
            }

            if (!UsersService.ValidPassword(pbNewPassword.Password))
            {
                Global.ValidationFailed(this, AccountResources.NewPasswordInvalid);
                pbNewPassword.FocusAndSelect();
                return(false);
            }

            if (string.Compare(pbNewPassword.Password, pbConfirmNewPassword.Password, false) != 0)
            {
                Global.ValidationFailed(this, AccountResources.NewConfirmPasswordDoestNotMatchWithNewPassword);
                pbConfirmNewPassword.FocusAndSelect();
                return(false);
            }

            return(true);
        }
コード例 #5
0
        private bool ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(tbUserName.Text))
            {
                Global.ValidationFailed(this, UsersResources.UserNameNull);
                tbUserName.FocusAndSelect();
                return(false);
            }

            if (!EditMode)
            {
                if (UsersService.Exist(tbUserName.Text))
                {
                    Global.ValidationFailed(this, UsersResources.UserNameDuplicate);
                    tbUserName.FocusAndSelect();
                    return(false);
                }
            }

            if (string.IsNullOrWhiteSpace(pbPassword.Password))
            {
                Global.ValidationFailed(this, UsersResources.PasswordNull);
                pbPassword.FocusAndSelect();
                return(false);
            }

            if (!UsersService.ValidPassword(pbPassword.Password))
            {
                Global.ValidationFailed(this, UsersResources.PasswordInvalid);
                pbPassword.FocusAndSelect();
                return(false);
            }

            if (string.IsNullOrWhiteSpace(pbConfirmPassword.Password))
            {
                Global.ValidationFailed(this, UsersResources.ConfirmPasswordNull);
                pbConfirmPassword.FocusAndSelect();
                return(false);
            }

            if (string.Compare(pbPassword.Password, pbConfirmPassword.Password, false) != 0)
            {
                Global.ValidationFailed(this, UsersResources.ConfirmPasswordDoestNotMatchWithPassword);
                pbConfirmPassword.FocusAndSelect();
                return(false);
            }

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

            return(true);
        }
コード例 #6
0
        private bool ValidateFields()
        {
            if (cmbStatus.SelectedIndex != 0 && cmbStatus.SelectedIndex != 4)
            {
                if (dtpOutDate.IsEmpty)
                {
                    Global.ValidationFailed(this,
                                            string.Format(SharedResources.Empty, tbOutDate.Text.Replace(":", null)));
                    dtpOutDate.FocusAndSelect();
                    return(false);
                }

                if (!dtpOutDate.IsValid)
                {
                    Global.ValidationFailed(this,
                                            string.Format(SharedResources.InvalidDate, tbOutDate.Text.Replace(":", null)));
                    dtpOutDate.FocusAndSelect();
                    return(false);
                }

                if (dtpInDate.Visibility == Visibility.Visible && dtpInDate.IsEmpty)
                {
                    Global.ValidationFailed(this, string.Format(SharedResources.Empty, tbInDate.Text.Replace(":", null)));
                    dtpInDate.FocusAndSelect();
                    return(false);
                }

                if (dtpInDate.Visibility == Visibility.Visible && !dtpInDate.IsValid)
                {
                    Global.ValidationFailed(this,
                                            string.Format(SharedResources.InvalidDate, tbInDate.Text.Replace(":", null)));
                    dtpInDate.FocusAndSelect();
                    return(false);
                }

                var lowerBound = dtpOutDate.Value;
                var upperBound = dtpInDate.Value;

                if (lowerBound.HasValue && upperBound.HasValue)
                {
                    if (lowerBound.Value > upperBound.Value)
                    {
                        Global.ValidationFailed(this, SharedResources.InvalidBound);
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #7
0
        private bool ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(tbUserName.Text))
            {
                Global.ValidationFailed(this, LoginResources.UserNameNull);
                tbUserName.FocusAndSelect();
                return(false);
            }

            if (string.IsNullOrWhiteSpace(pbPassword.Password))
            {
                Global.ValidationFailed(this, LoginResources.PasswordNull);
                pbPassword.FocusAndSelect();
                return(false);
            }

            return(true);
        }
コード例 #8
0
        private bool ValidateFields()
        {
            if (string.IsNullOrWhiteSpace(cmbNames.Text))
            {
                Global.ValidationFailed(this, PropsResources.NameNull);
                cmbNames.Focus();
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(tbPropNo.Text))
            {
                int temp;
                if (!int.TryParse(tbPropNo.Text, out temp))
                {
                    Global.ValidationFailed(this, PropsResources.PropNoInvalid);
                    tbPropNo.FocusAndSelect();
                    return(false);
                }
                if (!EditMode)
                {
                    if (PropsService.Exist(int.Parse(tbPropNo.Text)))
                    {
                        Global.ValidationFailed(this, PropsResources.PropNoDuplicate);
                        tbPropNo.FocusAndSelect();
                        return(false);
                    }
                }
                else
                {
                    if (PropsService.Exist(int.Parse(tbPropNo.Text), _current))
                    {
                        Global.ValidationFailed(this, PropsResources.PropNoDuplicate);
                        tbPropNo.FocusAndSelect();
                        return(false);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(tbSerialNo.Text))
            {
                if (!EditMode)
                {
                    if (PropsService.Exist(tbSerialNo.Text))
                    {
                        Global.ValidationFailed(this, PropsResources.SerialNoDuplicate);
                        tbSerialNo.FocusAndSelect();
                        return(false);
                    }
                }
                else
                {
                    if (PropsService.Exist(tbSerialNo.Text, _current))
                    {
                        Global.ValidationFailed(this, PropsResources.SerialNoDuplicate);
                        tbSerialNo.FocusAndSelect();
                        return(false);
                    }
                }
            }

            if (!dtpPurchasingDate.IsValid)
            {
                Global.ValidationFailed(this, PropsResources.PurchasingDateInvalid);
                dtpPurchasingDate.FocusAndSelect();
                return(false);
            }

            if (!dtpWarrantyExpirationDate.IsValid)
            {
                Global.ValidationFailed(this, PropsResources.WarrantyExpirationDateInvalid);
                dtpWarrantyExpirationDate.FocusAndSelect();
                return(false);
            }

            return(true);
        }
コード例 #9
0
        private bool ValidateFields()
        {
            if (_materials)
            {
                if (cmbMaterials.SelectedValue == null)
                {
                    cmbMaterials.Focus();
                    return(false);
                }
            }
            else if (cmbItems.SelectedValue == null)
            {
                cmbItems.Focus();
                return(false);
            }

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

            int temp;

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

            if (cmbLabs.SelectedValue == null)
            {
                cmbLabs.Focus();
                return(false);
            }

            if (string.IsNullOrWhiteSpace(tbTargetApplicant.Text))
            {
                Global.ValidationFailed(this,
                                        string.Format(RepositoryMaterialsAndItemsResources.TargetNull,
                                                      tbTargetApplicant.Tag));
                tbTargetApplicant.FocusAndSelect();
                return(false);
            }

            if (cmbActionType.SelectedIndex == 0)
            {
                int result;
                if (_materials)
                {
                    RepositoryMaterialsService.Instanse.ValidateAmount((Guid)cmbMaterials.SelectedValue,
                                                                       -int.Parse(tbAmount.Text), out result);
                    if (result == -1)
                    {
                        if (
                            MessageWindowHelpers.Show(this,
                                                      string.Format(
                                                          RepositoryMaterialsAndItemsResources.CriticalAmount,
                                                          new[] { tbAmount.Text, cmbActionType.Tag, cmbMaterials.Text }),
                                                      MessageBoxButton.YesNo, MessageBoxImage.Warning) ==
                            MessageBoxResult.Yes)
                        {
                            return(true);
                        }
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                    if (result >= 0)
                    {
                        Global.ValidationFailed(this,
                                                string.Format(RepositoryMaterialsAndItemsResources.InvalidAmount,
                                                              new[] {
                            result.ToString(),
                            cmbEntryMode.SelectedIndex == 0
                                                                            ? tbAmount.Tag
                                                                            : ComputingUnit.Count.ToUIString(true)
                        }));
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                }
                else
                {
                    RepositoryItemsService.Instanse.ValidateAmount((Guid)cmbItems.SelectedValue,
                                                                   -int.Parse(tbAmount.Text), out result);
                    if (result == -1)
                    {
                        if (
                            MessageWindowHelpers.Show(this,
                                                      string.Format(RepositoryMaterialsAndItemsResources.CriticalCount,
                                                                    new[]
                                                                    { tbAmount.Text, cmbActionType.Tag, cmbItems.Text }),
                                                      MessageBoxButton.YesNo, MessageBoxImage.Warning) ==
                            MessageBoxResult.Yes)
                        {
                            return(true);
                        }
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                    if (result >= 0)
                    {
                        Global.ValidationFailed(this,
                                                string.Format(RepositoryMaterialsAndItemsResources.InvalidCount,
                                                              new[] { result.ToString(), tbAmount.Tag }));
                        tbAmount.FocusAndSelect();
                        return(false);
                    }
                }
            }

            return(true);
        }