// 动态创建控件
        // 注意:这段代码需要每次加载页面都执行,因此不能放在 if(!IsPostBack) 逻辑判断中
        protected void Page_Init(object sender, EventArgs e)
        {
            // 创建一个 FormRow 控件并添加到 Form2
            FormRow row = new FormRow();

            row.ID = "rowUser";
            Form2.Rows.Add(row);


            TextBox tbxUser = new TextBox();

            tbxUser.ID          = "tbxUserName";
            tbxUser.Text        = "";
            tbxUser.Label       = "用户名";
            tbxUser.ShowLabel   = true;
            tbxUser.ShowRedStar = true;
            tbxUser.Required    = true;
            row.Items.Add(tbxUser);


            DropDownList ddlGender = new DropDownList();

            ddlGender.ID    = "ddlGender";
            ddlGender.Label = "性别(自动回发)";
            ddlGender.Items.Add("男", "0");
            ddlGender.Items.Add("女", "1");
            ddlGender.SelectedIndex         = 0;
            ddlGender.AutoPostBack          = true;
            ddlGender.SelectedIndexChanged += new EventHandler(ddlGender_SelectedIndexChanged);
            row.Items.Add(ddlGender);
        }
        protected void ddlGender_SelectedIndexChanged(object sender, EventArgs e)
        {
            FormRow      rowUser   = Form2.FindControl("rowUser") as FormRow;
            DropDownList ddlGender = rowUser.FindControl("ddlGender") as DropDownList;

            Alert.ShowInTop("选择的性别:" + ddlGender.SelectedText);
        }
Exemple #3
0
        // CreatNewRow()在表单中创建新的一行
        private FormRow CreatNewRow()
        {
            FormRow NewRow = new FormRow();

            NewRow.Layout = LayoutType.HBox;

            return(NewRow);
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            FormRow      rowUser     = Form2.FindControl("rowUser") as FormRow;
            TextBox      tbxUserName = rowUser.FindControl("tbxUserName") as TextBox;
            DropDownList ddlGender   = rowUser.FindControl("ddlGender") as DropDownList;

            Alert.ShowInTop("用户名:" + tbxUserName.Text + "  性别:" + ddlGender.SelectedText);
        }
        private void ProcessFormRow(FormRow formRow, ref int index, ref int itemId)
        {
            var items = formRow.Items;
            var count = items.Count;

            if (count <= 0)
            {
                return;
            }

            var formItem = items[0];
            var basisIdentifierAsString = $"Group_{itemId++}";
            var groupIdentifier         = StringIdentifier.IdentifierWithStringId($"{basisIdentifierAsString}_0");
            var groupModelController    = UPGroupModelController.GroupModelController(formItem, groupIdentifier, this);

            if (groupModelController == null)
            {
                return;
            }

            groupModelController.ExplicitLabel = formItem.Label;
            groupModelController.RootTabIndex  = index;
            if (count > 1)
            {
                var currentModelController = groupModelController;
                for (var indexFormRow = 1; indexFormRow < count; indexFormRow++)
                {
                    var alternateItem            = items[indexFormRow];
                    var alternateModelController = UPGroupModelController.GroupModelController(alternateItem, StringIdentifier.IdentifierWithStringId($"{0}_{indexFormRow }"), this);
                    if (alternateModelController != null)
                    {
                        alternateModelController.RootTabIndex  = index;
                        alternateModelController.ExplicitLabel = alternateItem.Label;
                        currentModelController.AlternateGroupModelController = alternateModelController;
                        currentModelController = alternateModelController;
                    }
                }
            }

            this.AddGroupController(groupModelController);
            index++;
            if (!string.IsNullOrWhiteSpace(formItem.ValueName))
            {
                if (this.namedGroupController != null)
                {
                    this.namedGroupController[formItem.ValueName] = groupModelController;
                }
                else
                {
                    this.namedGroupController = new Dictionary <string, UPGroupModelController>
                    {
                        [formItem.ValueName] = groupModelController
                    };
                }
            }
        }
        public void Add(FormRow row)
        {
            if (row == null || Group.Rows.Contains(row))
            {
                return;
            }

            Group.Rows.Add(row);
            LoadRows();
        }
        //提交事件
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string reasons = string.Empty;
                string works   = string.Empty;
                for (int i = 0; i < len; i++)
                {
                    string rowid    = "rowUser" + i;
                    string txtid    = "txtReason" + i;
                    string workname = "txtWork" + i;

                    FormRow        rowUser = Form2.FindControl(rowid) as FormRow;
                    FineUI.TextBox reason  = rowUser.FindControl(txtid) as FineUI.TextBox;
                    FineUI.TextBox work    = rowUser.FindControl(workname) as FineUI.TextBox;
                    //&符号拼接
                    reasons += reason.Text + "&";
                    works   += work.Text + "&";
                }
                reasons = reasons.Substring(0, reasons.Length - 1);
                string flag = string.Empty;
                if (IsAdd.ToString() == "新增")
                {
                    flag = operate.InsertRecommend(typename, id, reasons, Convert.ToBoolean(isenable), works);
                }
                else if (IsAdd.ToString() == "修改")
                {
                    flag = operate.UpdateRecommend(typename, id, reasons, Convert.ToBoolean(isenable), works);
                }
                if (flag == "保存成功" || flag == "修改成功")
                {
                    PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
                    PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
                    Alert.ShowInParent(flag);
                }
                else
                {
                    Alert.ShowInParent(flag);
                }
            }
            catch (Exception ex)
            {
                Alert.ShowInParent(ex.Message.ToString());
            }
        }
        public int RunAdapter([FromBody] FormAdapterDTO form)
        {
            long formID   = form.formID;
            int  LocaleID = form.localID;

            FormRow formrow = new FormRow();

            foreach (var f in form.forms)
            {
                formrow.AddItem(f);
            }
            MyFormCommitResult formcommitresult = new MyFormCommitResult();
            Class2             formadapter      = new Class2(formID, LocaleID);

            formcommitresult = formadapter.AddFormData(formrow);

            return((int)formcommitresult);
        }
        private static FormRow <TControl> LabelledControl <TModel, TProperty, TControl>(this HtmlHelper <TModel> helper, string labelText, Expression <Func <TModel, TProperty> > property, ControlFactory <TControl> factory)
            where TControl : Control
        {
            var propertyName = property.GetExpressionText();
            var name         = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(propertyName);
            var id           = TagBuilder.CreateSanitizedId(name);
            var metaData     = ModelMetadata.FromLambdaExpression(property, helper.ViewData);

            var controlContext = new ControlContext
            {
                Helper   = helper,
                Id       = id,
                Name     = name,
                Metadata = metaData,
            };

            labelText = labelText ?? metaData.DisplayName ?? metaData.PropertyName;
            var label = new HtmlTag("label").Text(labelText).Attr("for", id);

            var control = factory(controlContext);

            var formRow = new FormRow <TControl>(helper, id, labelText, control);

            if (metaData.AdditionalValues.ContainsKey(Metadata.HintText))
            {
                formRow.Hint((string)metaData.AdditionalValues[Metadata.HintText]);
            }

            if (metaData.AdditionalValues.ContainsKey(Metadata.MaxLength))
            {
                int maxLength = (int)metaData.AdditionalValues[Metadata.MaxLength];

                if (maxLength <= 5)
                {
                    formRow.Width(ControlWidth.Small);
                }
                else if (maxLength <= 25)
                {
                    formRow.Width(ControlWidth.Medium);
                }
            }

            return(formRow);
        }
