Beispiel #1
0
        private void InitializeGrid()
        {
            grid = new ListView();
            scwGrid.Add(grid);
            grid.Show();

            grid.WidthRequest  = 500;
            grid.HeightRequest = 200;

            ColumnController cc = new ColumnController();

            CellText ct = new CellText("ItemName")
            {
                IsEditable = true
            };

            colItem = new Column(Translator.GetString("Item"), ct, 1);
            colItem.ButtonPressEvent += ItemColumn_ButtonPressEvent;
            colItem.KeyPressEvent    += ItemColumn_KeyPress;
            cc.Add(colItem);

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

            colQtty = new Column(Translator.GetString("Qtty"), ctq, 0.1)
            {
                MinWidth = 70
            };
            colQtty.ButtonPressEvent += QttyColumn_ButtonPressEvent;
            colQtty.KeyPressEvent    += QtyColumn_KeyPress;
            cc.Add(colQtty);

            CellTextCurrency ctc = new CellTextCurrency("OriginalPriceOut")
            {
                IsEditable = true
            };

            colSalePrice = new Column(Translator.GetString("Price"), ctc, 0.1)
            {
                MinWidth = 70
            };
            colSalePrice.ButtonPressEvent += SalePriceColumn_ButtonPressEvent;
            colSalePrice.KeyPressEvent    += SalePriceColumn_KeyPress;
            cc.Add(colSalePrice);

            grid.ColumnController   = cc;
            grid.Model              = new BindingListModel(selectedDetails);
            grid.AllowSelect        = false;
            grid.CellsFucusable     = true;
            grid.ManualFucusChange  = true;
            grid.RulesHint          = true;
            grid.CellKeyPressEvent += Grid_CellKeyPressEvent;
            grid.Mapped            += (sender, e) => EditGridCell(0, 0);
            gridNavigator           = new GridNavigator(grid, EditGridCell, GridColumnEditOver, GridColumnEditBelow);
        }
        protected virtual void InitializeQuantityColumn(ColumnController cc)
        {
            CellTextQuantity ctf = new CellTextQuantity("Quantity");

            colQuantity = new Column(Translator.GetString("Qtty"), ctf, 0.1)
            {
                MinWidth = 70
            };
            cc.Add(colQuantity);
        }
Beispiel #3
0
        protected override void InitializeQuantityColumn(ColumnController cc)
        {
            CellTextQuantity ctq = new CellTextQuantity("ExpectedQuantity");
            Column           col = new Column(Translator.GetString("Available"), ctq, 0.1)
            {
                MinWidth = 70
            };

            col.ButtonPressEvent += QtyColumn_ButtonPressEvent;
            col.KeyPressEvent    += QtyColumn_KeyPress;
            cc.Add(col);

            base.InitializeQuantityColumn(cc);
            colQuantity.ListCell.PropertyName = "EnteredQuantity";
        }
Beispiel #4
0
        protected override void InitializeQuantityColumn(ColumnController cc)
        {
            CellTextQuantity ctq = new CellTextQuantity("ExpectedQuantity");
            Column           col = new Column(Translator.GetString("Available"), ctq, 0.1)
            {
                MinWidth = 70
            };

            cc.Add(col);

            ctq         = new CellTextQuantity("EnteredQuantity");
            colQuantity = new Column(Translator.GetString("Qtty"), ctq, 0.1)
            {
                MinWidth = 70
            };
            cc.Add(colQuantity);
        }
Beispiel #5
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;
        }
