protected void RefreshGridColumns()
        {
            ColumnController cc = new ColumnController();

            AddNumberColumn(cc);

            AddPartnerColumn(cc);

            cc.Add(new Column(Translator.GetString("Location"), "Location", 0.2, "Location")
            {
                MinWidth = 70
            });

            CellTextDate ctd = new CellTextDate("Date");

            cc.Add(new Column(Translator.GetString("Date"), ctd, 0.1, "Date")
            {
                MinWidth = 80
            });

            if (highlightEntities)
            {
                highlight = new PangoStyle {
                    Color = Colors.Red
                };

                grid.CellStyleProvider = grid_CellStyleProvider;
            }

            grid.ColumnController = cc;
            grid.CellFocusIn     += grid_CellFocusIn;
        }
        protected virtual void InitializeManufacturedDateColumn(ColumnController cc)
        {
            CellTextDate ctd = new CellTextDate("ProductionDate");

            colProductionDate = new Column(Translator.GetString("Production date"), ctd, 0.1)
            {
                MinWidth = 70
            };
            cc.Add(colProductionDate);
        }
Esempio n. 3
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;
        }
        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;
        }