private void AddCostFollowUp() { if (CostFollowUpList.Any(x => x.IsRejected)) { return; } if (CostFollowUpItem != null) { if ((CostFollowUpList.IndexOf(CostFollowUpItem)) != (CostFollowUpList.Count - 1)) { return; } // if (CostFollowUpList[CostFollowUpList.Count - 1].ObjStatus.IsEmpty) return; CostFollowUpList.Add(new RFQCostFollowUp { Style = Style, ParentID = SubHeaderSerial }); // CostFollowUpItem = CostFollowUpList[CostFollowUpList.Count - 1]; // CostFollowUpItem.ObjStatus.IsEmpty = true; // CostFollowUpItem.ObjStatus.IsNew = true; CostFollowUpItem.Parent = this; } else { CostFollowUpList.Add(new RFQCostFollowUp { Style = Style, ParentID = SubHeaderSerial }); CostFollowUpItem = CostFollowUpList[CostFollowUpList.Count - 1]; // CostFollowUpItem.ObjStatus.IsEmpty = true; // CostFollowUpItem.ObjStatus.IsNew = true; CostFollowUpItem.Parent = this; } }
private void InitializeCollections() { HeaderItems = new ObservableCollection <RFQHeaderItem>(); HeaderItems.CollectionChanged += (s, e) => { if (e.NewItems != null) { foreach (RFQHeaderItem item in e.NewItems) { item.PropertyChanged += (s1, e1) => RaisePropertyChanged(e1.PropertyName); var item1 = item; item.DeleteDetailItem += (ss, ee) => { if (item1.ObjStatus.IsSavedDBItem) { HeaderItemsDeletedList.Add(item1); } HeaderItems.Remove(item1); }; } } if (e.OldItems != null) { foreach (RFQHeaderItem item in e.OldItems) { item.PropertyChanged -= ((s1, e1) => RaisePropertyChanged(e1.PropertyName)); } } }; HeaderServices = new ObservableCollection <RFQHeaderServices>(); HeaderServices.CollectionChanged += (s, e) => { if (e.NewItems != null) { foreach (RFQHeaderServices item in e.NewItems) { item.PropertyChanged += (s1, e1) => RaisePropertyChanged(e1.PropertyName); //DeleteService var item1 = item; item.DeleteService += (ss, ee) => { if (item1.ObjStatus.IsSavedDBItem) { HeaderServicesDeletedList.Add(item1); } HeaderServices.Remove(item1); }; } } if (e.OldItems != null) { foreach (RFQHeaderServices item in e.OldItems) { item.PropertyChanged -= ((s1, e1) => RaisePropertyChanged(e1.PropertyName)); } } }; FollowUpList = new ObservableCollection <RFQFollowUpViewModel>(); FollowUpList.CollectionChanged += (s, e) => { FollowupsApproved = FollowUpList.Any(x => x.IsApproved) && CostFollowUpList.Any(x => x.IsApproved); if (e.NewItems != null) { foreach (RFQFollowUpViewModel item in e.NewItems) { item.PropertyChanged += (s1, e1) => { RaisePropertyChanged(e1.PropertyName); FollowupsApproved = FollowUpList.Any(x => x.IsApproved) && CostFollowUpList.Any(x => x.IsApproved); }; var item1 = item; item.ResampleAction += (s1, e1) => { FollowUpList .Insert(FollowUpList.IndexOf((s1 as RFQFollowUpViewModel)) + 1 , new RFQFollowUpViewModel() { Style = Style, ParentID = SubHeaderSerial }); FollowUpList[FollowUpList.IndexOf((s1 as RFQFollowUpViewModel)) + 1].StatusID = 4; FollowUpList[FollowUpList.IndexOf((s1 as RFQFollowUpViewModel)) + 1].SizeCode = FollowUpList[FollowUpList.IndexOf((s1 as RFQFollowUpViewModel))].SizeCode; var upViewModel = s1 as RFQFollowUpViewModel; if (upViewModel != null && upViewModel.ObjStatus.IsNew) { item1.ObjStatus.IsEmpty = true; item1.ObjStatus.IsNew = true; } else { var followUpViewModel = s1 as RFQFollowUpViewModel; if (followUpViewModel == null || !followUpViewModel.ObjStatus.IsSavedDBItem) { return; } var rfqFollowUpViewModel = s1 as RFQFollowUpViewModel; rfqFollowUpViewModel.ObjStatus.IsChanged = true; } }; //DeleteFollowup item.DeleteFollowup += (ss, ee) => { if (item1.ObjStatus.IsSavedDBItem) { FollowupDeletedList.Add(item1); } FollowUpList.Remove(item1); }; } } if (e.OldItems != null) { foreach (RFQFollowUpViewModel item in e.OldItems) { item.PropertyChanged -= ((s1, e1) => RaisePropertyChanged(e1.PropertyName)); item.ResampleAction -= new EventHandler((s1, e1) => { }); } } }; CostFollowUpList = new ObservableCollection <RFQCostFollowUp>(); CostFollowUpList.CollectionChanged += (s, e) => { FollowupsApproved = FollowUpList.Any(x => x.IsApproved) && CostFollowUpList.Any(x => x.IsApproved); if (e.NewItems != null) { //foreach (RFQCostFollowUp item in e.NewItems) //{ // item.PropertyChanged // += (s1, e1) => // { // RaisePropertyChanged(e1.PropertyName); // FollowupsApproved = FollowUpList.Any(x => x.IsApproved) && // CostFollowUpList.Any(x => x.IsApproved); // }; // var item1 = item; // item.ResampleAction += ((s1, e1) => // { // CostFollowUpList // .Insert(CostFollowUpList.IndexOf((s1 as RFQCostFollowUp)) + 1 // , new RFQCostFollowUp() { Style = Style, ParentID = SubHeaderSerial }); // CostFollowUpList[CostFollowUpList.IndexOf((s1 as RFQCostFollowUp)) + 1].Status = 4; // var rfqCostFollowUp = s1 as RFQCostFollowUp; // if (rfqCostFollowUp != null && rfqCostFollowUp.ObjStatus.IsNew) // { // item1.ObjStatus.IsEmpty = true; // item1.ObjStatus.IsNew = true; // } // else // { // var costFollowUp = s1 as RFQCostFollowUp; // if (costFollowUp != null && costFollowUp.ObjStatus.IsSavedDBItem) // { // (s1 as RFQCostFollowUp).ObjStatus.IsChanged = true; // } // } // }); // //DeleteCostingFollowup // item.DeleteCostingFollowup += (ss, ee) => // { // if (item1.ObjStatus.IsSavedDBItem) // CostFollowupDeleted.Add(item1); // CostFollowUpList.Remove(item1); // }; //} if (e.OldItems != null) { foreach (RFQCostFollowUp item in e.OldItems) { item.PropertyChanged -= new PropertyChangedEventHandler((s1, e1) => RaisePropertyChanged(e1.PropertyName)); item.ResampleAction -= new EventHandler((s1, e1) => { }); } } } }; RFQItems = new ObservableCollection <GenericViewModel>(); RFQItems.CollectionChanged += (s, e) => { if (e.NewItems != null) { foreach (GenericViewModel item in e.NewItems) { item.PropertyChanged += (s1, e1) => RaisePropertyChanged(e1.PropertyName); } } if (e.OldItems != null) { foreach (GenericViewModel item in e.OldItems) { item.PropertyChanged -= new PropertyChangedEventHandler((s1, e1) => RaisePropertyChanged(e1.PropertyName)); } } }; RFQServices = new ObservableCollection <GenericViewModel>(); RFQServices.CollectionChanged += (s, e) => { if (e.NewItems != null) { foreach (GenericViewModel item in e.NewItems) { item.PropertyChanged += (s1, e1) => RaisePropertyChanged(e1.PropertyName); } } if (e.OldItems != null) { foreach (GenericViewModel item in e.OldItems) { item.PropertyChanged -= new PropertyChangedEventHandler((s1, e1) => RaisePropertyChanged(e1.PropertyName)); } } }; }