static public void SaveRemarks(string ownerGUIDFieldName, string ownerGUID, string userMessagePrefix, DataView v) { if (v == null) { return; } string savefilter = v.RowFilter; v.RowFilter = ""; // ReSharper disable InconsistentNaming using (var Remark_u = new iTRAACProc("Remark_u")) // ReSharper restore InconsistentNaming foreach (var remark in v.Cast <DataRowView>().Where(remark => remark.IsDirty())) { Remark_u.AssignValues(remark); if (!Remark_u.ExecuteNonQuery(userMessagePrefix + " Save Remark: ")) { continue; } remark["RowGUID"] = Remark_u["@RowGUID"]; //for inserts remark.AcceptChanges(); } v.RowFilter = savefilter; }
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); }
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); }
private bool SaveJustSponsorRecord() { // ReSharper disable InconsistentNaming using (var Sponsor_u = new iTRAACProc("Sponsor_u")) // ReSharper restore InconsistentNaming { Fields.Row.SetAllNonDBNullColumnsToEmptyString("-"); try { Sponsor_u.AssignValues(Fields); if (!Sponsor_u.ExecuteDataSet(UserMessagePrefix)) { return(false); //base class clears "Fields" dirty flags for us } CacheTables(Sponsor_u); } finally { Fields.Row.RemoveEmptyPlaceholder("-"); } } return(true); }
private bool SaveJustSponsorRecord() { // ReSharper disable InconsistentNaming using (var Sponsor_u = new iTRAACProc("Sponsor_u")) // ReSharper restore InconsistentNaming { Fields.Row.SetAllNonDBNullColumnsToEmptyString("-"); try { Sponsor_u.AssignValues(Fields); if (!Sponsor_u.ExecuteDataSet(UserMessagePrefix)) return (false); //base class clears "Fields" dirty flags for us CacheTables(Sponsor_u); } finally { Fields.Row.RemoveEmptyPlaceholder("-"); } } return (true); }
protected override bool SaveSubClass() { //validate everything first so we see all the red boxes at once... var isValid = true; ValidateGeneric(ref isValid, "Rank"); ValidateGeneric(ref isValid, "DEROS"); ValidateGeneric(ref isValid, "DutyLocation"); ValidateGeneric(ref isValid, "DutyPhoneDSN1", "'?'.Length == 3", "Enter 3 Digits"); ValidateGeneric(ref isValid, "DutyPhoneDSN2", "'?'.Length == 4", "Enter 4 Digits"); ValidateGeneric(ref isValid, "OfficialMailCMR"); ValidateGeneric(ref isValid, "OfficialMailBox"); ValidateGeneric(ref isValid, "OfficialMailCity"); ValidateGeneric(ref isValid, "OfficialMailState"); ValidateGeneric(ref isValid, "OfficialMailZip", "'?'.Length == 5", "Enter 5 Digits"); ValidateGeneric(ref isValid, "HomePhoneCountry"); ValidateGeneric(ref isValid, "HomePhone"); var validateUTAP = Fields.Field<bool>("IsUTAPActive"); ValidateGeneric(Fields, ref isValid, "HomeStreet,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomeStreetNumber,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomeCity,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomePostal,IsUTAPActive", validateUTAP); foreach(DataRowView member in HouseMembers) { ValidateGeneric(member, ref isValid, "SSN1", true, "'?'.Length == 3", "Enter 3 Digits"); ValidateGeneric(member, ref isValid, "SSN2", true, "'?'.Length == 2", "Enter 2 Digits"); ValidateGeneric(member, ref isValid, "SSN3", true, "'?'.Length == 4", "Enter 4 Digits"); if (ValidateGeneric(member, ref isValid, "FName")) ValidateGeneric(member, ref isValid, "FName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case."); if (ValidateGeneric(member, ref isValid, "LName")) ValidateGeneric(member, ref isValid, "LName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case."); } if (!isValid) { ShowUserMessage("Please correct all highlighted fields before saving."); return (false); } //then save attempt to save everything if we made it through all the validation... if (Fields.IsDirty()) if (!SaveJustSponsorRecord()) return (false); foreach (var member in HouseMembers.Cast<DataRowView>().Where(member => member.IsDirty())) // ReSharper disable InconsistentNaming using (Proc Client_u = new iTRAACProc("Client_u")) // ReSharper restore InconsistentNaming { Client_u.AssignValues(member); if (!Client_u.ExecuteDataSet(UserMessagePrefix)) return (false); member.AcceptChanges(); CacheTables(Client_u); } RemarkModel.SaveRemarks("SponsorGUID", GUID, UserMessagePrefix, SponsorRemarks); return (true); }
protected override bool SaveSubClass() { //validate everything first so we see all the red boxes at once... var isValid = true; ValidateGeneric(ref isValid, "Rank"); ValidateGeneric(ref isValid, "DEROS"); ValidateGeneric(ref isValid, "DutyLocation"); ValidateGeneric(ref isValid, "DutyPhoneDSN1", "'?'.Length == 3", "Enter 3 Digits"); ValidateGeneric(ref isValid, "DutyPhoneDSN2", "'?'.Length == 4", "Enter 4 Digits"); ValidateGeneric(ref isValid, "OfficialMailCMR"); ValidateGeneric(ref isValid, "OfficialMailBox"); ValidateGeneric(ref isValid, "OfficialMailCity"); ValidateGeneric(ref isValid, "OfficialMailState"); ValidateGeneric(ref isValid, "OfficialMailZip", "'?'.Length == 5", "Enter 5 Digits"); ValidateGeneric(ref isValid, "HomePhoneCountry"); ValidateGeneric(ref isValid, "HomePhone"); var validateUTAP = Fields.Field <bool>("IsUTAPActive"); ValidateGeneric(Fields, ref isValid, "HomeStreet,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomeStreetNumber,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomeCity,IsUTAPActive", validateUTAP); ValidateGeneric(Fields, ref isValid, "HomePostal,IsUTAPActive", validateUTAP); foreach (DataRowView member in HouseMembers) { ValidateGeneric(member, ref isValid, "SSN1", true, "'?'.Length == 3", "Enter 3 Digits"); ValidateGeneric(member, ref isValid, "SSN2", true, "'?'.Length == 2", "Enter 2 Digits"); ValidateGeneric(member, ref isValid, "SSN3", true, "'?'.Length == 4", "Enter 4 Digits"); if (ValidateGeneric(member, ref isValid, "FName")) { ValidateGeneric(member, ref isValid, "FName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case."); } if (ValidateGeneric(member, ref isValid, "LName")) { ValidateGeneric(member, ref isValid, "LName", true, "'?' != '?'.toUpperCase()", "Use proper uppper/lower casing for all names.\nForms will automatically print in all upper case."); } } if (!isValid) { ShowUserMessage("Please correct all highlighted fields before saving."); return(false); } //then save attempt to save everything if we made it through all the validation... if (Fields.IsDirty()) { if (!SaveJustSponsorRecord()) { return(false); } } foreach (var member in HouseMembers.Cast <DataRowView>().Where(member => member.IsDirty())) { // ReSharper disable InconsistentNaming using (Proc Client_u = new iTRAACProc("Client_u")) // ReSharper restore InconsistentNaming { Client_u.AssignValues(member); if (!Client_u.ExecuteDataSet(UserMessagePrefix)) { return(false); } member.AcceptChanges(); CacheTables(Client_u); } } RemarkModel.SaveRemarks("SponsorGUID", GUID, UserMessagePrefix, SponsorRemarks); return(true); }
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); }
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); }
static public void SaveRemarks(string ownerGUIDFieldName, string ownerGUID, string userMessagePrefix, DataView v) { if (v == null) return; string savefilter = v.RowFilter; v.RowFilter = ""; // ReSharper disable InconsistentNaming using (var Remark_u = new iTRAACProc("Remark_u")) // ReSharper restore InconsistentNaming foreach (var remark in v.Cast<DataRowView>().Where(remark => remark.IsDirty())) { Remark_u.AssignValues(remark); if (!Remark_u.ExecuteNonQuery(userMessagePrefix + " Save Remark: ")) continue; remark["RowGUID"] = Remark_u["@RowGUID"]; //for inserts remark.AcceptChanges(); } v.RowFilter = savefilter; }