Exemple #10
0
        private void AddFormData(IActivityForm activityForm)
        {
            IDictionary userInputFields = (IDictionary)HttpContext.Session["userInputFields"];

            if (userInputFields == null)
            {
                userInputFields = new Hashtable();
            }
            HttpContext.Session.Add("activityForm", activityForm);
            IList       fields     = activityForm.Fields;
            IEnumerator fildEnumer = fields.GetEnumerator();
            IList       formRows   = new ArrayList();

            while (fildEnumer.MoveNext())
            {
                IField field = (IField)fildEnumer.Current;
                // Construct a meaningfull name that is http-compliant
                String attributeName = field.Attribute.Name;
                String parameterName = convertToHttpCompliant(attributeName);

                IHtmlFormatter htmlFormatter = field.GetHtmlFormatter();
                if (htmlFormatter != null)
                {
                    Object objectToFormat = null;
                    if (userInputFields.Contains(attributeName))
                    {
                        objectToFormat = userInputFields[attributeName];
                    }
                    else
                    {
                        objectToFormat = activityForm.AttributeValues[field.Attribute.Name];
                    }
                    // TODO: Test if there is the possibility to simplify the interface, see null
                    String  html    = htmlFormatter.ObjectToHtml(objectToFormat, parameterName, null);
                    FormRow formRow = new FormRow(field, html);
                    formRows.Add(formRow);
                }
                else
                {
                    //log.Warn("skipping field for attribute '" + attributeName + "' because it doesn't have a HtmlFormatter");
                }
            }
            ViewData["formRows"] = formRows;
        }
