Пример #1
0
        protected override void InitializeGrid()
        {
            base.InitializeGrid();
            GetEntities();

            ColumnController cc = new ColumnController();

            CellTextEnumerator cte       = new CellTextEnumerator();
            Column             colNumber = new Column("№", cte, 0.01)
            {
                MinWidth = 25, Visible = BusinessDomain.AppConfiguration.EnableLineNumber
            };

            cc.Add(colNumber);

            CellTextDouble ctf;
            Column         col = null;

            if (!BusinessDomain.LoggedUser.HideItemsPurchasePrice)
            {
                ctf = new CellTextCurrency("PriceIn", PriceType.Purchase);
                col = new Column(Translator.GetString("Purchase price"), ctf, 0.1)
                {
                    MinWidth = 70
                };
                cc.Add(col);
            }

            if (!BusinessDomain.LoggedUser.HideItemsAvailability)
            {
                ctf = new CellTextQuantity("AvailableQuantity");
                col = new Column(Translator.GetString("Qtty"), ctf, 0.1, "AvailableQuantity")
                {
                    MinWidth = 70
                };
                cc.Add(col);
            }

            CellText ct;

            if (BusinessDomain.AppConfiguration.AllowItemLotName)
            {
                ct = new CellText("Name")
                {
                    IsEditable = true
                };
                col = new Column(Translator.GetString("Lot"), ct, 0.1)
                {
                    MinWidth = 70
                };
                cc.Add(col);
                entities.FilterProperties.Add("Name");
            }

            if (BusinessDomain.AppConfiguration.AllowItemSerialNumber)
            {
                ct  = new CellText("SerialNumber");
                col = new Column(Translator.GetString("Serial number"), ct, 0.1)
                {
                    MinWidth = 80
                };
                cc.Add(col);
                entities.FilterProperties.Add("SerialNumber");
            }

            CellTextDate ctd;

            if (BusinessDomain.AppConfiguration.AllowItemExpirationDate)
            {
                ctd = new CellTextDate("ExpirationDate");
                col = new Column(Translator.GetString("Expiration date"), ctd, 0.1)
                {
                    MinWidth = 70
                };
                cc.Add(col);
            }

            if (BusinessDomain.AppConfiguration.AllowItemManufacturedDate)
            {
                ctd = new CellTextDate("ProductionDate");
                col = new Column(Translator.GetString("Production date"), ctd, 0.1)
                {
                    MinWidth = 70
                };
                cc.Add(col);
            }

            if (BusinessDomain.AppConfiguration.AllowItemLocation)
            {
                ct  = new CellText("Location");
                col = new Column(Translator.GetString("Lot location"), ct, 0.1)
                {
                    MinWidth = 70
                };
                cc.Add(col);
                entities.FilterProperties.Add("Location");
            }

            // If no columns are visible show the number at least
            if (col == null)
            {
                colNumber.Visible = true;
            }

            grid.ColumnController = cc;
            grid.Model            = entities;
        }
