protected override void LoadSubClass() { string TableNames = "TaxForm"; Fields = TableCache(GUID, ref TableNames, "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(); //default state to readonly when form has been filed or voided _IsReadOnly = iTRAACHelpers.IsBitOn(Fields["StatusFlags"], StatusFlagsForm.Filed) || iTRAACHelpers.IsBitOn(Fields["StatusFlags"], StatusFlagsForm.Voided); //create the logical lookup field for "Location" via TaxForm.LocationCode to TaxOffice.TaxOfficeCode dsCache.AddRelation("Location", TaxOffice.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; Remark.CommonRemarkTableSettings(TaxFormRemarks); TaxFormRemarks.Table.RowChanged += TaxFormRemarks_RowChanged; if (IsIncomplete) { Validate(); //flip on all the red boxes so the user is prompted to resolve right away } }
private void RefreshTaxFormsList(bool refreshData = true) { TaxForms.DetachRowsAndDispose(); if (refreshData) { // hack alert... TableCache currently assumes it's looking for *single* model style records via their RowGUID // yet we're passing the Sponsor RowGUID to a proc that loads a *LIST* of forms // this 'works' because (a) we know we want to refresh the data so we specifically desire a cache *miss* in this case which is guaranteed because we'll never find a SponsorGUID in the TaxForms table // and (b) we need that SponsorGUID to target its list of forms EntityLookup(GUID, "Sponsor_TaxForm", "Sponsor_TaxForms"); //refresh the list of forms for this sponsor so we see the new ones just created } TaxForms = Fields.CreateChildView("Sponsor_TaxForm"); SetTaxFormsRowFilter(); Class1TaxFormsCountUnreturned = (TaxForms.Cast <DataRowView>().Where(r => r.Field <int>("FormTypeID") == 1 && (r.Field <bool>("IsUnreturnedID") || r.Field <bool>("IsIncompleteId")))).Count(); TaxFormsCountReturnedNotFiled = (TaxForms.Cast <DataRowView>().Where(r => r.Field <string>("Status") == "Returned")).Count(); OnPropertyChanged("Fields"); //added this to update Suspension info due to Form Violation OnPropertyChanged("SponsorRemarks"); //ditto on the Remarks driven by Form Violation OnPropertyChanged("TaxForms"); OnPropertyChanged("HasUnreturnedClass2"); OnPropertyChanged("Class1TaxForms_CountUnreturned"); OnPropertyChanged("Class1TaxForms_CountRemainingToBuy"); OnPropertyChanged("Class1TaxForms_RemainingToBuyToolTipText"); OnPropertyChanged("TaxForms_CountReturnedNotFiled"); }
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 } }
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 }
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; }