Exemple #11
0
        private string SaveReportInFile()
        {
            StringBuilder sb          = new StringBuilder();
            String        result      = "";
            var           replacedStr = "";

            if (FormRow.Items.Count > 0)
            {
                FormRow.SelectAllCells();
                FormRow.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
                ApplicationCommands.Copy.Execute(null, FormRow);
                CBlowingRow.UnselectAllCells();
                result = (string)Clipboard.GetData(DataFormats.CommaSeparatedValue);
                // replacedStr = result.Replace(",", ";");
                sb.Append(result);
            }


            if (BlowingRow.Items.Count > 0)
            {
                BlowingRow.SelectAllCells();
                BlowingRow.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
                ApplicationCommands.Copy.Execute(null, BlowingRow);
                BlowingRow.UnselectAllCells();
                result      = (string)Clipboard.GetData(DataFormats.CommaSeparatedValue);
                replacedStr = result.Replace(",", ";");
                sb.Append(replacedStr);
            }


            if (CBlowingRow.Items.Count > 0)
            {
                CBlowingRow.SelectAllCells();
                CBlowingRow.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
                ApplicationCommands.Copy.Execute(null, CBlowingRow);
                CBlowingRow.UnselectAllCells();
                result      = (string)Clipboard.GetData(DataFormats.CommaSeparatedValue);
                replacedStr = result.Replace(",", ";");
                sb.Append(replacedStr);
            }


            return(sb.ToString());
        }
        public int RunAdapterSample()
        {
            //SET Parameters
            long    formID   = 3281;
            int     LocaleID = 1000;
            FormRow formrow  = new FormRow();

            formrow.AddItem(new FormField("Text_Box_1", "resource1-LF", "string"));
            formrow.AddItem(new FormField("Checkbox_1", "1", "integer"));
            formrow.AddItem(new FormField("Date_Picker_1", "09/02/2019 05:00:00", "time"));
            formrow.AddItem(new FormField("Text_Area_1", "10 - questa è 'con apici semplici' la prima riga&#xD;&#xA; questa è la &quot;seconda&quot; riga con apici", "string"));
            formrow.AddItem(new FormField("Text_Box_2", "9999.83", "real"));
            MyFormCommitResult formcommitresult = new MyFormCommitResult();
            Class2             formadapter      = new Class2(formID, LocaleID);

            formcommitresult = formadapter.AddFormData(formrow);

            return((int)formcommitresult);
        }
 public FormRowViewModel(FormRow row)
 {
     Columns = new ObservableCollection <FormColumnViewModel>();
     Row     = row;
 }
        private FormDefinition BuildDefinition(Type type)
        {
            // Only classes are allowed.
            // Primitives should be retrieved from prebuilt definitions.
            if (!type.IsClass || typeof(MulticastDelegate).IsAssignableFrom(type.BaseType))
            {
                return(null);
            }

            var formDefinition    = new FormDefinition(type);
            var mode              = DefaultFields.AllExcludingReadonly;
            var grid              = new[] { 1d };
            var beforeFormContent = new List <(FormContentAttribute attr, FormElement element)>();
            var afterFormContent  = new List <(FormContentAttribute attr, FormElement element)>();

            foreach (var attribute in type.GetCustomAttributes())
            {
                switch (attribute)
                {
                case ResourceAttribute resource:
                    formDefinition.Resources.Add(resource.Name, resource.Value is string expr
                            ? (IValueProvider)BoundExpression.Parse(expr)
                            : new LiteralValue(resource.Value));
                    break;

                case FormAttribute form:
                    mode = form.Mode;
                    grid = form.Grid;
                    if (grid == null || grid.Length < 1)
                    {
                        grid = new[] { 1d }
                    }
                    ;

                    break;

                case FormContentAttribute contentAttribute:
                    if (contentAttribute.InsertAfter)
                    {
                        afterFormContent.Add((contentAttribute, contentAttribute.GetElement()));
                    }
                    else
                    {
                        beforeFormContent.Add((contentAttribute, contentAttribute.GetElement()));
                    }

                    break;
                }
            }

            beforeFormContent.Sort((a, b) => a.attr.Position.CompareTo(b.attr.Position));
            afterFormContent.Sort((a, b) => a.attr.Position.CompareTo(b.attr.Position));

            var gridLength = grid.Length;

            // Pass one - get list of valid properties.
            var properties = Utilities
                             .GetProperties(type, mode)
                             .Select(p => new PropertyInfoWrapper(p))
                             .ToArray();

            // Pass two - build form elements.
            var elements = new List <ElementWrapper>();

            foreach (var property in properties)
            {
                var deserializer = TryGetDeserializer(property.PropertyType);
                // Query property builders.
                var element = Build(property, deserializer);

                if (element == null)
                {
                    continue;
                }

                // Pass three - initialize elements.
                foreach (var initializer in FieldInitializers)
                {
                    initializer.Initialize(element, property, deserializer);
                }

                var wrapper = new ElementWrapper(element, property);
                // Set layout.
                var attr = property.GetCustomAttribute <FieldAttribute>();
                if (attr != null)
                {
                    wrapper.Position   = attr.Position;
                    wrapper.Row        = attr.Row;
                    wrapper.Column     = attr.Column;
                    wrapper.ColumnSpan = attr.ColumnSpan;
                }

                elements.Add(wrapper);
            }

            // Pass four - order elements.
            elements = elements.OrderBy(element => element.Position).ToList();

            // Pass five - group rows and calculate layout.
            var layout = PerformLayout(grid, elements);

            // Pass six - add attached elements.
            var rows = new List <FormRow>();

            // Before form.
            rows.AddRange(CreateRows(beforeFormContent, gridLength));

            foreach (var row in layout)
            {
                var before = new List <(FormContentAttribute attr, FormElement element)>();
                var after  = new List <(FormContentAttribute attr, FormElement element)>();
                foreach (var element in row.Elements)
                {
                    var property = element.Property;
                    foreach (var attr in property.GetCustomAttributes <FormContentAttribute>())
                    {
                        (attr.InsertAfter ? after : before).Add((attr, attr.GetElement()));
                    }
                }

                before.Sort((a, b) => a.attr.Position.CompareTo(b.attr.Position));
                after.Sort((a, b) => a.attr.Position.CompareTo(b.attr.Position));

                // Before element.
                rows.AddRange(CreateRows(before, gridLength));

                // Field row.
                var formRow = new FormRow();
                formRow.Elements.AddRange(
                    row.Elements.Select(w => new FormElementContainer(w.Column, w.ColumnSpan, w.Element)));
                rows.Add(formRow);

                // After element.
                rows.AddRange(CreateRows(after, gridLength));
            }

            // After form.
            rows.AddRange(CreateRows(afterFormContent, gridLength));

            // Wrap up everything.
            formDefinition.Grid     = grid;
            formDefinition.FormRows = rows;
            formDefinition.Freeze();
            foreach (var element in formDefinition.FormRows.SelectMany(r => r.Elements).SelectMany(c => c.Elements))
            {
                element.Freeze();
            }

            return(formDefinition);
        }
        private void CreateDocument()
        {
            FormTable tL = new FormTable();
            tL.Columns = "50%;*";
            tL.Width = "100%";
            tL.CellPadding = 5;

            FormRow row1 = new FormRow();
            FormCell cell11 = new FormCell();
            cell11.ColSpan = 2;
            cell11.Name = "cell_11";
            row1.Cells.Add(cell11);
            tL.Rows.Add(row1);

            FormRow row2 = new FormRow();
            FormCell cell21 = new FormCell();
            FormCell cell22 = new FormCell();
            cell21.ColSpan = 1;
            cell22.ColSpan = 1;
            cell21.Name = "cell_21";
            cell22.Name = "cell_22";
            row2.Cells.Add(cell21);
            row2.Cells.Add(cell22);
            tL.Rows.Add(row2);

            FormRow row3 = new FormRow();
            FormCell cell31 = new FormCell();
            cell31.ColSpan = 2;
            cell31.Name = "cell_31";
            row3.Cells.Add(cell31);
            tL.Rows.Add(row3);

            FormSection sec1 = new FormSection();
            sec1.BorderType = 1;
            sec1.ItemIndex = 1;
            sec1.ShowLabel = true;
            sec1.Uid = "dd6acdd98240403984e561399d33d9a9";
            sec1.Labels.Add(new FormLabel("Sec1", Thread.CurrentThread.CurrentUICulture.Name));
            cell11.Sections.Add(sec1);

            FormSection sec2 = new FormSection();
            sec2.BorderType = 0;
            sec2.ItemIndex = 1;
            sec2.ShowLabel = true;
            sec2.Uid = "886cb9a3aae34e68ac8ef234d0ce8ce2";
            sec2.Labels.Add(new FormLabel("Sec2", Thread.CurrentThread.CurrentUICulture.Name));
            cell21.Sections.Add(sec2);

            FormSection sec3 = new FormSection();
            sec3.BorderType = 0;
            sec3.ItemIndex = 1;
            sec3.ShowLabel = true;
            sec3.Uid = "bb6acbb98240403784e561397b33d7a7";
            sec3.Labels.Add(new FormLabel("Sec3", Thread.CurrentThread.CurrentUICulture.Name));
            cell22.Sections.Add(sec3);

            FormSection sec4 = new FormSection();
            sec4.BorderType = 0;
            sec4.ItemIndex = 1;
            sec4.ShowLabel = true;
            sec4.Uid = Guid.NewGuid().ToString("N");
            sec4.Labels.Add(new FormLabel("Sec4", Thread.CurrentThread.CurrentUICulture.Name));
            cell31.Sections.Add(sec4);

            FormControl ctrl1 = new FormControl(FormController.SmartTableLayoutType);
            ctrl1.Columns = "50%;*";
            ctrl1.Width = "100%";
            ctrl1.CellPadding = 5;

            FormItem item1 = new FormItem();
            item1.LabelWidth = "120px";
            item1.ShowLabel = true;
            item1.Labels.Add(new FormLabel("test label1:", Thread.CurrentThread.CurrentUICulture.Name));
            item1.Uid = "9b3c4642e59b405faa2a1f38559a06cc";
            item1.RowIndex = 1;
            item1.CellIndex = 1;
            item1.RowSpan = 1;
            item1.ColSpan = 2;
            FormControl item1c = new FormControl(FormController.MetaPrimitiveControlType);
            item1c.Uid = Guid.NewGuid().ToString("N");
            item1c.Source = "Title";
            item1.Control = item1c;
            ctrl1.Items.Add(item1);

            FormItem item2 = new FormItem();
            item2.LabelWidth = "120px";
            item2.ShowLabel = true;
            item2.Labels.Add(new FormLabel("test label2:", Thread.CurrentThread.CurrentUICulture.Name));
            item2.Uid = "cafa725a31b74ad6a069e3b6446d89c0";
            item2.RowIndex = 2;
            item2.CellIndex = 1;
            item2.RowSpan = 1;
            item2.ColSpan = 1;
            FormControl item2c = new FormControl(FormController.MetaPrimitiveControlType);
            item2c.Uid = Guid.NewGuid().ToString("N");
            item2c.Source = "Priority";
            item2.Control = item2c;
            ctrl1.Items.Add(item2);

            FormItem item3 = new FormItem();
            item3.LabelWidth = "120px";
            item3.ShowLabel = true;
            item3.Labels.Add(new FormLabel("test label3:", Thread.CurrentThread.CurrentUICulture.Name));
            item3.Uid = "8d36be893c3f4cf1b5295be6853eb246";
            item3.RowIndex = 3;
            item3.CellIndex = 1;
            item3.RowSpan = 1;
            item3.ColSpan = 1;
            FormControl item3c = new FormControl(FormController.MetaPrimitiveControlType);
            item3c.Uid = Guid.NewGuid().ToString("N");
            item3c.Source = "Created";
            item3.Control = item3c;
            ctrl1.Items.Add(item3);

            FormItem item4 = new FormItem();
            item4.LabelWidth = "120px";
            item4.ShowLabel = true;
            item4.Labels.Add(new FormLabel("test label4:", Thread.CurrentThread.CurrentUICulture.Name));
            item4.Uid = "a5d87024cbf849cea5d273d77a292e6f";
            item4.RowIndex = 2;
            item4.CellIndex = 2;
            item4.RowSpan = 2;
            item4.ColSpan = 1;
            FormControl item4c = new FormControl(FormController.MetaPrimitiveControlType);
            item4c.Uid = Guid.NewGuid().ToString("N");
            item4c.Source = "Description";
            item4.Control = item4c;
            ctrl1.Items.Add(item4);

            sec1.Control = ctrl1;

            //FormDocument fd = new FormDocument();
            FormDocument fd = FormDocument.Load("Task", "[MC_BaseForm]");
            fd.MetaClassName = "Task";
            fd.Name = "[MC_BaseForm]";
            fd.FormTable = tL;
            fd.Save();
        }
 public void AddFormRow(FormRow row) {
     this.Rows.Add(row);
 }
