Esempio n. 1
0
        private void SetGridData()
        {
            var checkCell         = new CheckBoxCell();
            var textCellName      = new GcTextBoxCell();
            var numberCellOrder   = new GcNumberCell();
            var checkCellIndex    = 0;
            var numberCellIndex   = 2;
            var useContractNumber = UseLongTermAdvanceReceived && RegisterContractInAdvance;
            var tableName         = InputGridTypeId == InputGridType.Billing ? nameof(Billing) : nameof(Receipt);

            var note1 = "備考1";
            var note2 = "備考2";
            var note3 = "備考3";
            var note4 = "備考4";

            foreach (var names in ColumnNameList.Where(x => x.TableName == tableName))
            {
                if (names.ColumnName == "Note1")
                {
                    note1 = names.DisplayColumnName;
                }
                if (names.ColumnName == "Note2")
                {
                    note2 = names.DisplayColumnName;
                }
                if (names.ColumnName == "Note3")
                {
                    note3 = names.DisplayColumnName;
                }
                if (names.ColumnName == "Note4")
                {
                    note4 = names.DisplayColumnName;
                }
            }

            if (InputControlList.Count > 0)
            {
                foreach (var input in InputControlList)
                {
                    if (input.ColumnName == "Note1")
                    {
                        input.ColumnNameJp = note1;
                    }
                    if (input.ColumnName == "Note2")
                    {
                        input.ColumnNameJp = note2;
                    }
                    if (input.ColumnName == "Note3")
                    {
                        input.ColumnNameJp = note3;
                    }
                    if (input.ColumnName == "Note4")
                    {
                        input.ColumnNameJp = note4;
                    }
                }

                if (!UseDiscount && InputGridTypeId.Equals(InputGridType.Billing))
                {
                    var discountIndex = InputControlList.FindIndex(
                        x => x.ColumnName.Equals(DiscountName) &&
                        x.ColumnNameJp.Equals(DiscountJpName));

                    InputControlList.RemoveAt(discountIndex);
                }

                if (!useContractNumber && InputGridTypeId.Equals(InputGridType.Billing))
                {
                    var contractIndex = InputControlList.FindIndex(
                        x => x.ColumnName.Equals(ContractName) &&
                        x.ColumnNameJp.Equals(ContractJpName));

                    InputControlList.RemoveAt(contractIndex);
                }

                grid.RowCount = InputControlList.Count;

                for (var i = 0; i < InputControlList.Count; i++)
                {
                    var inputControl = new InputControl();
                    inputControl = InputControlList[i];

                    checkCell       = (CheckBoxCell)grid.Rows[i].Cells[0];
                    checkCell.Value = inputControl.TabStop;

                    textCellName       = (GcTextBoxCell)grid.Rows[i].Cells[1];
                    textCellName.Value = inputControl.ColumnNameJp;

                    numberCellOrder       = (GcNumberCell)grid.Rows[i].Cells[2];
                    numberCellOrder.Value = inputControl.TabIndex;

                    OnCheckedChanged(i, checkCellIndex, numberCellIndex);
                }
            }
            else
            {
                var columnBillingName = new List <string> {
                    nameof(Billing.SalesAt),
                    nameof(Billing.BillingCategoryId),
                    nameof(Billing.TaxClassId),
                    nameof(Billing.DebitAccountTitleId),
                    nameof(Billing.UseDiscount),
                    nameof(Billing.Note1),
                    nameof(Billing.ContractNumber),
                    nameof(Billing.Quantity),
                    nameof(Billing.UnitSymbol),
                    nameof(Billing.UnitPrice),
                    nameof(Billing.Price),
                    nameof(Billing.TaxAmount),
                    nameof(Billing.BillingAmount),
                };

                var columnBillingNameJp = new List <string>
                {
                    "売上日", "請求区分", "税区", "債権科目", "歩引計算",
                    note1, "契約番号", "数量", "単位", "単価",
                    "金額(抜)", "消費税", "請求額"
                };

                var columnReceiptName = new List <string>
                {
                    "ReceiptCategory", "Note1", "DueAt", "ReceiptAmount", "BillNumber",
                    "BillBankCode", "BillBranchCode", "BillDrawAt", "BillDrawer",
                    "Note2", "Note3", "Note4"
                };

                var columnReceiptNameJp = new List <string>
                {
                    "入金区分", note1, "期日", "金額", "手形番号",
                    "銀行コード", "支店コード", "振出日", "振出人",
                    note2, note3, note4
                };

                if (!UseDiscount && InputGridTypeId == InputGridType.Billing)
                {
                    var nameIndex   = columnBillingName.FindIndex(x => x.Equals(DiscountName));
                    var jpNameIndex = columnBillingNameJp.FindIndex(x => x.Equals(DiscountJpName));
                    columnBillingName.RemoveAt(nameIndex);
                    columnBillingNameJp.RemoveAt(jpNameIndex);
                }

                if (!useContractNumber && InputGridTypeId == InputGridType.Billing)
                {
                    var nameIndex   = columnBillingName.FindIndex(x => x.Equals(ContractName));
                    var jpNameIndex = columnBillingNameJp.FindIndex(x => x.Equals(ContractJpName));
                    columnBillingName.RemoveAt(nameIndex);
                    columnBillingNameJp.RemoveAt(jpNameIndex);
                }

                var columnName = InputGridTypeId == InputGridType.Billing
                    ? columnBillingName : columnReceiptName;
                var columnNameJp = InputGridTypeId == InputGridType.Billing
                    ? columnBillingNameJp : columnReceiptNameJp;

                grid.RowCount = columnName.Count;

                for (var i = 0; i < grid.RowCount; i++)
                {
                    checkCell       = (CheckBoxCell)grid.Rows[i].Cells[0];
                    checkCell.Value = true;

                    textCellName       = (GcTextBoxCell)grid.Rows[i].Cells[1];
                    textCellName.Value = columnNameJp[i];

                    numberCellOrder       = (GcNumberCell)grid.Rows[i].Cells[2];
                    numberCellOrder.Value = i + 1;

                    OnCheckedChanged(i, checkCellIndex, numberCellIndex);

                    var inputControl = new InputControl();
                    inputControl.CompanyId       = CompanyId;
                    inputControl.LoginUserId     = Login.UserId;
                    inputControl.InputGridTypeId = InputGridTypeId;
                    inputControl.ColumnName      = columnName[i];
                    inputControl.ColumnNameJp    = columnNameJp[i];
                    inputControl.ColumnOrder     = i + 1;
                    inputControl.TabIndex        = i + 1;
                    inputControl.TabStop         = 1;
                    InputControlList.Add(inputControl);
                }
            }
        }
