// ReSharper disable once InconsistentNaming
        public LedgerAttachmentViewModel(TblLedgerHeaderViewModel Row)
        {
            HeaderRow       = Row;
            MainRowList     = new SortableCollectionView <GlLedgerAttachmentViewModel>();
            SelectedMainRow = new GlLedgerAttachmentViewModel();

            Glclient.GetTblLedgerHeaderAttachmentCompleted += (s, sv) =>
            {
                MainRowList.Clear();
                foreach (var row in sv.Result)
                {
                    var newrow = new GlLedgerAttachmentViewModel();
                    newrow.InjectFrom(row);
                    MainRowList.Add(newrow);
                }
                Loading = false;
            };

            Glclient.GetTblLedgerHeaderAttachmentAsync(HeaderRow.Iserial);
            Glclient.UpdateOrInsertTblLedgerHeaderAttachmentCompleted += (s, x) => Glclient.GetTblLedgerHeaderAttachmentAsync(HeaderRow.Iserial);

            Glclient.DeleteTblLedgerHeaderAttachmentCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };
        }
Exemple #2
0
        public FabricBomViewModel(FabricSetupsWFViewModel viewModel)
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                _fabricViewModel.InjectFrom(viewModel);
                MainRowList     = new SortableCollectionView <TblFabricBomViewModel>();
                SelectedMainRow = new TblFabricBomViewModel();

                Client.GetTblFabricBomCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblFabricBomViewModel {
                            ItemPerRow = new ItemsDto()
                        };

                        var ItemRow =
                            sv.FabricServiceList.FirstOrDefault(
                                x => x.Iserial == row.Item && x.ItemGroup == row.ItemType);

                        newrow.ItemPerRow.Code      = ItemRow.Code;
                        newrow.ItemPerRow.Name      = ItemRow.Name;
                        newrow.ItemPerRow.Unit      = ItemRow.Unit;
                        newrow.ItemPerRow.ItemGroup = ItemRow.ItemGroup;

                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertTblFabricBomCompleted += (s, x) =>
                {
                    var savedRow = (TblFabricBomViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblFabricBomCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };
            }
        }
Exemple #3
0
        public ExcuseRuleViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList     = new SortableCollectionView <TblExcuseRuleViewModel>();
                SelectedMainRow = new TblExcuseRuleViewModel();

                AttService.AxPeriodsCompleted += (s, sv) =>
                {
                    PeriodList = sv.Result;
                };
                AttService.AxPeriodsAsync();
                AttService.ExcuseTypeCompleted += (s, sv) =>
                {
                    ExcuseTypeList = sv.Result;
                };
                AttService.ExcuseTypeAsync();

                AttService.GetTblExcuseRuleCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblExcuseRuleViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                AttService.UpdateOrInsertTblExcuseRuleCompleted += (s, x) =>
                {
                    var savedRow = (TblExcuseRuleViewModel)MainRowList.ElementAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                AttService.DeleteTblExcuseRuleCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #4
0
        public ServiceCodingViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList     = new SortableCollectionView <TblServiceViewModel>();
                SelectedMainRow = new TblServiceViewModel();

                var tblAssetsTypeclient = new CRUD_ManagerServiceClient();
                tblAssetsTypeclient.GetGenericAsync("TblServiceGroup", "%%", "%%", "%%", "Iserial", "ASC");

                tblAssetsTypeclient.GetGenericCompleted += (s, sv) =>
                {
                    ServiceGroupList = sv.Result;
                };

                Client.GetTblServiceCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblServiceViewModel();

                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertTblServiceCompleted += (s, x) =>
                {
                    var savedRow = (TblServiceViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblServiceCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #5
0
        public AttachmentModel(string TableName, int masterId)
        {
            this.TableName  = TableName;
            this.MasterId   = masterId;
            MainRowList     = new SortableCollectionView <AttachmentViewModel>();
            SelectedMainRow = new AttachmentViewModel();

            assistanceClient.GetAttachmentCompleted += (s, sv) =>
            {
                MainRowList.Clear();
                foreach (var row in sv.Result)
                {
                    var newrow = new AttachmentViewModel();
                    newrow.InjectFrom(row);
                    MainRowList.Add(newrow);
                }
                Loading = false;
            };

            assistanceClient.UpdateOrInsertAttachmentCompleted += (s, sv) =>
            {
                FolderPath = "/Uploads" + "/" + sv.FolderPath;
                var folderName = FolderPath;// + "/" + Style.SeasonPerRow.Ename + "_" + Style.Brand + "_" + Style.SectionPerRow.Ename;

                //var counter = 0;
                foreach (var item in MainRowList)
                {
                    if (item.Iserial == 0)
                    {
                        var oldItem = sv.Result.FirstOrDefault(r => r.OrginalFileName == item.OrginalFileName);
                        if (oldItem != null)
                        {
                            item.Path       = oldItem.Path;
                            item.FolderPath = folderName;
                            item.UploadFile(item.AttachmentPerRow);
                        }
                        //counter++;
                    }
                }
            };
            assistanceClient.GetAttachmentAsync(TableName, MasterId);
            //assistanceClient.UpdateOrInsertAttachmentCompleted += (s, x) => assistanceClient.GetAttachmentAsync(TableName);

            assistanceClient.DeleteAttachmentCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };
        }
        public GeneratePurchaseHeaderCurrenciesViewModel(int generatePurchaseHeader)
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                _generatepurchasehaderIserial = generatePurchaseHeader;
                GetItemPermissions(PermissionItemName.GeneratePurchase.ToString());
                MainRowList     = new SortableCollectionView <TblGeneratePurchaseHeaderCurrenciesViewModel>();
                SelectedMainRow = new TblGeneratePurchaseHeaderCurrenciesViewModel();
                Client.GetTblCurrencyCompleted += (s, sv) =>
                {
                    CurrencyList = sv.Result;
                };
                Client.GetTblCurrencyAsync(0, int.MaxValue, "it.Iserial", null, null);

                GetMaindata();
                Client.TblGeneratePurchaseHeaderCurrencyCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblGeneratePurchaseHeaderCurrenciesViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertTblGeneratePurchaseHeaderCurrencyCompleted += (s, x) =>
                {
                    var savedRow = (TblGeneratePurchaseHeaderCurrenciesViewModel)MainRowList.GetItemAt(x.outindex);
                    Loading = false;
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblGeneratePurchaseHeaderCurrencyCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    Loading = false;
                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };
            }
        }
