예제 #1
0
        private void GLs_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                int.TryParse(SystemAccountingSettingModel.GLLength, out int SystemAccountingSettingModelGLLength);
                long z = 1;
                long r = 0;
                for (int i = 1; i <= SystemAccountingSettingModelGLLength; i++)
                {
                    r += z * 9;
                    z *= 10;
                }
                if (!_uow.GLs.Any())
                {
                    LastGLCode = 1;
                }
                else
                {
                    LastGLCode = _uow.GLs.Select(x => x.GLCode).Max() + 1;
                }
                if (LastGLCode == 1)
                {
                    var stringLastGLCode = LastGLCode.ToString();
                    var lastGLsCode      = stringLastGLCode.ToString().PadRight(SystemAccountingSettingModelGLLength, '0');
                    ((GL)e.NewItems[0]).GLCode = int.Parse(lastGLsCode);
                    LastGLCode++;
                    // LastGLCode = _uow.GLs.Select(x => x.GLCode).Max() + 1;
                }
                else if (LastGLCode > 1 && LastGLCode <= r)
                {
                    ((GL)e.NewItems[0]).GLCode = LastGLCode;
                    LastGLCode = _uow.GLs.Select(x => x.GLCode).Max() + 1;
                }
                else
                {
                    var manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, new Point(0, 0), 100);

                    var alert = new RadDesktopAlert
                    {
                        FlowDirection = FlowDirection.RightToLeft,
                        Header        = "اطلاعات",
                        Content       = ".شماره گذاری حساب گروه به پایان رسیده است",
                        ShowDuration  = 1000,
                    };
                    manager.ShowAlert(alert);
                }
                GLCodeEmptyValue = LastGLCode;
            }
        }
예제 #2
0
 private void OnAddGL()
 {
     int.TryParse(SystemAccountingSettingModel.GLLength, out int SystemAccountingSettingModelGLLength);
     if (LastGLCode == 1)
     {
         var stringLastGLCode = LastGLCode.ToString();
         var lastGLsCode      = stringLastGLCode.ToString().PadRight(SystemAccountingSettingModelGLLength, '0');
         if (GLs.CurrentItem is GL gl)
         {
             gl.GLCode = int.Parse(lastGLsCode);
         }
     }
     else if (LastGLCode != 1)
     {
         //if (GLs.CurrentItem is GL gl)
         //{
         //    gl.GLCode = LastGLCode;
         //}
     }
     GLCodeEmptyValue = 0;
 }
예제 #3
0
        public void LoadGLs()
        {
            _uow    = new SainaDbContext();
            _allGLs = _uow.Set <GL>().ToList();
            // _allGLs = _uow.Set<GL>().AsNoTracking().ToListAsync().ConfigureAwait(false);
            GLs = new QueryableCollectionView(_uow.GLs.ToList());
            SystemAccountingSettingModel = AutoMapper.Mapper.Map <SystemAccountingSettingModel, EditableSystemAccountingSettingModel>(_systemAccountingSettingsService.GetSystemAccountingSettingModel());

            int.TryParse(SystemAccountingSettingModel.GLLength, out int SystemAccountingSettingModelGLLength);
            if (_uow.GLs.Any())
            {
                LastGLCode = _uow.GLs.Select(x => x.GLCode).Max() + 1;
            }
            else
            {
                LastGLCode = 1;
            }

            LastGLLenght = (LastGLCode.ToString()).Length;
            Sum          = "0," + SystemAccountingSettingModelGLLength.ToString();
            //var lastSLCode = stringLastGLCode.ToString().PadLeft(SystemAccountingSettingModelSLLength - SystemAccountingSettingModelTLLength, '0');

            Regex = $"^[0-9]{{{Sum}}}$";
            if (SystemAccountingSettingModelGLLength == 0)
            {
                EnableTab = false;
                Error?.Invoke("تنظیمات حسابداری انجام نشده است");
            }
            else if (SystemAccountingSettingModelGLLength > 0 && LastGLLenght != SystemAccountingSettingModelGLLength)
            {
                EnableSave = false;
                EnableTab  = true;
            }
            else
            {
                EnableSave = true;
                EnableTab  = true;
            }
        }