コード例 #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;
                }
            }
            var newrow = new TblDepreciationTransactionHeaderViewModel
            {
                CreatedBy = LoggedUserInfo.Iserial,
                TransDate = DateTime.Now,
            };

            MainRowList.Insert(currentRowIndex + 1, newrow);
            SelectedMainRow = newrow;
        }
コード例 #2
0
        public DepreciationViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions("Depreciation");
                GetCustomePermissions("Depreciation");
                Glclient = new GlServiceClient();
                Glclient.GetTblRetailCurrencyCompleted += (s, sv) =>
                {
                    CurrencyList = sv.Result;
                };
                Glclient.GetTblRetailCurrencyAsync(0, int.MaxValue, "It.Iserial", null, null,
                                                   LoggedUserInfo.DatabasEname);
                var depreciationMethodClient = new GlServiceClient();
                depreciationMethodClient.GetGenericCompleted += (s, sv) =>
                {
                    DepreciationMethodList = sv.Result;
                };
                depreciationMethodClient.GetGenericAsync("TblDepreciationMethod", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

                MainRowList     = new SortableCollectionView <TblDepreciationTransactionHeaderViewModel>();
                SelectedMainRow = new TblDepreciationTransactionHeaderViewModel();
                Glclient.GetTblDepreciationTransactionHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblDepreciationTransactionHeaderViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                };

                Glclient.GetTblDepreciationTransactionDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        SelectedMainRow.DetailList.Add(row);
                    }

                    Loading = false;
                };

                //Glclient.GetLockupFromPreTransactionCompleted += (s, sv) =>
                //{
                //    foreach (var row in sv.Result)
                //    {
                //        if (SelectedMainRow.DetailsList.All(x => x.TblDepreciationTransactionDetail1 != row.Iserial))
                //        {
                //            var newrow = new TblDepreciationTransactionDetailViewModel();
                //            newrow.InjectFrom(row);
                //            newrow.ChequePerRow = new TblBankCheque();
                //            newrow.Iserial = 0;
                //            newrow.TblDepreciationTransactionHeader = 0;
                //            newrow.TblDepreciationTransactionDetail1 = row.Iserial;
                //            if (row.TblBankCheque1 != null) newrow.ChequePerRow.InjectFrom(row.TblBankCheque1);
                //            newrow.TblJournalAccountTypePerRow = new GenericTable();
                //            if (row.TblJournalAccountType != null)
                //                newrow.TblJournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType);
                //            newrow.TblJournalAccountType1PerRow = new GenericTable();
                //            if (row.TblJournalAccountType1 != null)
                //                newrow.TblJournalAccountType1PerRow.InjectFrom(row.TblJournalAccountType1);
                //            newrow.EntityDetail1TblJournalAccountType = row.EntityDetail1TblJournalAccountType;
                //            newrow.EntityDetail2TblJournalAccountType = row.EntityDetail2TblJournalAccountType;
                //            newrow.EntityPerRow =
                //        sv.entityList.FirstOrDefault(
                //             x => x.TblJournalAccountType == row.EntityDetail1TblJournalAccountType
                //             && x.Iserial == row.EntityDetail1);

                //            newrow.OffsetEntityPerRow =
                //                 sv.entityList.FirstOrDefault(
                //                    x => x.TblJournalAccountType == row.EntityDetail2TblJournalAccountType
                //                    && x.Iserial == row.EntityDetail2);
                //            newrow.Saved = true;

                //            SelectedMainRow.DetailsList.Add(newrow);
                //        }
                //    }

                //    Loading = false;

                //    SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault();
                //};

                Glclient.UpdateOrInsertTblDepreciationTransactionHeaderCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                    Loading = false;
                };
                Glclient.DeleteTblDepreciationTransactionHeaderCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };
                Glclient.GetTblLedgerDetailForDepreciationCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblLedgerMainDetailViewModel {
                            CurrencyPerRow = new TblCurrencyTest()
                        };
                        newrow.CurrencyPerRow.InjectFrom(row.TblCurrency1);
                        if (row.TblBankTransactionType1 != null)
                        {
                            newrow.BankTransactionTypePerRow = new GenericTable();
                            newrow.BankTransactionTypePerRow.InjectFrom(row.TblBankTransactionType1);
                        }
                        newrow.MethodOfPaymentPerRow    = row.TblMethodOfPayment1;
                        newrow.JournalAccountTypePerRow = new GenericTable();
                        newrow.OffsetAccountTypePerRow  = new GenericTable();
                        if (row.TblJournalAccountType1 != null)
                        {
                            newrow.JournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType1);
                        }
                        if (row.TblJournalAccountType2 != null)
                        {
                            newrow.OffsetAccountTypePerRow.InjectFrom(row.TblJournalAccountType2);
                        }
                        newrow.EntityPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == row.TblJournalAccountType &&
                                                         x.Iserial == row.EntityAccount);
                        newrow.OffsetEntityPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == row.OffsetAccountType && x.Iserial == row.OffsetEntityAccount);
                        newrow.InjectFrom(row);
                        if (newrow.DrOrCr == true)
                        {
                            if (row.Amount != null)
                            {
                                newrow.DrAmount = row.Amount;
                            }
                        }
                        else
                        {
                            if (row.Amount != null)
                            {
                                newrow.CrAmount = row.Amount;
                            }
                        }
                        if (row.TblBankCheque1 != null)
                        {
                            newrow.ChequePerRow = row.TblBankCheque1;
                        }
                        newrow.TransactionExists = sv.TransactionExist.FirstOrDefault(x => x.Key == newrow.Iserial).Value;

                        if (row.TblAccount != null)
                        {
                            newrow.AccountPerRow = new TblAccount
                            {
                                Code    = row.TblAccount.Code,
                                Iserial = row.TblAccount.Iserial,
                                Ename   = row.TblAccount.Ename,
                                Aname   = row.TblAccount.Aname
                            };
                        }

                        TblLedgerDetailsList.Add(newrow);
                    }
                    Loading         = false;
                    DetailFullCount = sv.fullCount;
                };
            }
        }