예제 #1
0
        private void CreateWebQueryField(TBlockFieldItem aFieldItem, string Range, bool NewLine)
        {
            #if VS90
            WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns));
            if (string.Compare(aFieldItem.QueryMode, "normal", true) == 0
                  || string.Compare(aFieldItem.QueryMode, "range", true) == 0)
            {
                if (QueryColumns != null)
                {
                    WebQueryColumns column = new WebQueryColumns();
                    column.Column = aFieldItem.DataField;
                    column.Caption = string.IsNullOrEmpty(aFieldItem.Description) ? aFieldItem.DataField : aFieldItem.Description;
                    if (string.Compare(aFieldItem.ControlType, "textbox", true) == 0)
                    {
                        column.ColumnType = "ClientQueryTextBoxColumn";
                    }
                    else if (string.Compare(aFieldItem.ControlType, "combobox", true) == 0)
                    {
                        column.ColumnType = "ClientQueryTextBoxColumn";
                    }
                    else if (string.Compare(aFieldItem.ControlType, "refvalbox", true) == 0)
                    {
                        column.ColumnType = "ClientQueryTextBoxColumn";
                    }
                    else if (string.Compare(aFieldItem.ControlType, "datetimebox", true) == 0)
                    {
                        column.ColumnType = "ClientQueryCalendarColumn";
                    }
                    if (string.Compare(aFieldItem.QueryMode, "normal", true) == 0)
                    {
                        column.Operator = (aFieldItem.DataType == typeof(string)) ? "%" : "=";
                    }
                    else
                    {
                        WebQueryColumns columnrev = new WebQueryColumns();
                        columnrev.Column = column.Column;
                        columnrev.Caption = column.Caption;
                        columnrev.ColumnType = column.ColumnType;
                        columnrev.Operator = ">=";
                        QueryColumns.Add(columnrev);
                        column.Operator = "<=";
                    }
                    QueryColumns.Add(column);
                }
            }

            WebDevPage.IHTMLElement ClientQuery = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("WebClientQuery1", 0);
            if (ClientQuery != null)
            {
                SetCollectionValue(ClientQuery, typeof(WebClientQuery).GetProperty("Columns"), QueryColumns);
            }
            #else
            WebClientQuery WebClientQuery1 = (WebClientQuery)FPage.FindControl("WebClientQuery1");
            if (WebClientQuery1 != null)
            {
                if (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE")
                {
                    WebQueryColumns qColumns = new WebQueryColumns();
                    qColumns.Column = aFieldItem.DataField;
                    qColumns.Caption = aFieldItem.Description;
                    if (qColumns.Caption == "")
                        qColumns.Caption = aFieldItem.DataField;
                    qColumns.Condition = "And";
                    if (aFieldItem.QueryMode.ToUpper() == "NORMAL")
                    {
                        if (aFieldItem.DataType == typeof(DateTime))
                            qColumns.Operator = "=";
                        if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) ||
                            aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16))
                            qColumns.Operator = "=";
                        if (aFieldItem.DataType == typeof(String))
                            qColumns.Operator = "%";
                    }

                    qColumns.NewLine = NewLine;

                    if (aFieldItem.QueryMode.ToUpper() == "RANGE")
                    {
                        qColumns.Condition = "And";
                        if (Range == "")
                        {
                            qColumns.Operator = "<=";
                            qColumns.NewLine = false;
                            CreateWebQueryField(aFieldItem, ">=", true);
                        }
                        else
                        {
                            qColumns.Operator = Range;
                        }
                    }
                    switch (aFieldItem.ControlType.ToUpper())
                    {
                        case "DATETIMEBOX":
                            qColumns.ColumnType = "ClientQueryCalendarColumn";
                            break;
                        case "CHECKBOX":
                            qColumns.ColumnType = "ClientQueryCheckBoxColumn";
                            break;
                        default:
                            qColumns.ColumnType = "ClientQueryTextBoxColumn";
                            break;
                    }

                    WebClientQuery1.Columns.Add(qColumns);
                }
                IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(WebClientQuery1, null, "", "M");
            }
            #endif
        }
예제 #2
0
        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)
            {
                ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("RemoteName", FClientData.ProviderName, 0);
                ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("DataMember", FClientData.TableName, 0);
                ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("Title", FClientData.FormTitle, 0);

                //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
                StringBuilder sb = new StringBuilder(eJQGridViewMaster.innerHTML);
                int idx = eJQGridViewMaster.innerHTML.IndexOf("</Columns>");
                List<string> KeyFields = new List<string>();

                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    //if (BFI.HideGridColumn)
                    //{
                    //    continue;
                    //}
                    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.IsKey)
                        KeyFields.Add(BFI.DataField);
                    idx = sb.ToString().LastIndexOf("</Columns>");
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                    if (BFI.ControlType == "ComboBox")
                    {
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                            "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>",
                                            BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "ComboGrid")
                    {
                        //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&amp;TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" />
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));

                    }
                    else if (BFI.ControlType == "RefValBox")
                    {
                        //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'"
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" />", BFI.DataField, sHeaderText));
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                        {
                            sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32)
                                || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float)
                                || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal)
                                || (BFI.ControlType != null && BFI.ControlType == "NumberBox"))
                        {
                            sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"right\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else
                        {
                            String maxLength = "";
                            if (BFI.DataType == typeof(String))
                            {
                                maxLength = " MaxLength=\"" + BFI.Length.ToString() + "\" ";
                            }
                            sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, maxLength, BFI.EditMask));
                        }
                    }
                }
                //eWebGridView1.innerHTML = sb.ToString();

                //StringBuilder sbQuery = new StringBuilder(sb.ToString());
                int idxQuery = sb.ToString().LastIndexOf("</QueryColumns>");
                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));
                }
                eJQGridViewMaster.innerHTML = sb.ToString();

                String sKeyFieldName = "";
                foreach (var item in KeyFields)
                {
                    sKeyFieldName += item + ";";
                }
                eJQGridViewMaster.outerHTML = eJQGridViewMaster.outerHTML.Replace("KeyFieldName=\"\"", String.Format("KeyFieldName=\"{0}\"", sKeyFieldName));
            }

            object oJQDialog1 = FDesignerDocument.webControls.item("JQDialog1", 0);
            WebDevPage.IHTMLElement eJQDialog1 = (WebDevPage.IHTMLElement)oJQDialog1;
            //object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0);
            //WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster;
            if (oJQDialog1 != null)
            {
                ((WebDevPage.IHTMLElement)oJQDialog1).setAttribute("Title", FClientData.FormTitle, 0);

                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("<JQTools:JQDataForm ID=\"dataFormMaster\" runat=\"server\" DataMember=\"{0}\" RemoteName=\"{1}\"" +
                                "HorizontalColumnsCount=\"2\">", FClientData.TableName, FClientData.ProviderName);
                sb.Append("<Columns>");
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    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";
                    }

                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                    if (BFI.ControlType == "ComboBox")
                    {
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" " +
                                            "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>",
                                            BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "ComboGrid")
                    {
                        //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&amp;TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" />
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" " +
                                                "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));

                    }
                    else if (BFI.ControlType == "RefValBox")
                    {
                        //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'"
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" " +
                                                "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" />", BFI.DataField, sHeaderText));
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                        {
                            sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32)
                            || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float)
                            || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal)
                            || (BFI.ControlType != null && BFI.ControlType == "NumberBox"))
                        {
                            sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else
                        {
                            String maxLength = "";
                            if (BFI.DataType == typeof(String))
                            {
                                maxLength = " maxlength='" + BFI.Length.ToString() + "' ";
                            }
                            sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"180\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, maxLength, BFI.EditMask));
                        }
                    }
                }
                sb.Append("</Columns>");
                sb.Append("</JQTools:JQDataForm>");

                eJQDialog1.innerHTML = eJQDialog1.innerHTML.Replace("<JQTools:JQDataForm ID=\"dataFormMaster\" runat=\"server\" />", sb.ToString());

                Default.BindingObjectID = "dataFormMaster";
                eJQDialog1.innerHTML += GetControlXml(Default);
                Validate.BindingObjectID = "dataFormMaster";
                eJQDialog1.innerHTML += GetControlXml(Validate);
            }
            else
            {
                if (FClientData.BaseFormName != "JQueryQuery1")
                {
                    WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement;
                    InsertControl(Page, Default);
                    InsertControl(Page, Validate);
                }
            }

            #else
            #endif
        }
예제 #3
0
        private void GenViewBlockControl(TBlockItem BlockItem)
        {
            var masterBlockItem = FClientData.Blocks.FindItem("Master");
            BlockItem.wDataSource = new WebDataSource();

            WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField));
            WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns));
            foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems)
            {
                TBlockFieldItem masterField = null;
                if (masterBlockItem != null)
                {
                    foreach (TBlockFieldItem item in masterBlockItem.BlockFieldItems)
                    {
                        if (item.DataField == fielditem.DataField)
                        {
                            masterField = item;
                        }
                    }
                }
                if (masterField != null)
                    GenQuery(masterField, QueryFields, QueryColumns, BlockItem.TableName);
                else
                    GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName);
            }

            object oJQGridViewMaster = FDesignerDocument.webControls.item("dataGridView", 0);
            WebDevPage.IHTMLElement eJQGridViewMaster = (WebDevPage.IHTMLElement)oJQGridViewMaster;
            //FClientData.ProviderName
            if (eJQGridViewMaster != null)
            {
                ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("RemoteName", FClientData.ProviderName, 0);
                ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("DataMember", FClientData.TableName, 0);
                ((WebDevPage.IHTMLElement)oJQGridViewMaster).setAttribute("Title", FClientData.FormTitle, 0);

                //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
                StringBuilder sb = new StringBuilder(eJQGridViewMaster.innerHTML);
                int idx = eJQGridViewMaster.innerHTML.IndexOf("</Columns>");
                List<string> KeyFields = new List<string>();

                var master = FClientData.Blocks.FindItem("Main");
                if (master == null)
                    master = FClientData.Blocks.FindItem("Master");
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    var visible = "true";
                    if (master != null)
                    {
                        foreach (TBlockFieldItem mBFI in master.BlockFieldItems)
                        {
                            if (mBFI.DataField == BFI.DataField && mBFI.HideGridColumn)
                            {
                                visible = "false";
                            }
                        }
                    }
                    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.IsKey)
                        KeyFields.Add(BFI.DataField);
                    idx = sb.ToString().LastIndexOf("</Columns>");
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                    if (BFI.ControlType == "ComboBox")
                    {
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                            "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\" Visible=\"{7}\"/>",
                                            BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask, visible));
                    }
                    else if (BFI.ControlType == "ComboGrid")
                    {
                        //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&amp;TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" />
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\" Visible=\"{10}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask, visible));

                    }
                    else if (BFI.ControlType == "RefValBox")
                    {
                        //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'"
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\" Visible=\"{10}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask, visible));
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\"  Visible=\"{2}\"/>", BFI.DataField, sHeaderText, visible));
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                        {
                            sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\" Visible=\"{3}\"/>", BFI.DataField, sHeaderText, BFI.EditMask, visible));
                        }
                        else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32)
                                || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float)
                                || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal)
                                || (BFI.ControlType != null && BFI.ControlType == "NumberBox"))
                        {
                            sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"right\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\" Visible=\"{3}\"/>", BFI.DataField, sHeaderText, BFI.EditMask, visible));
                        }
                        else
                        {
                            String maxLength = "";
                            if (BFI.DataType == typeof(String))
                            {
                                maxLength = " MaxLength=\"" + BFI.Length.ToString() + "\" ";
                            }
                            sb.Insert(idx, String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" {2} Format=\"{3}\" Visible=\"{4}\"/>", BFI.DataField, sHeaderText, maxLength, BFI.EditMask, visible));
                        }
                    }
                }

                int idxQuery = sb.ToString().LastIndexOf("</QueryColumns>");
                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));
                }
                eJQGridViewMaster.innerHTML = sb.ToString();

                String sKeyFieldName = "";
                foreach (var item in KeyFields)
                {
                    sKeyFieldName += item + ";";
                }
                eJQGridViewMaster.outerHTML = eJQGridViewMaster.outerHTML.Replace("KeyFieldName=\"\"", String.Format("KeyFieldName=\"{0}\"", sKeyFieldName));
            }
        }