Exemple #17
0
        // 自动生成表单函数
        private List <ControlBase> AutoGenerateForm(DataView VerifyDv, string MajorId, string TableId)
        {
            List <ControlBase> items = new List <ControlBase>();

            string       AttriFormat   = null;  // 表单校验类型
            TextBox      Control1      = null;  // 单文本
            TextArea     Control2      = null;  // 文本框
            DatePicker   Control3      = null;  // 日期选择框
            DropDownList Control4      = null;  // 单选框、复选框、其他字段
            NumberBox    Control5      = null;  // 数值
            string       VerifyValue   = null;  // 校验值
            ListItem     NewList       = null;  // 下拉列表元素
            string       RadioValue    = null;  // 单选列表值
            bool         IsControlLeft = true;  // 判断控件是否该放在窗口左边
            FormRow      NewFormRow    = null;  // 新的表单行
            DataView     DependedTable = null;  // 其他字段 - 依赖的表
            int          DependedTableId;       // 其他字段 - 依赖的表名
            int          DependedAttriId;       // 其他字段 - 依赖的属性ID
            int          DisplayOrder;          // 其他字段 - 依赖字段的显示顺序
            string       sSQL = null;
            int          j;

            for (int i = 0; i < VerifyDv.Count; i++)
            {
                AttriFormat = VerifyDv[i][3].ToString();
                VerifyValue = VerifyDv[i][5].ToString();
                if (IsControlLeft)
                {
                    NewFormRow = CreatNewRow();
                }
                if (AttriFormat == "单文本")
                {
                    Control1         = new TextBox();
                    Control1.Label   = VerifyDv[i][1].ToString();
                    Control1.BoxFlex = 1;
                    Control1.ID      = VerifyDv[i][0].ToString();
                    if (Convert.ToInt32(VerifyDv[i][6]) != 0)
                    {
                        Control1.MaxLength = Convert.ToInt32(VerifyDv[i][6]);
                    }

                    NewFormRow.Items.Add(Control1);
                }
                else if (AttriFormat == "文本框")
                {
                    Control2         = new TextArea();
                    Control2.Label   = VerifyDv[i][1].ToString();
                    Control2.BoxFlex = 1;
                    Control2.ID      = VerifyDv[i][0].ToString();
                    if (Convert.ToInt32(VerifyDv[i][6]) != 0)
                    {
                        Control2.MaxLength = Convert.ToInt32(VerifyDv[i][6]);
                    }

                    NewFormRow.Items.Add(Control2);
                }
                else if (AttriFormat == "日期")
                {
                    Control3                  = new DatePicker();
                    Control3.Label            = VerifyDv[i][1].ToString();
                    Control3.BoxFlex          = 1;
                    Control3.DateFormatString = "yyyyMMdd";
                    Control3.ID               = VerifyDv[i][0].ToString();
                    if (Convert.ToInt32(VerifyDv[i][6]) != 0)
                    {
                        Control3.MaxLength = Convert.ToInt32(VerifyDv[i][6]);
                    }

                    NewFormRow.Items.Add(Control3);
                }
                else if (AttriFormat == "单选")
                {
                    Control4         = new DropDownList();
                    Control4.Label   = VerifyDv[i][1].ToString();
                    Control4.BoxFlex = 1;
                    Control4.ID      = VerifyDv[i][0].ToString();
                    if (Convert.ToInt32(VerifyDv[i][6]) != 0)
                    {
                        Control4.MaxLength = Convert.ToInt32(VerifyDv[i][6]);
                    }

                    while (VerifyValue != null)
                    {
                        // 截取校验值并赋值给RadioValue
                        RadioValue = VerifyValue.IndexOf('$') >= 0 ? (VerifyValue.Substring(0, VerifyValue.IndexOf('$'))) : VerifyValue;
                        // 创建新列表元素并加入下拉列表中
                        NewList       = new ListItem();
                        NewList.Text  = RadioValue;
                        NewList.Value = RadioValue;
                        Control4.Items.Add(NewList);

                        // 移除校验值中已经确认的值
                        VerifyValue = VerifyValue.IndexOf('$') >= 0 ? VerifyValue.Remove(0, VerifyValue.IndexOf("$") + 1) : null;
                    }

                    NewFormRow.Items.Add(Control4);
                }
                else if (AttriFormat == "数值")
                {
                    Control5         = new NumberBox();
                    Control5.Label   = VerifyDv[i][1].ToString();
                    Control5.BoxFlex = 1;
                    Control5.ID      = VerifyDv[i][0].ToString();
                    if (Convert.ToInt32(VerifyDv[i][6]) != 0)
                    {
                        Control5.MaxLength = Convert.ToInt32(VerifyDv[i][6]);
                    }

                    NewFormRow.Items.Add(Control5);
                }
                else if (AttriFormat == "其他字段")
                {
                    Control4         = new DropDownList();
                    Control4.Label   = VerifyDv[i][1].ToString();
                    Control4.BoxFlex = 1;
                    Control4.ID      = VerifyDv[i][0].ToString();
                    if (Convert.ToInt32(VerifyDv[i][6]) != 0)
                    {
                        Control4.MaxLength = Convert.ToInt32(VerifyDv[i][6]);
                    }

                    DependedTableId = Convert.ToInt32(VerifyValue.Substring(0, VerifyValue.IndexOf('$')));
                    DependedAttriId = Convert.ToInt32(VerifyValue.Substring(VerifyValue.IndexOf('$') + 1));
                    sSQL            = "SELECT attriDisplayOrder FROM [dbo].[tableAttributeArrange] WHERE tableID = " + DependedTableId + " AND attributeID = " + DependedAttriId;
                    DisplayOrder    = Convert.ToInt32(SqlHelper.getDataSource(sSQL)[0][0].ToString());

                    sSQL          = "exec [dbo].[GetTableDataList] " + DependedTableId + ",'" + Session["SchoolId"] + "','" + MajorId + "'";
                    DependedTable = SqlHelper.getDataSource(sSQL);
                    for (j = 0; j < DependedTable.Count; j++)
                    {
                        RadioValue    = DependedTable[j][DisplayOrder].ToString();
                        NewList       = new ListItem();
                        NewList.Text  = RadioValue;
                        NewList.Value = RadioValue;
                        Control4.Items.Add(NewList);
                    }

                    NewFormRow.Items.Add(Control4);
                }
                else if (AttriFormat == "复选框")
                {
                    Control4                   = new DropDownList();
                    Control4.Label             = VerifyDv[i][1].ToString();
                    Control4.BoxFlex           = 1;
                    Control4.EnableMultiSelect = true;
                    Control4.ID                = VerifyDv[i][0].ToString();
                    if (Convert.ToInt32(VerifyDv[i][6]) != 0)
                    {
                        Control4.MaxLength = Convert.ToInt32(VerifyDv[i][6]);
                    }

                    while (VerifyValue != null)
                    {
                        // 截取校验值并赋值给RadioValue
                        RadioValue = VerifyValue.IndexOf('$') >= 0 ? (VerifyValue.Substring(0, VerifyValue.IndexOf('$'))) : VerifyValue;
                        // 创建新列表元素并加入下拉列表中
                        NewList       = new ListItem();
                        NewList.Text  = RadioValue;
                        NewList.Value = RadioValue;
                        Control4.Items.Add(NewList);

                        // 移除校验值中已经确认的值
                        VerifyValue = VerifyValue.IndexOf('$') >= 0 ? VerifyValue.Remove(0, VerifyValue.IndexOf("$") + 1) : null;
                    }

                    NewFormRow.Items.Add(Control4);
                }

                if (!IsControlLeft)
                {
                    items.Add(NewFormRow);
                }
                IsControlLeft = !IsControlLeft;
            }
            // 向AddDataForm载入剩下的单个控件
            if (!IsControlLeft)
            {
                items.Add(NewFormRow);
            }

            return(items);
        }
 public void Remove(FormRow row)
 {
     Group.Rows.Remove(row);
     LoadRows();
 }
 public FormRowChangeEvent(FormRow row, global::System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
 public void RemoveFormRow(FormRow row) {
     this.Rows.Remove(row);
 }
        // 动态创建控件
        // 注意:这段代码需要每次加载页面都执行,因此不能放在 if(!IsPostBack) 逻辑判断中
        protected void Page_Init(object sender, EventArgs e)
        {
            IsAdd    = RequestHelper.GetRequestString("IsAdd", "");
            id       = RequestHelper.GetRequestString("id", "");
            name     = RequestHelper.GetRequestString("name", "");
            typename = RequestHelper.GetRequestString("typename", "");
            isenable = RequestHelper.GetRequestString("isenable", "");

            //非空判断
            if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(typename) || string.IsNullOrEmpty(isenable))
            {
                Alert.ShowInParent("请选择演员");
                return;
            }

            string[] strid   = id.Split(',');
            string[] strname = name.Split(',');
            len = strname.Length;

            if (IsAdd.ToString() == "修改")
            {
                //获取理由
                DataTable dt = operate.GetRecommendByTypeNameEach(typename);
                // 创建一个 FormRow 控件并添加到 Form2
                for (int i = 0; i < len; i++)
                {
                    FormRow row = new FormRow();
                    row.ID = "rowUser" + i;
                    Form2.Rows.Add(row);
                    row.ColumnWidths = "50% 50%";

                    FineUI.TextBox tbxUser = new FineUI.TextBox();
                    FineUI.TextBox tbxWork = new FineUI.TextBox();
                    tbxUser.ID          = "txtReason" + i;
                    tbxUser.Text        = "";
                    tbxUser.Label       = strname[i];
                    tbxUser.ShowLabel   = true;
                    tbxUser.ShowRedStar = false;
                    tbxUser.Required    = false;
                    tbxUser.MaxLength   = 200;
                    tbxUser.EmptyText   = "请输入推荐理由";

                    tbxWork.ID          = "txtWork" + i;
                    tbxWork.Text        = "";
                    tbxWork.Label       = "作品";
                    tbxWork.ShowLabel   = true;
                    tbxWork.ShowRedStar = false;
                    tbxWork.Required    = false;
                    tbxWork.MaxLength   = 30;
                    tbxWork.EmptyText   = "请输入作品";
                    for (int m = 0; m < dt.Rows.Count; m++)
                    {
                        if (dt.Rows[m]["PersonID"].ToString() == strid[i])
                        {
                            tbxUser.Text = dt.Select(" PersonID='" + strid[i] + "' ")[0]["Reason"].ToString();
                            tbxWork.Text = dt.Select(" PersonID='" + strid[i] + "' ")[0]["Work"].ToString();
                        }
                    }

                    row.Items.Add(tbxUser);
                    row.Items.Add(tbxWork);
                }
            }
            else if (IsAdd.ToString() == "新增")
            {
                // 创建一个 FormRow 控件并添加到 Form2
                for (int i = 0; i < len; i++)
                {
                    FormRow row = new FormRow();
                    row.ID = "rowUser" + i;
                    Form2.Rows.Add(row);
                    row.ColumnWidths = "50% 50%";

                    FineUI.TextBox tbxUser = new FineUI.TextBox();
                    tbxUser.ID          = "txtReason" + i;
                    tbxUser.Text        = "";
                    tbxUser.Label       = strname[i];
                    tbxUser.ShowLabel   = true;
                    tbxUser.ShowRedStar = false;
                    tbxUser.Required    = false;
                    tbxUser.MaxLength   = 200;
                    tbxUser.EmptyText   = "请输入推荐理由";
                    row.Items.Add(tbxUser);

                    FineUI.TextBox tbxWork = new FineUI.TextBox();
                    tbxWork.ID          = "txtWork" + i;
                    tbxWork.Text        = "";
                    tbxWork.Label       = "作品";
                    tbxWork.ShowLabel   = true;
                    tbxWork.ShowRedStar = false;
                    tbxWork.Required    = false;
                    tbxWork.MaxLength   = 30;
                    tbxWork.EmptyText   = "请输入作品";
                    row.Items.Add(tbxWork);
                }
            }
        }
        //#region SaveXml
        //protected void btnSave2_Click(object sender, EventArgs e)
        //{
        //    FormDocumentData.LoadFormTableFromXml(txtXml.Text);
        //    fRenderer.FormDocumentData = FormDocumentData;
        //    fRenderer.DataBind();
        //}
        //#endregion


        #region CreateDocument
        private void CreateDocument()
        {
            FormTable tL = new FormTable();

            tL.Columns     = "50%;*";
            tL.Width       = "100%";
            tL.CellPadding = 5;

            FormRow  row1   = new FormRow();
            FormCell cell11 = new FormCell();

            cell11.ColSpan = 2;
            cell11.Name    = "cell_11";
            row1.Cells.Add(cell11);
            tL.Rows.Add(row1);

            FormRow  row2   = new FormRow();
            FormCell cell21 = new FormCell();
            FormCell cell22 = new FormCell();

            cell21.ColSpan = 1;
            cell22.ColSpan = 1;
            cell21.Name    = "cell_21";
            cell22.Name    = "cell_22";
            row2.Cells.Add(cell21);
            row2.Cells.Add(cell22);
            tL.Rows.Add(row2);

            FormRow  row3   = new FormRow();
            FormCell cell31 = new FormCell();

            cell31.ColSpan = 2;
            cell31.Name    = "cell_31";
            row3.Cells.Add(cell31);
            tL.Rows.Add(row3);

            FormSection sec1 = new FormSection();

            sec1.BorderType = 1;
            sec1.ItemIndex  = 1;
            sec1.ShowLabel  = true;
            sec1.Uid        = "dd6acdd98240403984e561399d33d9a9";
            sec1.Labels.Add(new FormLabel("Sec1", Thread.CurrentThread.CurrentUICulture.Name));
            cell11.Sections.Add(sec1);

            FormSection sec2 = new FormSection();

            sec2.BorderType = 0;
            sec2.ItemIndex  = 1;
            sec2.ShowLabel  = true;
            sec2.Uid        = "886cb9a3aae34e68ac8ef234d0ce8ce2";
            sec2.Labels.Add(new FormLabel("Sec2", Thread.CurrentThread.CurrentUICulture.Name));
            cell21.Sections.Add(sec2);

            FormSection sec3 = new FormSection();

            sec3.BorderType = 0;
            sec3.ItemIndex  = 1;
            sec3.ShowLabel  = true;
            sec3.Uid        = "bb6acbb98240403784e561397b33d7a7";
            sec3.Labels.Add(new FormLabel("Sec3", Thread.CurrentThread.CurrentUICulture.Name));
            cell22.Sections.Add(sec3);

            FormSection sec4 = new FormSection();

            sec4.BorderType = 0;
            sec4.ItemIndex  = 1;
            sec4.ShowLabel  = true;
            sec4.Uid        = Guid.NewGuid().ToString("N");
            sec4.Labels.Add(new FormLabel("Sec4", Thread.CurrentThread.CurrentUICulture.Name));
            cell31.Sections.Add(sec4);

            FormControl ctrl1 = new FormControl(FormController.SmartTableLayoutType);

            ctrl1.Columns     = "50%;*";
            ctrl1.Width       = "100%";
            ctrl1.CellPadding = 5;

            FormItem item1 = new FormItem();

            item1.LabelWidth = "120px";
            item1.ShowLabel  = true;
            item1.Labels.Add(new FormLabel("test label1:", Thread.CurrentThread.CurrentUICulture.Name));
            item1.Uid       = "9b3c4642e59b405faa2a1f38559a06cc";
            item1.RowIndex  = 1;
            item1.CellIndex = 1;
            item1.RowSpan   = 1;
            item1.ColSpan   = 2;
            FormControl item1c = new FormControl(FormController.MetaPrimitiveControlType);

            item1c.Uid    = Guid.NewGuid().ToString("N");
            item1c.Source = "Title";
            item1.Control = item1c;
            ctrl1.Items.Add(item1);

            FormItem item2 = new FormItem();

            item2.LabelWidth = "120px";
            item2.ShowLabel  = true;
            item2.Labels.Add(new FormLabel("test label2:", Thread.CurrentThread.CurrentUICulture.Name));
            item2.Uid       = "cafa725a31b74ad6a069e3b6446d89c0";
            item2.RowIndex  = 2;
            item2.CellIndex = 1;
            item2.RowSpan   = 1;
            item2.ColSpan   = 1;
            FormControl item2c = new FormControl(FormController.MetaPrimitiveControlType);

            item2c.Uid    = Guid.NewGuid().ToString("N");
            item2c.Source = "Priority";
            item2.Control = item2c;
            ctrl1.Items.Add(item2);

            FormItem item3 = new FormItem();

            item3.LabelWidth = "120px";
            item3.ShowLabel  = true;
            item3.Labels.Add(new FormLabel("test label3:", Thread.CurrentThread.CurrentUICulture.Name));
            item3.Uid       = "8d36be893c3f4cf1b5295be6853eb246";
            item3.RowIndex  = 3;
            item3.CellIndex = 1;
            item3.RowSpan   = 1;
            item3.ColSpan   = 1;
            FormControl item3c = new FormControl(FormController.MetaPrimitiveControlType);

            item3c.Uid    = Guid.NewGuid().ToString("N");
            item3c.Source = "Created";
            item3.Control = item3c;
            ctrl1.Items.Add(item3);

            FormItem item4 = new FormItem();

            item4.LabelWidth = "120px";
            item4.ShowLabel  = true;
            item4.Labels.Add(new FormLabel("test label4:", Thread.CurrentThread.CurrentUICulture.Name));
            item4.Uid       = "a5d87024cbf849cea5d273d77a292e6f";
            item4.RowIndex  = 2;
            item4.CellIndex = 2;
            item4.RowSpan   = 2;
            item4.ColSpan   = 1;
            FormControl item4c = new FormControl(FormController.MetaPrimitiveControlType);

            item4c.Uid    = Guid.NewGuid().ToString("N");
            item4c.Source = "Description";
            item4.Control = item4c;
            ctrl1.Items.Add(item4);

            sec1.Control = ctrl1;

            //FormDocument fd = new FormDocument();
            FormDocument fd = FormDocument.Load("Task", "[MC_BaseForm]");

            fd.MetaClassName = "Task";
            fd.Name          = "[MC_BaseForm]";
            fd.FormTable     = tL;
            fd.Save();
        }