예제 #1
0
        public RecordNavigationCommand(Action<object, RecordNavigation> execute, RecordNavigation navigation, Func<object, RecordNavigation, bool> canNavigate, Predicate<object> canExecute)
        {
            if (execute == null)
            {
                throw new ArgumentNullException("execute");
            }
            if (navigation == RecordNavigation.None)
            {
                throw new ArgumentException("navigation parameter cannot be None");
            }
            if (canNavigate == null)
            {
                throw new ArgumentNullException("canNavigate");
            }

            _execute = execute;
            Navigation = navigation;
            _canNavigate = canNavigate;
            _canExecute = canExecute;
        }
예제 #2
0
        private void PerformNavigation(object parameter, RecordNavigation navigation)
        {
            if (navigation == RecordNavigation.Position)
            {
                int position;

                if (!((parameter is TextBox) && int.TryParse((parameter as TextBox).Text, out position)))
                {
                    Set(() => CurrentPosition, CurrentPosition, true);
                    return;
                }

                if (!(parameter is TextBox) && !int.TryParse(parameter.ToString(), out position))
                {
                    Set(() => CurrentPosition, CurrentPosition, true);
                    return;
                }

                base.PerformNavigation(position, navigation);
            }
            else
            {
                base.PerformNavigation(0, navigation);
            }
        }
예제 #3
0
 private bool CanNavigate(object parameter, RecordNavigation navigation)
 {
     if (navigation == RecordNavigation.Position)
     {
         int dummy;
         return NavigationsEnabled.Contains(navigation) &&
                 parameter is TextBox ||
                 int.TryParse((parameter as TextBox).Text, out dummy);
     }
     return NavigationsEnabled.Contains(navigation);
 }
예제 #4
0
        private void NavigateRecord(RecordNavigation navigation)
        {
            SalesOrder queryResult;
            var        currSalesNo     = 1;
            var        expectedSalesNo = string.Empty;

            if (string.IsNullOrEmpty(lblSalesNo.Text))
            {
                if (navigation == RecordNavigation.First || navigation == RecordNavigation.Previous || navigation == RecordNavigation.Next)
                {
                    navigation = RecordNavigation.First;
                }
                else
                {
                    navigation = RecordNavigation.Last;
                }
            }
            else
            {
                currSalesNo = Convert.ToInt32(lblSalesNo.Text.Substring(lblSalesNo.Text.Trim().Length - 6));
            }

            switch (navigation)
            {
            case RecordNavigation.First:
                queryResult = _uow.Repository.GetAll().OrderBy(s => s.SalesNo).FirstOrDefault();
                break;

            case RecordNavigation.Previous:
                queryResult = null;
                if (currSalesNo > 1)
                {
                    expectedSalesNo = string.Concat("SO-", (currSalesNo - 1).ToString().PadLeft(6, '0'));
                    queryResult     = _uow.Repository.GetAll().Where(s => s.SalesNo == expectedSalesNo).FirstOrDefault();
                }
                break;

            case RecordNavigation.Next:
                queryResult = null;
                var lastRec = _uow.Repository.GetAll().OrderByDescending(s => s.SalesNo).FirstOrDefault();
                if (lastRec.Id != txtSalesOrderId.Text.Trim())
                {
                    expectedSalesNo = string.Concat("SO-", (currSalesNo + 1).ToString().PadLeft(6, '0'));
                    queryResult     = _uow.Repository.GetAll().Where(s => s.SalesNo == expectedSalesNo).FirstOrDefault();
                }
                break;

            case RecordNavigation.Last:
                queryResult = _uow.Repository.GetAll().OrderByDescending(s => s.SalesNo).FirstOrDefault();
                break;

            default:
                CommonMessageHelper.ContactAdminError();
                return;
            }

            if (queryResult != null)
            {
                LoadDataItem(queryResult);
            }

            SetUIButtonGroup();
        }
예제 #5
0
 public RecordNavigationCommand(Action<object, RecordNavigation> execute, RecordNavigation navigation, Func<object, RecordNavigation, bool> canNavigate)
     : this(execute, navigation, canNavigate, null)
 {
 }