Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        public void LoadFormFields()
        {
            Data.UIForm.UIFields form = new Data.UIForm.UIFields(Common.GetConnection(this.ClientID));
            DataTable            dt   = form.GetFormFields(this.ClientID, this.FormID);

            FormFields = new List <FormField>();
            foreach (System.Data.DataRow row in dt.Rows)
            {
                var serial = new JsonSerializer();
                serial.Formatting = Formatting.Indented;
                var        ff   = new FormField(this.ClientID);
                RenderType rt   = row["FieldRenderType"] == null ? RenderType.TEXT : (RenderType)row["FieldRenderType"];
                var        fatt = row["FieldAttribute"] == null ? "" : (string)row["FieldAttribute"];
                if (rt == RenderType.BOOLEAN)
                {
                    using (var sr = new StringReader(fatt))
                        using (var jr = new JsonTextReader(sr))
                            ff = serial.Deserialize <FormFields.Boolean>(jr);
                }
                else if (rt == RenderType.NUMBER)
                {
                    using (var sr = new StringReader(fatt))
                        using (var jr = new JsonTextReader(sr))
                            ff = serial.Deserialize <FormFields.Numeric>(jr);
                    //  ff = Newtonsoft.Json.JsonConvert.DeserializeObject<FormFields.Numeric>(fatt);
                }
                else if (rt == RenderType.PICKER)
                {
                    using (var sr = new StringReader(fatt))
                        using (var jr = new JsonTextReader(sr))
                            ff = serial.Deserialize <FormFields.Date>(jr);
                    //  ff = Newtonsoft.Json.JsonConvert.DeserializeObject<FormFields.Date>(fatt);
                }
                else if (rt == RenderType.SELECTION)
                {
                    using (var sr = new StringReader(fatt))
                        using (var jr = new JsonTextReader(sr))
                            ff = serial.Deserialize <FormFields.Selection>(jr);
                    if (((FormFields.Selection)ff).LookUpSource != "")
                    {
                    }
                }
                else if (rt == RenderType.TEXT)
                {
                    using (var sr = new StringReader(fatt))
                        using (var jr = new JsonTextReader(sr))
                            ff = serial.Deserialize <FormFields.Text>(jr);
                    // ff = Newtonsoft.Json.JsonConvert.DeserializeObject<FormFields.Text>(fatt);
                }
                else if (rt == RenderType.UPLOAD)
                {
                    using (var sr = new StringReader(fatt))
                        using (var jr = new JsonTextReader(sr))
                            ff = serial.Deserialize <FormFields.Upload>(jr);
                    //  ff = Newtonsoft.Json.JsonConvert.DeserializeObject<FormFields.Upload>(fatt);
                }
                ff.SetForm(this.FormID);
                ff.FormFieldID = row["FieldID"] == null ? "" : (string)row["FieldID"];
                //   ff.Attribute.DataField = row["DataField"] == null ? "" : (string)row["DataField"];
                ff.FieldRenderType = rt;
                FormFields.Add(ff);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="field"></param>
 /// <returns></returns>
 public FormBuilder AddField(FormField field)
 {
     UIForm.FormFields.Add(field);
     return(this);
 }