Пример #2
0
        private void InitializeSecondGrid()
        {
            if (secondGrid == null)
            {
                secondGrid = new ListView {
                    Name = "secondGrid"
                };

                ScrolledWindow sWindow = new ScrolledWindow {
                    HscrollbarPolicy = PolicyType.Automatic, VscrollbarPolicy = PolicyType.Automatic
                };
                sWindow.Add(secondGrid);

                algSecondGrid.Add(sWindow);
                sWindow.Show();
                secondGrid.Show();
            }

            ColumnController cc = new ColumnController();

            if (BusinessDomain.AppConfiguration.EnableLineNumber)
            {
                CellTextEnumerator cte = new CellTextEnumerator();
                colSecondLineNumber = new Column("№", cte, 0.01)
                {
                    MinWidth = 25
                };
                cc.Add(colSecondLineNumber);
            }

            CellText ct;

            if (BusinessDomain.AppConfiguration.EnableItemCode)
            {
                ct = new CellText("ItemCode");
                colSecondItemCode = new Column(Translator.GetString("Code"), ct, 0.1)
                {
                    MinWidth = 70
                };
                cc.Add(colSecondItemCode);
            }

            ct = new CellText("ItemName")
            {
                IsEditable = true
            };
            ct.CellEditBegin += CellEditBeginOnProdRecipe;
            colSecondItem     = new Column(Translator.GetString("Item"), ct, 1);
            colSecondItem.ButtonPressEvent += SecondItemColumn_ButtonPressEvent;
            colSecondItem.KeyPressEvent    += SecondItemColumn_KeyPress;
            cc.Add(colSecondItem);

            colSecondMeasure = new Column(Translator.GetString("Measure"), "MUnitName", 0.1)
            {
                MinWidth = 70
            };
            cc.Add(colSecondMeasure);

            CellTextQuantity ctq = new CellTextQuantity("Quantity")
            {
                IsEditable = true
            };

            colSecondQuantity = new Column(Translator.GetString("Qtty"), ctq, 0.1)
            {
                MinWidth = 70
            };
            colSecondQuantity.ButtonPressEvent += SecondQtyColumn_ButtonPressEvent;
            colSecondQuantity.KeyPressEvent    += SecondQtyColumn_KeyPress;
            cc.Add(colSecondQuantity);

            CellTextCurrency ctc = new CellTextCurrency("PriceIn", PriceType.Purchase);

            colSecondPurchaseValue = new Column(Translator.GetString("Purchase price"), ctc, 0.1)
            {
                MinWidth = 70
            };
            cc.Add(colSecondPurchaseValue);

            if (BusinessDomain.AppConfiguration.AllowItemLotName)
            {
                ct = new CellText("Lot")
                {
                    IsEditable = true
                };
                colSecondLot = new Column(Translator.GetString("Lot"), ct, 0.1)
                {
                    MinWidth = 70
                };
                colSecondLot.ButtonPressEvent += SecondLotColumn_ButtonPressEvent;
                colSecondLot.KeyPressEvent    += SecondLotColumn_KeyPress;
                cc.Add(colSecondLot);
            }

            if (BusinessDomain.AppConfiguration.AllowItemSerialNumber)
            {
                ct = new CellText("SerialNumber")
                {
                    IsEditable = true
                };
                colSecondSerialNo = new Column(Translator.GetString("Serial number"), ct, 0.1)
                {
                    MinWidth = 80
                };
                colSecondSerialNo.ButtonPressEvent += SecondSerialNoColumn_ButtonPressEvent;
                colSecondSerialNo.KeyPressEvent    += SecondSerialNoColumn_KeyPress;
                cc.Add(colSecondSerialNo);
            }

            CellTextDate ctd;

            if (BusinessDomain.AppConfiguration.AllowItemExpirationDate)
            {
                ctd = new CellTextDate("ExpirationDate")
                {
                    IsEditable = true
                };
                colSecondExpirationDate = new Column(Translator.GetString("Expiration date"), ctd, 0.1)
                {
                    MinWidth = 70
                };
                colSecondExpirationDate.ButtonPressEvent += SecondExpirationDateColumn_ButtonPressEvent;
                colSecondExpirationDate.KeyPressEvent    += SecondExpirationDateColumn_KeyPress;
                cc.Add(colSecondExpirationDate);
            }

            if (BusinessDomain.AppConfiguration.AllowItemManufacturedDate)
            {
                ctd = new CellTextDate("ProductionDate")
                {
                    IsEditable = true
                };
                colSecondProductionDate = new Column(Translator.GetString("Production date"), ctd, 0.1)
                {
                    MinWidth = 70
                };
                colSecondProductionDate.ButtonPressEvent += SecondProductionDateColumn_ButtonPressEvent;
                colSecondProductionDate.KeyPressEvent    += SecondProductionDateColumn_KeyPress;
                cc.Add(colSecondProductionDate);
            }

            if (BusinessDomain.AppConfiguration.AllowItemLocation)
            {
                ct = new CellText("LotLocation")
                {
                    IsEditable = true
                };
                colSecondLotLocation = new Column(Translator.GetString("Lot location"), ct, 0.1)
                {
                    MinWidth = 70
                };
                colSecondLotLocation.ButtonPressEvent += SecondLotLocationColumn_ButtonPressEvent;
                colSecondLotLocation.KeyPressEvent    += SecondLotLocationColumn_KeyPress;
                cc.Add(colSecondLotLocation);
            }

            if (BusinessDomain.AppConfiguration.EnableItemVatRate)
            {
                CellTextDouble ctf = new CellTextDouble("VatRate")
                {
                    IsEditable = true, FixedFaction = BusinessDomain.AppConfiguration.PercentPrecision
                };
                colSecondVatRate = new Column(BusinessDomain.AppConfiguration.UseSalesTaxInsteadOfVAT ?
                                              Translator.GetString("Tax %") :
                                              Translator.GetString("VAT %"), ctf, 0.1)
                {
                    MinWidth = 70
                };
                colSecondVatRate.ButtonPressEvent += SecondVatRateColumn_ButtonPressEvent;
                colSecondVatRate.KeyPressEvent    += SecondVatRateColumn_KeyPress;
                cc.Add(colSecondVatRate);
            }

            ctc            = new CellTextCurrency("Total", PriceType.Purchase);
            colSecondTotal = new Column(Translator.GetString("Amount"), ctc, 0.1)
            {
                MinWidth = 70
            };
            cc.Add(colSecondTotal);

            secondGrid.ColumnController   = cc;
            secondGrid.AllowSelect        = false;
            secondGrid.CellsFucusable     = true;
            secondGrid.ManualFucusChange  = true;
            secondGrid.RulesHint          = true;
            secondGrid.CellKeyPressEvent -= secondGrid_CellKeyPressEvent;
            secondGrid.CellKeyPressEvent += secondGrid_CellKeyPressEvent;
            secondGrid.CellStyleProvider  = secondGrid_CellStyleProvider;
        }