Beispiel #6
0
        private ConfirmPriceRules(IEnumerable <PriceRule> rulesToApply, Operation <T> operation, bool priceWithVAT = false)
        {
            this.rulesToApply = new List <PriceRule> (rulesToApply);
            Initialize();

            gridOperationDetails = new ListView {
                Name = "gridOperationDetails", WidthRequest = 600, HeightRequest = 250
            };
            ColumnController columnController = new ColumnController();

            columnController.Add(new Column(Translator.GetString("Item"), "ItemName", 1));

            CellTextQuantity cellQuantity   = new CellTextQuantity("Quantity");
            Column           columnQuantity = new Column(Translator.GetString("Qtty"), cellQuantity, 0.1)
            {
                MinWidth = 55
            };

            columnController.Add(columnQuantity);

            CellTextDouble cellPrice   = new CellTextCurrency(priceWithVAT ? "OriginalPriceOutPlusVAT" : "OriginalPriceOut");
            Column         columnPrice = new Column(Translator.GetString("Price"), cellPrice, 0.1)
            {
                MinWidth = 55
            };

            columnController.Add(columnPrice);

            CellTextDouble cellDiscount = new CellTextDouble("Discount");

            cellDiscount.FixedFaction = BusinessDomain.AppConfiguration.PercentPrecision;
            Column columnDiscount = new Column(Translator.GetString("Discount %"), cellDiscount, 0.1);

            columnDiscount.Visible  = BusinessDomain.AppConfiguration.AllowPercentDiscounts;
            columnDiscount.MinWidth = 100;
            columnController.Add(columnDiscount);

            BindingListModel <T> model     = GetChangedDetails(operation);
            PriceType            priceType = PriceType.SaleTotal;

            if (model.Count > 0)
            {
                priceType = model [0].TotalsPriceType;
            }

            CellTextDouble cellTotal   = new CellTextCurrency(priceWithVAT ? "TotalPlusVAT" : "Total", priceType);
            Column         columnTotal = new Column(Translator.GetString("Amount"), cellTotal, 0.1)
            {
                MinWidth = 55
            };

            columnController.Add(columnTotal);

            gridOperationDetails.ColumnController = columnController;

            gridOperationDetails.Model = model;
            scwOperationDetails.Add(gridOperationDetails);
            gridOperationDetails.Show();

            CellRendererToggle cellRendererToggle = new CellRendererToggle {
                Activatable = true
            };

            cellRendererToggle.Toggled += (o, args) =>
            {
                TreeIter row;
                TreePath treePath = new TreePath(args.Path);
                treeviewPriceRules.Model.GetIter(out row, treePath);
                PriceRule priceRule = (PriceRule)treeviewPriceRules.Model.GetValue(row, 2);
                bool      value     = !(bool)treeviewPriceRules.Model.GetValue(row, 0);
                if (value)
                {
                    if (treePath.Indices [0] <= this.rulesToApply.Count)
                    {
                        this.rulesToApply.Insert(treePath.Indices [0], priceRule);
                    }
                    else
                    {
                        this.rulesToApply.Add(priceRule);
                    }
                }
                else
                {
                    this.rulesToApply.Remove(priceRule);
                }
                gridOperationDetails.Model = GetChangedDetails(operation);
                treeviewPriceRules.Model.SetValue(row, 0, value);
            };
            treeviewPriceRules.AppendColumn(string.Empty, cellRendererToggle, "active", 0);
            treeviewPriceRules.AppendColumn(Translator.GetString("Price rule"), new CellRendererText(), "text", 1);
            treeviewPriceRules.AppendColumn(Translator.GetString("Price rule"), new CellRendererText(), "text", 2).Visible = false;
            TreeStore treeStore = new TreeStore(typeof(bool), typeof(string), typeof(object));

            foreach (PriceRule priceRule in this.rulesToApply)
            {
                treeStore.AppendValues(true, priceRule.Name, priceRule);
            }
            treeviewPriceRules.Model = treeStore;
        }
        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 ();

            CellText ct = new CellText ("ItemName");
            colSecondItem = new Column (Translator.GetString ("Item"), ct, 1);
            cc.Add (colSecondItem);

            CellTextQuantity ctq = new CellTextQuantity ("Quantity");
            colSecondQuantity = new Column (Translator.GetString ("Qtty"), ctq, 0.1) { MinWidth = 70 };
            cc.Add (colSecondQuantity);

            if (!BusinessDomain.LoggedUser.HideItemsPurchasePrice) {
                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");
                colSecondLot = new Column (Translator.GetString ("Lot"), ct, 0.1) { MinWidth = 70 };
                cc.Add (colSecondLot);
            }

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

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

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

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

            secondGrid.ColumnController = cc;
            secondGrid.AllowSelect = false;
            secondGrid.CellsFucusable = true;
            secondGrid.ManualFucusChange = true;
            secondGrid.RulesHint = true;
        }
        private void InitializeGrid()
        {
            try {
                if (initialized)
                {
                    return;
                }

                ColumnController cc = new ColumnController();
                supportsSumming = false;

                for (int i = 0; i < dataQueryResult.Result.Columns.Count; i++)
                {
                    DbField  field            = dataQueryResult.Columns [i].Field;
                    DataType fieldType        = ReportProvider.GetDataFieldType(field);
                    string   columnName       = dataQueryResult.Result.Columns [i];
                    string   columnHeaderText = ReportProvider.GetReportFieldColumnName(dataQueryResult, i);

                    CellText cell;
                    bool     thisColumnSummable = false;
                    switch (fieldType)
                    {
                    case DataType.Date:
                        cell = new CellTextDate(columnName);
                        break;

                    case DataType.DateTime:
                        cell = new CellTextDateTime(columnName);
                        break;

                    case DataType.Quantity:
                        cell = new CellTextQuantity(columnName);
                        thisColumnSummable = true;
                        break;

                    case DataType.CurrencyIn:
                        cell = new CellTextCurrency(columnName, PriceType.Purchase);
                        thisColumnSummable = true;
                        break;

                    case DataType.CurrencyOut:
                        cell = new CellTextCurrency(columnName);
                        thisColumnSummable = true;
                        break;

                    case DataType.Currency:
                        cell = new CellTextCurrency(columnName, PriceType.Unknown);
                        thisColumnSummable = true;
                        break;

                    case DataType.Percent:
                        cell = new CellTextDouble(columnName)
                        {
                            FixedFaction = BusinessDomain.AppConfiguration.PercentPrecision
                        };
                        break;

                    case DataType.Id:
                    case DataType.UserId:
                        cell = new CellTextNumber(columnName);
                        break;

                    case DataType.DocumentNumber:
                        cell = new CellTextNumber(columnName)
                        {
                            FixedDigits = BusinessDomain.AppConfiguration.DocumentNumberLength
                        };
                        break;

                    case DataType.OperationType:
                        cell = new CellTextLookup <int> (columnName);
                        CellTextLookup <int> cellOperationType = (CellTextLookup <int>)cell;
                        foreach (OperationType operationType in Enum.GetValues(typeof(OperationType)))
                        {
                            if (operationType > 0)
                            {
                                cellOperationType.Lookup.Add((int)operationType, Translator.GetOperationTypeName(operationType));
                            }
                        }
                        break;

                    case DataType.DocumentType:
                        cell = new CellTextLookup <int> (columnName).Load(DocumentBase.GetAllDocumentTypes());
                        break;

                    case DataType.BasePaymentType:
                        cell = new CellTextLookup <int> (columnName).Load(PaymentType.GetAllBaseTypePairs());
                        break;

                    case DataType.PaymentType:
                        cell = new CellTextLookup <long> (columnName);
                        CellTextLookup <long> cellPaymentType = (CellTextLookup <long>)cell;
                        foreach (PaymentType paymentType in PaymentType.GetAll())
                        {
                            cellPaymentType.Lookup.Add(paymentType.Id, paymentType.Name);
                        }
                        break;

                    case DataType.PriceGroupType:
                        cell = new CellTextLookup <int> (columnName).Load(Currency.GetAllPriceGroups());
                        break;

                    case DataType.PartnerType:
                        cell = new CellTextLookup <int> (columnName).Load(Partner.GetAllTypes());
                        break;

                    case DataType.ItemType:
                        cell = new CellTextLookup <int> (columnName).Load(Item.GetAllTypes());
                        break;

                    case DataType.UserAccessLevel:
                        cell = new CellTextLookup <int> (columnName).Load(User.GetAllAccessLevels());
                        break;

                    case DataType.TurnoverType:
                        cell = new CellTextLookup <int> (columnName).Load(CashBookEntry.GetAllTurnoverTypes());
                        break;

                    case DataType.TurnoverDirection:
                        cell = new CellTextLookup <int> (columnName).Load(CashBookEntry.GetAllTurnoverDirections());
                        break;

                    case DataType.TaxGroupCode:
                        cell = new CellTextLookup <string> (columnName).Load(VATGroup.AllCodes);
                        break;

                    case DataType.Sign:
                        cell = new CellTextLookup <int> (columnName).Load(Payment.GetAllSignTypes());
                        break;

                    case DataType.PaymentMode:
                        cell = new CellTextLookup <int> (columnName).Load(Payment.GetAllModeTypes());
                        break;

                    case DataType.Text:
                        cell = new CellText(columnName);
                        break;

                    default:
                        continue;
                    }
                    Column col = new Column(columnHeaderText, cell, 0.1, columnName)
                    {
                        MinWidth = 100,
                        Visible  = !skip.Contains(field) && CheckColumnVisible(dataQueryResult, i)
                    };
                    cc.Add(col);
                    supportsSumming |= thisColumnSummable && col.Visible;
                }

                grid.ColumnController = cc;
                // Prevent the grid from reapplying the old sort
                grid.Model               = null;
                grid.Model               = model;
                grid.AllowSelect         = true;
                grid.AllowMultipleSelect = true;
                grid.CellsFucusable      = true;
                grid.RulesHint           = true;
                grid.SortColumnsHint     = true;
                grid.RowActivated       -= grid_RowActivated;
                grid.RowActivated       += grid_RowActivated;
                initialized              = true;
            } finally {
                EventHandler onInitialized = Initialized;
                if (onInitialized != null)
                {
                    onInitialized(this, EventArgs.Empty);
                }
            }
        }
        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;
        }
        private void InitializeProductsGrid()
        {
            if (grdProducts == null)
            {
                grdProducts = new ListView {
                    Name = "grdProducts"
                };

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

                algProducts.Add(sWindow);
                sWindow.Show();
                grdProducts.Show();
            }

            ColumnController cc = new ColumnController();

            CellText ct = new CellText("ItemName")
            {
                IsEditable = true
            };

            colSecondItem = new Column(Translator.GetString("Item"), ct, 1);
            colSecondItem.ButtonPressEvent += ProdItem_ButtonPressEvent;
            colSecondItem.KeyPressEvent    += ProdItem_KeyPress;
            cc.Add(colSecondItem);

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

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

            colSecondQuantity = new Column(Translator.GetString("Qtty"), ctq, 0.1)
            {
                MinWidth = 70
            };
            colSecondQuantity.ButtonPressEvent += ProdQty_ButtonPressEvent;
            colSecondQuantity.KeyPressEvent    += ProdQty_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);

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

            grdProducts.ColumnController   = cc;
            grdProducts.Model              = new BindingListModel(recipe.DetailsProd);
            grdProducts.Model.ListChanged += OperationModel_ListChanged;
            grdProducts.AllowSelect        = false;
            grdProducts.CellsFucusable     = true;
            grdProducts.ManualFucusChange  = true;
            grdProducts.RulesHint          = true;
            grdProducts.CellKeyPressEvent += grdProducts_CellKeyPressEvent;
        }