private void SettleControlColumnsFromXmlNode(Control currentControl, XmlNode rootNode)
		{
			foreach (XmlNode node in rootNode.ChildNodes)
			{
				ClientGridColumn column = new ClientGridColumn();

				foreach (XmlAttribute attr in node.Attributes)
				{
					PropertyInfo piDest = TypePropertiesCacheQueue.Instance.GetPropertyInfo(column.GetType(), attr.Name);
					if (piDest != null)
					{
						if (string.IsNullOrEmpty(attr.Value) || piDest.CanWrite == false)
							continue;

						if (piDest.PropertyType == typeof(Unit))
							piDest.SetValue(column, Unit.Parse(attr.Value), null);
						else if (piDest.PropertyType == typeof(bool))
						{
							piDest.SetValue(column, bool.Parse(attr.Value), null);
						}
						else
							piDest.SetValue(column, attr.Value, null);
					}
				}

				var subNode = node.SelectSingleNode("editTemplate");

				if (subNode != null)
				{
					column.EditTemplate = new ClientGridColumnEditTemplate();

					foreach (XmlAttribute subAttr in subNode.Attributes)
					{
						PropertyInfo piDest = TypePropertiesCacheQueue.Instance.GetPropertyInfo(column.EditTemplate.GetType(), subAttr.Name);
						if (piDest != null)
						{
							if (string.IsNullOrEmpty(subAttr.Value) || piDest.CanWrite == false)
								continue;

							if (piDest.PropertyType.IsEnum)
							{
								var enumValue = DataConverter.ChangeType(subAttr.Value, piDest.PropertyType);
								piDest.SetValue(column.EditTemplate, enumValue, null);
							}
							else if (piDest.PropertyType == typeof(Unit))
								piDest.SetValue(column.EditTemplate, Unit.Parse(subAttr.Value), null);
							else if (piDest.PropertyType == typeof(bool))
							{
								piDest.SetValue(column.EditTemplate, bool.Parse(subAttr.Value), null);
							}
							else
								piDest.SetValue(column.EditTemplate, subAttr.Value, null);
						}
					}
				}

				ClientGrid gridControl = (ClientGrid)currentControl;
				gridControl.Columns.Add(column);
			}
		}
		public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			ClientGridColumn column = new ClientGridColumn();

			column.DataField = DictionaryHelper.GetValue(dictionary, "dataField", string.Empty);
			column.HeaderText = DictionaryHelper.GetValue(dictionary, "headerText", string.Empty);
			column.HeaderTips = DictionaryHelper.GetValue(dictionary, "headerTips", string.Empty);
			column.HeaderTipsStyle = DictionaryHelper.GetValue(dictionary, "headerTipsStyle", "{color:Red}");
			column.SortExpression = DictionaryHelper.GetValue(dictionary, "sortExpression", string.Empty);
			column.SelectColumn = DictionaryHelper.GetValue(dictionary, "selectColumn", false);
			column.ShowSelectAll = DictionaryHelper.GetValue(dictionary, "showSelectAll", false);

			column.DataType = DictionaryHelper.GetValue(dictionary, "dataType", DataType.String);
			column.MaxLength = DictionaryHelper.GetValue(dictionary, "maxLength", 0);
			column.FormatString = DictionaryHelper.GetValue(dictionary, "formatString", string.Empty);
			column.EditorStyle = DictionaryHelper.GetValue(dictionary, "editorStyle", string.Empty);
			column.EditorTooltips = DictionaryHelper.GetValue(dictionary, "editorTooltips", string.Empty);
			column.EditorReadOnly = DictionaryHelper.GetValue(dictionary, "editorReadOnly", false);
			column.EditorEnabled = DictionaryHelper.GetValue(dictionary, "editorEnabled", true);
			column.Visible = DictionaryHelper.GetValue(dictionary, "visible", true);
			column.IsDynamicColumn = DictionaryHelper.GetValue(dictionary, "isDynamicColumn", false);
			column.AutoBindingValidation = DictionaryHelper.GetValue(dictionary, "autoBindingValidation", false);
			column.IsFixedLine = DictionaryHelper.GetValue(dictionary, "isFixedLine", false);
			column.IsStatistic = DictionaryHelper.GetValue(dictionary, "isStatistic", false);

			if (dictionary.ContainsKey("editTemplate"))
			{
				column.EditTemplate = JSONSerializerExecute.Deserialize<ClientGridColumnEditTemplate>(dictionary["editTemplate"]);
			}

			return column;
		}
        protected void btn_getEntityDefine_Click(object sender, EventArgs e)
        {
            center_panel.Visible = true;



            RecordResultCollection rrc = GetData(txt_Code.Text.Trim());

            List <string> cou = rrc.Select(p => p.EntityName).Distinct().ToList();

            foreach (string entityName in cou)
            {
                ClientGrid gr = new ClientGrid();

                gr.EnableViewState = false;


                gr.ID                 = entityName;
                gr.AllowPaging        = false;
                gr.ShowEditBar        = true;
                gr.AutoPaging         = false;
                gr.ShowCheckBoxColumn = true;
                gr.ID                 = Guid.NewGuid().ToString();
                controlIDs.Add(gr.ID);
                var recordCollention = rrc.Where(p => p.EntityName.Equals(entityName));
                ClientGridColumn cgc = new ClientGridColumn();  //checkbox
                cgc.SelectColumn  = true;
                cgc.ShowSelectAll = true;
                cgc.HeaderStyle   = "{width:'30px',textAlign:'left',fontWeight:'bold'}";
                cgc.ItemStyle     = "{width:'30px',textAlign:'left'}";

                gr.Columns.Add(cgc);

                ClientGridColumn cgIndex = new ClientGridColumn();

                cgIndex.DataField   = "rowIndex";
                cgIndex.HeaderText  = "序号";
                cgIndex.HeaderStyle = "{width:'30px',textAlign:'center'}";
                cgIndex.ItemStyle   = "{width:'30px',textAlign:'center'}";
                cgIndex.DataType    = DataType.Integer;
                gr.Columns.Add(cgIndex);

                ClientGridColumn cgFieldName = new ClientGridColumn();
                cgFieldName.DataField             = "FieldName";
                cgFieldName.HeaderText            = "字段名";
                cgFieldName.HeaderStyle           = "{textAlign:'left'}";
                cgFieldName.ItemStyle             = "{textAlign:'left'}";
                cgFieldName.DataType              = DataType.String;
                cgFieldName.EditTemplate.EditMode = ClientGridColumnEditMode.TextBox;
                gr.Columns.Add(cgFieldName);

                ClientGridColumn cgFieldDesc = new ClientGridColumn();
                cgFieldDesc.DataField             = "FieldDesc";
                cgFieldDesc.HeaderText            = "字段描述";
                cgFieldDesc.HeaderStyle           = "{textAlign:'left'}";
                cgFieldDesc.ItemStyle             = "{textAlign:'left'}";
                cgFieldDesc.DataType              = DataType.String;
                cgFieldDesc.EditTemplate.EditMode = ClientGridColumnEditMode.TextBox;
                gr.Columns.Add(cgFieldDesc);

                ClientGridColumn cgFieldTypeName = new ClientGridColumn();
                cgFieldTypeName.DataField             = "FieldType";
                cgFieldTypeName.HeaderText            = "字段类型";
                cgFieldTypeName.HeaderStyle           = "{textAlign:'left'}";
                cgFieldTypeName.ItemStyle             = "{textAlign:'left'}";
                cgFieldTypeName.DataType              = DataType.String;
                cgFieldTypeName.EditTemplate.EditMode = ClientGridColumnEditMode.TextBox;
                gr.Columns.Add(cgFieldTypeName);


                ClientGridColumn cgFieldLength = new ClientGridColumn();
                cgFieldLength.DataField             = "FieldLength";
                cgFieldLength.HeaderText            = "字段长度";
                cgFieldLength.HeaderStyle           = "{textAlign:'left'}";
                cgFieldLength.ItemStyle             = "{textAlign:'left'}";
                cgFieldLength.DataType              = DataType.String;
                cgFieldLength.EditTemplate.EditMode = ClientGridColumnEditMode.TextBox;
                gr.Columns.Add(cgFieldLength);

                ClientGridColumn cgFieldDefaultValue = new ClientGridColumn();
                cgFieldDefaultValue.DataField             = "DefaultValue";
                cgFieldDefaultValue.HeaderText            = "字段默认值";
                cgFieldDefaultValue.HeaderStyle           = "{textAlign:'left'}";
                cgFieldDefaultValue.ItemStyle             = "{textAlign:'left'}";
                cgFieldDefaultValue.DataType              = DataType.String;
                cgFieldDefaultValue.EditTemplate.EditMode = ClientGridColumnEditMode.TextBox;
                gr.Columns.Add(cgFieldDefaultValue);

                ClientGridColumn cgOuterFieldName = new ClientGridColumn();
                cgOuterFieldName.DataField   = "FieldName";
                cgOuterFieldName.HeaderText  = "关联字段/结构";
                cgOuterFieldName.HeaderStyle = "{textAlign:'left'}";
                cgOuterFieldName.ItemStyle   = "{textAlign:'left'}";
                cgOuterFieldName.DataType    = DataType.String;
                gr.Columns.Add(cgOuterFieldName);
                gr.InitialData = recordCollention.ToList();



                DataBindingItem dbItem = new DataBindingItem();
                dbItem.ControlID           = entityName;
                dbItem.DataPropertyName    = "EntityFieldMappingCollection";
                dbItem.ControlPropertyName = "InitialData";
                dbItem.Direction           = BindingDirection.Both;

                Panel pa = new Panel();

                Label lb = new Label();
                lb.Text = string.Format(@"<div class='dialogTitle'>
                                <div class='lefttitle' style='text-align: left;'>
                                    <img src='../Images/icon_01.gif'/>
                                    编辑{0}主实体字段及关联</div>
                            </div>", entityName);
                pa.Controls.Add(lb);

                Panel pn = new Panel();
                pn.ID       = "Panel_" + entityName;
                pn.CssClass = "dialogContent";

                pn.Controls.Add(gr);

                center_panel.Controls.Add(pa);
                center_panel.Controls.Add(pn);
            }



            ViewState["controlids"] = controlIDs;



            EntityMapping mapping = new EntityMapping();
        }