Exemple #7
0
        public FingerPrintTransactionViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList     = new SortableCollectionView <FingerPrintTransactionModel>();
                SelectedMainRow = new FingerPrintTransactionModel();
                GetItemPermissions(PermissionItemName.FingerPrintTransaction.ToString());


                Client.GetFingerPrintTransactionCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new FingerPrintTransactionModel();
                        newrow.InjectFrom(row);
                        newrow.StorePerRow =
                            sv.storesAllCompanies.FirstOrDefault(
                                x => x.Code == row.StoreCode && x.Organization == row.Company);
                        newrow.EmpPerRow = sv.empList.FirstOrDefault(x => x.Emplid == row.UserId);

                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertFingerPrintTransactionCompleted += (s, x) =>
                {
                    var savedRow = (FingerPrintTransactionModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteFingerPrintTransactionCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    var oldrow = MainRowList.FirstOrDefault(x => x.GlSerial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #8
0
        public TransferMsgViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                GetItemPermissions(PermissionItemName.TransferMsg.ToString());
                MainRowList     = new SortableCollectionView <TblTransferMsgViewModel>();
                SelectedMainRow = new TblTransferMsgViewModel();


                Client.GetTblTransferMsgCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblTransferMsgViewModel();

                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertTblTransferMsgCompleted += (s, x) =>
                {
                    var savedRow = (TblTransferMsgViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblTransferMsgCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #9
0
        public MissionViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList      = new SortableCollectionView <TblMissionViewModel>();
                SelectedMainRows = new ObservableCollection <TblMissionViewModel>();

                AttService.MissionTypeCompleted += (x, y) =>
                {
                    Ccmission = y.Result;
                };
                AttService.MissionTypeAsync();

                AttService.UpdateAndInsertTblMissionCompleted += (x, y) =>
                {
                    var savedRow = (TblMissionViewModel)MainRowList.GetItemAt(y.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(y.Result);
                    }
                };

                AttService.GetTblMissionCompleted += (x, y) =>
                {
                    foreach (var row in y.Result)
                    {
                        var newrow = new TblMissionViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                };
                AttService.DeleteTblMissionCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #10
0
        public EmpLeavingTransactionForManagmentViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                GetItemPermissions(PermissionItemName.EmpLeavingTransactionForManagment.ToString());
                MainRowList     = new SortableCollectionView <TblEmpLeavingTransactionViewModel>();
                SelectedMainRow = new TblEmpLeavingTransactionViewModel();
                Client.GetEmpLeavingTransactionCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblEmpLeavingTransactionViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.DeleteEmpLeavingTransactionCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    Loading = false;
                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #11
0
        public SequenceViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.Sequence.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblSequenceViewModel>();
                SelectedMainRow = new TblSequenceViewModel();

                Glclient.GetTblSequenceCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblSequenceViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("Sequence");
                    }
                };

                Glclient.UpdateOrInsertTblSequencesCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblSequenceCompleted += (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);
                    }
                };

                GetMaindata();
            }
        }
        public MethodOfPaymentViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.MethodOfPayment.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblMethodOfPaymentViewModel>();
                SelectedMainRow = new TblMethodOfPaymentViewModel();

                var bankTransactionTypeClient = new GlServiceClient();
                bankTransactionTypeClient.GetGenericCompleted += (s, sv) =>
                {
                    BankTransactionTypeList = sv.Result;
                };
                bankTransactionTypeClient.GetGenericAsync("TblBankTransactionType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

                var journalAccountTypeClient = new GlServiceClient();
                journalAccountTypeClient.GetGenericCompleted += (s, sv) =>
                {
                    JournalAccountTypeList = sv.Result;
                };
                journalAccountTypeClient.GetGenericAsync("TblJournalAccountType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

                Glclient.GetTblMethodOfPaymentCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblMethodOfPaymentViewModel();
                        if (row.TblBankTransactionType1 != null)
                        {
                            newrow.BankTransactionTypePerRow = new GenericTable();
                            newrow.BankTransactionTypePerRow.InjectFrom(row.TblBankTransactionType1);
                        }
                        if (row.TblJournalAccountType1 != null)
                        {
                            newrow.JournalAccountTypePerRow = new GenericTable();
                            newrow.JournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType1);
                        }
                        newrow.EntityAccountPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == row.TblJournalAccountType && x.Iserial == row.Entity);
                        newrow.AccountPerRow = row.TblAccount;
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

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

                Glclient.UpdateOrInsertTblMethodOfPaymentsCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblMethodOfPaymentCompleted += (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);
                    }
                };

                GetMaindata();
            }
        }
