//Audit Trail methods //Evaluates Initialize when->Reading record formulas specified at the data access layer protected virtual void ContactsRecord_ReadRecord(Object sender, System.EventArgs e) { //Apply Initialize->Reading record formula only if validation is successful. ContactsRecord ContactsRec = (ContactsRecord)sender; if (ContactsRec != null && !ContactsRec.IsReadOnly) { } }
//Evaluates Initialize when->Updating formulas specified at the data access layer protected virtual void ContactsRecord_UpdatingRecord(Object sender, System.ComponentModel.CancelEventArgs e) { //Apply Initialize->Updating formula only if validation is successful. ContactsRecord ContactsRec = (ContactsRecord)sender; Validate_Updating(); if (ContactsRec != null && !ContactsRec.IsReadOnly) { } }
//Evaluates Initialize when->Inserting formulas specified at the data access layer protected virtual void ContactsRecord_InsertingRecord(Object sender, System.ComponentModel.CancelEventArgs e) { //Apply Initialize->Inserting formula only if validation is successful. ContactsRecord ContactsRec = (ContactsRecord)sender; Validate_Inserting(); if (ContactsRec != null && !ContactsRec.IsReadOnly) { ContactsRec.Parse(EvaluateFormula("\"false\"", this, null), ContactsTable.RecordDeleted); } }
/// <summary> /// This is a shared function that can be used to get a ContactsRecord record using a where and order by clause. /// </summary> public static ContactsRecord GetRecord(BaseFilter join, string where, OrderBy orderBy) { SqlFilter whereFilter = null; if (where != null && where.Trim() != "") { whereFilter = new SqlFilter(where); } ArrayList recList = ContactsTable.Instance.GetRecordList(join, whereFilter, null, orderBy, BaseTable.MIN_PAGE_NUMBER, BaseTable.MIN_BATCH_SIZE); ContactsRecord rec = null; if (recList.Count > 0) { rec = (ContactsRecord)recList[0]; } return(rec); }
static Contact ToContact(ContactsRecord contactsRecord) { var record = contactsRecord.GetChildRecord(TizenContact.Name, 0); var phones = new List <ContactPhone>(); var phonesCount = contactsRecord.GetChildRecordCount(TizenContact.Number); for (var i = 0; i < phonesCount; i++) { var nameRecord = contactsRecord.GetChildRecord(TizenContact.Number, i); var number = nameRecord.Get <string>(TizenNumber.NumberData); phones.Add(new ContactPhone(number)); } var emails = new List <ContactEmail>(); var emailCount = contactsRecord.GetChildRecordCount(TizenContact.Email); for (var i = 0; i < emailCount; i++) { var emailRecord = contactsRecord.GetChildRecord(TizenContact.Email, i); var addr = emailRecord.Get <string>(TizenEmail.Address); emails.Add(new ContactEmail(addr)); } return(new Contact( (record?.Get <int>(TizenName.ContactId))?.ToString(), record?.Get <string>(TizenName.Prefix), record?.Get <string>(TizenName.First), record?.Get <string>(TizenName.Addition), record?.Get <string>(TizenName.Last), record?.Get <string>(TizenName.Suffix), phones, emails)); }
private static Contact ContactFromContactsRecord(ContactsRecord contactsRecord) { var contact = new Contact(); if (contactsRecord.GetChildRecordCount(TizenContact.Name) > 0) { var recordName = contactsRecord.GetChildRecord(TizenContact.Name, 0); contact.HonorificNamePrefix = recordName.Get <string>(TizenName.Prefix) ?? string.Empty; contact.FirstName = recordName.Get <string>(TizenName.First) ?? string.Empty; contact.MiddleName = recordName.Get <string>(TizenName.Addition) ?? string.Empty; contact.LastName = recordName.Get <string>(TizenName.Last) ?? string.Empty; contact.HonorificNameSuffix = recordName.Get <string>(TizenName.Suffix) ?? string.Empty; contact.YomiGivenName = recordName.Get <string>(TizenName.PhoneticFirst) ?? string.Empty; contact.YomiFamilyName = recordName.Get <string>(TizenName.PhoneticLast) ?? string.Empty; } var emailCount = contactsRecord.GetChildRecordCount(TizenContact.Email); for (var mailId = 0; mailId < emailCount; mailId++) { var emailRecord = contactsRecord.GetChildRecord(TizenContact.Email, mailId); var address = emailRecord.Get <string>(TizenEmail.Address); var type = (TizenEmail.Types)emailRecord.Get <int>(TizenEmail.Type); contact.Emails.Add(new ContactEmail() { Address = address, Kind = GetContactEmailKind(type) }); } var phoneCount = contactsRecord.GetChildRecordCount(TizenContact.Number); for (var phoneId = 0; phoneId < phoneCount; phoneId++) { var phoneRecord = contactsRecord.GetChildRecord(TizenContact.Number, phoneId); var number = phoneRecord.Get <string>(TizenNumber.NumberData); var type = (TizenNumber.Types)phoneRecord.Get <int>(TizenNumber.Type); contact.Phones.Add(new ContactPhone() { Number = number, Kind = GetContactPhoneKind(type) }); } var addressCount = contactsRecord.GetChildRecordCount(TizenContact.Address); for (var addressId = 0; addressId < addressCount; addressId++) { var addressRecord = contactsRecord.GetChildRecord(TizenContact.Address, addressId); var country = addressRecord.Get <string>(TizenAddress.Country); var locality = addressRecord.Get <string>(TizenAddress.Locality); var street = addressRecord.Get <string>(TizenAddress.Street); var region = addressRecord.Get <string>(TizenAddress.Region); var postalCode = addressRecord.Get <string>(TizenAddress.PostalCode); var type = (TizenAddress.Types)addressRecord.Get <int>(TizenAddress.Type); contact.Addresses.Add(new ContactAddress() { Country = country ?? string.Empty, Locality = locality ?? string.Empty, PostalCode = postalCode ?? string.Empty, Region = region ?? string.Empty, StreetAddress = street ?? string.Empty, Kind = GetContactAddressKind(type) }); } if (contactsRecord.GetChildRecordCount(TizenContact.Note) > 0) { contact.Notes = contactsRecord .GetChildRecord(TizenContact.Note, 0)? .Get <string>(TizenNote.Contents) ?? string.Empty; } if (contactsRecord.GetChildRecordCount(TizenContact.Nickname) > 0) { contact.Nickname = contactsRecord .GetChildRecord(TizenContact.Nickname, 0)? .Get <string>(TizenNickname.Name) ?? string.Empty; } return(contact); }
public virtual void SetContactId() { string selectedValue = null; // figure out the selectedValue // Set the ContactId QuickSelector on the webpage with value from the // DatabaseOLR_db%dbo.HonourContactLinks database record. // this.DataSource is the DatabaseOLR_db%dbo.HonourContactLinks record retrieved from the database. // this.ContactId is the ASP:QuickSelector on the webpage. // You can modify this method directly, or replace it with a call to // base.SetContactId(); // and add your own custom code before or after the call to the base function. // Default Value could also be NULL. if (this.DataSource != null && this.DataSource.IsCreated) { selectedValue = this.DataSource.ContactId.ToString(); } else { selectedValue = EvaluateFormula("URL(\"ContactId\")"); } // Add the Please Select item. if (selectedValue == null || selectedValue == "") { MiscUtils.ResetSelectedItem(this.ContactId, new ListItem(this.Page.GetResourceValue("Txt:PleaseSelect", "OLR"), "--PLEASE_SELECT--")); } // Populate the item(s) to the control this.ContactId.SetFieldMaxLength(50); System.Collections.Generic.IDictionary <string, object> variables = new System.Collections.Generic.Dictionary <string, object>(); FormulaEvaluator evaluator = new FormulaEvaluator(); if (selectedValue != null && selectedValue.Trim() != "" && !MiscUtils.SetSelectedValue(this.ContactId, selectedValue) && !MiscUtils.SetSelectedDisplayText(this.ContactId, selectedValue)) { // construct a whereclause to query a record with DatabaseOLR_db%dbo.Contacts.ContactId = selectedValue CompoundFilter filter2 = new CompoundFilter(CompoundFilter.CompoundingOperators.And_Operator, null); WhereClause whereClause2 = new WhereClause(); filter2.AddFilter(new BaseClasses.Data.ColumnValueFilter(ContactsTable.ContactId, selectedValue, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, false)); whereClause2.AddFilter(filter2, CompoundFilter.CompoundingOperators.And_Operator); // Execute the query try { ContactsRecord[] rc = ContactsTable.GetRecords(whereClause2, new OrderBy(false, false), 0, 1); System.Collections.Generic.IDictionary <string, object> vars = new System.Collections.Generic.Dictionary <string, object> (); // if find a record, add it to the dropdown and set it as selected item if (rc != null && rc.Length == 1) { ContactsRecord itemValue = rc[0]; string cvalue = null; string fvalue = null; if (itemValue.ContactIdSpecified) { cvalue = itemValue.ContactId.ToString(); } FormulaEvaluator evaluator2 = new FormulaEvaluator(); System.Collections.Generic.IDictionary <string, object> variables2 = new System.Collections.Generic.Dictionary <string, object>(); variables2.Add(itemValue.TableAccess.TableDefinition.TableCodeName, itemValue); fvalue = EvaluateFormula("=ContactId", itemValue, variables2, evaluator2); if (fvalue == null || fvalue.Trim() == "") { fvalue = cvalue; } MiscUtils.ResetSelectedItem(this.ContactId, new ListItem(fvalue, cvalue)); } } catch { } } string url = this.ModifyRedirectUrl("../Contacts/Contacts-QuickSelector.aspx", "", true); url = this.Page.ModifyRedirectUrl(url, "", true); url += "?Target=" + this.ContactId.ClientID + "&Formula=" + (this.Page as BaseApplicationPage).Encrypt("=ContactId") + "&IndexField=" + (this.Page as BaseApplicationPage).Encrypt("ContactId") + "&EmptyValue=" + (this.Page as BaseApplicationPage).Encrypt("--PLEASE_SELECT--") + "&EmptyDisplayText=" + (this.Page as BaseApplicationPage).Encrypt(this.Page.GetResourceValue("Txt:PleaseSelect")) + "&Mode=" + (this.Page as BaseApplicationPage).Encrypt("FieldValueSingleSelection") + "&RedirectStyle=" + (this.Page as BaseApplicationPage).Encrypt("Popup"); this.ContactId.Attributes["onClick"] = "initializePopupPage(this, '" + url + "', " + Convert.ToString(ContactId.AutoPostBack).ToLower() + ", event); return false;"; }