예제 #4
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
            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);
            }

            object oJQDialog1 = FDesignerDocument.webControls.item("JQDialog1", 0);
            WebDevPage.IHTMLElement eJQDialog1 = (WebDevPage.IHTMLElement)oJQDialog1;
            //object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0);
            //WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster;
            if (oJQDialog1 != null)
            {
                ((WebDevPage.IHTMLElement)oJQDialog1).setAttribute("Title", FClientData.FormTitle, 0);

                StringBuilder sb = new StringBuilder();
                String detailEditDialogID = String.Empty;
                if (FClientData.BaseFormName == "JQueryMasterDetail2")
                {
                    detailEditDialogID = "EditDialogID=\"JQDialog2\"";
                }
                sb.AppendFormat("<JQTools:JQDataGrid ID=\"dataGridDetail\" runat=\"server\" DataMember=\"{0}\" RemoteName=\"{1}\" Title=\"明細資料\"" +
                                "AutoApply=\"False\" Pagination=\"False\" ParentObjectID=\"dataFormMaster\" {2}>", BlockItem.TableName, FClientData.ProviderName, detailEditDialogID);
                sb.Append("<Columns>");
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    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";
                    }

                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                    if (BFI.ControlType == "ComboBox")
                    {
                        sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                            "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>",
                                            BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "ComboGrid")
                    {
                        //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&amp;TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" />
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));

                    }
                    else if (BFI.ControlType == "RefValBox")
                    {
                        //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'"
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" />", BFI.DataField, sHeaderText));
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                        {
                            sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32)
                                || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float)
                                || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal)
                                || (BFI.ControlType != null && BFI.ControlType == "NumberBox"))
                        {
                            sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"right\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else
                        {
                            sb.Append(String.Format("<JQTools:JQGridColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                    }
                }
                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("<JQTools:JQRelationColumn FieldName=\"{0}\" ParentFieldName=\"{1}\" />", BlockItem.Relation.ChildColumns[i].ColumnName, BlockItem.Relation.ParentColumns[i].ColumnName);
                    }
                    sb.Append("</RelationColumns>");
                }

                sb.Append("<TooItems>");
                sb.Append("<JQTools:JQToolItem Icon=\"icon-add\" ItemType=\"easyui-linkbutton\" OnClick=\"insertItem\" Text=\"新增\" />");
                sb.Append("<JQTools:JQToolItem Icon=\"icon-edit\" ItemType=\"easyui-linkbutton\" OnClick=\"updateItem\" Text=\"更改\" />");
                sb.Append("<JQTools:JQToolItem Icon=\"icon-remove\" ItemType=\"easyui-linkbutton\" OnClick=\"deleteItem\" Text=\"刪除\" />");
                sb.Append("</TooItems>");
                sb.Append("</JQTools:JQDataGrid>");

                eJQDialog1.innerHTML = eJQDialog1.innerHTML.Replace("<JQTools:JQDataGrid ID=\"dataGridDetail\" runat=\"server\" />", sb.ToString());

                object ojqDialog2 = FDesignerDocument.webControls.item("JQDialog2", 0);
                if (ojqDialog2 == null)
                {
                    eJQDialog1.innerHTML += GetControlXml(Default);
                    eJQDialog1.innerHTML += GetControlXml(Validate);
                }
            }

            //object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0);
            //WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster;
            object oJQDialog2 = FDesignerDocument.webControls.item("JQDialog2", 0);
            WebDevPage.IHTMLElement eJQDialog2 = (WebDevPage.IHTMLElement)oJQDialog2;
            if (oJQDialog2 != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("<JQTools:JQDataForm ID=\"dataFormDetail\" runat=\"server\" HorizontalColumnsCount=\"2\"  DataMember=\"{0}\" RemoteName=\"{1}\"  ParentObjectID=\"dataFormMaster\" >", BlockItem.TableName, FClientData.ProviderName);
                sb.Append("<Columns>");
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    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";
                    }
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                    if (BFI.ControlType == "ComboBox")
                    {
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombobox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                            "EditorOptions=\"remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}'\" Format=\"{6}\"/>",
                                            BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "ComboGrid")
                    {
                        //EditorOptions=",url:'../handler/jqDataHandle.ashx?RemoteName=SCustomers.Customers&amp;TableName=Customers',columns:[[{field:'CustomerID',title:'CustomerID',width:80,align:'left'}]]" />
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"infocombogrid\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"panelWidth:350,remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));

                    }
                    else if (BFI.ControlType == "RefValBox")
                    {
                        //EditorOptions="title:'JQRefval',panelWidth:350,remoteName:'SCustomers.Customer',tableName:'Customer',columns:[{field:'CustomerID',title:'CustomerID',width:80,align:'left'},{field:'CompanyName',title:'CompanyName',width:80,align:'left'}],columnMatches:[],valueField:'CustomerID'"
                        String columns = "{field:'" + BFI.ComboValueField + "',title:'" + BFI.ComboValueFieldCaption + "',width:80,align:'left'}";
                        if (BFI.ComboValueField != BFI.ComboTextField)
                        {
                            columns += ",{field:'" + BFI.ComboTextField + "',title:'" + BFI.ComboTextFieldCaption + "',width:80,align:'left'}";
                        }
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"inforefval\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" " +
                                                "EditorOptions=\"title:'JQRefval',panelWidth:350,columnMatches:[],remoteName:'{4}',tableName:'{5}',valueField:'{2}',textField:'{3}',valueFieldCaption:'{7}',textFieldCaption:'{8}',columns:[{6}]\" Format=\"{9}\"/>",
                                                BFI.DataField, sHeaderText, BFI.ComboValueField, BFI.ComboTextField, BFI.ComboRemoteName, BFI.ComboEntityName, columns, BFI.ComboValueFieldCaption, BFI.ComboTextFieldCaption, BFI.EditMask));
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"checkbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" />", BFI.DataField, sHeaderText));
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                        {
                            sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"datebox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else if (BFI.DataType == typeof(Int16) || BFI.DataType == typeof(Int32)
                                || BFI.DataType == typeof(Int64) || BFI.DataType == typeof(float)
                                || BFI.DataType == typeof(double) || BFI.DataType == typeof(decimal)
                                || (BFI.ControlType != null && BFI.ControlType == "NumberBox"))
                        {
                            sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"numberbox\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                        else
                        {
                            sb.Append(String.Format("<JQTools:JQFormColumn Alignment=\"left\" Editor=\"text\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" Format=\"{2}\"/>", BFI.DataField, sHeaderText, BFI.EditMask));
                        }
                    }
                }
                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("<JQTools:JQRelationColumn FieldName=\"{0}\" ParentFieldName=\"{1}\" />", BlockItem.Relation.ChildColumns[i].ColumnName, BlockItem.Relation.ParentColumns[i].ColumnName);
                    }
                    sb.Append("</RelationColumns>");
                }
                sb.Append("</JQTools:JQDataForm>");

                eJQDialog2.innerHTML = eJQDialog2.innerHTML.Replace("<JQTools:JQDataForm ID=\"dataFormDetail\" runat=\"server\" ParentObjectID=\"dataFormMaster\" />", sb.ToString());

                Default.BindingObjectID = "dataFormDetail";
                eJQDialog1.innerHTML += GetControlXml(Default);
                Validate.BindingObjectID = "dataFormDetail";
                eJQDialog1.innerHTML += GetControlXml(Validate);
            }
            #else

            #endif
        }
예제 #5
0
        private void GenDetailBlock_2()
        {
            MWizard.TBlockItem BlockItem = null;
            foreach (TBlockItem B in FClientData.Blocks)
            {
                if (B.wDataSource == null)
                {
                    BlockItem = B;
                    break;
                }
            }

            #if VS90
            object oDetail = FDesignerDocument.webControls.item("Detail", 0);

            WebDevPage.IHTMLElement eDetail = null;

            if (oDetail == null || !(oDetail is WebDevPage.IHTMLElement))
                return;
            eDetail = (WebDevPage.IHTMLElement)oDetail;
            eDetail.setAttribute("DataMember", BlockItem.TableName, 0);

            WebDevPage.IHTMLElement FormView = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("wfvDetail", 0);
            if (FormView != null)
            {
                WebDefault Default = new WebDefault();
                Default.ID = "wd" + BlockItem.TableName;
                Default.DataSourceID = eDetail.getAttribute("ID", 0).ToString();
                Default.DataMember = BlockItem.TableName;

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

                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 Page = FDesignerDocument.pageContentElement;
                ////InsertControl(Page, Default);
                ////InsertControl(Page, Validate);

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

                FormView = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("wfvDetail", 0);
                ////RefreshFormView(FormView, BlockItem);
            }
            #else
            #endif
        }
