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); }
public bool Save() { //removing this now that i prefer the subclass to walk through it's objects and make sure more than this simple property: //if (!IsModified) return (true); bool success = SaveSubClass(); if (success) { Fields.AcceptChanges(); IsModified = false; } return(success); }
protected override bool SaveSubClass() { bool success = true; if (Fields.IsDirty()) { using (var taxOfficeU = new iTRAACProc("TaxOffice_u")) { if (taxOfficeU.AssignValues(Current.Fields).ExecuteNonQuery("Tax Office - ", true)) { Fields.AcceptChanges(); } else { success = false; } } } if (UserTable.GetChanges() != null) { using (var userU = new iTRAACProc("User_u")) { foreach (DataRowView r in from DataRowView r in UserTable.DefaultView where r.IsDirty() select r) { if (userU.AssignValues(r).ExecuteNonQuery(String.Format("Saving User: {0} - ", r["UserNameId"]))) { r.AcceptChanges(); } else { success = false; } } } } return(success); }