private List<DictionaryEntry> GetControlValues(ControlCollection collection) { List<DictionaryEntry> list = new List<DictionaryEntry>(); if (this.DesignMode) { foreach (Control ct in collection) { PropertyInfo[] pis = ct.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < pis.Length; i++) { if (pis[i].PropertyType == typeof(string)) { if (string.Compare(pis[i].Name, "Text", true) == 0 || string.Compare(pis[i].Name, "ToolTip", true) == 0) { list.Add(new DictionaryEntry(string.Format("{0}.{1}", ct.ID, pis[i].Name) , pis[i].GetValue(ct, null).ToString())); } } } if (ct is JQDataForm) { JQDataForm ctrl = ct as JQDataForm; for (int i = 0; i < ctrl.Columns.Count; i++) { list.Add(new DictionaryEntry(string.Format("{0}.{1}.Caption", ct.ID, ctrl.Columns[i].FieldName), String.IsNullOrEmpty(ctrl.Columns[i].Caption) ? ctrl.Columns[i].FieldName : ctrl.Columns[i].Caption)); switch (ctrl.Columns[i].Editor) { case "flipswitch": JQFlipSwitch jfs = new JQFlipSwitch(); jfs.LoadProperties(ctrl.Columns[i].EditorOptions); list.Add(new DictionaryEntry(string.Format("{0}.{1}.flipswitch.OnText", ct.ID, ctrl.Columns[i].FieldName), jfs.OnText)); list.Add(new DictionaryEntry(string.Format("{0}.{1}.flipswitch.OffText", ct.ID, ctrl.Columns[i].FieldName), jfs.OffText)); break; case "refval": JQRefval jr = new JQRefval(); jr.LoadProperties(ctrl.Columns[i].EditorOptions); list.Add(new DictionaryEntry(string.Format("{0}.{1}.refval.DialogTitle", ct.ID, ctrl.Columns[i].FieldName), jr.DialogTitle)); for (int j = 0; j < jr.Columns.Count; j++) { list.Add(new DictionaryEntry(string.Format("{0}.{1}.refval.Caption.{2}", ct.ID, ctrl.Columns[i].FieldName, jr.Columns[j].FieldName), String.IsNullOrEmpty(jr.Columns[j].Caption) ? jr.Columns[j].FieldName : jr.Columns[j].Caption)); } break; } } } if (ct is JQDataGrid) { JQDataGrid ctrl = ct as JQDataGrid; for (int i = 0; i < ctrl.Columns.Count; i++) { list.Add(new DictionaryEntry(string.Format("{0}.{1}.Caption", ct.ID, ctrl.Columns[i].FieldName), String.IsNullOrEmpty(ctrl.Columns[i].Caption) ? ctrl.Columns[i].FieldName : ctrl.Columns[i].Caption)); } for (int i = 0; i < ctrl.QueryColumns.Count; i++) { list.Add(new DictionaryEntry(string.Format("{0}.{1}.QueryColumnCaption{2}", ct.ID, ctrl.QueryColumns[i].FieldName, ctrl.QueryColumns[i].Condition), String.IsNullOrEmpty(ctrl.QueryColumns[i].Caption) ? ctrl.QueryColumns[i].FieldName : ctrl.QueryColumns[i].Caption)); } list.Add(new DictionaryEntry(string.Format("{0}.Title", ct.ID), ctrl.Title)); } if (ct is JQValidate) { JQValidate ctrl = ct as JQValidate; for (int i = 0; i < ctrl.Columns.Count; i++) { if (!String.IsNullOrEmpty(ctrl.Columns[i].CheckMethod)) list.Add(new DictionaryEntry(string.Format("{0}.{1}.ValidateMessage", ct.ID, ctrl.Columns[i].FieldName), ctrl.Columns[i].ValidateMessage)); } } if (ct.Controls.Count > 0) { list.AddRange(GetControlValues(ct.Controls)); } } } return list; }
private void GenMainBlockControl(TBlockItem BlockItem) { #if VS90 //object oMaster = FDesignerDocument.webControls.item("Master", 0); //WebDevPage.IHTMLElement eMaster = null; //if (oMaster == null || !(oMaster is WebDevPage.IHTMLElement)) // return; //eMaster = (WebDevPage.IHTMLElement)oMaster; BlockItem.wDataSource = new WebDataSource(); JQDefault Default = new JQDefault(); Default.ID = "defaultMaster"; // +BlockItem.TableName; Default.BindingObjectID = "dataGridMaster"; JQValidate Validate = new JQValidate(); Validate.ID = "validateMaster"; // +BlockItem.TableName; Validate.BindingObjectID = "dataGridMaster"; WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField)); WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns)); foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems) { GenDefault(fielditem, Default, Validate); GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName); } object oJQGridViewMaster = FDesignerDocument.webControls.item("dataGridMaster", 0); WebDevPage.IHTMLElement eJQGridViewMaster = (WebDevPage.IHTMLElement)oJQGridViewMaster; //FClientData.ProviderName if (eJQGridViewMaster != null) { StringBuilder sb = new StringBuilder(eJQGridViewMaster.innerHTML); ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("RemoteName", FClientData.ProviderName, 0); ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("DataMember", FClientData.TableName, 0); ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("Title", FClientData.FormTitle, 0); //((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("Title", FClientData.FormTitle, 0); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { int idx = sb.ToString().LastIndexOf("</Columns>"); if (idx == -1) { sb.AppendLine("<Columns></Columns>"); idx = sb.ToString().LastIndexOf("</Columns>"); } String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; var relationOptions = string.Empty; if ((BFI.ControlType == "RefValBox" || BFI.ControlType == "ComboBox") && !string.IsNullOrEmpty(BFI.ComboValueField) && !string.IsNullOrEmpty(BFI.ComboTextField) && !string.IsNullOrEmpty(BFI.ComboRemoteName) && !string.IsNullOrEmpty(BFI.ComboEntityName)) { relationOptions = string.Format("RelationOptions=\"{{RemoteName:'{0}',DisplayMember:'{1}',ValueMember:'{2}'}}\"" , BFI.ComboRemoteName, BFI.ComboTextField, BFI.ComboValueField); } sb.Insert(idx, String.Format("<JQMobileTools:JQGridColumn Alignment=\"left\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, relationOptions, BFI.EditMask)); } var toolItems = new List<JQMobileTools.JQToolItem>(); if (FClientData.BaseFormName == "JQMobileQuery" || FClientData.BaseFormName == "VBJQMobileQuery") { toolItems.Add(JQMobileTools.JQToolItem.PreviousPageItem); toolItems.Add(JQMobileTools.JQToolItem.NextPageItem); toolItems.Add(JQMobileTools.JQToolItem.QueryItem); toolItems.Add(JQMobileTools.JQToolItem.RefreshItem); } else { toolItems.Add(JQMobileTools.JQToolItem.InsertItem); toolItems.Add(JQMobileTools.JQToolItem.PreviousPageItem); toolItems.Add(JQMobileTools.JQToolItem.NextPageItem); toolItems.Add(JQMobileTools.JQToolItem.QueryItem); toolItems.Add(JQMobileTools.JQToolItem.RefreshItem); toolItems.Add(JQMobileTools.JQToolItem.BackItem); } int idxTool = sb.ToString().LastIndexOf("</ToolItems>"); if (idxTool != -1) { foreach (var item in toolItems) { idxTool = sb.ToString().LastIndexOf("</ToolItems>"); sb.Insert(idxTool, String.Format("<JQMobileTools:JQToolItem Icon=\"{0}\" Name=\"{1}\" Text=\"{2}\" Visible=\"True\" />", item.Icon, item.Name, item.Text)); } } int idxQuery = sb.ToString().LastIndexOf("</QueryColumns>"); if (idxQuery != -1) { foreach (WebQueryField item in QueryFields) { idxQuery = sb.ToString().LastIndexOf("</QueryColumns>"); sb.Insert(idxQuery, item.Mode); //sb.Insert(idxQuery, String.Format("<JQTools:JQQueryColumn Caption=\"{0}\" Condition=\"{1}\" Editor=\"text\" FieldName=\"{2}\" />", item.Caption, item.Operator, item.Column)); } //foreach (WebQueryColumns item in QueryColumns) //{ // idxQuery = sb.ToString().LastIndexOf("</QueryColumns>"); // //sb.Insert(idxQuery, item.Mode); // sb.Insert(idxQuery, String.Format("<JQMobileTools:JQQueryColumn Caption=\"{0}\" Condition=\"{1}\" Editor=\"text\" FieldName=\"{2}\" />", item.Caption, item.Operator, item.Column)); //} } eJQGridViewMaster.innerHTML = sb.ToString(); } //object oJQDialog1 = FDesignerDocument.webControls.item("JQDialog1", 0); //WebDevPage.IHTMLElement eJQDialog1 = (WebDevPage.IHTMLElement)oJQDialog1; //if (oJQDialog1 != null) //{ //((WebDevPage.IHTMLElement)oJQDialog1).setAttribute("Title", FClientData.FormTitle, 0); object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0); WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster; if (eJQFormViewMaster != null) { StringBuilder sb = new StringBuilder(); ((WebDevPage.IHTMLElement)oJQFormViewMaster).setAttribute("RemoteName", FClientData.ProviderName, 0); ((WebDevPage.IHTMLElement)oJQFormViewMaster).setAttribute("DataMember", FClientData.TableName, 0); ((WebDevPage.IHTMLElement)oJQFormViewMaster).setAttribute("Title", FClientData.FormTitle, 0); sb.Append("<Columns>"); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { JQControl control = null; string editor = "text"; String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox") && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField) || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName))) { BFI.ControlType = "TextBox"; } if (BFI.ControlType == "ComboBox") { control = new JQSelects() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField }; editor = "selects"; } else if (BFI.ControlType == "RefValBox") { control = new JQRefval() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField }; //(control as JQRefval).Columns.Add(new JQRefValColumn() { FieldName = BFI.ComboValueField, Caption = BFI.ComboValueFieldCaption }); editor = "refval"; } else if (BFI.ControlType == "RadioButton") { control = new JQRadioButtons() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField }; editor = "radiobuttons"; } else if (BFI.ControlType == "CheckBox") { JQCollection<JQDataItem> items = new JQCollection<JQDataItem>(control); JQDataItem item1 = new JQDataItem(); item1.Text = "Yes"; item1.Value = "Yes"; JQDataItem item2 = new JQDataItem(); item2.Text = "No"; item2.Value = "No"; items.Add(item1); items.Add(item2); control = new JQCheckBoxes() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField, Items = items }; editor = "checkboxes"; } else if (BFI.ControlType == "DateTimeBox") { control = new JQDate(); editor = "date"; } else { control = new JQTextBox(); } sb.AppendFormat("<{0}:{1} Caption=\"{2}\" FieldName=\"{3}\" Editor=\"{4}\" Width=\"120\" EditorOptions=\"{5}\"></{0}:{1}>" , "JQMobileTools", "JQFormColumn", sHeaderText, BFI.DataField, editor, control.Options); } sb.Append("</Columns>"); eJQFormViewMaster.innerHTML = sb.ToString(); WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement; Default.BindingObjectID = "dataFormMaster"; InsertControl(Page, Default); Validate.BindingObjectID = "dataFormMaster"; InsertControl(Page, Validate); } //} //else //{ // if (FClientData.BaseFormName != "JQueryQuery1") // { // WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement; // InsertControl(Page, Default); // InsertControl(Page, Validate); // } //} #else #endif }
private void ApplyColumnCaption(object value, string objectName) { if (value == null || objectName == null) { return; } XmlNode nodelanguage = GetLanguageNode(); if (nodelanguage != null && nodelanguage.ChildNodes.Count > 0) { XmlNode nodefield = nodelanguage.FirstChild; while (nodefield != null) { string strfield = nodefield.Attributes["field"].Value; string strvalue = nodefield.Attributes["value"].Value; if (string.CompareOrdinal(strfield, 0, objectName, 0, objectName.Length) == 0) { if (strfield.Length >= objectName.Length && strfield[objectName.Length] == '.') { string strfield2 = strfield.Substring(objectName.Length + 1); if (value is JQDataGrid) { foreach (JQGridColumn dc in ((JQDataGrid)value).Columns) { if (objectName + "." + dc.FieldName + ".Caption" == strfield) { dc.Caption = strvalue; break; } } foreach (JQQueryColumn dc in ((JQDataGrid)value).QueryColumns) { if (objectName + "." + dc.FieldName + ".QueryColumnCaption" + dc.Condition == strfield) { dc.Caption = strvalue; break; } } if (objectName + "." + "Title" == strfield) { (value as JQDataGrid).Title = strvalue; } } else if (value is JQDataForm) { foreach (JQFormColumn dc in ((JQDataForm)value).Columns) { if (objectName + "." + dc.FieldName + ".Caption" == strfield) { dc.Caption = strvalue; break; } var keys = strfield.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (strfield.StartsWith(objectName + "." + dc.FieldName) && keys.Length > 3) { switch (dc.Editor) { case "flipswitch": JQFlipSwitch jfs = new JQFlipSwitch(); jfs.LoadProperties(dc.EditorOptions); if (keys[3] == "OnText") dc.EditorOptions = dc.EditorOptions.Replace(String.Format("OnText:'{0}'", jfs.OnText), String.Format("OnText:'{0}'", strvalue)); else if (keys[3] == "OffText") dc.EditorOptions = dc.EditorOptions.Replace(String.Format("OffText:'{0}'", jfs.OffText), String.Format("OffText:'{0}'", strvalue)); break; case "refval": JQRefval jr = new JQRefval(); jr.LoadProperties(dc.EditorOptions); if (keys[3] == "DialogTitle") dc.EditorOptions = dc.EditorOptions.Replace(String.Format("DialogTitle:'{0}'", jr.DialogTitle), String.Format("DialogTitle:'{0}'", strvalue)); else if (keys[3] == "Caption") { for (int j = 0; j < jr.Columns.Count; j++) { if (jr.Columns[j].FieldName == keys[4]) dc.EditorOptions = dc.EditorOptions.Replace(String.Format("Caption:'{0}'", jr.Columns[j].Caption), String.Format("Caption:'{0}'", strvalue)); } } break; } break; } } } else if (value is JQValidate) { foreach (JQValidateColumn dc in ((JQValidate)value).Columns) { if (objectName + "." + dc.FieldName + ".ValidateMessage" == strfield) { dc.ValidateMessage = strvalue; break; } } } } } nodefield = nodefield.NextSibling; } } }
private void GenDetailBlock(String TemplateName) { MWizard.TBlockItem BlockItem = null; foreach (TBlockItem B in FClientData.Blocks) { if (B.wDataSource == null) { BlockItem = B; break; } } #if VS90 JQDefault Default = new JQDefault(); Default.ID = "defaultDetail"; // +BlockItem.TableName; Default.BindingObjectID = "dataGridDetail"; JQValidate Validate = new JQValidate(); Validate.ID = "validateDetail"; // +BlockItem.TableName; Validate.BindingObjectID = "dataGridDetail"; WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField)); WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns)); foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems) { GenDefault(fielditem, Default, Validate); //GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName); } WebDevPage.IHTMLElement eJQDataGridDetail = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("dataGridDetail", 0); if (eJQDataGridDetail != null) { ((WebDevPage.IHTMLElement)eJQDataGridDetail).setAttribute("RemoteName", FClientData.ProviderName, 0); ((WebDevPage.IHTMLElement)eJQDataGridDetail).setAttribute("DataMember", BlockItem.TableName, 0); StringBuilder sb = new StringBuilder(eJQDataGridDetail.innerHTML); //sb.Append("<Columns>"); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { int idx = sb.ToString().LastIndexOf("</Columns>"); if (idx == -1) { sb.AppendLine("<Columns></Columns>"); idx = sb.ToString().LastIndexOf("</Columns>"); } String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; var relationOptions = string.Empty; if ((BFI.ControlType == "RefValBox" || BFI.ControlType == "ComboBox") && !string.IsNullOrEmpty(BFI.ComboValueField) && !string.IsNullOrEmpty(BFI.ComboTextField) && !string.IsNullOrEmpty(BFI.ComboRemoteName) && !string.IsNullOrEmpty(BFI.ComboEntityName)) { relationOptions = string.Format("RelationOptions=\"{{RemoteName:'{0}',DisplayMember:'{1}',ValueMember:'{2}'}}\"" , BFI.ComboRemoteName, BFI.ComboTextField, BFI.ComboValueField); } sb.Insert(idx, String.Format("<JQMobileTools:JQGridColumn Alignment=\"left\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, relationOptions, BFI.EditMask)); } //sb.Append("</Columns>"); eJQDataGridDetail.innerHTML = sb.ToString(); } WebDevPage.IHTMLElement eJQDataFormDetail = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("dataFormDetail", 0); if (eJQDataFormDetail != null) { StringBuilder sb = new StringBuilder(); ((WebDevPage.IHTMLElement)eJQDataFormDetail).setAttribute("RemoteName", FClientData.ProviderName, 0); ((WebDevPage.IHTMLElement)eJQDataFormDetail).setAttribute("DataMember", BlockItem.TableName, 0); sb.Append("<Columns>"); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { JQControl control = null; string editor = "text"; String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description; if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox") && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField) || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName))) { BFI.ControlType = "TextBox"; } if (BFI.ControlType == "ComboBox") { control = new JQSelects() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField }; editor = "selects"; } else if (BFI.ControlType == "RefValBox") { control = new JQRefval() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField }; //(control as JQRefval).Columns.Add(new JQRefValColumn() { FieldName = BFI.ComboValueField, Caption = BFI.ComboValueFieldCaption }); editor = "refval"; } else if (BFI.ControlType == "RadioButton") { control = new JQRadioButtons() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField }; editor = "radiobuttons"; } else if (BFI.ControlType == "CheckBox") { JQCollection<JQDataItem> items = new JQCollection<JQDataItem>(control); JQDataItem item1 = new JQDataItem(); item1.Text = "Yes"; item1.Value = "Yes"; JQDataItem item2 = new JQDataItem(); item2.Text = "No"; item2.Value = "No"; items.Add(item1); items.Add(item2); control = new JQCheckBoxes() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField, Items = items }; editor = "checkboxes"; } else if (BFI.ControlType == "DateTimeBox") { control = new JQDate(); editor = "date"; } else { control = new JQTextBox(); } sb.AppendFormat("<{0}:{1} Caption=\"{2}\" FieldName=\"{3}\" Editor=\"{4}\" Width=\"120\" EditorOptions=\"{5}\"></{0}:{1}>" , "JQMobileTools", "JQFormColumn", sHeaderText, BFI.DataField, editor, control.Options); } sb.Append("</Columns>"); if (BlockItem.Relation != null && BlockItem.Relation.ChildColumns.Length > 0) { sb.Append("<RelationColumns>"); for (int i = 0; i < BlockItem.Relation.ChildColumns.Length; i++) { sb.AppendFormat("<JQMobileTools:JQRelationColumn FieldName=\"{0}\" ParentFieldName=\"{1}\" />", BlockItem.Relation.ChildColumns[i].ColumnName, BlockItem.Relation.ParentColumns[i].ColumnName); } sb.Append("</RelationColumns>"); } eJQDataFormDetail.innerHTML = sb.ToString(); WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement; Default.BindingObjectID = "dataFormDetail"; InsertControl(Page, Default); Validate.BindingObjectID = "dataFormDetail"; InsertControl(Page, Validate); } #else #endif }