예제 #6
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" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName);
            Default.DataSourceID = eMaster.getAttribute("ID", 0).ToString();
            Default.DataMember = FClientData.TableName;

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

            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 Page = FDesignerDocument.pageContentElement;
            InsertControl(Page, Default);
            InsertControl(Page, Validate);

            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}", WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), wqc.Column);
                        aWebRefVal.Visible = false;
                        InsertControl(Page, aWebRefVal);
                        break;
                    }
                    else if (wqc.ColumnType == "ClientQueryComboBoxColumn" && wqc.Column == fielditem.DataField
                        && !String.IsNullOrEmpty(fielditem.ComboTextField) && !String.IsNullOrEmpty(fielditem.ComboValueField))
                    {
                        WebRefVal aWebRefVal = new WebRefVal();
                        aWebRefVal.ID = wqc.WebRefVal;
                        aWebRefVal.DataTextField = fielditem.ComboTextField;
                        aWebRefVal.DataValueField = fielditem.ComboValueField;
                        aWebRefVal.DataSourceID = String.Format("wds{0}{1}", fielditem.ComboEntityName, 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 (BFI.ControlType == "RefValBox" && String.IsNullOrEmpty(BFI.RefValNo))
                    BFI.ControlType = "TextBox";
                if (BFI.ControlType == "ComboBox" && (String.IsNullOrEmpty(BFI.ComboRemoteName)
                                                    || String.IsNullOrEmpty(BFI.ComboTextField)
                                                    || String.IsNullOrEmpty(BFI.ComboValueField)))
                    BFI.ControlType = "TextBox";
                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();
            WebDevPage.IHTMLElement AjaxGridView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxGridView1", 0);
            if (AjaxGridView1 != null)
            {
                AjaxTools.ExtGridColumnCollection aExtGridColumnCollection = new AjaxTools.ExtGridColumnCollection(new AjaxTools.AjaxGridView(), typeof(AjaxTools.ExtColumnMatch));
                DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName];
                bool flag = true;
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    AjaxTools.ExtGridColumn extCol = new AjaxTools.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 = 75;
                    if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                    {
                        String DataSourceID = GenWebDataSource(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "RefVal", "", true);
                        String extComboBox = GenExtComboBox(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "ExtRefVal", "", DataSourceID);
                        try
                        {
                            String str = AjaxGridView1.innerHTML;
                        }
                        catch
                        {
                            AjaxGridView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxGridViewDetail", 0);
                        }
                        extCol.EditControlId = extComboBox;
                        extCol.Editor = AjaxTools.ExtGridEditor.ComboBox;
                    }
                    else if (BFI.ControlType == "ComboBox")
                    {
                        String DataSourceID = GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", "", true);
                        String extComboBox = GenExtComboBox(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "ExtComboBox", "", DataSourceID);
                        try
                        {
                            String str = AjaxGridView1.innerHTML;
                        }
                        catch
                        {
                            AjaxGridView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxGridViewDetail", 0);
                        }
                        extCol.EditControlId = extComboBox;
                        extCol.Editor = AjaxTools.ExtGridEditor.ComboBox;
                    }
                    this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType);

                    aExtGridColumnCollection.Add(extCol);

                    flag = !flag;
                }

                SetCollectionValue(AjaxGridView1, typeof(AjaxTools.AjaxGridView).GetProperty("Columns"), aExtGridColumnCollection);
            }
            #else
            bool isAjaxPage = false;
            if (FPage.FindControl("AjaxScriptManager1") != null)
                isAjaxPage = true;

            WebDataSource Master = (WebDataSource)FPage.FindControl("Master");
            BlockItem.wDataSource = Master;
            WebGridView WebGridView1 = (WebGridView)FPage.FindControl("wgvMaster");
            if (WebGridView1 == null)
                WebGridView1 = (WebGridView)FPage.FindControl("WebGridView1");
            //Generate RESX
            //???GenResx(Master);

            //WebGridView1.DataMember = FClientData.TableName;
            //???WebGridView1.Columns.Clear();
            System.Web.UI.WebControls.BoundField aBoundField = null;
            System.Web.UI.WebControls.TemplateField aTemplateField = null;

            WebDefault aDefault = new WebDefault();
            aDefault.ID = "wd" + BlockItem.TableName;
            aDefault.DataSourceID = Master.ID;
            aDefault.DataMember = Master.DataMember;
            WebValidate aValidate = new WebValidate();
            aValidate.ID = "wv" + BlockItem.TableName;
            aValidate.DataSourceID = Master.ID;
            aValidate.DataMember = Master.DataMember;

            if (WebGridView1 != null)
            {
                List<string> KeyFields = new List<string>();
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                    {
                        String DataSourceID = GenWebDataSource(BFI, BlockItem.TableName, "RefVal", "");
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        if (isAjaxPage)
                        {
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewAjaxRefValEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, WebGridView1, FLabelList);
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewAjaxRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, WebGridView1, FLabelList);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewAjaxRefValFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, WebGridView1, FLabelList);
                        }
                        else
                        {
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewRefValEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, WebGridView1);
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, WebGridView1);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewRefValFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, WebGridView1);
                        }
                        WebGridView1.Columns.Add(aTemplateField);
                    }
                    else if (BFI.ControlType == "ComboBox")
                    {
                        String DataSourceID = GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", "");
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewComboBoxEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewComboBoxItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                        aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewComboBoxFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                        WebGridView1.Columns.Add(aTemplateField);
                    }
                    else if (BFI.ControlType == "ValidateBox")
                    {
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewValidateBoxEditItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewValidateBoxItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                        aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewValidateBoxFooterItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                        WebGridView1.Columns.Add(aTemplateField);
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewCheckBoxEditItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewCheckBoxItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                        aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewCheckBoxFooterItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                        WebGridView1.Columns.Add(aTemplateField);
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType.ToUpper() == "DATETIMEBOX"))
                        {
                            aTemplateField = new System.Web.UI.WebControls.TemplateField();
                            aTemplateField.HeaderText = BFI.Description;
                            aTemplateField.SortExpression = BFI.DataField;
                            if (aTemplateField.HeaderText == "")
                                aTemplateField.HeaderText = BFI.DataField;
                            if (isAjaxPage)
                            {
                                aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeEditItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, WebGridView1);
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, WebGridView1);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, WebGridView1);
                            }
                            else
                            {
                                aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewDateTimeEditItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, WebGridView1);
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewDateTimeItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, WebGridView1);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, WebGridView1);
                            }
                            WebGridView1.Columns.Add(aTemplateField);
                        }
                        else
                        {
                            if (BFI.EditMask != null && BFI.EditMask != String.Empty)
                            {
                                aTemplateField = new System.Web.UI.WebControls.TemplateField();
                                aTemplateField.HeaderText = BFI.Description;
                                aTemplateField.SortExpression = BFI.DataField;
                                if (aTemplateField.HeaderText == "")
                                    aTemplateField.HeaderText = BFI.DataField;
                                aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewTextBoxEditItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, WebGridView1);
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewTextBoxItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, WebGridView1);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewTextBoxFooterItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, WebGridView1);
                                WebGridView1.Columns.Add(aTemplateField);
                            }
                            else
                            {
                                aBoundField = new System.Web.UI.WebControls.BoundField();
                                aBoundField.DataField = BFI.DataField;
                                aBoundField.SortExpression = BFI.DataField;
                                aBoundField.HeaderText = BFI.Description;
                                //Field.HeaderStyle.Width = BFI.Length * ColumnWidthPixel;
                                if (aBoundField.HeaderText == "")
                                    aBoundField.HeaderText = BFI.DataField;
                                WebGridView1.Columns.Add(aBoundField);
                            }
                        }
                    }
                    if (BFI.IsKey)
                        KeyFields.Add(BFI.DataField);

                    CreateQueryField(BFI, "", null, BlockItem.TableName);

                    GenDefault(BFI, aDefault, aValidate);
                }

                DataTable DT = FWizardDataSet.RealDataSet.Tables[0];
                DataColumn[] PrimDc = DT.PrimaryKey;
                string[] AA = new string[PrimDc.Length];
                for (int J = 0; J < PrimDc.Length; J++)
                    AA[J] = PrimDc[J].ColumnName;

                /*
                WebGridView1.DataKeyNames = new string[AA.Length];
                for (int I = 0; I < AA.Length; I++)
                {
                    WebGridView1.DataKeyNames[I] = AA[I];
                }
                 */
                FWebDefaultList.Add(aDefault);
                FWebValidateList.Add(aValidate);
                IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(WebGridView1, null, "", "M");
            }

            Object aAjaxGridView = FPage.FindControl("AjaxGridView1");
            if (aAjaxGridView != null)
            {
                bool flag = true;
                DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName];
                IList iColumns = aAjaxGridView.GetType().GetProperty("Columns").GetValue(aAjaxGridView, null) as IList;
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    Type columnsType = aAjaxGridView.GetType().GetProperty("Columns").PropertyType.GetProperties()[0].PropertyType;
                    object extCol = Activator.CreateInstance(columnsType);
                    if (BFI.CheckNull == "Y")
                        extCol.GetType().GetProperty("AllowNull").SetValue(extCol, false, null);
                    else
                        extCol.GetType().GetProperty("AllowNull").SetValue(extCol, true, null);
                    extCol.GetType().GetProperty("AllowSort").SetValue(extCol, false, null);
                    extCol.GetType().GetProperty("ColumnName").SetValue(extCol, string.Format("col{0}", BFI.DataField), null);
                    extCol.GetType().GetProperty("DataField").SetValue(extCol, BFI.DataField, null);
                    extCol.GetType().GetProperty("DefaultValue").SetValue(extCol, BFI.DefaultValue, null);
                    extCol.GetType().GetProperty("ExpandColumn").SetValue(extCol, true, null);
                    if (BFI.Description != null && BFI.Description != String.Empty)
                        extCol.GetType().GetProperty("HeaderText").SetValue(extCol, BFI.Description, null);
                    else
                        extCol.GetType().GetProperty("HeaderText").SetValue(extCol, BFI.DataField, null);
                    extCol.GetType().GetProperty("IsKeyField").SetValue(extCol, BFI.IsKey, null);
                    //extCol.GetType().GetProperty("IsKeyField").SetValue(extCol, IsKeyField(BFI.DataField, srcTable.PrimaryKey), null);
                    extCol.GetType().GetProperty("NewLine").SetValue(extCol, flag, null);
                    extCol.GetType().GetProperty("Resizable").SetValue(extCol, true, null);
                    extCol.GetType().GetProperty("TextAlign").SetValue(extCol, "left", null);
                    extCol.GetType().GetProperty("Visible").SetValue(extCol, true, null);
                    extCol.GetType().GetProperty("Width").SetValue(extCol, 75, null);
                    this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType);
                    iColumns.Add(extCol);
                    flag = !flag;
                }
                IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(aAjaxGridView, null, "", "M");
            }
            #endif
        }
