private void GenViewBlockControl(TBlockItem BlockItem) { #if VS90 //object oView = FDesignerDocument.webControls.item("View", 0); //if (oView == null) // oView = FDesignerDocument.webControls.item("Master", 0); //WebDevPage.IHTMLElement eView = null; //WebDevPage.IHTMLElement eWebView1 = null; //if (oView == null || !(oView is WebDevPage.IHTMLElement)) // return; //eView = (WebDevPage.IHTMLElement)oView; //BlockItem.wDataSource = new WebDataSource(); //String viewDataMember = FClientData.ViewProviderName.Substring(FClientData.ViewProviderName.IndexOf('.') + 1, FClientData.ViewProviderName.Length - // FClientData.ViewProviderName.IndexOf('.') - 1); //if (eView != null) //{ // eView.setAttribute("DataMember", viewDataMember, 0); //} //object oWebView1 = FDesignerDocument.webControls.item("WgView", 0); //if (oWebView1 != null) //{ // eWebView1 = (WebDevPage.IHTMLElement)oWebView1; // //eWebView1.setAttribute("DataMember", viewDataMember, 0); //} //if (oWebView1 == null) // oWebView1 = FDesignerDocument.webControls.item("WebGridView1", 0); //if (oWebView1 != null) //{ // eWebView1 = (WebDevPage.IHTMLElement)oWebView1; // //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了 // StringBuilder sb = new StringBuilder(eWebView1.innerHTML); // int idx = eWebView1.innerHTML.IndexOf("</Columns>"); // List<string> KeyFields = new List<string>(); // foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) // { // idx = sb.ToString().IndexOf("</Columns>"); // sb.Insert(idx, "\r <asp:BoundField DataField=\"" + BFI.DataField + "\" HeaderText=\"" + (string.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description) + "\" SortExpression=\"" + BFI.DataField + "\" />\r\n "); // } // eWebView1.innerHTML = sb.ToString(); //} BlockItem.wDataSource = new WebDataSource(); EFBase.EFCollection<ExtTools.ExtGridColumn> aExtGridColumnCollection = new EFBase.EFCollection<ExtTools.ExtGridColumn>(new ExtTools.ExtGridView()); EFBase.EFCollection<ExtTools.ExtQueryField> aExtQueryFieldCollection = new EFBase.EFCollection<ExtTools.ExtQueryField>(new ExtTools.ExtGridView()); bool flag = true; //DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName]; foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { ExtTools.ExtGridColumn extCol = new ExtTools.ExtGridColumn(); if (BFI.CheckNull == "Y") extCol.AllowNull = false; else extCol.AllowNull = true; //extCol.AllowSort = false; extCol.ColumnName = string.Format("col{0}", BFI.DataField); extCol.DataField = BFI.DataField; extCol.ExpandColumn = true; if (BFI.Description != null && BFI.Description != String.Empty) extCol.HeaderText = BFI.Description; else extCol.HeaderText = BFI.DataField; extCol.IsKeyField = BFI.IsKey; //extCol.IsKeyField = IsKeyField(BFI.DataField, srcTable.PrimaryKey); extCol.NewLine = flag; //extCol.Resizable = true; //extCol.TextAlign = "left"; extCol.Visible = true; extCol.Width = 120; extCol.DefaultValue = BFI.DefaultValue; extCol.Formatter = BFI.EditMask; extCol.FieldType = EFClientTools.Common.TypeHelper.ReturnDataType(BFI.DataType); if (BFI.QueryMode == "Normal") { ExtTools.ExtQueryField aExtQueryField = new ExtTools.ExtQueryField(); aExtQueryField.Condition = "And"; aExtQueryField.DataField = BFI.DataField; aExtQueryField.Caption = BFI.Description; if (BFI.DataType == typeof(int) || BFI.DataType == typeof(float) || BFI.DataType == typeof(double)) { aExtQueryField.Operator = "="; } else { aExtQueryField.Operator = "%"; } aExtQueryFieldCollection.Add(aExtQueryField); } else if (BFI.QueryMode == "Range") { ExtTools.ExtQueryField aExtQueryField = new ExtTools.ExtQueryField(); aExtQueryField.DataField = BFI.DataField; aExtQueryField.Caption = BFI.Description; aExtQueryField.Condition = "And"; aExtQueryField.Operator = ">="; aExtQueryFieldCollection.Add(aExtQueryField); ExtTools.ExtQueryField aExtQueryField2 = new ExtTools.ExtQueryField(); aExtQueryField2.DataField = BFI.DataField; aExtQueryField2.Caption = BFI.Description; aExtQueryField2.Condition = "And"; aExtQueryField2.Operator = "<="; aExtQueryFieldCollection.Add(aExtQueryField2); } this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType); aExtGridColumnCollection.Add(extCol); flag = !flag; } WebDevPage.IHTMLElement ExtGVView = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("ExtGVView", 0); if (ExtGVView != null) { SetCollectionValue(ExtGVView, typeof(ExtTools.ExtGridView).GetProperty("Columns"), aExtGridColumnCollection); } if (ExtGVView != null && aExtQueryFieldCollection.Count > 0) { SetCollectionValue(ExtGVView, typeof(ExtTools.ExtGridView).GetProperty("QueryFields"), aExtQueryFieldCollection); } #endif }
private void GenDetailBlock(String TemplateName) { MWizard.TBlockItem BlockItem = null; foreach (TBlockItem B in FClientData.Blocks) { if (B.wDataSource == null) { BlockItem = B; break; } } #if VS90 EFBase.EFCollection<ExtTools.ExtGridColumn> aExtGridColumnCollection = new EFBase.EFCollection<ExtTools.ExtGridColumn>(new ExtTools.ExtGridView()); //DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName]; bool flag = true; Dictionary<String, String> dMappings = EFAssembly.EFClientToolsAssemblyAdapt.DesignClientUtility.GetEntityPropertieMappings(FClientData.AssemblyName, FClientData.CommandName, FClientData.DetailEntityName); foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems) { ExtTools.ExtGridColumn extCol = new ExtTools.ExtGridColumn(); if (BFI.CheckNull == "Y") extCol.AllowNull = false; else extCol.AllowNull = true; //extCol.AllowSort = false; extCol.ColumnName = string.Format("col{0}", BFI.DataField); extCol.DataField = BFI.DataField; extCol.DefaultValue = BFI.DefaultValue; extCol.ExpandColumn = true; if (BFI.Description != null && BFI.Description != String.Empty) extCol.HeaderText = BFI.Description; else extCol.HeaderText = BFI.DataField; extCol.IsKeyField = BFI.IsKey; if (extCol.IsKeyField) { foreach (var mapping in dMappings) { if (mapping.Key == BFI.DataField) extCol.Mapping = mapping.Value; } } //extCol.IsKeyField = IsKeyField(BFI.DataField, srcTable.PrimaryKey); extCol.NewLine = flag; //extCol.Resizable = true; //extCol.TextAlign = "left"; extCol.Visible = true; extCol.Width = 120; extCol.DefaultValue = BFI.DefaultValue; extCol.Formatter = BFI.EditMask; extCol.FieldType = EFClientTools.Common.TypeHelper.ReturnDataType(BFI.DataType); if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null) { String DataSourceID = GenEFDataSource(BFI, BlockItem.TableName, "RefVal", ""); String extComboBox = GenExtComboBox(BFI, BlockItem.TableName, "ExtRefVal", "", DataSourceID); extCol.EditControlId = extComboBox; extCol.Editor = ExtTools.ExtGridEditor.ComboBox; extCol.Mapping = BFI.ComboEntitySetName + "." + BFI.ComboValueField; } else if (BFI.ControlType == "ComboBox") { String DataSourceID = GenEFDataSource(BFI, BFI.ComboEntityName, "ComboBox", ""); String extComboBox = GenExtComboBox(BFI, BlockItem.TableName, "ExtComboBox", "", DataSourceID); extCol.EditControlId = extComboBox; extCol.Editor = ExtTools.ExtGridEditor.ComboBox; extCol.Mapping = BFI.ComboEntitySetName + "." + BFI.ComboValueField; } this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType); aExtGridColumnCollection.Add(extCol); flag = !flag; } WebDevPage.IHTMLElement ExtGVDetail = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("ExtGVDetail", 0); if (ExtGVDetail != null) { SetCollectionValue(ExtGVDetail, typeof(ExtTools.ExtGridView).GetProperty("Columns"), aExtGridColumnCollection); } #endif }