//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(); }
protected bool SaveMe(bool isFiling = false, bool updateSponsor = true) { // generally, inserts and deletes will be edge cases handled elsewhere, modified fields on existing rows are the primary save scenario for child lists hanging off main entities like TaxForm (e.g. TaxFormRemarks) //pulling back on this for now... seems theoretically possible to save a pending NF2 with un-printed status just like NF1's, it's not "issued" until it's printed //if (IsClass2 && !Validate()) //{ // ShowUserMessage("It is invalid to save an NF2/EF2 that's not fully completed."); // return (false); //} if (Fields.IsDirty()) //the "Fields" logic does actually need to be here if called from FileForm() rather than base.Save(); { // ReSharper disable InconsistentNaming using (var TaxForm_u = new iTRAACProc("TaxForm_u")) // ReSharper restore InconsistentNaming { TaxForm_u.AssignValues(Fields); TaxForm_u["@IsFiling"] = isFiling; if (!TaxForm_u.ExecuteDataSet(UserMessagePrefix)) { return(false); } Fields.AcceptChanges(); if (isFiling) { CacheTables(TaxForm_u); } } if (updateSponsor) { OnFormStatusChange(); } } if (ExtendedFields.IsDirty()) { // ReSharper disable InconsistentNaming using (var TaxForm_TransactionTypeExt_u = new Proc("TaxForm_TransactionTypeExt_u")) // ReSharper restore InconsistentNaming { TaxForm_TransactionTypeExt_u.AssignValues(ExtendedFields); TaxForm_TransactionTypeExt_u["@TaxFormGUID"] = GUID; if (!TaxForm_TransactionTypeExt_u.ExecuteNonQuery(UserMessagePrefix)) { return(false); } } ExtendedFields.AcceptChanges(); } RemarkModel.SaveRemarks("FKRowGUID", GUID, UserMessagePrefix, TaxFormRemarks); return(true); }
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 }