protected virtual void InitializeDiscountColumn(ColumnController cc)
        {
            CellTextDouble ctf = new CellTextDouble("Discount")
            {
                FixedFaction = BusinessDomain.AppConfiguration.PercentPrecision
            };

            colDiscount = new Column(Translator.GetString("Discount %"), ctf, 0.1)
            {
                MinWidth = 70
            };
            cc.Add(colDiscount);
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
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;
        }
예제 #4
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;
        }