예제 #7
0
        private void GenMainBlockControl_2(TBlockItem BlockItem)
        {
            #if VS90
            object oMaster = FDesignerDocument.webControls.item("Master", 0);

            WebDevPage.IHTMLElement eMaster = null;
            WebDevPage.IHTMLElement eWebDetailView1 = null;

            if (oMaster == null || !(oMaster is WebDevPage.IHTMLElement))
                return;
            eMaster = (WebDevPage.IHTMLElement)oMaster;
            eMaster.setAttribute("AutoApply", "true", 0);

            BlockItem.wDataSource = new WebDataSource();
            string mastertablename = string.Empty;
            if (eMaster != null)
            {
                mastertablename = FClientData.ProviderName.Split('.')[1];
                eMaster.setAttribute("DataMember", mastertablename, 0);
            }
            WebDefault Default = new WebDefault();
            Default.ID = "wd" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName);
            Default.DataSourceID = eMaster.getAttribute("ID", 0).ToString();
            Default.DataMember = mastertablename;

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

            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 Page = FDesignerDocument.pageContentElement;
            InsertControl(Page, Default);
            InsertControl(Page, Validate);

            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}", WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), wqc.Column);
                        aWebRefVal.Visible = false;
                        InsertControl(Page, aWebRefVal);
                        break;
                    }
                    else if (wqc.ColumnType == "ClientQueryComboBoxColumn" && wqc.Column == fielditem.DataField
                            && !String.IsNullOrEmpty(fielditem.ComboTextField) && !String.IsNullOrEmpty(fielditem.ComboValueField))
                    {
                        WebRefVal aWebRefVal = new WebRefVal();
                        aWebRefVal.ID = wqc.WebRefVal;
                        aWebRefVal.DataTextField = fielditem.ComboTextField;
                        aWebRefVal.DataValueField = fielditem.ComboValueField;
                        aWebRefVal.DataSourceID = String.Format("wds{0}{1}", fielditem.ComboEntityName, 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 oWebDetailView1 = FDesignerDocument.webControls.item("wdvMaster", 0);
            eWebDetailView1 = (WebDevPage.IHTMLElement)oWebDetailView1;
            //eWebDetailView1.setAttribute("DataMember", FClientData.TableName, 0);
            //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
            StringBuilder sb = new StringBuilder(eWebDetailView1.innerHTML);
            int idx = eWebDetailView1.innerHTML.IndexOf("<EmptyDataRowStyle ForeColor=\"Black\" />");
            sb.Insert(idx, "<Fields>\r\n            </Fields>\r\n            ");
            eWebDetailView1.innerHTML = sb.ToString();
            idx = eWebDetailView1.innerHTML.IndexOf("</Fields>");
            List<string> KeyFields = new List<string>();
            foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
            {
                idx = sb.ToString().IndexOf("</Fields>");
                if (BFI.ControlType == "RefValBox" && String.IsNullOrEmpty(BFI.RefValNo))
                    BFI.ControlType = "TextBox";
                if (BFI.ControlType == "ComboBox" && (String.IsNullOrEmpty(BFI.ComboRemoteName)
                                                    || String.IsNullOrEmpty(BFI.ComboTextField)
                                                    || String.IsNullOrEmpty(BFI.ComboValueField)))
                    BFI.ControlType = "TextBox";
                if (!string.IsNullOrEmpty(BFI.RefValNo) || BFI.RefField != null)
                {
                    sb.Insert(idx, GenDetailViewTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                }
                else if (BFI.ControlType == "ComboBox" || BFI.ControlType == "ValidateBox" || BFI.ControlType == "CheckBox")
                {
                    sb.Insert(idx, GenDetailViewTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                }
                else
                {
                    if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                    {
                        sb.Insert(idx, GenDetailViewTemplateFieldHTML("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            ");
                    }
                }
            }
            eWebDetailView1.innerHTML = sb.ToString();
            #else
            bool isAjaxPage = false;
            if (FPage.FindControl("AjaxScriptManager1") != null)
                isAjaxPage = true;

            WebDataSource Master = (WebDataSource)FPage.FindControl("Master");
            Master.AutoApply = true;
            BlockItem.wDataSource = Master;
            WebDetailsView wdvMaster = (WebDetailsView)FPage.FindControl("wdvMaster");

            //Generate RESX
            //???GenResx(Master);

            //wdvMaster.DataMember = FClientData.TableName;
            //???WebGridView1.Columns.Clear();
            System.Web.UI.WebControls.BoundField aBoundField = null;
            System.Web.UI.WebControls.TemplateField aTemplateField = null;
            WebDefault aDefault = new WebDefault();
            aDefault.ID = "wd" + BlockItem.TableName;
            aDefault.DataSourceID = Master.ID;
            aDefault.DataMember = Master.DataMember;
            WebValidate aValidate = new WebValidate();
            aValidate.ID = "wv" + BlockItem.TableName;
            aValidate.DataSourceID = Master.ID;
            aValidate.DataMember = Master.DataMember;
            List<string> KeyFields = new List<string>();
            foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
            {
                if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                {
                    String DataSourceID = GenWebDataSource(BFI, BlockItem.TableName, "RefVal", "");
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewRefValEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, null);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, null);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewRefValInsertItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, null);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else if (BFI.ControlType == "ComboBox")
                {
                    String DataSourceID = GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", "");
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewComboBoxEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewComboBoxItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewComboBoxFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewComboBoxInsertItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else if (BFI.ControlType == "ValidateBox")
                {
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewValidateBoxEditItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewValidateBoxInsertItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewValidateBoxItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewValidateBoxInsertItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else if (BFI.ControlType == "CheckBox")
                {
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewCheckBoxEditItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewCheckBoxInsertItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewCheckBoxItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewCheckBoxInsertItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else
                {
                    if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType.ToUpper() == "DATETIMEBOX"))
                    {
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewDateTimeEditItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewDateTimeItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewDateTimeInsertItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        wdvMaster.Fields.Add(aTemplateField);
                    }
                    else
                    {
                        if (BFI.EditMask != null && BFI.EditMask != String.Empty)
                        {
                            aTemplateField = new System.Web.UI.WebControls.TemplateField();
                            aTemplateField.HeaderText = BFI.Description;
                            aTemplateField.SortExpression = BFI.DataField;
                            if (aTemplateField.HeaderText == "")
                                aTemplateField.HeaderText = BFI.DataField;
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewTextBoxEditItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewTextBoxItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewTextBoxFooterItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewTextBoxInsertItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            wdvMaster.Fields.Add(aTemplateField);
                        }
                        else
                        {
                            aBoundField = new System.Web.UI.WebControls.BoundField();
                            aBoundField.DataField = BFI.DataField;
                            aBoundField.SortExpression = BFI.DataField;
                            aBoundField.HeaderText = BFI.Description;
                            aBoundField.HeaderStyle.Width = 150;//BFI.Length * ColumnWidthPixel;
                            if (aBoundField.HeaderText == "")
                                aBoundField.HeaderText = BFI.DataField;
                            wdvMaster.Fields.Add(aBoundField);
                        }
                    }
                }

                if (BFI.IsKey)
                    KeyFields.Add(BFI.DataField);

                CreateQueryField(BFI, "", null, BlockItem.TableName);

                GenDefault(BFI, aDefault, aValidate);
            }

            DataTable DT = FWizardDataSet.RealDataSet.Tables[0];
            DataColumn[] PrimDc = DT.PrimaryKey;
            string[] AA = new string[PrimDc.Length];
            for (int J = 0; J < PrimDc.Length; J++)
                AA[J] = PrimDc[J].ColumnName;
            /*
            wdvMaster.DataKeyNames = new string[AA.Length];
            for (int I = 0; I < AA.Length; I++)
            {
                wdvMaster.DataKeyNames[I] = AA[I];
            }
             */
            FWebDefaultList.Add(aDefault);
            FWebValidateList.Add(aValidate);
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            NotifyRefresh(200);
            FComponentChangeService.OnComponentChanged(wdvMaster, null, "", "M");
            #endif
        }
예제 #8
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
            object oDetail = FDesignerDocument.webControls.item("Detail", 0);

            WebDevPage.IHTMLElement eDetail = null;
            WebDevPage.IHTMLElement eWebGridView1 = null;

            if (oDetail == null || !(oDetail is WebDevPage.IHTMLElement))
                return;
            eDetail = (WebDevPage.IHTMLElement)oDetail;
            eDetail.setAttribute("DataMember", BlockItem.TableName, 0);

            WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField));
            WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns));
            if (FDesignerDocument.webControls.item("wd" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), 0) == null && FDesignerDocument.webControls.item("wv" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), 0) == null)
            {
                WebDefault Default = new WebDefault();
                Default.ID = "wd" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName);
                Default.DataSourceID = eDetail.getAttribute("ID", 0).ToString();
                Default.DataMember = BlockItem.TableName;

                WebValidate Validate = new WebValidate();
                Validate.ID = "wv" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName);
                Validate.DataSourceID = eDetail.getAttribute("ID", 0).ToString();
                Validate.DataMember = BlockItem.TableName;

                foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems)
                {
                    GenDefault(fielditem, Default, Validate);
                    GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName);
                }

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

            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("wgvDetail", 0);
            eWebGridView1 = (WebDevPage.IHTMLElement)oWebGridView1;
            if (eWebGridView1 != null)
            {
                //eWebGridView1.setAttribute("DataSourceID", "Detail", 0);
                //eWebGridView1.setAttribute("DataMember", BlockItem.TableName, 0);

                //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
                StringBuilder sb = new StringBuilder(eWebGridView1.innerHTML);
                int idx = eWebGridView1.innerHTML.IndexOf("</Columns>");
                List<string> KeyFields = new List<string>();
                AddNewRowControlCollection controls = new AddNewRowControlCollection(null, typeof(AddNewRowControlItem));
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    //if (TemplateName == "WMasterDetail4" || TemplateName == "VBWebCMasterDetail4")
                    //{
                    //    BFI.RefField = null;
                    //    BFI.ControlType = "TextBox";
                    //}
                    string controlid = string.Empty;
                    WebGridView.AddNewRowControlType type = WebGridView.AddNewRowControlType.TextBox;
                    idx = sb.ToString().IndexOf("</Columns>");
                    if (!string.IsNullOrEmpty(BFI.RefValNo) || BFI.RefField != null)
                    {
                        sb.Insert(idx, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                        controlid = WzdUtils.RemoveSpecialCharacters("wrv" + BlockItem.TableName + BFI.DataField + "F");
                        type = WebGridView.AddNewRowControlType.RefVal;
                    }
                    else if (BFI.ControlType == "ComboBox")
                    {
                        sb.Insert(idx, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                        controlid = WzdUtils.RemoveSpecialCharacters("wdd" + BlockItem.TableName + BFI.DataField + "F");
                        type = WebGridView.AddNewRowControlType.DropDownList;
                    }
                    else if (BFI.ControlType == "ValidateBox")
                    {
                        sb.Insert(idx, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                        controlid = WzdUtils.RemoveSpecialCharacters("wvb" + BlockItem.TableName + BFI.DataField + "F");
                        type = WebGridView.AddNewRowControlType.TextBox;
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        sb.Insert(idx, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                        controlid = WzdUtils.RemoveSpecialCharacters("cb" + BlockItem.TableName + BFI.DataField + "F");
                        type = WebGridView.AddNewRowControlType.CheckBox;
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                        {
                            sb.Insert(idx, GenTemplateFieldHTML("DateTimeBox", BlockItem, BFI));
                            controlid = WzdUtils.RemoveSpecialCharacters("wdt" + BlockItem.TableName + BFI.DataField + "F");
                            type = WebGridView.AddNewRowControlType.DateTimePicker;
                        }
                        else
                        {
                            sb.Insert(idx, "\r            <asp:BoundField DataField=\"" + BFI.DataField + "\" HeaderText=\"" + (string.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description) + "\" SortExpression=\"" + BFI.DataField + "\" />\r\n            ");
                        }
                    }
                    if (controlid.Length > 0)
                    {
                        AddNewRowControlItem item = new AddNewRowControlItem();
                        item.FieldName = BFI.DataField;
                        item.ControlID = controlid;
                        item.ControlType = type;
                        controls.Add(item);
                    }
                }
                eWebGridView1.innerHTML = sb.ToString();
                SetCollectionValue(eWebGridView1, typeof(WebGridView).GetProperty("AddNewRowControls"), controls);
            }

            WebDevPage.IHTMLElement AjaxGridView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxGridViewDetail", 0);
            if (AjaxGridView1 != null)
            {
                AjaxTools.ExtGridColumnCollection aExtGridColumnCollection = new AjaxTools.ExtGridColumnCollection(new AjaxTools.AjaxGridView(), typeof(AjaxTools.ExtColumnMatch));
                DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName];
                bool flag = true;
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    AjaxTools.ExtGridColumn extCol = new AjaxTools.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;
                    extCol.IsKeyField = IsKeyField(BFI.DataField, srcTable.PrimaryKey);
                    extCol.NewLine = flag;
                    extCol.Resizable = true;
                    extCol.TextAlign = "left";
                    extCol.Visible = true;
                    extCol.Width = 75;
                    if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                    {
                        String DataSourceID = GenWebDataSource(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "RefVal", "", true);
                        String extComboBox = GenExtComboBox(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "ExtRefVal", "", DataSourceID);
                        try
                        {
                            String str = AjaxGridView1.innerHTML;
                        }
                        catch
                        {
                            AjaxGridView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxGridViewDetail", 0);
                        }
                        extCol.EditControlId = extComboBox;
                        extCol.Editor = AjaxTools.ExtGridEditor.ComboBox;
                    }
                    else if (BFI.ControlType == "ComboBox")
                    {
                        String DataSourceID = GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", "", true);
                        String extComboBox = GenExtComboBox(BFI, BlockItem.TableName, "ExtComboBox", "", DataSourceID);
                        try
                        {
                            String str = AjaxGridView1.innerHTML;
                        }
                        catch
                        {
                            AjaxGridView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxGridViewDetail", 0);
                        }
                        extCol.EditControlId = extComboBox;
                        extCol.Editor = AjaxTools.ExtGridEditor.ComboBox;
                    }
                    this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType);

                    aExtGridColumnCollection.Add(extCol);

                    flag = !flag;

                }
                SetCollectionValue(AjaxGridView1, typeof(AjaxTools.AjaxGridView).GetProperty("Columns"), aExtGridColumnCollection);
            }

            #else
            bool isAjaxPage = false;
            if (FPage.FindControl("AjaxScriptManager1") != null)
                isAjaxPage = true;

            WebDataSource Detail = (WebDataSource)FPage.FindControl("Detail");
            Detail.DataMember = BlockItem.TableName;
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            FComponentChangeService.OnComponentChanged(Detail, null, "", "M");
            WebGridView WebGridView2 = (WebGridView)FPage.FindControl("WebGridView2");
            if (WebGridView2 == null)
            {
                WebGridView2 = (WebGridView)FPage.FindControl("wgvDetail");
            }
            if (WebGridView2 != null)
            {
                int length = WebGridView2.Columns.Count;
                for (int i = 1; i < length; i++)
                {
                    WebGridView2.Columns.RemoveAt(1);
                }
                WebGridView2.DataSourceID = "Detail";
                //WebGridView2.DataMember = BlockItem.TableName;
                //???WebGridView2.Columns.Clear();
                System.Web.UI.WebControls.BoundField aBoundField = null;
                System.Web.UI.WebControls.TemplateField aTemplateField = null;
                WebDefault aDefault = new WebDefault();
                aDefault.ID = "wd" + BlockItem.TableName;
                aDefault.DataSourceID = Detail.ID;
                aDefault.DataMember = Detail.DataMember;
                WebValidate aValidate = new WebValidate();
                aValidate.ID = "wv" + BlockItem.TableName;
                aValidate.DataSourceID = Detail.ID;
                aValidate.DataMember = Detail.DataMember;
                List<string> KeyFields = new List<string>();
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    //if (TemplateName == "WMasterDetail4")
                    //{
                    //    BFI.RefValNo = null;
                    //    BFI.ControlType = "TextBox";
                    //    BFI.DataType = null;
                    //}
                    if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                    {
                        String DataSourceID = GenWebDataSource(BFI, BlockItem.TableName, "RefVal", "");
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;

                        if (isAjaxPage)
                        {
                            if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                            {
                                aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewAjaxRefValEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, WebGridView2, FLabelList);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewAjaxRefValFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, WebGridView2, FLabelList);
                            }
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewAjaxRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, WebGridView2, FLabelList);
                        }
                        else
                        {
                            if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                            {
                                aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewRefValEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, WebGridView2);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewRefValFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, WebGridView2);
                            }
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, WebGridView2);
                        }

                        WebGridView2.Columns.Add(aTemplateField);
                    }
                    else if (BFI.ControlType == "ComboBox")
                    {
                        String DataSourceID = GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", "");
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                        {
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewComboBoxEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewComboBoxFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                        }
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewComboBoxItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                        WebGridView2.Columns.Add(aTemplateField);
                    }
                    else if (BFI.ControlType == "ValidateBox")
                    {
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                        {
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewValidateBoxEditItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewValidateBoxFooterItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                        }
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewValidateBoxItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                        WebGridView2.Columns.Add(aTemplateField);
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                        {
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewCheckBoxEditItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewCheckBoxFooterItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                        }
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewCheckBoxItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                        WebGridView2.Columns.Add(aTemplateField);
                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType.ToUpper() == "DATETIMEBOX"))
                        {
                            aTemplateField = new System.Web.UI.WebControls.TemplateField();
                            aTemplateField.HeaderText = BFI.Description;
                            aTemplateField.SortExpression = BFI.DataField;
                            if (aTemplateField.HeaderText == "")
                                aTemplateField.HeaderText = BFI.DataField;

                            if (isAjaxPage)
                            {
                                if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                                {
                                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeEditItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, WebGridView2);
                                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, WebGridView2);
                                }
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, WebGridView2);
                            }
                            else
                            {
                                if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                                {
                                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewDateTimeEditItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, WebGridView2);
                                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, WebGridView2);
                                }
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewDateTimeItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, WebGridView2);
                            }
                            WebGridView2.Columns.Add(aTemplateField);
                        }
                        else
                        {
                            if (BFI.EditMask != null && BFI.EditMask != String.Empty)
                            {
                                aTemplateField = new System.Web.UI.WebControls.TemplateField();
                                aTemplateField.HeaderText = BFI.Description;
                                aTemplateField.SortExpression = BFI.DataField;
                                if (aTemplateField.HeaderText == "")
                                    aTemplateField.HeaderText = BFI.DataField;
                                if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4")
                                {
                                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewTextBoxEditItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, WebGridView2);
                                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewTextBoxFooterItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, WebGridView2);
                                }
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewTextBoxItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, WebGridView2);
                                WebGridView2.Columns.Add(aTemplateField);
                            }
                            else
                            {
                                aBoundField = new System.Web.UI.WebControls.BoundField();
                                aBoundField.DataField = BFI.DataField;
                                aBoundField.SortExpression = BFI.DataField;
                                aBoundField.HeaderText = BFI.Description;
                                //Field.HeaderStyle.Width = BFI.Length * ColumnWidthPixel;
                                if (aBoundField.HeaderText == "")
                                    aBoundField.HeaderText = BFI.DataField;
                                WebGridView2.Columns.Add(aBoundField);
                            }
                        }
                    }
                    if (BFI.IsKey)
                        KeyFields.Add(BFI.DataField);

                    GenDefault(BFI, aDefault, aValidate);
                }
                /*
                WebGridView2.DataKeyNames = new string[KeyFields.Count];
                for (int I = 0; I < KeyFields.Count; I++)
                    WebGridView2.DataKeyNames[I] = KeyFields[I];
                 */
                if (TemplateName != "WMasterDetail4" && TemplateName != "VBWebCMasterDetail4" && TemplateName != "WMasterDetail6")
                {
                    FWebDefaultList.Add(aDefault);
                    FWebValidateList.Add(aValidate);
                }
                FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
                FComponentChangeService.OnComponentChanged(WebGridView2, null, "", "M");
            }

            Object aAjaxGridView = FPage.FindControl("AjaxGridViewDetail");
            if (aAjaxGridView != null)
            {
                bool flag = true;
                DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName];
                IList iColumns = aAjaxGridView.GetType().GetProperty("Columns").GetValue(aAjaxGridView, null) as IList;
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    Type columnsType = aAjaxGridView.GetType().GetProperty("Columns").PropertyType.GetProperties()[0].PropertyType;
                    object extCol = Activator.CreateInstance(columnsType);
                    if (BFI.CheckNull == "Y")
                        extCol.GetType().GetProperty("AllowNull").SetValue(extCol, false, null);
                    else
                        extCol.GetType().GetProperty("AllowNull").SetValue(extCol, true, null);
                    extCol.GetType().GetProperty("AllowSort").SetValue(extCol, false, null);
                    extCol.GetType().GetProperty("ColumnName").SetValue(extCol, string.Format("col{0}", BFI.DataField), null);
                    extCol.GetType().GetProperty("DataField").SetValue(extCol, BFI.DataField, null);
                    extCol.GetType().GetProperty("DefaultValue").SetValue(extCol, BFI.DefaultValue, null);
                    extCol.GetType().GetProperty("ExpandColumn").SetValue(extCol, true, null);
                    if (BFI.Description != null && BFI.Description != String.Empty)
                        extCol.GetType().GetProperty("HeaderText").SetValue(extCol, BFI.Description, null);
                    else
                        extCol.GetType().GetProperty("HeaderText").SetValue(extCol, BFI.DataField, null);
                    extCol.GetType().GetProperty("IsKeyField").SetValue(extCol, IsKeyField(BFI.DataField, srcTable.PrimaryKey), null);
                    extCol.GetType().GetProperty("NewLine").SetValue(extCol, flag, null);
                    extCol.GetType().GetProperty("Resizable").SetValue(extCol, true, null);
                    extCol.GetType().GetProperty("TextAlign").SetValue(extCol, "left", null);
                    extCol.GetType().GetProperty("Visible").SetValue(extCol, true, null);
                    extCol.GetType().GetProperty("Width").SetValue(extCol, 75, null);
                    if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                    {
                        String DataSourceID = GenWebDataSource(BFI, BlockItem.TableName, "RefVal", "", true);
                        String extComboBox = GenExtComboBox(BFI, BlockItem.TableName, "ExtRefVal", "", DataSourceID);
                        extCol.GetType().GetProperty("EditControlId").SetValue(extCol, extComboBox, null);
                        extCol.GetType().GetProperty("Editor").SetValue(extCol, extCol.GetType().GetProperty("Editor").PropertyType.GetField("ComboBox").GetValue(extCol), null);
                    }
                    else if (BFI.ControlType == "ComboBox")
                    {
                        String DataSourceID = GenWebDataSource(BFI, BlockItem.TableName, "ComboBox", "", true);
                        String extComboBox = GenExtComboBox(BFI, BlockItem.TableName, "ExtComboBox", "", DataSourceID);
                        extCol.GetType().GetProperty("EditControlId").SetValue(extCol, extComboBox, null);
                        extCol.GetType().GetProperty("Editor").SetValue(extCol, extCol.GetType().GetProperty("Editor").PropertyType.GetField("ComboBox").GetValue(extCol), null);
                    }
                    this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType);
                    iColumns.Add(extCol);
                    flag = !flag;
                }
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(aAjaxGridView, null, "", "M");
            }
            #endif
        }
