Beispiel #1
0
        private bool ValidateGL()
        {
            var result       = true;
            var errorMessage = "";

            if (GL != null)
            {
                if (_gLsService.HasTitle(GL.Title, GL.GLId))
                {
                    errorMessage += $"عنوان نباید تکراری باشد {Environment.NewLine}";
                }
                if (_gLsService.Hasduplicate(GL.GLCode, GL.GLId))
                {
                    errorMessage += $"کد حساب نباید تکراری باشد {Environment.NewLine}";
                }

                if (GL.GLCode == 0)
                {
                    errorMessage += $"کد حساب نباید 0 باشد {Environment.NewLine}";
                }
                if (GL.Title == null || GL.Title == "")
                {
                    errorMessage += $"عنوان حساب نباید خالی باشد {Environment.NewLine}";
                }
                if (errorMessage.Length > 0)
                {
                    result = false;
                    DialogParameters parameters = new DialogParameters();
                    parameters.OkButtonContent = "بستن";
                    parameters.Header          = "!اخطار";
                    parameters.Content         = errorMessage;
                    RadWindow.Alert(parameters);
                }
                return(result);
            }
            else
            {
                return(true);
            }
        }
        //private void OnCancel()
        //{
        //    Done?.Invoke();
        //}
        private async void OnSave()
        {
            string errors = "";

            if (GL.GLId == 0)
            {
                //   var editingGL = Mapper.Map<EditableGL, GL>(GL);
                if (GL.Title == null || GL.Title == "")
                {
                    errors += "عنوان خالی می باشد" + Environment.NewLine;
                }
                if (GL.GLCode == 0)
                {
                    errors += "کد حساب اشتباه می باشد" + Environment.NewLine;
                }
                if (_gLsService.HasTitle(GL.Title, GL.GLId))
                {
                    errors += ("عنوان نباید تکراری باشد") + Environment.NewLine;
                }
                ;
                if (_gLsService.Hasduplicate(GL.GLCode, GL.GLId))
                {
                    errors += ("کد  حساب نباید تکراری باشد") + Environment.NewLine;
                }
            }
            else
            {
                if (GL.Title == null || GL.Title == "")
                {
                    errors += "عنوان خالی می باشد" + Environment.NewLine;
                }
                if (GL.GLCode == 0)
                {
                    errors += "کد حساب اشتباه می باشد" + Environment.NewLine;
                }
                if (await _gLsService.HasTitleTree(GL.Title, GL.GLId))
                {
                    errors += ("عنوان نباید تکراری باشد") + Environment.NewLine;
                }
                ;
                if (await _gLsService.HasduplicateTree(GL.GLCode, GL.GLId))
                {
                    errors += ("کد  حساب نباید تکراری باشد") + Environment.NewLine;
                }
            }
            if (errors.Length > 0)
            {
                DialogParameters parameters = new DialogParameters();
                parameters.OkButtonContent = "بستن";
                parameters.Header          = "اخطار";
                parameters.Content         = errors;
                RadWindow.Alert(parameters);
            }
            else
            {
                try
                {
                    SaveClicked(GL);
                }
                catch (Exception ex)
                {
                    Failed(ex);
                }
                finally
                {
                    GL = null;
                }
            }
        }