예제 #1
0
        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();
        }
예제 #2
0
        public ViewableFileCollection(SymanticForm form)
        {
            this.EncapsulatedForm = form;

            //pre-populate all the fields, along with any existing records
            FormfieldCollection allFields = new FormfieldCollection().Where(Formfield.Columns.Formid, this.EncapsulatedForm.Form.Id).Load();

            ///get the related fields
            this.relatedFields = new List <SymanticField>();
            for (int i = 0; i < allFields.Count; i++)
            {
                EditableField field = new EditableField(allFields[i]);
                this.relatedFields.Add(field);
            }
            /// Sort the fields in field order
            this.relatedFields = this.relatedFields.OrderBy(field => field.Metadata.FieldOrder).ToList();
        }
예제 #3
0
 /// <summary>
 /// Attempts to set the values for this field. If necessary it will parse as a code. It will only work if this is a multiple option field
 /// </summa
 public void SetMultipleValues(string[] values)
 {
     if (this.Type != FieldType.MultipleOption)
     {
         throw new NotSupportedException("Cannot set multiple values when the field typ eis not multiple option");
     }
     /// Attempt to parse each value, we can only store parseable values
     /// The last code in the list will be the one stored in the code value field
     foreach (string value in values)
     {
         int parsedCode = -1;
         if (!Int32.TryParse(value, out parsedCode))
         {
             throw new ArgumentException("Cannot parse the given value as a code");
         }
     }
     /// We don't set a code value. We only set text for this.
     this.TextValue = EditableField.CombineTextFromCheckboxValue(values);
 }
예제 #4
0
        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();
        }
예제 #5
0
 /// <summary>
 /// Attempts to set the value for this field. If necessary it will parse as a code.
 /// </summary>
 public void SetValue(string value)
 {
     if (this.Type == FieldType.Textvalue)
     {
         this.TextValue = value;
         return;
     }
     if (this.Type == FieldType.SingleOption)
     {
         int parsedCode = -1;
         if (!Int32.TryParse(value, out parsedCode))
         {
             throw new ArgumentException("Cannot parse the given value as a code");
         }
         this.CodeValue = parsedCode;
         return;
     }
     if (this.Type == FieldType.MultipleOption)
     {
         /// For multiple values, we need to decode the string and call the special store method for multiple values
         this.SetMultipleValues(EditableField.ParseTextForCheckboxValue(value));
         return;
     }
 }