private void UserInitialization()
        {
            Misp.Kernel.Domain.ReconciliationContext context = this.ContextService.getReconciliationContext();

            List <Kernel.Domain.Measure> measures = this.MeasureService.getAllLeafts();

            this.LeftMeasureComboBox.ItemsSource  = measures;
            this.RightMeasureComboBox.ItemsSource = measures;

            List <Kernel.Domain.Attribute> types = this.Service.getReconciliationTypes();

            this.RecoTypeComboBox.ItemsSource = types;
            if (context != null && context.defaultRecoTypeAttribute != null)
            {
                this.RecoTypeComboBox.SelectedItem = context.defaultRecoTypeAttribute;
            }


            this.BalanceFormulaComboBox.ItemsSource = new BalanceFormula[]
            {
                BalanceFormula.LEFT_MINUS_RIGHT,
                BalanceFormula.LEFT_PLUS_RIGHT
            };
            this.visibleInShortcutCheckbox.IsChecked = true;

            this.visibleInShortcutCheckbox.Unchecked += OnHandlingCheckbox;
            this.visibleInShortcutCheckbox.Checked   += OnHandlingCheckbox;
            this.UseDebitCreditCheckBox.Checked      += OnHandlingCheckbox;
            this.UseDebitCreditCheckBox.Unchecked    += OnHandlingCheckbox;


            this.BalanceFormulaComboBox.SelectionChanged += OnHandlingCombobox;
            this.RecoTypeComboBox.SelectionChanged       += OnHandlingCombobox;
            this.LeftMeasureComboBox.SelectionChanged    += OnHandlingCombobox;
            this.RightMeasureComboBox.SelectionChanged   += OnHandlingCombobox;
        }
예제 #2
0
        private Decimal[] BuildBottomBalance(Grille grid, GridBrowser browser)
        {
            Decimal      credit            = 0;
            Decimal      debit             = 0;
            GrilleColumn leftAmountColumn  = null;
            GrilleColumn rightAmountColumn = null;
            GrilleColumn creditDebitColumn = null;
            Measure      leftMeasure       = this.EditedObject.leftMeasure;
            Measure      rightMeasure      = this.EditedObject.rightMeasure;

            if (leftMeasure != null)
            {
                leftAmountColumn = grid.GetColumn(ParameterType.MEASURE.ToString(), leftMeasure.oid.Value);
            }
            if (rightMeasure != null)
            {
                rightAmountColumn = grid.GetColumn(ParameterType.MEASURE.ToString(), rightMeasure.oid.Value);
            }
            if (leftAmountColumn != null && rightAmountColumn != null)
            {
                String creditValue = "C";
                String debitValue  = "D";
                if (this.EditedObject.useDebitCredit == true)
                {
                    Misp.Kernel.Domain.ReconciliationContext context = ApplicationManager.Instance.ControllerFactory.ServiceFactory.GetReconciliationContextService().getReconciliationContext();
                    if (context != null)
                    {
                        creditValue = context.creditAttributeValue != null ? context.creditAttributeValue.name : "C";
                        debitValue  = context.debitAttributeValue != null ? context.debitAttributeValue.name : "D";
                        if (context.dcNbreAttribute != null)
                        {
                            creditDebitColumn = grid.GetColumn(ParameterType.SCOPE.ToString(), context.dcNbreAttribute.oid.Value);
                        }
                    }
                }
                foreach (object row in browser.gridControl.SelectedItems)
                {
                    if (row is GridItem)
                    {
                        String side = ((GridItem)row).Side;
                        if (string.IsNullOrWhiteSpace(side))
                        {
                            continue;
                        }
                        GrilleColumn amountColumn = side == GridItem.LEFT_SIDE ? leftAmountColumn : rightAmountColumn;
                        if (amountColumn == null)
                        {
                            continue;
                        }
                        Object[] datas  = ((GridItem)row).Datas;
                        Decimal  amount = 0;
                        object   item   = item = datas[amountColumn.position];
                        try
                        {
                            Decimal.TryParse(item.ToString(), out amount);
                        }
                        catch (Exception) { }

                        if (this.EditedObject.useDebitCredit == true)
                        {
                            if (creditDebitColumn == null)
                            {
                                continue;
                            }
                            item = datas[creditDebitColumn.position];
                            Boolean isCredit = item != null && item.ToString().Equals(creditValue, StringComparison.OrdinalIgnoreCase);
                            Boolean isDebit  = item != null && item.ToString().Equals(debitValue, StringComparison.OrdinalIgnoreCase);

                            if (side == GridItem.LEFT_SIDE)
                            {
                                if (isCredit)
                                {
                                    credit += amount;
                                }
                                else if (isDebit)
                                {
                                    credit -= amount;
                                }
                            }
                            else
                            {
                                if (isCredit)
                                {
                                    debit += amount;
                                }
                                else if (isDebit)
                                {
                                    debit -= amount;
                                }
                            }
                        }
                        else
                        {
                            if (side == GridItem.LEFT_SIDE)
                            {
                                credit += amount;
                            }
                            else
                            {
                                debit += amount;
                            }
                        }
                    }
                }
            }
            Decimal[] balances = new Decimal[] { credit, debit };
            return(balances);
        }