Esempio n. 2
0
    public void Controls_CanKeepListsOfControls_WithoutAllocatingGCMemory()
    {
        InputSystem.AddDevice <Mouse>(); // Noise.
        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();

        var list = new InputControlList <InputControl>();

        try
        {
            Assert.That(list.Count, Is.Zero);
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());

            list.Capacity = 10;

            list.Add(gamepad.leftStick);
            list.Add(null); // Permissible to add null entry.
            list.Add(keyboard.spaceKey);
            list.Add(keyboard);

            Assert.That(list.Count, Is.EqualTo(4));
            Assert.That(list.Capacity, Is.EqualTo(6));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.Null);
            Assert.That(list[2], Is.SameAs(keyboard.spaceKey));
            Assert.That(list[3], Is.SameAs(keyboard));
            Assert.That(() => list[4], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(),
                        Is.EquivalentTo(new InputControl[] { gamepad.leftStick, null, keyboard.spaceKey, keyboard }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(list.Contains(keyboard));

            list.RemoveAt(1);
            list.Remove(keyboard);

            Assert.That(list.Count, Is.EqualTo(2));
            Assert.That(list.Capacity, Is.EqualTo(8));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.SameAs(keyboard.spaceKey));
            Assert.That(() => list[2], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(), Is.EquivalentTo(new InputControl[] { gamepad.leftStick, keyboard.spaceKey }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));

            list.AddRange(new InputControl[] { keyboard.aKey, keyboard.bKey }, count: 1, destinationIndex: 0);

            Assert.That(list.Count, Is.EqualTo(3));
            Assert.That(list.Capacity, Is.EqualTo(7));
            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.aKey, gamepad.leftStick, keyboard.spaceKey }));

            list.AddRange(new InputControl[] { keyboard.bKey, keyboard.cKey });

            Assert.That(list.Count, Is.EqualTo(5));
            Assert.That(list.Capacity, Is.EqualTo(5));
            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.aKey, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey }));

            using (var toAdd = new InputControl[] { gamepad.buttonNorth, gamepad.buttonEast, gamepad.buttonWest }.ToControlList())
                list.AddSlice(toAdd, count: 1, destinationIndex: 1, sourceIndex: 2);

            Assert.That(list.Count, Is.EqualTo(6));
            Assert.That(list.Capacity, Is.EqualTo(4));
            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.aKey, gamepad.buttonWest, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey }));

            list[0] = keyboard.zKey;

            Assert.That(list,
                        Is.EquivalentTo(new InputControl[]
                                        { keyboard.zKey, gamepad.buttonWest, gamepad.leftStick, keyboard.spaceKey, keyboard.bKey, keyboard.cKey }));

            list.Clear();

            Assert.That(list.Count, Is.Zero);
            Assert.That(list.Capacity, Is.EqualTo(10));
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(!list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(!list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));
        }
        finally
        {
            list.Dispose();
        }
    }
