Exemplo n.º 1
0
        public void AddNewMainRow(bool checkLastRow)
        {
            var currentRowIndex = (MainRowList.IndexOf(SelectedMainRow));

            if (checkLastRow)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMainRow,
                                                          new ValidationContext(SelectedMainRow, null, null), valiationCollection, true);

                if (!isvalid)
                {
                    return;
                }
            }
            if (AllowAdd != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }
            var newrow = new TblCostDimDetailViewModel();

            MainRowList.Insert(currentRowIndex + 1, newrow);
            SelectedMainRow = newrow;
        }
Exemplo n.º 2
0
        public CostDimChildViewModel(LedgerHeaderViewModel ledgerHeaderViewModel)
        {
            if (!IsDesignTime)
            {
                LedgerHeaderViewModel = ledgerHeaderViewModel;
                GetItemPermissions(PermissionItemName.Account.ToString());
                Glclient = new GlServiceClient();

                MainRowList     = new SortableCollectionView <TblCostDimDetailViewModel>();
                SelectedMainRow = new TblCostDimDetailViewModel();

                Glclient.GetTblCostDimSetupHeaderForAccountCompleted += (s, sv) =>
                {
                    if (sv.Result != null)
                    {
                        foreach (var row in sv.Result.TblCostDimDetails)
                        {
                            var newrow = new TblCostDimDetailViewModel();
                            newrow.InjectFrom(row);
                            newrow.CostCenterPerRow = row.TblCostCenter1;
                            MainRowList.Add(newrow);
                        }
                    }

                    Loading = false;

                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Glclient.SaveTblCostDimHeaderCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        ledgerHeaderViewModel.SelectedDetailRow.TblCostDimHeader = ev.Result;
                        ledgerHeaderViewModel.SaveMainRow();
                    }
                    catch (Exception)
                    {
                    }
                };
                GetMaindata();
            }
        }