예제 #1
0
        private void GenMainBlockControl(TBlockItem BlockItem)
        {
            #if VS90
            //object oMaster = FDesignerDocument.webControls.item("Master", 0);

            //WebDevPage.IHTMLElement eMaster = null;
            //WebDevPage.IHTMLElement eWebGridView1 = null;

            //if (oMaster == null || !(oMaster is WebDevPage.IHTMLElement))
            //    return;
            //eMaster = (WebDevPage.IHTMLElement)oMaster;

            //WebDefault Default = new WebDefault();
            //Default.ID = "wd" + BlockItem.TableName;
            //Default.DataSourceID = eMaster.getAttribute("ID", 0).ToString();
            //Default.DataMember = FClientData.TableName;

            //WebValidate Validate = new WebValidate();
            //Validate.ID = "wv" + BlockItem.TableName;
            //Validate.DataSourceID = eMaster.getAttribute("ID", 0).ToString();
            //Validate.DataMember = FClientData.TableName;

            //WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement;
            //InsertControl(Page, Default);
            //InsertControl(Page, Validate);

            //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);
            //}

            //foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems)
            //{
            //    foreach (WebQueryColumns wqc in QueryColumns)
            //    {
            //        if (wqc.ColumnType == "ClientQueryRefValColumn" && wqc.Column == fielditem.DataField && fielditem.RefValNo != String.Empty)
            //        {
            //            WebDataSource aWebDataSource = new WebDataSource();
            //            InfoCommand aInfoCommand = new InfoCommand(FClientData.DatabaseType);
            //            aInfoCommand.Connection = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, true);
            //            //aInfoCommand.Connection = FClientData.Owner.GlobalConnection;
            //            IDbDataAdapter DA = DBUtils.CreateDbDataAdapter(aInfoCommand);
            //            if (FSYS_REFVAL != null)
            //                FSYS_REFVAL.Dispose();
            //            FSYS_REFVAL = new DataSet();
            //            aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL where REFVAL_NO = '{0}'", fielditem.RefValNo);
            //            WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, FSYS_REFVAL, fielditem.RefValNo);

            //            WebRefVal aWebRefVal = new WebRefVal();
            //            aWebRefVal.ID = wqc.WebRefVal;
            //            aWebRefVal.DataTextField = FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString();
            //            aWebRefVal.DataValueField = FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString();
            //            aWebRefVal.DataSourceID = String.Format("wds{0}{1}", BlockItem.TableName, wqc.Column);
            //            aWebRefVal.Visible = false;
            //            InsertControl(Page, aWebRefVal);
            //            break;
            //        }
            //    }
            //}

            //WebDevPage.IHTMLElement Navigator = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("WebNavigator1", 0);
            //if (Navigator != null)
            //{
            //    SetCollectionValue(Navigator, typeof(WebNavigator).GetProperty("QueryFields"), QueryFields);
            //}
            //WebDevPage.IHTMLElement ClientQuery = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("WebClientQuery1", 0);
            //if (ClientQuery != null)
            //{
            //    SetCollectionValue(ClientQuery, typeof(WebClientQuery).GetProperty("Columns"), QueryColumns);
            //}

            //object oWebGridView1 = FDesignerDocument.webControls.item("wgvMaster", 0);
            //if (oWebGridView1 == null)
            //    oWebGridView1 = FDesignerDocument.webControls.item("WebGridView1", 0);
            //eWebGridView1 = (WebDevPage.IHTMLElement)oWebGridView1;
            ////eWebGridView1.setAttribute("DataMember", FClientData.TableName, 0);

            ////这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
            //StringBuilder sb = new StringBuilder(eWebGridView1.innerHTML);
            //int idx = eWebGridView1.innerHTML.IndexOf("</Columns>");
            //if (idx == -1)
            //{
            //    idx = sb.ToString().IndexOf("<SelectedRowStyle");
            //    sb.Insert(idx, "<Columns>\r\n            </Columns>");
            //}
            //List<string> KeyFields = new List<string>();
            //foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
            //{
            //    idx = sb.ToString().IndexOf("</Columns>");
            //    if (!string.IsNullOrEmpty(BFI.RefValNo) || BFI.RefField != null)
            //    {
            //        sb.Insert(idx, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
            //    }
            //    else if (BFI.ControlType == "ComboBox" || BFI.ControlType == "ValidateBox" || BFI.ControlType == "CheckBox")
            //    {
            //        sb.Insert(idx, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
            //    }
            //    else
            //    {
            //        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
            //        {
            //            sb.Insert(idx, GenTemplateFieldHTML("DateTimeBox", BlockItem, BFI));
            //        }
            //        else
            //        {
            //            sb.Insert(idx, "\r            <asp:BoundField DataField=\"" + BFI.DataField + "\" HeaderText=\"" + (string.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description) + "\" SortExpression=\"" + BFI.DataField + "\" />\r\n            ");
            //        }
            //    }
            //}
            //eWebGridView1.innerHTML = sb.ToString();

            BlockItem.wDataSource = new WebDataSource();
            EFBase.EFCollection<ExtTools.ExtFormField> aClientCollection
                = new EFBase.EFCollection<ExtTools.ExtFormField>(new ExtTools.ExtFormView());
            //DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName];
            bool flag = true;
            foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
            {
                ExtTools.ExtFormField extCol = new ExtTools.ExtFormField();
                if (BFI.CheckNull == "Y")
                    extCol.AllowNull = false;
                else
                    extCol.AllowNull = true;
                extCol.DataField = BFI.DataField;
                if (BFI.Description != null && BFI.Description != String.Empty)
                {
                    extCol.Caption = BFI.Description;
                }
                else
                {
                    extCol.Caption = BFI.DataField;
                }
                extCol.IsKeyField = BFI.IsKey;
                //extCol.IsKeyField = IsKeyField(BFI.DataField, srcTable.PrimaryKey);
                extCol.NewLine = flag;
                extCol.Width = 120;
                extCol.DefaultValue = BFI.DefaultValue;
                extCol.Formatter = BFI.EditMask;
                extCol.FieldType = EFClientTools.Common.TypeHelper.ReturnDataType(BFI.DataType);
                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);

                aClientCollection.Add(extCol);

                flag = !flag;
            }
            WebDevPage.IHTMLElement ExtFVMaster = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("ExtFVMaster", 0);
            if (ExtFVMaster != null)
            {
                SetCollectionValue(ExtFVMaster, typeof(ExtTools.ExtFormView).GetProperty("Fields"), aClientCollection);
            }
            #endif
        }
예제 #2
0
        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
        }
예제 #3
0
        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
        }