Пример #1
0
        public void AddNewDetailRow(bool checkLastRow)
        {
            var currentRowIndex = (SelectedMainRow.DetailList.IndexOf(SelectedDetailRow));

            if (AllowAdd != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }

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

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

                if (!isvalid)
                {
                    return;
                }
            }
            var newrow = new TblIssueJournalDetailViewModel();

            SelectedMainRow.DetailList.Insert(currentRowIndex + 1, newrow);
            SelectedDetailRow = newrow;
        }
Пример #2
0
        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);
                    }
                };
            }
        }