示例#1
0
 public bool CheckIfEnableEdit(int status)
 {
     return(FullStyleTNAStatusList.FirstOrDefault(w => w.Iserial == status).EnableEdit);
 }
示例#2
0
        public StyleTNAStatusViewModel(StyleHeaderViewModel styleViewModel)
        {
            TempStyleViewModel = styleViewModel;

            if (!DesignerProperties.IsInDesignTool)
            {
                MainRowList     = new ObservableCollection <TblStyleTNAStatusDetailModel>();
                SelectedMainRow = new TblStyleTNAStatusDetailModel();

                ProductionClient.GetTblStyleTNAStatusDetailCompleted += (s, sv) =>
                {
                    if (sv.Error != null)
                    {
                        MessageBox.Show(sv.Error.Message);
                    }

                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblStyleTNAStatusDetailModel();
                        newrow.InjectFrom(row);
                        newrow.UserPerRow           = row.TblAuthUser1;
                        newrow.StyleTNAStatusPerRow = new GenericTable();
                        if (row.TblStyleTNAStatu != null)
                        {
                            GenericTable newTempRow = new GenericTable().InjectFrom(row.TblStyleTNAStatu) as GenericTable;
                            newrow.StyleTNAStatusPerRow = newTempRow;
                        }
                        MainRowList.Add(newrow);
                    }

                    AddNewMainRow();
                    Loading = false;
                };

                ProductionClient.GetTblUsersStyleTNAStatusAsync(LoggedUserInfo.Iserial);

                ProductionClient.GetTblUsersStyleTNAStatusCompleted += (s, sv) =>
                {
                    StyleTNAStatusList.Clear();
                    FullStyleTNAStatusList.Clear();
                    foreach (var item in sv.Result.ToList())
                    {
                        FullStyleTNAStatusList.Add(new ProductionService.TblStyleTNAStatu().InjectFrom(item) as ProductionService.TblStyleTNAStatu);
                    }
                    foreach (var item in sv.Result.ToList())
                    {
                        if (!CheckIfEnableEdit(TempStyleViewModel.SelectedTnaRow.TblStyleTNAStatus))
                        {
                            if (item.DisplayAfterApprove)
                            {
                                StyleTNAStatusList.Add(new ProductionService.TblStyleTNAStatu().InjectFrom(item) as ProductionService.TblStyleTNAStatu);
                            }
                        }
                        else
                        {
                            if (!item.DisplayAfterApprove)
                            {
                                StyleTNAStatusList.Add(new ProductionService.TblStyleTNAStatu().InjectFrom(item) as ProductionService.TblStyleTNAStatu);
                            }
                        }
                    }
                };
                ProductionClient.UpdateOrInsertTblStyleTNAStatusDetailCompleted += (s, sv) =>
                {
                    TempStyleViewModel.SelectedTnaRow.TblStyleTNAStatus = sv.Result.TblStyleTnaStatus;
                };

                GetMaindata();
            }
        }