Exemple #13
0
        public PostingProfileHeaderViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.PostingProfile.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblPostingProfileHeaderViewModel>();
                SelectedMainRow = new TblPostingProfileHeaderViewModel();

                var journalAccountTypeClient = new GlServiceClient();
                journalAccountTypeClient.GetGenericCompleted += (s, sv) =>
                {
                    JournalAccountTypeList = sv.Result;
                };
                journalAccountTypeClient.GetGenericAsync("TblJournalAccountType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

                Glclient.GetTblPostingProfileHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPostingProfileHeaderViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

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

                Glclient.UpdateOrInsertTblPostingProfileHeadersCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblPostingProfileHeaderCompleted += (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.GetTblPostingProfileDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPostingProfileDetailViewModel
                        {
                            AccountPerRow            = row.TblAccount1,
                            JournalAccountTypePerRow = new GenericTable()
                        };
                        newrow.JournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType);

                        newrow.InjectFrom(row);
                        newrow.EntityAccountPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == newrow.Type && x.scope == newrow.Scope &&
                                                         x.Iserial == newrow.Entity);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }
                    Loading         = false;
                    DetailFullCount = sv.fullCount;

                    if (SelectedMainRow.DetailsList.Any() &&
                        (SelectedDetailRow == null))
                    {
                        SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault();
                    }

                    if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }

                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("Users");
                    }
                };

                Glclient.UpdateOrInsertTblPostingProfileDetailsCompleted += (s, x) =>
                {
                    var savedRow = (TblPostingProfileDetailViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                    Loading = false;
                };

                Glclient.DeleteTblPostingProfileDetailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    Loading = false;
                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                    if (!SelectedMainRow.DetailsList.Any())
                    {
                        AddNewDetailRow(false);
                    }
                };

                GetMaindata();
            }
        }
        public AccSizeGroupViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList       = new SortableCollectionView <TblAccSizeGroupViewModel>();
                SelectedMainRow   = new TblAccSizeGroupViewModel();
                SelectedDetailRow = new TblAccSizeCodeViewModel();



                Client.GetTblAccSizeGroupCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblAccSizeGroupViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };
                Client.GetTblAccSizeCodeCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblAccSizeCodeViewModel();
                        newrow.InjectFrom(row);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }
                    if (sv.Result.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }
                    Loading = false;
                };
                Client.UpdateOrInsertTblAccSizeGroupCompleted += (s, x) =>
                {
                    var savedRow = (TblAccSizeGroupViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };

                Client.UpdateOrInsertTblAccSizeCodeCompleted += (s, x) =>
                {
                    var savedRow = (TblAccSizeCodeViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }

                    //if (x.Result.TblSalaryRelation1 != null)
                    //{
                    //    var headerIserial = x.Result.TblSalaryRelation;

                    //    SelectedMainRow.Iserial = headerIserial;
                    //}
                };

                Client.DeleteTblAccSizeGroupCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                Client.DeleteTblAccSizeCodeCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #15
0
        public StyleAttachmentViewModel(TblStyleViewModel style)
        {
            Style           = style;
            MainRowList     = new SortableCollectionView <TblStyleAttachmentViewModel>();
            SelectedMainRow = new TblStyleAttachmentViewModel();

            Client.GetTblStyleAttachmentCompleted += (s, sv) =>
            {
                MainRowList.Clear();
                foreach (var row in sv.Result)
                {
                    var newrow = new TblStyleAttachmentViewModel();
                    newrow.InjectFrom(row);
                    MainRowList.Add(newrow);
                }
                Loading = false;
            };

            Client.MaxIserialOfStyleForAttachmentCompleted += (s, sv) =>
            {
                FolderPath = "Uploads" + "/" + sv.attachmentPath;
                var folderName = FolderPath + "/" + Style.SeasonPerRow.Ename + "_" + Style.Brand + "_" +
                                 Style.SectionPerRow.Ename;

                var counter = 0;
                foreach (var item in MainRowList)
                {
                    if (item.Iserial == 0)
                    {
                        var maxIserial = sv.Result;

                        item.AttachmentPath = folderName + "/" + style.StyleCode + maxIserial + counter + item.AttachmentPerRow.Extension;
                        item.FolderPath     = folderName;
                        item.UploadFile(item.AttachmentPerRow);

                        //using (FileStream fs = File.Create("binary.dat", 2048, FileOptions.None))
                        //{
                        //    BinaryFormatter formatter = new BinaryFormatter();
                        //    string s = "this is a test";
                        //    formatter.Serialize(fs, Encoding.Unicode.GetBytes(s));
                        //}

                        //using (var stream = File.Create(item.AttachmentPathThumbnail))
                        //{
                        //    stream.Write(buffer, 0, buffer.Length);
                        //    stream.Flush();
                        //    stream.Close();

                        //}
                        //var temp = new FileInfo(item.AttachmentPathThumbnail);
                        //item.UploadFile(temp);

                        counter++;
                    }
                }

                var isvalid = false;

                foreach (var tblStyleAttachmentViewModel in MainRowList)
                {
                    isvalid = Validator.TryValidateObject(tblStyleAttachmentViewModel, new ValidationContext(tblStyleAttachmentViewModel, null, null), null, true);

                    if (!isvalid)
                    {
                        return;
                    }
                }

                if (isvalid)
                {
                    var savelist = new ObservableCollection <TblStyleAttachment>();
                    GenericMapper.InjectFromObCollection(savelist, MainRowList);

                    Client.UpdateOrInsertTblStyleAttachmentAsync(savelist);
                }
            };
            Client.GetTblStyleAttachmentAsync(style.Iserial);
            Client.UpdateOrInsertTblStyleAttachmentCompleted += (s, x) => Client.GetTblStyleAttachmentAsync(style.Iserial);

            Client.DeleteTblStyleAttachmentCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };
        }