예제 #9
0
        private void GenDetailBlock_2()
        {
            MWizard.TBlockItem BlockItem = null;
            foreach (TBlockItem B in FClientData.Blocks)
            {
                if (B.wDataSource == null)
                {
                    BlockItem = B;
                    break;
                }
            }

            #if VS90
            object oDetail = FDesignerDocument.webControls.item("Detail", 0);

            WebDevPage.IHTMLElement eDetail = null;

            if (oDetail == null || !(oDetail is WebDevPage.IHTMLElement))
                return;
            eDetail = (WebDevPage.IHTMLElement)oDetail;
            eDetail.setAttribute("DataMember", BlockItem.TableName, 0);

            WebDevPage.IHTMLElement FormView = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("wfvDetail", 0);
            if (FormView != null)
            {
                WebDefault Default = new WebDefault();
                Default.ID = "wd" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName);
                Default.DataSourceID = eDetail.getAttribute("ID", 0).ToString();
                Default.DataMember = BlockItem.TableName;

                WebValidate Validate = new WebValidate();
                Validate.ID = "wv" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName);
                Validate.DataSourceID = eDetail.getAttribute("ID", 0).ToString();
                Validate.DataMember = BlockItem.TableName;

                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 Page = FDesignerDocument.pageContentElement;
                InsertControl(Page, Default);
                InsertControl(Page, Validate);

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

                FormView = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("wfvDetail", 0);
                RefreshFormView(FormView, BlockItem);
            }
            #else
            bool isAjaxPage = false;
            if (FPage.FindControl("AjaxScriptManager1") != null)
                isAjaxPage = true;

            WebDataSource Detail = (WebDataSource)FPage.FindControl("Detail");
            Detail.DataMember = BlockItem.TableName;
            WebFormView WebFormView2 = (WebFormView)FPage.FindControl("wfvDetail");
            if (WebFormView2 == null)
            {
                return;
            }
            //WebFormView2.DataMember = BlockItem.TableName;

            WebDefault aDefault = new WebDefault();
            aDefault.ID = "wd" + BlockItem.TableName;
            aDefault.DataSourceID = Detail.ID;
            aDefault.DataMember = Detail.DataMember;
            WebValidate aValidate = (WebValidate)FPage.FindControl("WebDetailValidate");
            if (aValidate == null)
            {
                aValidate = new WebValidate();
                aValidate.ID = "wv" + BlockItem.TableName;
            }
            aValidate.DataSourceID = Detail.ID;
            aValidate.DataMember = Detail.DataMember;

            IDbConnection conn = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, false);
            InfoCommand aInfoCommand = new InfoCommand(FClientData.DatabaseType);
            aInfoCommand.Connection = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, true);
            //aInfoCommand.Connection = conn;
            String OWNER = String.Empty, SS = this.FClientData.RealTableName, TableName = String.Empty;
            if (SS.Contains("."))
            {
                OWNER = WzdUtils.GetToken(ref SS, new char[] { '.' });
                TableName = SS;
            }
            aInfoCommand.CommandText = "Select * from COLDEF where TABLE_NAME='" + TableName + "' OR TABLE_NAME='" + OWNER + "." + TableName + "'";
            IDbDataAdapter DA = DBUtils.CreateDbDataAdapter(aInfoCommand);
            DataSet dsColdef = new DataSet();
            WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, dsColdef, this.FClientData.TableName);
            FormViewDesigner aDesigner = FDesignerHost.GetDesigner(WebFormView2) as FormViewDesigner;
            Boolean Done = false;
            WebDataSourceDesigner aWebDataSourceDesigner = FDesignerHost.GetDesigner(Detail) as WebDataSourceDesigner;
            if (aWebDataSourceDesigner != null)
                aWebDataSourceDesigner.RefreshSchema(true);

            foreach (TemplateGroup tempGroup in aDesigner.TemplateGroups)
            {
                foreach (TemplateDefinition tempDefin in tempGroup.Templates)
                {
                    if (tempDefin.Name == "EditItemTemplate" || tempDefin.Name == "InsertItemTemplate" || tempDefin.Name == "ItemTemplate")
                    {
                        StringBuilder builder = new StringBuilder();
                        string content = tempDefin.Content;
                        if (content == null || content.Length == 0)
                            continue;

                        string[] ctrlTexts = content.Split("\r\n".ToCharArray());
                        int i = 0;
                        int j = 0;
                        int m = WebFormView2.LayOutColNum * 2;

                        List<string> lists = new List<string>();
                        String ExtraName = "";

                        foreach (TBlockFieldItem aFieldItem in BlockItem.BlockFieldItems)
                        {
                            if (!Done)
                            {
                                GenDefault(aFieldItem, aDefault, aValidate);
                            }

                            lists.Add(aFieldItem.DataField);
                            if ((aFieldItem.RefValNo != null && aFieldItem.RefValNo != "") || aFieldItem.RefField != null)
                            {
                                String DataSourceID = GenWebDataSource(aFieldItem, BlockItem.TableName, "RefVal", "");
                                switch (tempDefin.Name)
                                {
                                    case "EditItemTemplate":
                                        ExtraName = "E";
                                        break;
                                    case "InsertItemTemplate":
                                        ExtraName = "I";
                                        if (aFieldItem.DefaultValue != null && aFieldItem.DefaultValue != "")
                                        {
                                            FormViewField aViewField = new FormViewField();
                                            aViewField.ControlID = "wrv2" + BlockItem.TableName + aFieldItem.DataField + ExtraName;
                                            aViewField.FieldName = aFieldItem.DataField;
                                            WebFormView2.Fields.Add(aViewField);
                                        }
                                        break;
                                    case "ItemTemplate":
                                        ExtraName = "";
                                        break;
                                }

                                DataSet aDataSet = new DataSet();
                                StringBuilder RefColumns = new StringBuilder("<Columns>");
                                aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", aFieldItem.RefValNo);
                                WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, aDataSet, aFieldItem.RefValNo);
                                if (aDataSet != null && aDataSet.Tables.Count > 0 && aDataSet.Tables[0].Rows.Count > 0)
                                {
                                    foreach (DataRow DR in aDataSet.Tables[0].Rows)
                                    {
                                        RefColumns.Append(Environment.NewLine);
                                        RefColumns.Append("<InfoLight:WebRefColumn ColumnName=\"" + DR["FIELD_NAME"].ToString() + "\" HeadText=\"" + DR["HEADER_TEXT"].ToString() + "\" Width=\"100\" />");
                                    }
                                    RefColumns.Append(Environment.NewLine);
                                    RefColumns.Append("</Columns>");
                                }
                                else
                                {
                                    RefColumns = new StringBuilder("");
                                }

                                if (tempDefin.Name == "ItemTemplate")
                                {
                                    String FormatStyle = FormatEditMask(aFieldItem.EditMask);

                                    String S6 = String.Empty;
                                    if (isAjaxPage)
                                    {
                                        S6 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                    }
                                    else
                                    {
                                        S6 = String.Format("<InfoLight:WebRefVal ID=\"{0}\" runat=\"server\" BindingValue='<%# Bind(\"{1}\"{5}) %>' " +
                                            "ButtonImageUrl=\"../Image/refval/RefVal.gif\" DataBindingField=\"{1}\" DataSourceID=\"{2}\" " +
                                            "DataTextField=\"{3}\" DataValueField=\"{4}\" ReadOnly=\"True\" ResxDataSet=\"\" " +
                                            "ResxFilePath=\"\" UseButtonImage=\"True\" Width=\"130px\" BackColor=\"Transparent\" BorderStyle=\"None\"> " +
                                            RefColumns.ToString() +
                                            "</InfoLight:WebRefVal>",
                                            "wrv2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.DataField,
                                            DataSourceID,
                                            FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                            FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                            FormatStyle
                                            );
                                    }
                                    lists.Add(S6);
                                }
                                else
                                {
                                    String FormatStyle = FormatEditMask(aFieldItem.EditMask);
                                    String S1 = String.Empty;
                                    if (isAjaxPage)
                                    {
                                        S1 = String.Format("<AjaxTools:AjaxRefVal ID=\"{0}\" runat=\"server\" BindingValue='<%# Bind(\"{1}\"{5}) %>' " +
                                                            "DataSourceID=\"{2}\" " +
                                                            "DataTextField=\"{3}\" DataValueField=\"{4}\" ResxDataSet=\"\">" +
                                                             RefColumns.ToString() +
                                                            "</AjaxTools:AjaxRefVal>",
                                                            "arv2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                            aFieldItem.DataField,
                                                            DataSourceID,
                                                            FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                                            FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                                            FormatStyle
                                                            );
                                    }
                                    else
                                    {
                                        S1 = String.Format("<InfoLight:WebRefVal ID=\"{0}\" runat=\"server\" BindingValue='<%# Bind(\"{1}\"{5}) %>' " +
                                            "ButtonImageUrl=\"../Image/refval/RefVal.gif\" DataBindingField=\"{1}\" DataSourceID=\"{2}\" " +
                                            "DataTextField=\"{3}\" DataValueField=\"{4}\" ReadOnly=\"False\" ResxDataSet=\"\" " +
                                            "ResxFilePath=\"\" UseButtonImage=\"True\"> " +
                                             RefColumns.ToString() +
                                            "</InfoLight:WebRefVal>",
                                            "wrv2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.DataField,
                                            DataSourceID,
                                            FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                            FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                            FormatStyle
                                            );
                                    }
                                    lists.Add(S1);
                                }
                            }
                            else if (aFieldItem.ControlType == "ComboBox")
                            {
                                String FormatStyle = FormatEditMask(aFieldItem.EditMask);
                                String DataSourceID = GenWebDataSource(aFieldItem, aFieldItem.ComboEntityName, "ComboBox", "");
                                String S5 = "";
                                switch (tempDefin.Name)
                                {
                                    case "EditItemTemplate":
                                        ExtraName = "E";
                                        S5 = String.Format("<InfoLight:WebDropDownList id=\"{0}\" runat=\"server\" DataMember=\"{1}\" DataSourceID=\"{2}\" __designer:wfdid=\"w3\" DataTextField=\"{3}\" Filter DataValueField=\"{4}\" AutoInsertEmptyData=\"False\" SelectedValue='<%# Bind(\"{5}\"{6})%>'  Width=\"130px\"></InfoLight:WebDropDownList>",
                                            "wdd2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.ComboEntityName,
                                            DataSourceID,
                                            aFieldItem.ComboTextField,
                                            aFieldItem.ComboValueField,
                                            aFieldItem.DataField,
                                            FormatStyle);
                                        break;
                                    case "InsertItemTemplate":
                                        ExtraName = "I";
                                        S5 = String.Format("<InfoLight:WebDropDownList id=\"{0}\" runat=\"server\" DataMember=\"{1}\" DataSourceID=\"{2}\" __designer:wfdid=\"w3\" DataTextField=\"{3}\" Filter DataValueField=\"{4}\" AutoInsertEmptyData=\"False\" SelectedValue='<%# Bind(\"{5}\"{6}) %>'  Width=\"130px\"></InfoLight:WebDropDownList>",
                                            "wdd2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.ComboEntityName,
                                            DataSourceID,
                                            aFieldItem.ComboTextField,
                                            aFieldItem.ComboValueField,
                                            aFieldItem.DataField,
                                            FormatStyle);
                                        if (aFieldItem.DefaultValue != null && aFieldItem.DefaultValue != "")
                                        {
                                            FormViewField aViewField = new FormViewField();
                                            aViewField.ControlID = "wdd2" + BlockItem.TableName + aFieldItem.DataField + ExtraName;
                                            aViewField.FieldName = aFieldItem.DataField;
                                            WebFormView2.Fields.Add(aViewField);
                                        }
                                        break;
                                    case "ItemTemplate":
                                        ExtraName = "";
                                        S5 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l2" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                        break;
                                }
                                lists.Add(S5);
                            }
                            else if (aFieldItem.ControlType == "ValidateBox")
                            {
                                String FormatStyle = FormatEditMask(aFieldItem.EditMask);
                                String S6 = "";
                                switch (tempDefin.Name)
                                {
                                    case "EditItemTemplate":
                                        ExtraName = "E";
                                        S6 = String.Format("<InfoLight:WebValidateBox ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{3}) %>' ValidateField=\"{1}\" WebValidateID=\"{2}\" MaxLength=\"{4}\"></InfoLight:WebValidateBox></td>",
                                            "wvb2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.DataField,
                                            aValidate.ID,
                                            FormatStyle,
                                            aFieldItem.Length);
                                        break;
                                    case "InsertItemTemplate":
                                        ExtraName = "I";
                                        if (aFieldItem.DefaultValue != null && aFieldItem.DefaultValue != "")
                                        {
                                            FormViewField aViewField = new FormViewField();
                                            aViewField.ControlID = "wdd2" + BlockItem.TableName + aFieldItem.DataField + ExtraName;
                                            aViewField.FieldName = aFieldItem.DataField;
                                            WebFormView2.Fields.Add(aViewField);
                                        }
                                        S6 = String.Format("<InfoLight:WebValidateBox ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{3}) %>' ValidateField=\"{1}\" WebValidateID=\"{2}\" MaxLength=\"{4}\"></InfoLight:WebValidateBox></td>",
                                            "wvb2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.DataField,
                                            aValidate.ID,
                                            FormatStyle,
                                            aFieldItem.Length);
                                        break;
                                    case "ItemTemplate":
                                        ExtraName = "";
                                        S6 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l2" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                        break;
                                }
                                lists.Add(S6);
                            }
                            else if (aFieldItem.ControlType == "CheckBox")
                            {
                                String FormatStyle = FormatEditMask(aFieldItem.EditMask);
                                String S6 = "";
                                switch (tempDefin.Name)
                                {
                                    case "EditItemTemplate":
                                        ExtraName = "E";
                                        S6 = String.Format("<asp:CheckBox ID=\"{0}\" runat=\"server\" Checked='<%# Bind(\"{1}\"{2}) %>'></asp:CheckBox></td>",
                                            "cb2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.DataField,
                                            FormatStyle);
                                        break;
                                    case "InsertItemTemplate":
                                        ExtraName = "I";
                                        S6 = String.Format("<asp:CheckBox ID=\"{0}\" runat=\"server\" Checked='<%# Bind(\"{1}\"{2}) %>'></asp:CheckBox></td>",
                                            "wvb2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                            aFieldItem.DataField,
                                            FormatStyle);
                                        break;
                                    case "ItemTemplate":
                                        ExtraName = "";
                                        S6 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l2" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                        break;
                                }
                                lists.Add(S6);
                            }
                            else
                            {
                                if (aFieldItem.DataType == typeof(DateTime) || (aFieldItem.ControlType != null && aFieldItem.ControlType.ToUpper() == "DATETIMEBOX"))
                                {
                                    String DataTimeType = "";
                                    if (aFieldItem.EditMask == "ShortDate")
                                        DataTimeType = "ShortDate";
                                    else if (aFieldItem.EditMask == "LongDate")
                                        DataTimeType = "ShortDate";
                                    else
                                        DataTimeType = "None";

                                    String FormatStyle = FormatEditMask(aFieldItem.EditMask);
                                    String S4 = "";
                                    if (isAjaxPage)
                                    {
                                        switch (tempDefin.Name)
                                        {
                                            case "EditItemTemplate":
                                                ExtraName = "E";
                                                if (aFieldItem.DataType == typeof(DateTime))
                                                    S4 = String.Format("<AjaxTools:AjaxDateTimePicker id=\"{0}\" runat=\"server\" Width=\"130px\" Text='<%# Bind(\"{1}\"{2}) %>' DateFormat=\"" + DataTimeType + "\" DateTimeType=\"DateTime\"></AjaxTools:AjaxDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);
                                                else if (aFieldItem.DataType == typeof(String) && (aFieldItem.ControlType != null && aFieldItem.ControlType.ToUpper() == "DATETIMEBOX"))
                                                    S4 = String.Format("<AjaxTools:AjaxDateTimePicker id=\"{0}\" runat=\"server\" Width=\"130px\" DateString='<%# Bind(\"{1}\"{2}) %>' DateFormat=\"" + DataTimeType + "\" DateTimeType=\"Varchar\"></AjaxTools:AjaxDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);
                                                break;
                                            case "InsertItemTemplate":
                                                ExtraName = "I";
                                                if (aFieldItem.DataType == typeof(DateTime))
                                                    S4 = String.Format("<AjaxTools:AjaxDateTimePicker id=\"{0}\" runat=\"server\" Width=\"130px\" Text='<%# Bind(\"{1}\"{2}) %>' DateFormat=\"" + DataTimeType + "\" DateTimeType=\"DateTime\"></AjaxTools:AjaxDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);
                                                else if (aFieldItem.DataType == typeof(String) && (aFieldItem.ControlType != null && aFieldItem.ControlType.ToUpper() == "DATETIMEBOX"))
                                                    S4 = String.Format("<AjaxTools:AjaxDateTimePicker id=\"{0}\" runat=\"server\" Width=\"130px\" DateString='<%# Bind(\"{1}\"{2}) %>' DateFormat=\"" + DataTimeType + "\" DateTimeType=\"Varchar\"></AjaxTools:AjaxDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);
                                                break;
                                            case "ItemTemplate":
                                                ExtraName = "";
                                                S4 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                                break;
                                        }
                                    }
                                    else
                                    {
                                        switch (tempDefin.Name)
                                        {
                                            case "EditItemTemplate":
                                                ExtraName = "E";
                                                if (aFieldItem.DataType == typeof(DateTime))
                                                    S4 = String.Format("<InfoLight:WebDateTimePicker id=\"{0}\" runat=\"server\" Width=\"100px\" Text='<%# Bind(\"{1}\"{2}) %>' __designer:wfdid=\"w14\" UseButtonImage=\"True\" DateFormat=\"" + DataTimeType + "\" DateTimeType=\"DateTime\"></InfoLight:WebDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);
                                                else if (aFieldItem.DataType == typeof(String) && (aFieldItem.ControlType != null && aFieldItem.ControlType.ToUpper() == "DATETIMEBOX"))
                                                    S4 = String.Format("<InfoLight:WebDateTimePicker id=\"{0}\" runat=\"server\" Width=\"100px\" DateString='<%# Bind(\"{1}\"{2}) %>' __designer:wfdid=\"w14\" UseButtonImage=\"True\" DateFormat=\"" + DataTimeType + "\" DateTimeType=\"Varchar\"></InfoLight:WebDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);
                                                break;
                                            case "InsertItemTemplate":
                                                ExtraName = "I";
                                                if (aFieldItem.DataType == typeof(DateTime))
                                                    S4 = String.Format("<InfoLight:WebDateTimePicker id=\"{0}\" runat=\"server\" Width=\"100px\" Text='<%# Bind(\"{1}\"{2}) %>' __designer:wfdid=\"w14\" UseButtonImage=\"True\" DateFormat=\"" + DataTimeType + "\" DateTimeType=\"DateTime\"></InfoLight:WebDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);
                                                else if (aFieldItem.DataType == typeof(String) && (aFieldItem.ControlType != null && aFieldItem.ControlType.ToUpper() == "DATETIMEBOX"))
                                                    S4 = String.Format("<InfoLight:WebDateTimePicker id=\"{0}\" runat=\"server\" Width=\"100px\" DateString='<%# Bind(\"{1}\"{2}) %>' __designer:wfdid=\"w14\" UseButtonImage=\"True\" DateFormat=\"" + DataTimeType + "\" DateTimeType=\"Varchar\"></InfoLight:WebDateTimePicker>",
                                                        "wdtp2" + BlockItem.TableName + aFieldItem.DataField + ExtraName,
                                                        aFieldItem.DataField,
                                                        FormatStyle);

                                                break;
                                            case "ItemTemplate":
                                                ExtraName = "";
                                                S4 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l2" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                                break;
                                        }
                                    }
                                    lists.Add(S4);
                                }
                                else
                                {
                                    String FormatStyle = FormatEditMask(aFieldItem.EditMask);

                                    if (tempDefin.Name == "ItemTemplate")
                                    {
                                        String S3 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l2" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                        lists.Add(S3);
                                    }
                                    else
                                    {
                                        if (tempDefin.Name == "InsertItemTemplate")
                                        {
                                            //if (aFieldItem.DefaultValue != null && aFieldItem.DefaultValue != "")
                                            //{
                                            FormViewField aViewField = new FormViewField();
                                            aViewField.ControlID = "tb2" + aFieldItem.DataField;
                                            aViewField.FieldName = aFieldItem.DataField;
                                            WebFormView2.Fields.Add(aViewField);
                                            //}
                                        }
                                        String S4 = String.Format("<asp:TextBox ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>' MaxLength=\"{3}\"></asp:TextBox>",
                                            "tb2" + aFieldItem.DataField,
                                            aFieldItem.DataField,
                                            FormatStyle,
                                            aFieldItem.Length);
                                        lists.Add(S4);
                                    }
                                }
                            }
                        }
                        Done = true;

                        j = j * 2;

                        if (m > 0)
                        {
                            builder.Append("<table>");
                        }

                        foreach (string ctrlText in lists.ToArray())
                        {
                            if (ctrlText == null || ctrlText.Length == 0)
                                continue;

                            if (m > 0)
                            {
                                if (i % m == 0)
                                {
                                    builder.Append("<tr>");
                                }

                                builder.Append("<td>");
                            }
                            // add dd

                            string ddText = "";
                            if (tempDefin.Name != "ItemTemplate")
                            {
                                ddText = GetDDText(ctrlText, BlockItem, tempDefin.Name);
                            }
                            else
                            {
                                ddText = GetDDText(ctrlText, BlockItem, tempDefin.Name);
                            }
                            builder.Append(ddText);
                            builder.Append("\r\n");

                            if (m > 0)
                            {
                                builder.Append("</td>");

                                if (i % m == m - 1)
                                {
                                    builder.Append("</tr>");
                                }
                            }
                            i++;
                        }

                        if (m > 0)
                        {
                            if (i % m != 0)
                            {
                                int n = m - (i % m);
                                int q = 0;
                                while (q < n)
                                {
                                    builder.Append("<td></td>");
                                    q++;
                                }
                                builder.Append("</tr>");
                            }
                            builder.Append("</table>");
                        }

                        tempDefin.Content = builder.ToString();
                    }
                }
            }

            if (!FWebDefaultList.Contains(aDefault))
                FWebDefaultList.Add(aDefault);
            //FWebValidateList.Add(aValidate);
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            NotifyRefresh(200);
            FComponentChangeService.OnComponentChanged(WebFormView2, null, "", "M");
            FComponentChangeService.OnComponentChanged(Detail, null, "", "M");
            FComponentChangeService.OnComponentChanged(aValidate, null, "", "M");
            #endif
        }
예제 #10
0
        /// <summary>
        /// 加入查询
        /// </summary>
        /// <param name="fieldItem">blockfielditem</param>
        /// <param name="queryFields">Navigator的查询集合</param>
        /// <param name="queryColumns">ClientQuery的查询集合</param>
        /// <param name="tableName">tablename</param>
        private void GenQuery(TBlockFieldItem fieldItem, WebQueryFiledsCollection queryFields, WebQueryColumnsCollection queryColumns
            , string tableName)
        {
            if (string.Compare(fieldItem.QueryMode, "normal", true) == 0
                  || string.Compare(fieldItem.QueryMode, "range", true) == 0)
            {
                if (queryFields != null)
                {
                    WebQueryField field = new WebQueryField();
                    field.FieldName = fieldItem.DataField;
                    field.Caption = string.IsNullOrEmpty(fieldItem.Description) ? fieldItem.DataField : fieldItem.Description;

                    if (string.Compare(fieldItem.QueryMode, "normal", true) == 0)
                    {
                        field.Condition = (fieldItem.DataType == typeof(string)) ? "%" : "=";
                    }
                    else
                    {
                        WebQueryField fieldrev = new WebQueryField();
                        fieldrev.FieldName = field.FieldName;
                        fieldrev.Caption = field.Caption;
                        fieldrev.RefVal = field.RefVal;
                        fieldrev.Condition = ">=";
                        fieldrev.Mode = InitQueryField(fieldItem, fieldrev);
                        queryFields.Add(fieldrev);
                        field.Condition = "<=";
                    }

                    field.Mode = InitQueryField(fieldItem, field);
                    queryFields.Add(field);
                }
                if (queryColumns != null)
                {
                    WebQueryColumns column = new WebQueryColumns();
                    column.Column = fieldItem.DataField;
                    column.Caption = string.IsNullOrEmpty(fieldItem.Description) ? fieldItem.DataField : fieldItem.Description;
                    if (string.Compare(fieldItem.ControlType, "textbox", true) == 0)
                    {
                        column.ColumnType = "ClientQueryTextBoxColumn";
                    }
                    else if (string.Compare(fieldItem.ControlType, "combobox", true) == 0)
                    {
                        column.ColumnType = "ClientQueryComboBoxColumn";
                        column.WebRefVal = string.Format("wrv{0}{1}QF", tableName, fieldItem.DataField);
                    }
                    else if (string.Compare(fieldItem.ControlType, "refvalbox", true) == 0)
                    {
                        if (fieldItem.RefValNo == String.Empty)
                            column.ColumnType = "ClientQueryTextBoxColumn";
                        else
                        {
                            column.ColumnType = "ClientQueryRefValColumn";
                            column.WebRefVal = string.Format("wrv{0}{1}QF", tableName, fieldItem.DataField);
                        }
                    }
                    else if (string.Compare(fieldItem.ControlType, "datetimebox", true) == 0)
                    {
                        column.ColumnType = "ClientQueryCalendarColumn";
                    }
                    if (string.Compare(fieldItem.QueryMode, "normal", true) == 0)
                    {
                        column.Operator = (fieldItem.DataType == typeof(string)) ? "%" : "=";
                    }
                    else
                    {
                        WebQueryColumns columnrev = new WebQueryColumns();
                        columnrev.Column = column.Column;
                        columnrev.Caption = column.Caption;
                        columnrev.ColumnType = column.ColumnType;
                        columnrev.WebRefVal = column.WebRefVal;
                        columnrev.Operator = ">=";
                        queryColumns.Add(columnrev);
                        column.Operator = "<=";
                    }
                    queryColumns.Add(column);
                }
            }
        }
예제 #11
0
        private void GenMainBlockControl_3(TBlockItem blockItem, String formViewName)
        {
            WebDevPage.IHTMLElement Master = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("Master", 0);
            string mastertablename = string.Empty;
            if (Master != null)
            {
                mastertablename = FClientData.ProviderName.Split('.')[1];
                Master.setAttribute("DataMember", mastertablename, 0);
                if (formViewName == "wfvMaster")
                {
                    Master.setAttribute("AutoApply", "true", 0);
                }
            }
            blockItem.wDataSource = new WebDataSource();
            WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement;

            WebDefault Default = new WebDefault();
            Default.ID = "wd" + blockItem.TableName;
            Default.DataSourceID = Master.getAttribute("ID", 0).ToString();
            Default.DataMember = mastertablename;

            WebValidate Validate = new WebValidate();
            Validate.ID = "wv" + blockItem.TableName;
            Validate.DataSourceID = Master.getAttribute("ID", 0).ToString();
            Validate.DataMember = mastertablename;

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

            InsertControl(Page, Default);
            InsertControl(Page, Validate);

            foreach (TBlockFieldItem fielditem in blockItem.BlockFieldItems)
            {
                foreach (WebQueryColumns wqc in QueryColumns)
                {
                    if (wqc.ColumnType == "ClientQueryRefValColumn" && wqc.Column == fielditem.DataField)
                    {
                        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);
            }
            //刷不了Schema所以直接用写的

            WebDevPage.IHTMLElement FormView = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item(formViewName, 0);
            if (FormView != null)
            {
                RefreshFormView(FormView, blockItem);
            }
            WebDevPage.IHTMLElement AjaxFromView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxFormView1", 0);
            if (AjaxFromView1 != null)
            {
                AjaxTools.AjaxFormFieldCollection aAjaxFormFieldCollection = new AjaxTools.AjaxFormFieldCollection(new AjaxTools.AjaxFormView(), typeof(AjaxTools.AjaxFormField));
                DataTable srcTable = FWizardDataSet.RealDataSet.Tables[blockItem.TableName];
                bool flag = true;
                foreach (TBlockFieldItem BFI in blockItem.BlockFieldItems)
                {
                    AjaxTools.AjaxFormField extCol = new AjaxTools.AjaxFormField();
                    if (BFI.CheckNull == "Y")
                        extCol.AllowNull = false;
                    else
                        extCol.AllowNull = true;
                    if (BFI.Description != null && BFI.Description != String.Empty)
                        extCol.Caption = BFI.Description;
                    else
                        extCol.Caption = BFI.DataField;
                    extCol.DataField = BFI.DataField;
                    extCol.DefaultValue = BFI.DefaultValue;
                    extCol.EditControlId = null;
                    extCol.FieldControlId = string.Format("ctrl{0}", BFI.DataField);
                    extCol.IsKeyField = IsKeyField(BFI.DataField, srcTable.PrimaryKey);
                    extCol.NewLine = flag;
                    //extCol.Resizable = true;
                    //extCol.TextAlign = "left";
                    //extCol.Visible = true;
                    extCol.Width = 140;
                    if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                    {
                        String DataSourceID = GenWebDataSource(BFI, blockItem.TableName, "RefVal", "", true);
                        String extComboBox = GenExtComboBox(BFI, blockItem.TableName, "ExtRefVal", "", DataSourceID);
                        try
                        {
                            String str = AjaxFromView1.innerHTML;
                        }
                        catch
                        {
                            AjaxFromView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxFormView1", 0);
                        }
                        extCol.EditControlId = extComboBox;
                        extCol.Editor = AjaxTools.ExtGridEditor.ComboBox;
                    }
                    else if (BFI.ControlType == "ComboBox")
                    {
                        String DataSourceID = GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", "", true);
                        String extComboBox = GenExtComboBox(BFI, blockItem.TableName, "ExtComboBox", "", DataSourceID);
                        try
                        {
                            String str = AjaxFromView1.innerHTML;
                        }
                        catch
                        {
                            AjaxFromView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxFormView1", 0);
                        } extCol.EditControlId = extComboBox;
                        extCol.Editor = AjaxTools.ExtGridEditor.ComboBox;
                    }
                    this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType);
                    aAjaxFormFieldCollection.Add(extCol);
                    flag = !flag;
                }

                SetCollectionValue(AjaxFromView1, typeof(AjaxTools.AjaxFormView).GetProperty("Fields"), aAjaxFormFieldCollection);
            }
        }
예제 #12
0
        private void GenMainBlockControl_2(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;
            BlockItem.wDataSource = new WebDataSource();

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

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

            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 Page = FDesignerDocument.pageContentElement;
            InsertControl(Page, Default);
            InsertControl(Page, Validate);
            //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;
            //        }
            //        else if (wqc.ColumnType == "ClientQueryComboBoxColumn" && wqc.Column == fielditem.DataField
            //            && !String.IsNullOrEmpty(fielditem.ComboTextField) && !String.IsNullOrEmpty(fielditem.ComboValueField))
            //        {
            //            WebRefVal aWebRefVal = new WebRefVal();
            //            aWebRefVal.ID = wqc.WebRefVal;
            //            aWebRefVal.DataTextField = fielditem.ComboTextField;
            //            aWebRefVal.DataValueField = fielditem.ComboValueField;
            //            aWebRefVal.DataSourceID = String.Format("wds{0}{1}", fielditem.ComboEntityName, 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("gridMaster", 0);
            eWebGridView1 = (WebDevPage.IHTMLElement)oWebGridView1;
            if (eWebGridView1 != null)
            {
                //eWebGridView1.setAttribute("DataMember", FClientData.TableName, 0);

                //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
                StringBuilder sb = new StringBuilder(eWebGridView1.innerHTML);
                int idx = eWebGridView1.innerHTML.IndexOf("</Columns>");
                List<string> KeyFields = new List<string>();
                int index = 1;
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    if (BFI.IsKey)
                        KeyFields.Add(BFI.DataField);
                    idx = sb.ToString().LastIndexOf("</Columns>");
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                    /*if (!string.IsNullOrEmpty(BFI.RefValNo) || BFI.RefField != null)
                    {
                        sb.Insert(idx, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                    }
                    else*/
                    if (BFI.ControlType == "ComboBox")
                    {
                        //GridViewDataComboBoxColumn
                        String sComboBox = String.Format("<dx:GridViewDataComboBoxColumn FieldName=\"{0}\" Caption=\"{1}\" VisibleIndex=\"{2}\" >\r\n", BFI.DataField, sHeaderText, index);
                        sComboBox += String.Format("<PropertiesComboBox DataSourceID=\"{0}\" ValueField=\"{1}\"", GenWebDataSource(BFI, BFI.ComboRemoteName, "ComboBox", ""), BFI.ComboValueField);
                        sComboBox += "TextFormatString=\"{0}\" >\r\n";
                        sComboBox += "<Columns>\r\n";
                        sComboBox += String.Format("<dx:ListBoxColumn Caption=\"{0}\" FieldName=\"{1}\" />", BFI.ComboTextFieldCaption, BFI.ComboTextField);
                        if (BFI.ComboTextField != BFI.ComboValueField)
                        {
                            sComboBox += String.Format("<dx:ListBoxColumn Caption=\"{0}\" FieldName=\"{1}\" />", BFI.ComboValueFieldCaption, BFI.ComboValueField);
                        }
                        sComboBox += "</Columns>\r\n";
                        sComboBox += "</PropertiesComboBox>\r\n";
                        sComboBox += "</dx:GridViewDataComboBoxColumn> \r\n";
                        sb.Insert(idx, sComboBox);
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {

                    }
                    else
                    {
                        if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                        {
                            //GridViewDataDateColumn
                            sb.Insert(idx, String.Format("<dx:GridViewDataDateColumn FieldName=\"{0}\" Caption=\"{1}\" VisibleIndex=\"{2}\" />", BFI.DataField, sHeaderText, index));
                        }
                        else
                        {
                            //GridViewDataTextColumn>
                            sb.Insert(idx, String.Format("<dx:GridViewDataTextColumn FieldName=\"{0}\" Caption=\"{1}\" VisibleIndex=\"{2}\" />", BFI.DataField, sHeaderText, index));
                        }
                    }
                    index++;
                }

                //<Templates>
                //    <DetailRow>
                //        <dx:ASPxGridView ID="gridDetail" runat="server" DataSourceID="Detail" KeyFieldName="DetailKeys" Width="100%" OnBeforePerformDataSelect="detailGrid_DataSelect">
                //            <Columns>
                //                <dx:GridViewCommandColumn VisibleIndex="0">
                //                    <EditButton Visible="True">
                //                    </EditButton>
                //                    <NewButton Visible="True">
                //                    </NewButton>
                //                    <DeleteButton Visible="True">
                //                    </DeleteButton>
                //                </dx:GridViewCommandColumn>
                //            </Columns>
                //            <Settings ShowFooter="True" />
                //        </dx:ASPxGridView>
                //    </DetailRow>
                //</Templates>

                BlockItem = null;
                foreach (TBlockItem B in FClientData.Blocks)
                {
                    if (B.wDataSource == null)
                    {
                        BlockItem = B;
                        break;
                    }
                }
                if (BlockItem != null)
                {
                    List<string> DetailKeyFields = new List<string>();
                    InsertIntoGridView(sb, "<Templates>\r\n");
                    InsertIntoGridView(sb, "<DetailRow>\r\n");
                    foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                    {
                        if (BFI.IsKey)
                            DetailKeyFields.Add(BFI.DataField);
                    }
                    String sDetailKeyFieldName = String.Empty;
                    foreach (var item in DetailKeyFields)
                    {
                        sDetailKeyFieldName += item + ";";
                    }
                    InsertIntoGridView(sb, String.Format("<dx:ASPxGridView ID=\"gridDetail\" runat=\"server\" DataSourceID=\"Detail\" KeyFieldName=\"{0}\" Width=\"100%\" OnBeforePerformDataSelect=\"detailGrid_DataSelect\" OnInitNewRow=\"gridDetail_InitNewRow\" OnRowValidating=\"gridDetail_RowValidating\">\r\n", sDetailKeyFieldName));
                    InsertIntoGridView(sb, "<Columns>\r\n");
                    InsertIntoGridView(sb, "<dx:GridViewCommandColumn VisibleIndex=\"0\">\r\n");
                    InsertIntoGridView(sb, "<EditButton Visible=\"True\" />\r\n");
                    InsertIntoGridView(sb, "<NewButton Visible=\"True\" />\r\n");
                    InsertIntoGridView(sb, "<DeleteButton Visible=\"True\" />\r\n");
                    InsertIntoGridView(sb, "</dx:GridViewCommandColumn>\r\n");

                    index = 1;
                    foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                    {
                        String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                        /*if (!string.IsNullOrEmpty(BFI.RefValNo) || BFI.RefField != null)
                        {
                            InsertIntoGridView(sb, GenTemplateFieldHTML(BFI.ControlType, BlockItem, BFI));
                        }
                        else*/
                        if (BFI.ControlType == "ComboBox")
                        {
                            //GridViewDataComboBoxColumn
                            String sComboBox = String.Format("<dx:GridViewDataComboBoxColumn FieldName=\"{0}\" Caption=\"{1}\" VisibleIndex=\"{2}\" >\r\n", BFI.DataField, sHeaderText, index);
                            sComboBox += String.Format("<PropertiesComboBox DataSourceID=\"{0}\" ValueField=\"{1}\"", GenWebDataSource(BFI, BFI.ComboRemoteName, "ComboBox", ""), BFI.ComboValueField);
                            sComboBox += "TextFormatString=\"{0}\" >\r\n";
                            sComboBox += "<Columns>\r\n";
                            sComboBox += String.Format("<dx:ListBoxColumn Caption=\"{0}\" FieldName=\"{1}\" />", BFI.ComboTextFieldCaption, BFI.ComboTextField);
                            if (BFI.ComboTextField != BFI.ComboValueField)
                            {
                                sComboBox += String.Format("<dx:ListBoxColumn Caption=\"{0}\" FieldName=\"{1}\" />", BFI.ComboValueFieldCaption, BFI.ComboValueField);
                            }
                            sComboBox += "</Columns>\r\n";
                            sComboBox += "</PropertiesComboBox>\r\n";
                            sComboBox += "</dx:GridViewDataComboBoxColumn> \r\n";
                            InsertIntoGridView(sb, sComboBox);
                        }
                        if (BFI.ControlType == "CheckBox")
                        {

                        }
                        else
                        {
                            if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType == "DateTimeBox"))
                            {
                                //GridViewDataDateColumn
                                InsertIntoGridView(sb, String.Format("<dx:GridViewDataDateColumn FieldName=\"{0}\" Caption=\"{1}\" VisibleIndex=\"{2}\" />", BFI.DataField, sHeaderText, index));
                            }
                            else
                            {
                                //GridViewDataTextColumn>
                                InsertIntoGridView(sb, String.Format("<dx:GridViewDataTextColumn FieldName=\"{0}\" Caption=\"{1}\" VisibleIndex=\"{2}\" />", BFI.DataField, sHeaderText, index));
                            }
                        }
                        index++;
                    }
                    InsertIntoGridView(sb, "</Columns>\r\n");
                    InsertIntoGridView(sb, "<Settings ShowFooter=\"True\" />\r\n");
                    InsertIntoGridView(sb, "</dx:ASPxGridView>\r\n");
                    InsertIntoGridView(sb, "</DetailRow>\r\n");
                    InsertIntoGridView(sb, "</Templates>\r\n");
                }

                eWebGridView1.innerHTML = sb.ToString();
                String sKeyFieldName = String.Empty;
                foreach (var item in KeyFields)
                {
                    sKeyFieldName += item + ";";
                }
                eWebGridView1.outerHTML = eWebGridView1.outerHTML.Replace("KeyFieldName=\"\"", String.Format("KeyFieldName=\"{0}\"", sKeyFieldName));
            }
            #else
            bool isAjaxPage = false;
            if (FPage.FindControl("AjaxScriptManager1") != null)
                isAjaxPage = true;

            WebDataSource Master = (WebDataSource)FPage.FindControl("Master");
            Master.AutoApply = true;
            BlockItem.wDataSource = Master;
            WebDetailsView wdvMaster = (WebDetailsView)FPage.FindControl("wdvMaster");

            //Generate RESX
            //???GenResx(Master);

            //wdvMaster.DataMember = FClientData.TableName;
            //???WebGridView1.Columns.Clear();
            System.Web.UI.WebControls.BoundField aBoundField = null;
            System.Web.UI.WebControls.TemplateField aTemplateField = null;
            WebDefault aDefault = new WebDefault();
            aDefault.ID = "wd" + BlockItem.TableName;
            aDefault.DataSourceID = Master.ID;
            aDefault.DataMember = Master.DataMember;
            WebValidate aValidate = new WebValidate();
            aValidate.ID = "wv" + BlockItem.TableName;
            aValidate.DataSourceID = Master.ID;
            aValidate.DataMember = Master.DataMember;
            List<string> KeyFields = new List<string>();
            foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
            {
                if ((BFI.RefValNo != null && BFI.RefValNo != "") || BFI.RefField != null)
                {
                    String DataSourceID = GenWebDataSource(BFI, BlockItem.TableName, "RefVal", "");
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewRefValEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, null);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, null);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewRefValInsertItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, null);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else if (BFI.ControlType == "ComboBox")
                {
                    String DataSourceID = GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", "");
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewComboBoxEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewComboBoxItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewComboBoxFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewComboBoxInsertItemTemplate", BFI, BlockItem.TableName, DataSourceID, FMyWebDropDownList, FLabelList);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else if (BFI.ControlType == "ValidateBox")
                {
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewValidateBoxEditItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewValidateBoxInsertItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewValidateBoxItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewValidateBoxInsertItemTemplate", BFI, BlockItem.TableName, aValidate, FWebValidateBoxList, FLabelList);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else if (BFI.ControlType == "CheckBox")
                {
                    aTemplateField = new System.Web.UI.WebControls.TemplateField();
                    aTemplateField.HeaderText = BFI.Description;
                    aTemplateField.SortExpression = BFI.DataField;
                    if (aTemplateField.HeaderText == "")
                        aTemplateField.HeaderText = BFI.DataField;
                    aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewCheckBoxEditItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewCheckBoxInsertItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewCheckBoxItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewCheckBoxInsertItemTemplate", BFI, BlockItem.TableName, FWebCheckBoxList, FLabelList);
                    wdvMaster.Fields.Add(aTemplateField);
                }
                else
                {
                    if (BFI.DataType == typeof(DateTime) || (BFI.ControlType != null && BFI.ControlType.ToUpper() == "DATETIMEBOX"))
                    {
                        aTemplateField = new System.Web.UI.WebControls.TemplateField();
                        aTemplateField.HeaderText = BFI.Description;
                        aTemplateField.SortExpression = BFI.DataField;
                        if (aTemplateField.HeaderText == "")
                            aTemplateField.HeaderText = BFI.DataField;
                        aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewDateTimeEditItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewDateTimeItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewDateTimeInsertItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, null);
                        wdvMaster.Fields.Add(aTemplateField);
                    }
                    else
                    {
                        if (BFI.EditMask != null && BFI.EditMask != String.Empty)
                        {
                            aTemplateField = new System.Web.UI.WebControls.TemplateField();
                            aTemplateField.HeaderText = BFI.Description;
                            aTemplateField.SortExpression = BFI.DataField;
                            if (aTemplateField.HeaderText == "")
                                aTemplateField.HeaderText = BFI.DataField;
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewTextBoxEditItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewTextBoxItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewTextBoxFooterItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            aTemplateField.InsertItemTemplate = new WebControlTemplate("DetailsViewTextBoxInsertItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, null);
                            wdvMaster.Fields.Add(aTemplateField);
                        }
                        else
                        {
                            aBoundField = new System.Web.UI.WebControls.BoundField();
                            aBoundField.DataField = BFI.DataField;
                            aBoundField.SortExpression = BFI.DataField;
                            aBoundField.HeaderText = BFI.Description;
                            aBoundField.HeaderStyle.Width = 150;//BFI.Length * ColumnWidthPixel;
                            if (aBoundField.HeaderText == "")
                                aBoundField.HeaderText = BFI.DataField;
                            wdvMaster.Fields.Add(aBoundField);
                        }
                    }
                }

                if (BFI.IsKey)
                    KeyFields.Add(BFI.DataField);

                CreateQueryField(BFI, "", null, BlockItem.TableName);

                GenDefault(BFI, aDefault, aValidate);
            }

            DataTable DT = FWizardDataSet.RealDataSet.Tables[0];
            DataColumn[] PrimDc = DT.PrimaryKey;
            string[] AA = new string[PrimDc.Length];
            for (int J = 0; J < PrimDc.Length; J++)
                AA[J] = PrimDc[J].ColumnName;
            /*
            wdvMaster.DataKeyNames = new string[AA.Length];
            for (int I = 0; I < AA.Length; I++)
            {
                wdvMaster.DataKeyNames[I] = AA[I];
            }
             */
            FWebDefaultList.Add(aDefault);
            FWebValidateList.Add(aValidate);
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            NotifyRefresh(200);
            FComponentChangeService.OnComponentChanged(wdvMaster, null, "", "M");
            #endif
        }
예제 #13
0
        private void GenViewBlockControl(TBlockItem BlockItem)
        {
            var masterBlockItem = FClientData.Blocks.FindItem("Master");
            BlockItem.wDataSource = new WebDataSource();

            WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField));
            WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns));
            foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems)
            {
                TBlockFieldItem masterField = null;
                if (masterBlockItem != null)
                {
                    foreach (TBlockFieldItem item in masterBlockItem.BlockFieldItems)
                    {
                        if (item.DataField == fielditem.DataField)
                        {
                            masterField = item;
                        }
                    }
                }
                if (masterField != null)
                    GenQuery(masterField, QueryFields, QueryColumns, BlockItem.TableName);
                else
                    GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName);
            }

            object oJQGridViewMaster = FDesignerDocument.webControls.item("dataGridView", 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>();
                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>");
                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>");
                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();

            }
        }
예제 #14
0
        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
        }
예제 #15
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

            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
        }
예제 #16
0
        public WebClientQuery()
        {
            _column = new WebQueryColumnsCollection(this, typeof(QueryColumns));
            _gaphorizontal = 10;
            _gapvertical = 10;
            _keepcondition = false;
            this.Font.Name = "Simsun";
            this.Font.Size = FontUnit.Medium;
            _font = this.Font;

            _forecolor = SystemColors.ControlText;
            _textcolor = SystemColors.ControlText;
            _bordercolor = Color.Black;
            _innertable = false;
        }