Esempio n. 3
0
    public void Controls_CanKeepListsOfControls_WithoutAllocatingGCMemory()
    {
        InputSystem.AddDevice <Mouse>(); // Noise.
        var gamepad  = InputSystem.AddDevice <Gamepad>();
        var keyboard = InputSystem.AddDevice <Keyboard>();

        var list = new InputControlList <InputControl>();

        try
        {
            Assert.That(list.Count, Is.Zero);
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());

            list.Capacity = 10;

            list.Add(gamepad.leftStick);
            list.Add(null); // Permissible to add null entry.
            list.Add(keyboard.spaceKey);
            list.Add(keyboard);

            Assert.That(list.Count, Is.EqualTo(4));
            Assert.That(list.Capacity, Is.EqualTo(6));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.Null);
            Assert.That(list[2], Is.SameAs(keyboard.spaceKey));
            Assert.That(list[3], Is.SameAs(keyboard));
            Assert.That(() => list[4], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(),
                        Is.EquivalentTo(new InputControl[] { gamepad.leftStick, null, keyboard.spaceKey, keyboard }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(list.Contains(keyboard));

            list.RemoveAt(1);
            list.Remove(keyboard);

            Assert.That(list.Count, Is.EqualTo(2));
            Assert.That(list.Capacity, Is.EqualTo(8));
            Assert.That(list[0], Is.SameAs(gamepad.leftStick));
            Assert.That(list[1], Is.SameAs(keyboard.spaceKey));
            Assert.That(() => list[2], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(list.ToArray(), Is.EquivalentTo(new InputControl[] { gamepad.leftStick, keyboard.spaceKey }));
            Assert.That(list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));

            list.Clear();

            Assert.That(list.Count, Is.Zero);
            Assert.That(list.Capacity, Is.EqualTo(10));
            Assert.That(list.ToArray(), Is.Empty);
            Assert.That(() => list[0], Throws.TypeOf <ArgumentOutOfRangeException>());
            Assert.That(!list.Contains(gamepad.leftStick));
            Assert.That(!list.Contains(null));
            Assert.That(!list.Contains(keyboard.spaceKey));
            Assert.That(!list.Contains(keyboard));
        }
        finally
        {
            list.Dispose();
        }
    }