Exemple #16
0
        public IncomeStatmentDesignViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.IncomeStatmentDesign.ToString());
                Glclient = new GlServiceClient();

                MainRowList            = new SortableCollectionView <TblIncomeStatmentDesignHeaderViewModel>();
                SelectedMainRow        = new TblIncomeStatmentDesignHeaderViewModel();
                JournalAccountTypeList = new ObservableCollection <GenericTable>();
                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Label"
                });

                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Account"
                });

                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Account With Subs"
                });

                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Cost Of Good Sold"
                });

                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Income Tax"
                });
                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Seprator"
                });

                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Double Seprator"
                });
                JournalAccountTypeList.Add(new GenericTable
                {
                    Code = "Total"
                });

                Glclient.GetTblIncomeStatmentDesignHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblIncomeStatmentDesignHeaderViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Count == 1)
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export      = false;
                        AllowExport = true;
                        //ExportGrid.ExportExcel("IncomeStatmentDesign");
                    }
                };

                Glclient.UpdateOrInsertTblIncomeStatmentDesignHeaderCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                    Loading = false;
                };
                Glclient.DeleteTblIncomeStatmentDesignHeaderCompleted += (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.GetTblIncomeStatmentDesignDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblIncomeStatmentDesignDetailViewModel();

                        newrow.InjectFrom(row);
                        if (row.Type.StartsWith("Account"))
                        {
                            newrow.Type          = row.Type;
                            newrow.AccountPerRow = new TblAccount {
                                Code = row.Description
                            };
                        }
                        SelectedMainRow.DetailsList.Add(newrow);
                    }
                    Loading         = false;
                    DetailFullCount = sv.fullCount;

                    if (SelectedMainRow.DetailsList.Count == 1)
                    {
                        SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault();
                    }

                    if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }
                };

                Glclient.UpdateOrInsertIncomeStatmentDesignDetailCompleted += (s, x) =>
                {
                    var savedRow = (TblIncomeStatmentDesignDetailViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                    Loading = false;
                };

                Glclient.DeleteIncomeStatmentDesignDetailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    Loading = false;
                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                    if (!SelectedMainRow.DetailsList.Any())
                    {
                        AddNewDetailRow(false);
                    }
                };

                GetMaindata();
            }
        }
Exemple #17
0
        public CostCenterViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.CostCenter.ToString());
                Glclient = new GlServiceClient();
                var costDimSetupTypeClient = new GlServiceClient();
                costDimSetupTypeClient.GetGenericCompleted += (s, sv) => { CostCenterTypeList = sv.Result; };
                costDimSetupTypeClient.GetGenericAsync("TblCostCenterType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);
                MainRowList     = new SortableCollectionView <TblCostCenterViewModel>();
                SelectedMainRow = new TblCostCenterViewModel();

                Glclient.GetTblCostCenterCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblCostCenterViewModel();
                        newrow.InjectFrom(row);
                        newrow.CostCenterTypePerRow = new GenericTable();
                        if (row.TblCostCenterType1 != null)
                        {
                            newrow.CostCenterTypePerRow.InjectFrom(row.TblCostCenterType1);
                        }
                        newrow.CostCenterPerRow = row.TblCostCenter2;

                        MainRowList.Add(newrow);
                    }

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

                Glclient.UpdateOrInsertTblCostCentersCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                    Loading = false;
                };
                Glclient.DeleteTblCostCenterCompleted += (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);
                    }
                };

                GetMaindata();
            }
        }
        public IssueJournalViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                GetItemPermissions(PermissionItemName.IssueJournalForm.ToString());
                MainRowList     = new SortableCollectionView <TblIssueJournalHeaderViewModel>();
                SelectedMainRow = new TblIssueJournalHeaderViewModel();
                SelectedRecRow  = new TblIssueJournalReceiveHeaderViewModel();
                Client.GetWarehouseswithOnHandAsync();
                Client.GetWarehouseswithOnHandCompleted += (l, c) =>
                {
                    WarehouseWithOnHandList = c.Result;
                };
                Client.GetTblIssueJournalHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblIssueJournalHeaderViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                };
                Client.GetTblIssueJournalReceiveHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblIssueJournalReceiveHeaderViewModel();
                        newrow.InjectFrom(row);
                        SelectedMainRow.SubDetailList.Add(newrow);
                    }
                    Loading            = false;
                    DetailSubFullCount = sv.fullCount;
                };
                Client.GetTblIssueJournalDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblIssueJournalDetailViewModel();
                        newrow.ColorPerRow = row.TblColor1;
                        newrow.ItemPerRow  = sv.itemsList.SingleOrDefault(x => x.Iserial == row.ItemCode && x.ItemGroup == row.ItemType);
                        newrow.InjectFrom(row);
                        SelectedMainRow.DetailList.Add(newrow);
                    }
                    Loading         = false;
                    DetailFullCount = sv.fullCount;
                };
                Client.UpdateOrInsertTblIssueJournalHeaderCompleted += (s, x) =>
                {
                    var savedRow = (TblIssueJournalHeaderViewModel)MainRowList.GetItemAt(x.outindex);
                    Loading = false;
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblIssueJournalHeaderCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    Loading = false;
                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                Client.UpdateOrInsertTblIssueJournalDetailCompleted += (s, x) =>
                {
                    var savedRow = (TblIssueJournalDetailViewModel)MainRowList.GetItemAt(x.outindex);
                    Loading = false;
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
            }
        }
