protected override void LoadSubClass() { Fields = EntityLookup(GUID, "TaxForm", "TaxForm_s"); GUID = Fields["RowGUID"].ToString(); //for the case where TaxForm_s can lookup on OrderNumber as well as GUID //currently comes back with the following tables loaded: TaxForm, (optional) TaxForm_Weapon or (optional) TaxForm_Vehicle Fields.PropertyChanged += FieldChange; SetExtendedFields(); _isLocked = IsFormStatusClosed || !IsFormFromMyOffice; //create the logical lookup field for "Location" via TaxForm.LocationCode to TaxOffice.TaxOfficeCode DsCache.AddRelation("Location", TaxOfficeModel.TaxOfficeTable.Columns["OfficeCode"], TaxFormTable.Columns["LocationCode"], false); if (!TaxFormTable.Columns.Contains("Location")) { TaxFormTable.Columns.Add("Location", typeof(string), "Parent(Location).Office"); } //create the TaxForm_Remark relationship DsCache.AddRelation("TaxForm_Remark", TaxFormTable.Columns["RowGUID"], TaxFormRemarksTable.Columns["FKRowGUID"], false); TaxFormRemarks = Fields.CreateChildView("TaxForm_Remark"); ShowDeletedRemarks = false; RemarkModel.CommonRemarkTableSettings(TaxFormRemarks); TaxFormRemarks.Table.RowChanged += TaxFormRemarksRowChanged; if (IsIncomplete) { Validate(); //flip on all the red boxes so the user is prompted to resolve right away } }
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() { //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); }
public void RemoveRemark(DataRowView remarkRow, string reason) { RemarkModel.Remove(remarkRow, reason); //OnPropertyChanged("IsPCS"); }
protected override void LoadSubClass() { if (Transactions == null) { Transactions = new TransactionList(this, "Transactions"); } //assumption we're taking with caching with Sponsor entities in particular: // the corresponding sproc returns the whole household of sponsor + dependent clients records // and also the "household" (sponsor) address/phone record // then this lookup method returns a cached model of the specific type // and the GUI can then pull what it needs off that object via basic properties //the specified GUID passed in is for the Sponsor's *Sponsor*table* RowGUID Fields = EntityLookup(GUID, "Sponsor", "Sponsor_s"); var sponsorTable = DsCache.Tables["Sponsor"]; sponsorTable.Columns["DutyPhoneDSN1"].AllowDBNull = false; //sucks to have to fix these but they're 'generated' from a real field so they lose their NOT NULL metadata sponsorTable.Columns["DutyPhoneDSN2"].AllowDBNull = false; ClientTable.ColumnChanged += ClientTableColumnChanged; ClientTable.RowChanged += ClientTableRowChanged; UTAPFields = RowLookup("Sponsor_UTAP", GUID); //create the logical lookup field for SuspensionTaxOffice via Sponsor.SuspensionTaxOfficeId to Office.TaxOfficeId DsCache.AddRelation("SuspensionTaxOffice", DsCache.Tables["TaxOffice"].Columns["TaxOfficeId"], sponsorTable.Columns["SuspensionTaxOfficeId"]); if (!sponsorTable.Columns.Contains("SuspensionTaxOffice")) { sponsorTable.Columns.Add("SuspensionTaxOffice", typeof(string), "Parent(SuspensionTaxOffice).Office"); } //map the parent-child relationships hanging off Sponsor ... DataColumn sponsorTableRowGUID = sponsorTable.Columns["RowGUID"]; //SponsorTable tweaks: if (!sponsorTable.Columns.Contains("CanSellForms")) { sponsorTable.Columns.Add("CanSellForms", typeof(bool), "Active AND ISNULL(SuspensionExpiry, #1/1/01#) = #1/1/01#"); sponsorTable.Columns["Active"].ReadOnly = true; //block access to this field from the UI, elsewhere in this class we temporarily open it up to make validated changes (see CheckClientActiveRules method) } //Dependents: DsCache.AddRelation("Sponsor_Client", sponsorTableRowGUID, ClientTable.Columns["SponsorGUID"]); HouseMembers = Fields.CreateChildView("Sponsor_Client"); HouseMembers.Sort = "IsSponsor desc, IsSpouse desc, LName, FName"; //if brand new sponsor, add a default row to fill out for convenience if (HouseMembers.Count == 0) { AddMember(); } //set ShowDeactive to true, if there's not an Active Sponsor ShowDeactiveMembers = !HouseMembers[0].Field <bool>("Active") || !HouseMembers[0].Field <bool>("IsSponsor"); if (!ClientTable.Columns.Contains("IsSponsorOrSpouse")) { ClientTable.Columns.Add("IsSponsorOrSpouse", typeof(bool), "IsSponsor OR IsSpouse"); ClientTable.Columns["Active"].ReadOnly = true; //block access to this field from the UI, elsewhere in this class we temporarily open it up to make validated changes (see CheckClientActiveRules method) } //TaxForms: DsCache.AddRelation("Sponsor_TaxForm", sponsorTableRowGUID, DsCache.Tables["Sponsor_TaxForm"].Columns["SponsorGUID"]); RefreshTaxFormsList(false); //Remarks: var remarkTable = DsCache.Tables["Sponsor_Remark"]; DsCache.AddRelation("Sponsor_Remark", sponsorTableRowGUID, remarkTable.Columns["SponsorGUID"]); SponsorRemarks = Fields.CreateChildView("Sponsor_Remark"); ShowDeletedRemarks = false; RemarkModel.CommonRemarkTableSettings(SponsorRemarks); SponsorRemarks.Table.RowChanged += SponsorRemarksRowChanged; SponsorRemarks.Table.ColumnChanging += SponsorRemarksColumnChanging; _potentialClientMatchesBgWorker.OnExecute = PotentialMatchesSearchExecute; _potentialClientMatchesBgWorker.OnCompleted = PotentialMatchesSearchCompleted; }
public void SetViolation(int remarkTypeId, string remarks) { RemarkModel.SaveNew(GUID, remarkTypeId, remarks); OnPropertyChanged("IsViolation"); OnFormStatusChange(); }