예제 #3
0
        private List <FormatCondition> BuildFormatConditions(GridBrowser grid, Measure leftMeasure, Measure rightMeasure)
        {
            List <FormatCondition> conditions = new List <FormatCondition>(0);

            if (leftMeasure == null && rightMeasure == null)
            {
                return(conditions);
            }
            if (this.EditedObject.useDebitCredit.Value)
            {
                Misp.Kernel.Domain.ReconciliationContext context = ApplicationManager.Instance.ControllerFactory.ServiceFactory.GetReconciliationContextService().getReconciliationContext();
                if (context != null && context.dcNbreAttribute != null)
                {
                    GrilleColumn creditDebitColumn = grid.Grille.GetColumn(ParameterType.SCOPE.ToString(), context.dcNbreAttribute.oid.Value);
                    if (creditDebitColumn != null)
                    {
                        String debitValue = context.debitAttributeValue != null ? context.debitAttributeValue.name : "D";
                        conditions.Add(new FormatCondition()
                        {
                            ApplyToRow = true,
                            Expression = "[" + creditDebitColumn.name + "] == '" + debitValue + "'",
                            FieldName  = creditDebitColumn.name,
                            Format     = new Format()
                            {
                                Foreground = Brushes.Red
                            }
                        });
                    }
                }
            }
            else
            {
                if (leftMeasure != null)
                {
                    GrilleColumn amountColumn = grid.Grille.GetColumn(ParameterType.MEASURE.ToString(), leftMeasure.oid.Value);
                    if (amountColumn != null)
                    {
                        conditions.Add(new FormatCondition()
                        {
                            ApplyToRow = true,
                            Expression = "[" + amountColumn.name + "] < 0.0",
                            FieldName  = amountColumn.name,
                            Format     = new Format()
                            {
                                Background = Brushes.Red
                            }
                        });
                    }
                }
                if (rightMeasure != null)
                {
                    GrilleColumn amountColumn = grid.Grille.GetColumn(ParameterType.MEASURE.ToString(), rightMeasure.oid.Value);
                    if (amountColumn != null)
                    {
                        conditions.Add(new FormatCondition()
                        {
                            ApplyToRow = true,
                            Expression = "[" + amountColumn.name + "] < 0.0",
                            FieldName  = amountColumn.name,
                            Format     = new Format()
                            {
                                Background = Brushes.Red
                            }
                        });
                    }
                }
            }
            return(conditions);
        }
예제 #4
0
 public GrilleColumn GetAccountNameColumn(ReconciliationContext context)
 {
     return(GetColumn(ParameterType.SCOPE.ToString(), context.accountNameAttribute.oid.Value));
 }
예제 #5
0
 public GrilleColumn GetAmountColumn(ReconciliationContext context)
 {
     return(GetColumn(ParameterType.MEASURE.ToString(), context.amountMeasure.oid.Value));
 }
예제 #6
0
 public GrilleColumn GetRecoNbrColumn(ReconciliationContext context)
 {
     return(null);// GetColumn(ParameterType.SCOPE.ToString(), context.recoNbreAttribute.oid.Value);
 }