Exemple #19
0
        public StyleImageViewModel(TblStyleViewModel style)
        {
            Style       = style;
            MainRowList = new SortableCollectionView <TblStyleImageViewModel>();

            GetColors();
            MainRowList.CollectionChanged += MainRowList_CollectionChanged;
            SelectedMainRow = new TblStyleImageViewModel();

            Client.GetTblStyleImageCompleted += (s, sv) =>
            {
                MainRowList.Clear();
                foreach (var row in sv.Result)
                {
                    var newrow = new TblStyleImageViewModel();
                    newrow.InjectFrom(row);
                    newrow.ColorPerRow = row.TblColor1;
                    MainRowList.Add(newrow);
                }
                Loading = false;
            };

            Client.GetTblColorLinkCompleted += (s, sv) =>
            {
                ColorList = new ObservableCollection <TblColor>();
                foreach (var row in sv.Result)
                {
                    ColorList.Add(row.TblColor1);
                }
            };

            Client.MaxIserialOfStyleCompleted += (s, sv) =>
            {
                FolderPath = "Uploads" + "/" + sv.imagePath;

                string folderName = FolderPath + "/" + Style.SeasonPerRow.Ename + "_" + Style.Brand + "_" +
                                    Style.SectionPerRow.Ename;

                var counter = 0;
                foreach (var item in MainRowList)
                {
                    if (item.Iserial == 0)
                    {
                        var maxIserial = sv.Result;

                        item.ImagePath  = folderName + "/" + style.StyleCode + maxIserial + counter + ".png";
                        item.FolderPath = folderName;
                        item.UploadFile(item.ImagePerRow);

                        counter++;
                    }
                }

                var isvalid = false;

                foreach (var tblStyleImageViewModel in MainRowList)
                {
                    isvalid = Validator.TryValidateObject(tblStyleImageViewModel, new ValidationContext(tblStyleImageViewModel, null, null), null, true);

                    if (!isvalid)
                    {
                        return;
                    }
                }

                if (isvalid)
                {
                    var savelist = new ObservableCollection <TblStyleImage>();
                    GenericMapper.InjectFromObCollection(savelist, MainRowList);

                    Client.UpdateOrInsertTblStyleImageAsync(savelist);
                }
            };
            Client.GetTblStyleImageAsync(style.Iserial);
            Client.UpdateOrInsertTblStyleImageCompleted += (s, x) => Client.GetTblStyleImageAsync(style.Iserial);

            Client.DeleteTblStyleImageCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };
        }
        public BrandSectionMailViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client.GetAllBrandsAsync(LoggedUserInfo.Iserial);

                Client.GetAllBrandsCompleted += (d, s) =>
                {
                    BrandList = s.Result;
                };

                lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) =>
                {
                    BrandSectionList.Clear();
                    foreach (var row in sv.Result)
                    {
                        BrandSectionList.Add(row.TblLkpBrandSection1);
                    }
                };
                MainRowList     = new SortableCollectionView <TblBrandSectionMailViewModel>();
                SelectedMainRow = new TblBrandSectionMailViewModel();

                Client.GetTblBrandSectionMailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblBrandSectionMailViewModel();
                        newrow.InjectFrom(row);

                        var newEmp = sv.EmpList.FirstOrDefault(x => x.EMPLID == newrow.Emp);

                        if (newEmp != null)
                        {
                            newrow.EmpPerRow = new EmployeesView
                            {
                                Emplid = newEmp.EMPLID,
                                Name   = newEmp.name
                            }
                        }
                        ;

                        MainRowList.Add(newrow);
                    }
                    Loading = false;

                    if (MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertTblBrandSectionMailCompleted += (s, x) =>
                {
                    var savedRow = (TblBrandSectionMailViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblBrandSectionMailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
        public UserCheckListViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList     = new SortableCollectionView <TblUserCheckListViewModel>();
                SelectedMainRow = new TblUserCheckListViewModel();


                Client.GetGenericAsync("TblCheckListGroup", "%%", "%%", "%%", "Iserial", "ASC");

                Client.GetGenericCompleted += (s, sv) =>
                {
                    CheckListGroupList = new ObservableCollection <GenericTable>();
                    foreach (var variable in sv.Result)
                    {
                        CheckListGroupList.Add(variable);
                    }
                };

                Client.GetTblUserCheckListCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblUserCheckListViewModel();

                        newrow.InjectFrom(row);
                        newrow.CheckListGroupPerRow = new GenericTable();

                        newrow.CheckListGroupPerRow.InjectFrom(row.TblCheckListGroup1);
                        MainRowList.Add(newrow);
                    }
                    Loading = false;

                    if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }

                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }

                    if (Export)
                    {
                        Export = false;

                        //var handler = ExportCompleted;
                        //if (handler != null) handler(this, EventArgs.Empty);
                        //ExportGrid.ExportExcel("Style");
                    }
                };

                Client.UpdateOrInsertTblUserCheckListCompleted += (s, x) =>
                {
                    var savedRow = (TblUserCheckListViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };

                Client.DeleteTblUserCheckListCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };
            }
        }
