Пример #1
0
        private void AmountInput_BeforeInput(object sender, BeforeInputEventArgs e)
        {
            AmountInputBox input              = sender as AmountInputBox;
            var            rowIndex           = int.Parse(input.Name.Substring(m_LastFocusControl.IndexOf("_") + 1));
            var            aInputCreditAmount = GetAmountInputBoxByName("aInputCredit_" + rowIndex).Value;
            var            aInputDebitsAmount = GetAmountInputBoxByName("aInputDebits_" + rowIndex).Value;

            if (input.Name.StartsWith("aInputCredit_") && aInputDebitsAmount > 0)
            {
                e.Disable = true;
            }
            else if (input.Name.StartsWith("aInputDebits_") && aInputCreditAmount > 0)
            {
                e.Disable = true;
            }
        }
Пример #2
0
        void Input(int val)
        {
            var args = new BeforeInputEventArgs();

            BeforeInputEvent?.Invoke(this, args);
            if (args.Disable)
            {
                return;
            }

            var cur   = GetForcusCell();
            int index = GetCellIndex(cur);

            if (m_EditModel == EditModel.FRACTIONAL)
            {
                InputFractional(index, val.ToString());
                return;
            }

            if (index == UNITS_DIGIT_INDEX)
            {
                if (cur.Content == null)
                {
                    FillCell(index, val.ToString());
                    cur.Tag = null;
                    return;
                }
                else if (cur.Tag != null)
                {
                    if (string.IsNullOrEmpty(cur.Content.ToString()) ||
                        cur.Tag.ToString() == "0")
                    {
                        FillCell(index, val.ToString());
                        cur.Tag = null;
                        return;
                    }
                }
            }

            bool bEmpty   = false;
            int  idxEmpty = UNITS_DIGIT_INDEX;

            while (idxEmpty > index)
            {
                var cellEmpty = cells[idxEmpty];
                if (cellEmpty.Content == null)
                {
                    bEmpty = true;
                    break;
                }
                else if (cellEmpty.Tag != null && cellEmpty.Tag.ToString() == "0")
                {
                    bEmpty = true;
                    break;
                }
                idxEmpty--;
            }

            if (bEmpty)
            {
                cells[idxEmpty].IsChecked = true;
                m_HeadIndex = idxEmpty;
                FillCell(idxEmpty, val.ToString());
                if (cells[idxEmpty].Tag != null)
                {
                    if (idxEmpty == UNITS_DIGIT_INDEX && cells[idxEmpty].Tag.ToString() == "0")
                    {
                        cells[idxEmpty].Tag = null;
                    }
                }
            }
            else if (--m_HeadIndex >= 0)
            {
                int idx = m_HeadIndex;
                while (idx < index)
                {
                    FillCell(idx, cells[++idx].Content.ToString());
                }
                FillCell(idx, val.ToString());
            }
        }