//public override bool IsModified //{ // get // { // return (base.IsModified || ExtendedFields.IsDirty() || TaxFormRemarks.IsDirty()); // } //} protected override void UnLoadSubClass() { if (ParentPackage != null) { ParentPackage.Rollback(); //only happens under NF2 scenario } if (TaxFormRemarks != null) { TaxFormRemarks.Table.RowChanged -= TaxFormRemarks_RowChanged; } TaxFormRemarks.DetachRowsAndDispose(); //blow away child row first to avoid the 'missing foreign to primary key' exception from the dataset police if (ExtendedFields != null) { ExtendedFields.PropertyChanged -= ExtendedFields_PropertyChanged; } ExtendedFields.DetachRow(); if (Fields != null) { Fields.PropertyChanged -= FieldChange; } Fields.DetachRow(); }
private void SetExtendedFields() { if (ExtendedFields != null) { ExtendedFields.PropertyChanged -= ExtendedFields_PropertyChanged; ExtendedFields.DetachRow(); } string extable = GetCurrentTransactionTypeExtendedTableName(); if (dsCache.Relations.Contains(extable)) //if this is a transaction type with extended fields required... { DataView ExtFields = Fields.CreateChildView(extable); if (ExtFields.Count == 0) //if no row already exists, create a default row for this tax form and transaction type to provide the empty slot for fields to be filled out { DataTable extTable = dsCache.Tables[extable]; //it'd be cool to break this out into a generic AddBlankRow() function that populates a GUID PK if present and cruises the column types to create blank default values DataRow extrow = extTable.NewRow(); DataColumnCollection cols = extTable.Columns; foreach (DataColumn col in cols) { if (!col.ColumnName.Contains("GUID")) { extrow[col.ColumnName] = ""; //fill out all non GUID fields generically to dodge not null errors } } extrow["RowGUID"] = Guid.NewGuid(); extrow["TaxFormGUID"] = GUID; extTable.Rows.Add(extrow); extrow.AcceptChanges(); } ExtendedFields = ExtFields[0]; ExtendedFields.PropertyChanged += ExtendedFields_PropertyChanged; } OnPropertyChanged("ExtendedFields"); //let the UI know to update the extended fields display when we change TransactionType }