Exemple #22
0
        public GlGenEntityViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.GlGenEntity.ToString());
                Glclient = new GlServiceClient();

                Glclient.GetTblJournalAccountTypeCompleted += (s, sv) =>
                {
                    JournalAccountTypeList = sv.Result;
                };
                Glclient.GetTblJournalAccountTypeAsync(true, LoggedUserInfo.DatabasEname);

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

                Glclient.GetTblGlGenEntityGroupCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblGlGenEntityGroupViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

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

                Glclient.UpdateOrInsertTblGlGenEntityGroupCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                    Loading = false;
                };
                Glclient.DeleteTblGlGenEntityGroupCompleted += (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.GetTblGlGenEntityCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblGlGenEntityViewModel();

                        newrow.InjectFrom(row);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }

                    Loading         = false;
                    DetailFullCount = sv.fullCount;
                    if (SelectedMainRow.DetailsList.Any() && (SelectedDetailRow == null))
                    {
                        SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault();
                    }
                    if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }
                };

                Glclient.UpdateOrInsertTblGlGenEntityCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        SelectedMainRow.DetailsList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblGlGenEntityCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }

                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                    if (!SelectedMainRow.DetailsList.Any())
                    {
                        AddNewDetailRow(false);
                    }
                };
            }
        }
        public FabricStructureViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList     = new SortableCollectionView <TblFabricStructureViewModel>();
                SelectedMainRow = new TblFabricStructureViewModel();

                Client.GetGenericCompleted += (s, sv) =>
                {
                    FabricCategoryList = sv.Result;
                };

                Client.GetGenericAsync("tbl_FabricCategories", "%%", "%%", "%%", "Iserial", "ASC");

                Client.GetTblFabricStructureCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblFabricStructureViewModel {
                            FabricCategoryPerRow = new GenericTable()
                        };
                        if (row.tbl_FabricCategories != null)
                        {
                            newrow.FabricCategoryPerRow.InjectFrom(row.tbl_FabricCategories1);
                        }
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertTblFabricStructureCompleted += (s, x) =>
                {
                    var savedRow = (TblFabricStructureViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblFabricStructureCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #24
0
        public PaymentScheduleViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client.GetVendPayModeAsync("CCM");
                Client.GetVendPayModeCompleted += (s, sv) =>
                {
                    VendPayModeList = sv.Result;
                };
                MainRowList       = new SortableCollectionView <TblPaymentScheduleViewModel>();
                SelectedMainRow   = new TblPaymentScheduleViewModel();
                SelectedDetailRow = new TblPaymentScheduleDetailViewModel();

                Client.GetTblPaymentScheduleSettingsAsync(0, 50, "it.Iserial", null, null);
                Client.GetTblPaymentScheduleSettingsCompleted += (s, sv) =>
                {
                    SchedulesSettingList = sv.Result;
                };
                Client.GetTblPaymentScheduleCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPaymentScheduleViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };
                Client.GetTblPaymentScheduleDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPaymentScheduleDetailViewModel
                        {
                            SettingPaymentPerRow = row.TblPaymentScheduleSetting
                        };
                        newrow.InjectFrom(row);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }
                    Loading = false;
                };
                Client.UpdateOrInsertTblPaymentScheduleCompleted += (s, x) =>
                {
                    var savedRow = (TblPaymentScheduleViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };

                Client.DeleteTblPaymentScheduleCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #25
0
        public PurchaseBudgetViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList       = new SortableCollectionView <TblPurchaseBudgetHeaderViewModel>();
                SelectedMainRow   = new TblPurchaseBudgetHeaderViewModel();
                SelectedDetailRow = new TblPurchaseBudgetDetailViewModel();

                Client.GetTblPurchaseBudgetHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPurchaseBudgetHeaderViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };
                Client.GetTblPurchaseBudgetDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPurchaseBudgetDetailViewModel();
                        newrow.InjectFrom(row);
                        newrow.SectionPerRow = row.TblLkpBrandSection1;
                        newrow.SeasonPerRow  = row.TblLkpSeason1;

                        SelectedMainRow.DetailsList.Add(newrow);
                    }
                    if (sv.Result.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }
                    Loading = false;
                };
                Client.UpdateOrInsertTblPurchaseBudgetHeaderCompleted += (s, x) =>
                {
                    var savedRow = MainRowList.ElementAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };

                Client.UpdateOrInsertTblPurchaseBudgetDetailCompleted += (s, x) =>
                {
                    var savedRow = (TblPurchaseBudgetDetailViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };


                Client.DeleteTblPurchaseBudgetHeaderCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                Client.DeleteTblPurchaseBudgetDetailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                };


                Client.GetAllBrandsCompleted += (s, sv) =>
                {
                    BrandList = sv.Result;
                };

                Client.GetAllSeasonsCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result.Where(w => w.IsMaster == true))
                    {
                        if (SeasonList.All(x => x.Iserial != row.Iserial))
                        {
                            SeasonList.Add(new TblLkpSeason().InjectFrom(row) as TblLkpSeason);
                        }
                    }
                };
                Client.GetAllSeasonsAsync();
                Client.GetAllBrandsAsync(LoggedUserInfo.Iserial);

                GetMaindata();
            }
        }
        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;
                };
            }
        }
