void UpdatePerson(New.Person person, Formrecord record) { switch (record.Formfield.Name) { case "Middle Initial": person.MiddleInitial = record.Storedvalue; return; case "SSN Last Four": person.SocialSecurityLastFour = TakeLastFourDigits(record.Storedvalue); return; case "Date of Birth": person.DateOfBirth = TryParseDate(record.Storedvalue); return; case "Gender": person.Gender = MaleOrFemale(record.Storedvalue); return; case "Phone": person.PrimaryPhoneNumber = StripExtraPhoneCharacters(record.Storedvalue); return; case "Alt. Phone": person.AlternatePhoneNumber = StripExtraPhoneCharacters(record.Storedvalue); return; case "E-mail Address": person.AlternateEmail = record.Storedvalue; return; case "Emergency Contact Name": person.EmergencyContactName = record.Storedvalue; return; case "Emergency Contact Phone": person.EmergencyContactPhoneNumber = StripExtraPhoneCharacters(record.Storedvalue); return; case "Position": person.Position = TryGetPosition(record.Storedvalue); return; case "Address": person.StreetAddress = record.Storedvalue; return; default: return; } ; }
public EditableFile(Formfile formFile) : base(formFile) { //pre-populate all the fields, along with any existing records FormfieldCollection allFields = new FormfieldCollection().Where(Formfield.Columns.Formid, this.SymanticForm.Form.Id).Load(); this.relatedFields = new List <EditableField>(); for (int i = 0; i < allFields.Count; i++) { Formrecord candidateRecord = this.FormFile.Formrecords().FirstOrDefault <Formrecord>(record => record.Fieldid == allFields[i].Id); EditableField field; if (candidateRecord != null) { field = new EditableField(candidateRecord); } else { field = new EditableField(allFields[i]); } field.FieldStoringCallback += new EventHandler <EditableFieldStoringCallbackArgs>(HandleEditableFieldStoring); this.relatedFields.Add(field); } /// Sort the fields in field order this.relatedFields = this.relatedFields.OrderBy(field => field.Metadata.FieldOrder).ToList(); }
void UpdateQual(Qualification qual, Formrecord record) { switch (record.Formfield.Name) { case "Date Last BFR or Qual Form 8": qual.LastBFR = TryParseDate(record.Storedvalue); return; case "Date Last Military Flight Physical": qual.LastMilitaryFlightPhysical = TryParseDate(record.Storedvalue); return; case "Date Last Altitude Chamber": qual.LastAltitudeChamber = TryParseDate(record.Storedvalue); return; case "Date Last Egrees Training LL-03": qual.LastEgreesTraining = TryParseDate(record.Storedvalue); return; case "Date Last Simulator Refresher": qual.LastSimulatorRefresher = TryParseDate(record.Storedvalue); return; case "Date Last CRM": qual.LastCRM = TryParseDate(record.Storedvalue); return; case "Date Last Life Support Training": qual.LastLifeSupportTraining = TryParseDate(record.Storedvalue); return; case "Date Last Flight": qual.LastFlight = TryParseDate(record.Storedvalue); return; case "Military FCF Qual": qual.MilitaryFCFQualification = PraseFCFQual(record.Storedvalue); return; default: return; } ; }
public EditableField(Formfield formfield, Formrecord formrecord) : this(formrecord) { if (formrecord.Formfield.Id != formfield.Id) { throw new NotSupportedException("Cannot encapsulate a record with a different field (Field IDs do not match)"); } }
/// <summary> /// Encapsulates an existing record for this field /// </summary> /// <param name="formrecord"></param> public EditableField(Formrecord formrecord) : this(formrecord.Formfield) { this.FormRecord = formrecord; this.Status = FieldStatus.Unmodified; this.workingTextValue = this.FormRecord.Storedvalue; this.workingCodeValue = this.FormRecord.Codeid; }
/// <summary> /// Deletes the field (and all codes, and all records) from the form /// </summary> public void Delete() { foreach (Formrecord record in this.FormField.Formrecords()) { Formrecord.Delete(record.Id); } foreach (Formcode code in this.FormField.Formcodes()) { Formcode.Delete(code.Id); } Formfield.Delete(this.FormField.Id); if (this.FieldDeleted != null) { this.FieldDeleted(this, EventArgs.Empty); } }
/// <summary> /// Stores the working values into the a record. /// </summary> public void Store() { EditableFieldStoringCallbackArgs fieldStoringCallbackArgs = new EditableFieldStoringCallbackArgs(); if (this.FieldStoringCallback != null) { this.FieldStoringCallback(this, fieldStoringCallbackArgs); } if (this.Status == FieldStatus.New) { if (!fieldStoringCallbackArgs.FileId.HasValue) { throw new NotSupportedException("Cannot save a new field without a file id provided by the field storing callback method"); } int fileid = fieldStoringCallbackArgs.FileId.Value; this.FormRecord = Formrecord.CreateNew(fileid, this.FormField.Id); if (this.FormRecord == null) { throw new NotSupportedException("Cannot store a new field without first creating the associated record"); } this.Status = FieldStatus.Modified; } if (this.Status == FieldStatus.Modified) { this.FormRecord.Storedvalue = this.TextValue; this.FormRecord.Codeid = null; //default if (this.Type == FieldType.SingleOption) { /// For single option we actually set the code value this.FormRecord.Codeid = this.CodeValue; if (this.CodeValue.HasValue && this.LookupCodes.Count(lookup => lookup.Id == this.CodeValue.Value) > 0) { this.FormRecord.Storedvalue = this.LookupCodes.Where(Formcode.Columns.Id, this.FormRecord.Codeid.Value)[0].Label; } } this.FormRecord.Save(Utility.GetActiveUsername()); this.Status = FieldStatus.Unmodified; } }