Exemple #27
0
        public GlRuleViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.GlRule.ToString());
                Glclient = new GlServiceClient();

                Glclient.GetGlInventoryGroupAsync(LoggedUserInfo.DatabasEname);

                Glclient.GetGlInventoryGroupCompleted += (s, sv) =>
                {
                    GlInventoryGroupList = sv.Result;
                };
                var journalAccountTypeClient = new GlServiceClient();
                journalAccountTypeClient.GetGenericCompleted += (s, sv) =>
                {
                    JournalAccountTypeList       = sv.Result;
                    JournalAccountTypeListFilter = new ObservableCollection <GenericTable>(sv.Result.Where(x => x.Iserial == 0 || x.Iserial == 8));
                    var newrow = JournalAccountTypeListFilter.FirstOrDefault(x => x.Iserial == 0);
                    newrow.Code  = "Group";
                    newrow.Ename = "Group";
                    newrow.Aname = "Group";
                };
                journalAccountTypeClient.GetGenericAsync("TblJournalAccountType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

                var glRuleTypeClient = new GlServiceClient();
                glRuleTypeClient.GetGenericCompleted += (s, sv) => { CostCenterTypeList = sv.Result; };
                glRuleTypeClient.GetGenericAsync("TblCostCenterType", "%%", "%%", "%%", "Iserial", "ASC",
                                                 LoggedUserInfo.DatabasEname);

                var tblCostCenterOptionClient = new GlServiceClient();
                tblCostCenterOptionClient.GetGenericCompleted += (s, sv) => { CostCenterOptionList = sv.Result; };
                tblCostCenterOptionClient.GetGenericAsync("tblCostCenterOption", "%%", "%%", "%%", "Iserial", "ASC",

                                                          LoggedUserInfo.DatabasEname);

                var tblCostAllocationMethodClient = new GlServiceClient();
                tblCostAllocationMethodClient.GetGenericCompleted += (s, sv) => { CostAllocationMethodList = sv.Result; };
                tblCostAllocationMethodClient.GetGenericAsync("TblCostAllocationMethod", "%%", "%%", "%%", "Iserial", "ASC",
                                                              LoggedUserInfo.DatabasEname);

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

                Glclient.GetTblGlRuleHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblGlRuleHeaderViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

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

                Glclient.UpdateOrInsertTblGlRuleHeadersCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblGlRuleHeaderCompleted += (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.GetTblGlRuleMainDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblGlRuleMainDetailViewModel();

                        newrow.EntityAccountPerRow = new Entity();

                        newrow.EntityAccountPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == row.TblJournalAccountType &&
                                                         x.Iserial == row.EntityAccount);

                        if (row.TblJournalAccountType1 != null)
                        {
                            newrow.JournalAccountTypePerRow = new GenericTable();
                            newrow.JournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType1);
                        }
                        if (row.TblCostCenterType1 != null)
                        {
                            newrow.CostCenterTypePerRow = new GenericTable();
                            newrow.CostCenterTypePerRow.InjectFrom(row.TblCostCenterType1);
                        }
                        if (row.TblCostCenterOption1 != null)
                        {
                            newrow.CostCenterOptionPerRow = new GenericTable();
                            newrow.CostCenterOptionPerRow.InjectFrom(row.TblCostCenterOption1);
                        }
                        if (row.TblCostAllocationMethod1 != null)
                        {
                            newrow.CostAllocationMethodPerRow = new GenericTable();
                            newrow.CostAllocationMethodPerRow.InjectFrom(row.TblCostAllocationMethod1);
                        }
                        newrow.InjectFrom(row);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }

                    Loading         = false;
                    DetailFullCount = sv.fullCount;
                    if (SelectedMainRow.DetailsList.Any() && (SelectedDetailRow == null))
                    {
                        SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault();
                    }
                    if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }
                };

                Glclient.UpdateOrInsertTblGlRuleMainDetailsCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        SelectedDetailRow.DetailsList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblGlRuleMainDetailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }

                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                    if (!SelectedMainRow.DetailsList.Any())
                    {
                        AddNewDetailRow(false);
                    }
                };

                Glclient.GetTblGlRuleDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblGlRuleDetailViewModel
                        {
                            CostCenterPerRow         = row.TblCostCenter1,
                            TblCostCenterType        = SelectedDetailRow.TblCostCenterType,
                            CostCenterTypePerRow     = SelectedDetailRow.CostCenterTypePerRow,
                            JournalAccountTypePerRow = JournalAccountTypeListFilter.FirstOrDefault(x => x.Iserial == row.TblJournalAccountType)
                        };

                        if (row.TblJournalAccountType != null)
                        {
                            newrow.GlInventoryGroupPerRow =
                                GlInventoryGroupList.FirstOrDefault(
                                    x =>
                                    x.TblJournalAccountType == row.TblJournalAccountType &&
                                    x.Iserial == row.GlInventoryGroup);
                        }

                        newrow.InjectFrom(row);

                        SelectedDetailRow.DetailsList.Add(newrow);
                    }
                    Loading            = false;
                    DetailSubFullCount = sv.fullCount;

                    if (SelectedDetailRow.DetailsList.Any() &&
                        (SelectedSubDetailRow == null))
                    {
                        SelectedSubDetailRow = SelectedDetailRow.DetailsList.FirstOrDefault();
                    }

                    if (DetailSubFullCount == 0 && SelectedDetailRow.DetailsList.Count == 0)
                    {
                        AddNewSubDetailRow(false);
                    }
                };

                Glclient.UpdateOrInsertTblGlRuleDetailsCompleted += (s, x) =>
                {
                    var savedRow = (TblGlRuleDetailViewModel)SelectedDetailRow.DetailsList.GetItemAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                    Loading = false;
                };

                Glclient.DeleteTblGlRuleDetailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    Loading = false;
                    var oldrow = SelectedDetailRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        SelectedDetailRow.DetailsList.Remove(oldrow);
                    }
                    if (!SelectedDetailRow.DetailsList.Any())
                    {
                        AddNewSubDetailRow(false);
                    }
                };

                GetMaindata();
            }
        }
Exemple #28
0
        public EmployeeBehalfViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                GetItemPermissions(PermissionItemName.EmployeeBehalfForm.ToString());
                //   GetCustomePermissions(PermissionItemName.EmployeeBehalf.ToString());
                MainRowList      = new SortableCollectionView <TblEmployeeBehalfViewModel>();
                SelectedMainRows = new ObservableCollection <TblEmployeeBehalfViewModel>();
                DetailList       = new SortableCollectionView <EmployeesView>();

                _empClient.GetEmpTableCompleted += (x, y) =>
                {
                    foreach (var item in y.Result)
                    {
                        MainRowList.Add(new TblEmployeeBehalfViewModel
                        {
                            Emplid    = item.Emplid,
                            EmpPerRow = item
                        }
                                        );
                        EmpViewList.Add(item);
                    }
                    Client.GetTblEmployeeBehalfAsync(new ObservableCollection <string>(EmpViewList.Select(e => e.Emplid)));
                    FullCount = y.fullCount;
                    Loading   = false;
                };

                Client.GetEmpTableCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        DetailList.Add(row);
                    }
                    DetailFullCount = sv.fullCount;
                    Loading         = false;
                };

                Client.UpdateOrInsertTblEmployeeBehalfCompleted += (x, y) =>
                {
                    var savedRow = (TblEmployeeBehalfViewModel)MainRowList.GetItemAt(y.outindex);
                    Loading = false;
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(y.Result);
                    }
                };

                Client.GetTblEmployeeBehalfCompleted += (x, y) =>
                {
                    foreach (var row in y.Result)
                    {
                        var tempRow = MainRowList.SingleOrDefault(w => w.Emplid == row.Emplid);
                        if (tempRow != null)
                        {
                            tempRow.ManagerId      = row.ManagerId;
                            tempRow.AttOperatorId  = row.AttOperatorId;
                            tempRow.Iserial        = row.Iserial;
                            tempRow.ManagerPerRow  = EmpViewList.FirstOrDefault(w => w.Emplid == row.ManagerId);
                            tempRow.EmpPerRow      = EmpViewList.FirstOrDefault(w => w.Emplid == row.Emplid);
                            tempRow.OperatorPerRow = EmpViewList.FirstOrDefault(w => w.Emplid == row.AttOperatorId);
                        }
                    }
                    Loading = false;
                };
                Client.DeleteTblEmployeeBehalfCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }
                    Loading = false;
                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };
                GetMaindata();
            }
        }
        public CheckListMailViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                GetItemPermissions(PermissionItemName.CheckListMail.ToString());
                MainRowList        = new SortableCollectionView <TblCheckListMailViewModel>();
                SelectedMainRow    = new TblCheckListMailViewModel();
                CheckListGroupList = new ObservableCollection <GenericTable>();

                Client.GetGenericAsync("TblCheckListGroup", "%%", "%%", "%%", "Iserial", "ASC");

                Client.GetGenericCompleted += (s, sv) =>
                {
                    CheckListGroupList = sv.Result;
                };
                Client.GetTblCheckListMailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblCheckListMailViewModel();
                        var newEmp = sv.EmpList.FirstOrDefault(x => x.EMPLID == newrow.Emp);

                        if (newEmp != null)
                        {
                            newrow.EmpPerRow = new EmployeesView
                            {
                                Emplid = newEmp.EMPLID,
                                Name   = newEmp.name
                            }
                        }
                        ;

                        newrow.CheckListGroupPerRow = new GenericTable();
                        newrow.CheckListGroupPerRow.InjectFrom(row.TblCheckListGroup1);
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Client.UpdateOrInsertTblCheckListMailCompleted += (s, x) =>
                {
                    var savedRow = (TblCheckListMailViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };
                Client.DeleteTblCheckListMailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }
Exemple #30
0
        public SeasonViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client.GetGenericCompleted += (s, sv) =>
                {
                    SeasonTrackTypeList = sv.Result;
                };

                Client.GetAllBrandsCompleted += (s, sv) =>
                {
                    BrandList = sv.Result;
                };
                Client.GetAllBrandsAsync(LoggedUserInfo.Iserial);

                Client.GetGenericAsync("TblSeasonTrackType", "%%", "%%", "%%", "Iserial", "ASC");
                MainRowList       = new SortableCollectionView <TblSeasonViewModel>();
                SelectedMainRow   = new TblSeasonViewModel();
                SelectedDetailRow = new TblSeasonTrackViewModel();

                SelectedMainRow.DetailsList.OnRefresh += DetailsList_OnRefresh;

                Client.GetTblLkpSeasonCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblSeasonViewModel();
                        newrow.InjectFrom(row);
                        newrow.RetailSeasonPerRow = new TblSeason {
                            Code = newrow.ShortCode
                        };
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };
                Client.GetTblSeasonTrackCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblSeasonTrackViewModel();
                        newrow.InjectFrom(row);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }

                    Loading         = false;
                    DetailFullCount = sv.fullCount;
                    if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }
                };
                Client.UpdateOrInsertTblLkpSeasonCompleted += (s, x) =>
                {
                    var savedRow = (TblSeasonViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };

                Client.UpdateOrInsertTblSeasonTrackCompleted += (s, x) =>
                {
                    var savedRow = (TblSeasonTrackViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }

                    //if (x.Result.TblSalaryRelation1 != null)
                    //{
                    //    var headerIserial = x.Result.TblSalaryRelation;

                    //    SelectedMainRow.Iserial = headerIserial;
                    //}
                };

                Client.DeleteTblLkpSeasonCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                };

                Client.DeleteTblSeasonTrackCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                };

                GetMaindata();
            }
        }