Example #1
0
 private void AddDetailBlockItem(string MasterItemName, TreeNodeCollection NodeCollection)
 {
     for (int I = 0; I < NodeCollection.Count; I++)
     {
         TDetailItem DetailItem = (TDetailItem)NodeCollection[I].Tag;
         TBlockItem BlockItem = new TBlockItem();
         BlockItem.Name = NodeCollection[I].Text;
         BlockItem.RelationName = DetailItem.Relation.RelationName;
         BlockItem.TableName = DetailItem.TableName;
         if (NodeCollection[I].Parent != null)
         {
             BlockItem.ParentItemName = NodeCollection[I].Parent.Text;
         }
         else
         {
             BlockItem.ParentItemName = MasterItemName;
         }
         FClientData.Blocks.Add(BlockItem);
         BlockItem.BlockFieldItems = DetailItem.BlockFieldItems;
         AddDetailBlockItem(MasterItemName, NodeCollection[I].Nodes);
     }
 }
Example #2
0
 private void SetBlockFieldControls(TBlockItem BlockItem)
 {
     if (BlockItem.Name == "View")
     {
         GenViewBlockControl(BlockItem);
     }
     else if (BlockItem.Name == "Main" || BlockItem.Name == "Master")
     {
         if (FClientData.BaseFormName == "JQuerySingle1" || FClientData.BaseFormName == "JQuerySingle2"
             || FClientData.BaseFormName == "JQueryQuery1" || FClientData.BaseFormName == "VBJQuerySingle1"
             || FClientData.BaseFormName == "VBJQuerySingle2" || FClientData.BaseFormName == "VBJQueryQuery1")
         {
             GenMainBlockControl(BlockItem);
         }
         else if (FClientData.BaseFormName == "JQueryMasterDetail1" || FClientData.BaseFormName == "JQueryMasterDetail2"
             || FClientData.BaseFormName == "VBJQueryMasterDetail1" || FClientData.BaseFormName == "VBJQueryMasterDetail2")
         {
             GenMainBlockControl(BlockItem);
             ////GenMainBlockControl_3(BlockItem, "wfvMaster");
         }
         else if (FClientData.BaseFormName == "JQueryQuery1" || FClientData.BaseFormName == "VBJQueryQuery1")
         {
             GenMainBlockControl(BlockItem);
             ////GenMainBlockControl_3(BlockItem, "wfvMaster");  //因為RefreshSchema要等Detail.DataMember全部設定完
         }
     }
 }
Example #3
0
        private void UpdateDataSource(TBlockItem MainBlockItem, TBlockItem ViewBlockItem)
        {
            InfoNavigator navigator3 = FRootForm.Controls["infoNavigator1"] as InfoNavigator;
            if (navigator3 != null)
                navigator3.ViewBindingSource = MainBlockItem.BindingSource;

            FViewGrid.DataSource = MainBlockItem.BindingSource;
            TBlockFieldItem FieldItem;
            //???FViewGrid.Columns.Clear();
            DataGridViewColumn Column;
            int I, Index;
            for (I = 0; I < ViewBlockItem.BlockFieldItems.Count; I++)
            {
                FieldItem = ViewBlockItem.BlockFieldItems[I] as TBlockFieldItem;
                if (FieldItem.Description == "")
                    Index = FViewGrid.Columns.Add(FieldItem.DataField, FieldItem.DataField);
                else
                    Index = FViewGrid.Columns.Add(FieldItem.DataField, FieldItem.Description);
                Column = FViewGrid.Columns[Index];
                Column.DataPropertyName = FieldItem.DataField;
                if (Column.HeaderText.Trim() == "")
                    Column.HeaderText = FieldItem.DataField;
            }
        }
Example #4
0
        //private void AddDetailBlockItem(string MasterItemName, System.Windows.Forms.TreeNodeCollection NodeCollection)
        //{
        //    for (int I = 0; I < NodeCollection.Count; I++)
        //    {
        //        TDetailItem DetailItem = (TDetailItem)NodeCollection[I].Tag;
        //        TBlockItem BlockItem = new TBlockItem();
        //        BlockItem.Name = NodeCollection[I].Text;
        //        BlockItem.RelationName = DetailItem.Relation.RelationName;
        //        BlockItem.TableName = DetailItem.TableName;
        //        if (NodeCollection[I].Parent != null)
        //        {
        //            BlockItem.ParentItemName = NodeCollection[I].Parent.Text;
        //        }
        //        else
        //        {
        //            BlockItem.ParentItemName = MasterItemName;
        //        }
        //        FClientData.Blocks.Add(BlockItem);
        //        BlockItem.BlockFieldItems = DetailItem.BlockFieldItems;
        //        AddDetailBlockItem(MasterItemName, NodeCollection[I].Nodes);
        //    }
        //}
        private void AddDetailBlockItem(string MasterItemName, System.Windows.Forms.TreeNodeCollection NodeCollection, ListView LV)
        {
            for (int I = 0; I < NodeCollection.Count; I++)
            {
                TBlockItem BlockItem = new TBlockItem();
                BlockItem.Name = NodeCollection[I].Text;
                BlockItem.TableName = ((TDetailItem)NodeCollection[I].Tag).TableName;
                BlockItem.Relation = ((TDetailItem)NodeCollection[I].Tag).Relation;
                BlockItem.RelationName = ((TDetailItem)NodeCollection[I].Tag).Relation.RelationName;
                for (int J = 0; J < LV.Items.Count; J++)
                {
                    ListViewItem aItem = LV.Items[J];
                    TBlockFieldItem BlockFieldItem = new TBlockFieldItem();
                    if (aItem.Tag != null)
                    {
                        BlockFieldItem.DataField = ((TBlockFieldItem)aItem.Tag).DataField;
                        BlockFieldItem.CheckNull = ((TBlockFieldItem)aItem.Tag).CheckNull;
                        BlockFieldItem.DefaultValue = ((TBlockFieldItem)aItem.Tag).DefaultValue;
                        BlockFieldItem.Description = ((TBlockFieldItem)aItem.Tag).Description;
                        BlockFieldItem.RefValNo = ((TBlockFieldItem)aItem.Tag).RefValNo;
                        BlockFieldItem.ControlType = ((TBlockFieldItem)aItem.Tag).ControlType;
                        BlockFieldItem.ComboRemoteName = ((TBlockFieldItem)aItem.Tag).ComboRemoteName;
                        BlockFieldItem.ComboEntityName = ((TBlockFieldItem)aItem.Tag).ComboEntityName;
                        BlockFieldItem.ComboTextField = ((TBlockFieldItem)aItem.Tag).ComboTextField;
                        BlockFieldItem.ComboValueField = ((TBlockFieldItem)aItem.Tag).ComboValueField;
                        BlockFieldItem.ComboTextFieldCaption = ((TBlockFieldItem)aItem.Tag).ComboTextFieldCaption;
                        BlockFieldItem.ComboValueFieldCaption = ((TBlockFieldItem)aItem.Tag).ComboValueFieldCaption;
                        BlockFieldItem.DataType = ((TBlockFieldItem)aItem.Tag).DataType;
                        BlockFieldItem.QueryMode = ((TBlockFieldItem)aItem.Tag).QueryMode;
                        BlockFieldItem.EditMask = ((TBlockFieldItem)aItem.Tag).EditMask;
                        BlockFieldItem.Length = ((TBlockFieldItem)aItem.Tag).Length;
                        BlockFieldItem.ComboOtherFields = ((TBlockFieldItem)aItem.Tag).ComboOtherFields;
                        BlockFieldItem.IsKey = ((TBlockFieldItem)aItem.Tag).IsKey;
                    }
                    else
                    {
                        BlockFieldItem.DataField = aItem.Text;
                    }
                    BlockItem.BlockFieldItems.Add(BlockFieldItem);

                }
                if (NodeCollection[I].Parent != null)
                {
                    BlockItem.ParentItemName = NodeCollection[I].Parent.Text;
                }
                else
                {
                    BlockItem.ParentItemName = MasterItemName;
                }
                FClientData.Blocks.Add(BlockItem);
                AddDetailBlockItem(MasterItemName, NodeCollection[I].Nodes, LV);
            }
        }
Example #5
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));
            }
        }
Example #6
0
        private string GenTemplateFieldHTML(string controlType, TBlockItem BlockItem, TBlockFieldItem BFI)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("<asp:TemplateField HeaderText=\"" + (string.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description) + "\" SortExpression=\"" + BFI.DataField + "\">");
            builder.AppendLine("<EditItemTemplate>");
            builder.AppendLine(GenTempateHTML("edit", controlType, BlockItem, BFI));
            builder.AppendLine("</EditItemTemplate>");
            builder.AppendLine("<FooterTemplate>");
            builder.AppendLine(GenTempateHTML("footer", controlType, BlockItem, BFI));
            builder.AppendLine("</FooterTemplate>");
            builder.AppendLine("<ItemTemplate>");
            builder.AppendLine(GenTempateHTML("item", controlType, BlockItem, BFI));
            builder.AppendLine("</ItemTemplate>");
            builder.AppendLine("</asp:TemplateField>");

            return builder.ToString();
        }
Example #7
0
        private void AddBlockItem(string BlockName, string ProviderName, string TableName, ListView LV)
        {
            int I;
            TBlockItem BlockItem = new TBlockItem();
            TBlockFieldItem BlockFieldItem;

            InfoCommand aInfoCommand = new InfoCommand(FClientData.DatabaseType);
            aInfoCommand.Connection = InternalConnection;
            String OWNER = String.Empty, SS = TableName;
            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 DS = new DataSet();
            WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, DS, TableName);
            BlockItem.Name = BlockName;
            BlockItem.ProviderName = ProviderName;
            BlockItem.TableName = TableName;
            for (I = 0; I < LV.Items.Count; I++)
            {
                ListViewItem aItem = LV.Items[I];
                BlockFieldItem = new TBlockFieldItem();
                if (aItem.Tag != null)
                {
                    BlockFieldItem.DataField = ((TBlockFieldItem)aItem.Tag).DataField;
                    BlockFieldItem.CheckNull = ((TBlockFieldItem)aItem.Tag).CheckNull;
                    BlockFieldItem.DefaultValue = ((TBlockFieldItem)aItem.Tag).DefaultValue;
                    BlockFieldItem.Description = ((TBlockFieldItem)aItem.Tag).Description;
                    BlockFieldItem.RefValNo = ((TBlockFieldItem)aItem.Tag).RefValNo;
                    BlockFieldItem.ControlType = ((TBlockFieldItem)aItem.Tag).ControlType;
                    BlockFieldItem.ComboEntityName = ((TBlockFieldItem)aItem.Tag).ComboEntityName;
                    BlockFieldItem.ComboRemoteName = ((TBlockFieldItem)aItem.Tag).ComboRemoteName;
                    BlockFieldItem.ComboTextField = ((TBlockFieldItem)aItem.Tag).ComboTextField;
                    BlockFieldItem.ComboValueField = ((TBlockFieldItem)aItem.Tag).ComboValueField;
                    BlockFieldItem.ComboTextFieldCaption = ((TBlockFieldItem)aItem.Tag).ComboTextFieldCaption;
                    BlockFieldItem.ComboValueFieldCaption = ((TBlockFieldItem)aItem.Tag).ComboValueFieldCaption;
                    BlockFieldItem.DataType = ((TBlockFieldItem)aItem.Tag).DataType;
                    BlockFieldItem.QueryMode = ((TBlockFieldItem)aItem.Tag).QueryMode;
                    BlockFieldItem.EditMask = ((TBlockFieldItem)aItem.Tag).EditMask;
                    BlockFieldItem.Length = ((TBlockFieldItem)aItem.Tag).Length;
                    BlockFieldItem.ComboOtherFields = ((TBlockFieldItem)aItem.Tag).ComboOtherFields;
                    BlockFieldItem.IsKey = ((TBlockFieldItem)aItem.Tag).IsKey;
                    BlockFieldItem.HideGridColumn = ((TBlockFieldItem)aItem.Tag).HideGridColumn;
                }
                else
                {
                    BlockFieldItem.DataField = aItem.Text;
                }
                /*
                BlockFieldItem.DataField = LV.Items[I].Text;
                DRs = DS.Tables[0].Select("FIELD_NAME='" + BlockFieldItem.DataField + "'");
                if (DRs.Length == 1)
                {
                    DR = DRs[0];
                    if (!DR.IsNull("FIELD_LENGTH"))
                       BlockFieldItem.Length = int.Parse(DR["FIELD_LENGTH"].ToString());
                    if (DR["IS_KEY"].ToString() == "Y")
                    {
                        BlockFieldItem.IsKey = true;
                    }
                    else
                    {
                        BlockFieldItem.IsKey = false;
                    }
                    BlockFieldItem.Description = DR["CAPTION"].ToString();
                    if (LV.Items[I].SubItems.Count == 3)
                    {
                        BlockFieldItem.RefValNo = aItem.SubItems[2].Text;
                    }
                    if (BlockFieldItem.Description == "")
                    {
                        BlockFieldItem.Description = BlockFieldItem.DataField;
                    }

                    BlockFieldItem.CheckNull = DR["CHECK_NULL"].ToString().ToUpper();
                    BlockFieldItem.DefaultValue = DR["DEFAULT_VALUE"].ToString();
                }
                 */
                BlockItem.BlockFieldItems.Add(BlockFieldItem);

            }
            FClientData.Blocks.Add(BlockItem);
        }
Example #8
0
 private void SetNavigatorBindingSource(TBlockItem BlockItem)
 {
     //InfoNavigator Navigator = (InfoNavigator)BlockItem.ContainerControl;
     InfoNavigator Navigator = FindComponent(FRootForm, (BlockItem.ContainerControl as InfoNavigator).AnyQueryID, typeof(InfoNavigator)) as InfoNavigator;
     Navigator.BindingSource = FindBindingSource(BlockItem);
     if (Navigator.BindingSource == null)
         Navigator.BindingSource = BlockItem.BindingSource;
     Navigator.ViewBindingSource = FindBindingSource(BlockItem);
     if(Navigator.ViewBindingSource == null)
         Navigator.ViewBindingSource = BlockItem.ViewBindingSource;
 }
Example #9
0
 public TNodeObject(TreeNode aTreeNode, TExtWebClientData ClientData)
 {
     Node = aTreeNode;
     aTreeNode.Tag = this;
     FBlockItem = new TBlockItem();
     FBlockItem.Name = aTreeNode.Text;
     ClientData.Blocks.Add(FBlockItem);
 }
Example #10
0
 private void GenPanelBlock(TBlockItem BlockItem)
 {
     switch (BlockItem.LayoutKind)
     {
         case TLayoutType.ltTextBox:
             {
                 GenTextBoxControl(BlockItem);
                 break;
             }
         case TLayoutType.ltDataGridView:
             {
                 GenDataGridViewControl(BlockItem);
                 break;
             }
     }
 }
Example #11
0
        private void GenTextBoxControl(TBlockItem BlockItem)
        {
            DataTable aTable = FindDataTable(BlockItem.BindingSource, BlockItem.ProviderName);

            TStringList aLabelList = new TStringList();
            TStringList aEditList = new TStringList();
            TBlockFieldItem aFieldItem;
            System.Windows.Forms.Label l = null;
            int TopOffset = 10;
            int LeftOffst = 100;
            InfoTextBox aInfoTextBox = null;
            InfoRefvalBox aInfoRefValBox = null;
            InfoDateTimePicker aInfoDateTimePicker = null;
            InfoRefVal aRefVal = null;
            InfoComboBox aComboBox = null;
            CheckBox aCheckBox = null;

            for (int I = 0; I < BlockItem.BlockFieldItems.Count; I++)
            {
                aFieldItem = BlockItem.BlockFieldItems[I] as TBlockFieldItem;
                aInfoTextBox = null;
                aInfoRefValBox = null;
                aInfoDateTimePicker = null;
                aRefVal = null;
                aComboBox = null;
                aCheckBox = null;

                if ((aFieldItem.RefValNo != null && aFieldItem.RefValNo != "") || aFieldItem.RefField != null)
                {
                    aRefVal = GenRefVal(aFieldItem, BlockItem.ProviderName);
                    aInfoRefValBox = FDesignerHost.CreateComponent(typeof(InfoRefvalBox)) as InfoRefvalBox;
                    aInfoRefValBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName);
                    aInfoRefValBox.Top = TopOffset + (aInfoRefValBox.Height + 5) * I;
                    aInfoRefValBox.Left = LeftOffst;
                    aInfoRefValBox.Width = 150;
                    aInfoRefValBox.Text = aFieldItem.DataField;
                    //aInfoRefValBox.Name = "tb" + aFieldItem.DataField;
                    aInfoRefValBox.Name = aFieldItem.DataField + "InfoRefValBox";
                    aInfoRefValBox.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true));
                    aInfoRefValBox.DataBindings[0].FormatString = aFieldItem.EditMask;
                    aInfoRefValBox.RefVal = aRefVal;
                    aInfoRefValBox.TextBoxBindingSource = BlockItem.BindingSource;
                    aInfoRefValBox.TextBoxBindingMember = aFieldItem.DataField;
                    //aInfoRefValBox.MaxLength = FieldItem.Length;
                    aEditList.Add(aInfoRefValBox);
                }
                else if (aFieldItem.ControlType == "ComboBox")
                {
                    string type = FindSystemDBType("SystemDB");

                    aComboBox = FDesignerHost.CreateComponent(typeof(InfoComboBox)) as InfoComboBox;
                    //aComboBox.Name = "icb" + aFieldItem.DataField;
                    aComboBox.Name = aFieldItem.DataField + "ComboBox";
                    aComboBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName);
                    aComboBox.Top = TopOffset + (aComboBox.Height + 5) * I;
                    aComboBox.Left = LeftOffst;
                    aComboBox.Width = 150;
                    aComboBox.SelectAlias = FClientData.Owner.SelectedAlias;
                    if (aFieldItem.ComboEntityName != null && aFieldItem.ComboTextField != null && aFieldItem.ComboValueField != null)
                    {
                        if (type == "1")
                            aComboBox.SelectCommand = String.Format("Select [{0}].[{1}], [{0}].[{2}] from [{0}]", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                        else if (type == "2")
                            aComboBox.SelectCommand = String.Format("Select [{0}].[{1}], [{0}].[{2}] from [{0}]", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                        else if (type == "3")
                            aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                        else if (type == "4")
                            aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                        else if (type == "5")
                            aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                        else if (type == "6")
                            aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                        else if (type == "7")
                            aComboBox.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                    }
                    aComboBox.DisplayMember = aFieldItem.ComboTextField;
                    aComboBox.ValueMember = aFieldItem.ComboValueField;
                    aComboBox.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true));
                    //if (dsColdef.Tables[0].Rows.Count > 0)
                    //    for (int j = 0; j < dsColdef.Tables[0].Rows.Count; j++)
                    //        if (dsColdef.Tables[0].Rows[j]["FIELD_NAME"].ToString() == aFieldItem.DataField && dsColdef.Tables[0].Rows[j]["EDITMASK"] != null)
                    //            aComboBox.DataBindings[0].FormatString = dsColdef.Tables[0].Rows[j]["EDITMASK"].ToString();
                    aComboBox.DataBindings[0].FormatString = aFieldItem.EditMask;
                    aEditList.Add(aComboBox);
                }
                else if (aFieldItem.ControlType == "CheckBox")
                {
                    aCheckBox = FDesignerHost.CreateComponent(typeof(CheckBox)) as CheckBox;
                    aCheckBox.Name = aFieldItem.DataField + "CheckBox";
                    aCheckBox.Site.Name = aFieldItem.DataField + "CheckBox";
                    aCheckBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName);
                    aCheckBox.Height = 22;
                    aCheckBox.Top = TopOffset + (aCheckBox.Height + 5) * I;
                    aCheckBox.Left = LeftOffst;
                    aCheckBox.Width = 150;
                    aCheckBox.DataBindings.Add(new Binding("Checked", BlockItem.BindingSource, aFieldItem.DataField, true));
                    aEditList.Add(aCheckBox);
                }
                else
                {
                    if (aTable.Columns[aFieldItem.DataField].DataType == typeof(DateTime) || (aFieldItem.ControlType != null && aFieldItem.ControlType.ToUpper() == "DATETIMEBOX"))
                    {
                        aInfoDateTimePicker = FDesignerHost.CreateComponent(typeof(InfoDateTimePicker)) as InfoDateTimePicker;
                        aInfoDateTimePicker.Parent = FindContainer(FRootForm, BlockItem.ContainerName);
                        aInfoDateTimePicker.Top = TopOffset + (aInfoDateTimePicker.Height + 5) * I;
                        aInfoDateTimePicker.Left = LeftOffst;
                        aInfoDateTimePicker.Width = 150;
                        //aInfoDateTimePicker.Name = "dtp" + aFieldItem.DataField;
                        aInfoDateTimePicker.Site.Name = aFieldItem.DataField + "InfoDateTimePicker";
                        aInfoDateTimePicker.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true));
                        //if (dsColdef.Tables[0].Rows.Count > 0)
                        //    for (int j = 0; j < dsColdef.Tables[0].Rows.Count; j++)
                        //        if (dsColdef.Tables[0].Rows[j]["FIELD_NAME"].ToString() == aFieldItem.DataField && dsColdef.Tables[0].Rows[j]["EDITMASK"] != null)
                        //            aInfoDateTimePicker.DataBindings[0].FormatString = dsColdef.Tables[0].Rows[j]["EDITMASK"].ToString();
                        aInfoDateTimePicker.DataBindings[0].FormatString = aFieldItem.EditMask;
                        aEditList.Add(aInfoDateTimePicker);
                    }
                    else
                    {
                        aInfoTextBox = FDesignerHost.CreateComponent(typeof(InfoTextBox)) as InfoTextBox;
                        aInfoTextBox.Parent = FindContainer(FRootForm, BlockItem.ContainerName);
                        aInfoTextBox.Top = TopOffset + (aInfoTextBox.Height + 5) * I;
                        aInfoTextBox.Left = LeftOffst;
                        aInfoTextBox.Width = 150;
                        aInfoTextBox.Text = aFieldItem.DataField;
                        //aInfoTextBox.Name = "tb" + aFieldItem.DataField;
                        aInfoTextBox.Site.Name = aFieldItem.DataField + "InfoTextBox";
                        aInfoTextBox.DataBindings.Add(new Binding("Text", BlockItem.BindingSource, aFieldItem.DataField, true));
                        //if (dsColdef.Tables[0].Rows.Count > 0)
                        //    for (int j = 0; j < dsColdef.Tables[0].Rows.Count; j++)
                        //        if (dsColdef.Tables[0].Rows[j]["FIELD_NAME"].ToString() == aFieldItem.DataField && dsColdef.Tables[0].Rows[j]["EDITMASK"] != null)
                        //            aInfoTextBox.DataBindings[0].FormatString = dsColdef.Tables[0].Rows[j]["EDITMASK"].ToString();
                        aInfoTextBox.DataBindings[0].FormatString = aFieldItem.EditMask;
                        aInfoTextBox.MaxLength = aFieldItem.Length;
                        aEditList.Add(aInfoTextBox);
                    }
                }

                CreateQueryField(aFieldItem, "", aRefVal, BlockItem.BindingSource);

                l = FDesignerHost.CreateComponent(typeof(System.Windows.Forms.Label)) as Label;
                l.Parent = FindContainer(FRootForm, BlockItem.ContainerName);
                l.AutoSize = true;
                l.Text = aFieldItem.Description;
                if (l.Text == "")
                    l.Text = aFieldItem.DataField;
                l.Left = LeftOffst - l.Width - 5;
                if (aInfoTextBox != null)
                {
                    l.Top = aInfoTextBox.Top + (aInfoTextBox.Height - l.Height) / 2;
                }
                if (aInfoDateTimePicker != null)
                {
                    l.Top = aInfoDateTimePicker.Top + (aInfoDateTimePicker.Height - l.Height) / 2;
                }
                aLabelList.Add(l);
            }
            AdjectLabelEditPos(aEditList, aLabelList);
        }
Example #12
0
        private void GenDataGridViewControl(TBlockItem BlockItem)
        {
            InfoDataGridView Grid = null;
            Control aControl = FindContainer(FRootForm, BlockItem.ContainerName);
            if (!(aControl is InfoDataGridView))
            {
                Grid = FDesignerHost.CreateComponent(typeof(InfoDataGridView), "grd" + BlockItem.ProviderName) as InfoDataGridView;
                Grid.Parent = aControl;
                Grid.Dock = DockStyle.Fill;
            }
            else
                Grid = (InfoDataGridView)aControl;
            Grid.DataSource = BlockItem.BindingSource;
            Grid.Columns.Clear();
            TBlockFieldItem aFieldItem;
            DataGridViewTextBoxColumn Column;
            InfoDataGridViewComboBoxColumn ComboBoxColumn;
            InfoDataGridViewRefValColumn RefValColumn;
            int I;
            for (I = 0; I < BlockItem.BlockFieldItems.Count; I++)
            {
                aFieldItem = BlockItem.BlockFieldItems[I] as TBlockFieldItem;
                if ((aFieldItem.RefValNo != null && aFieldItem.RefValNo != "") || aFieldItem.RefField != null)
                {
                    InfoRefVal aInfoRefVal = GenRefVal(aFieldItem, BlockItem.ProviderName);
                    RefValColumn = FDesignerHost.CreateComponent(typeof(InfoDataGridViewRefValColumn), "dgc" + BlockItem.ProviderName + aFieldItem.DataField) as InfoDataGridViewRefValColumn;
                    RefValColumn.DataPropertyName = aFieldItem.DataField;
                    RefValColumn.DefaultCellStyle.Format = aFieldItem.EditMask;
                    RefValColumn.HeaderText = aFieldItem.Description;
                    RefValColumn.MaxInputLength = aFieldItem.Length;
                    if (RefValColumn.HeaderText.Trim() == "")
                        RefValColumn.HeaderText = aFieldItem.DataField;
                    RefValColumn.RefValue = aInfoRefVal;
                    Grid.Columns.Add(RefValColumn);
                }
                else if (aFieldItem.ControlType == "ComboBox")
                {
                    string type = FindSystemDBType("SystemDB");

                    InfoRefVal bInfoRefVal = FDesignerHost.CreateComponent(typeof(InfoRefVal), "irv" + BlockItem.ProviderName + aFieldItem.DataField) as InfoRefVal;
                    bInfoRefVal.SelectAlias = FClientData.Owner.SelectedAlias;
                    if (type == "1")
                        bInfoRefVal.SelectCommand = String.Format("Select [{0}].[{1}], [{0}].[{2}] from [{0}]", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                    else if (type == "2")
                        bInfoRefVal.SelectCommand = String.Format("Select [{0}].[{1}], [{0}].[{2}] from [{0}]", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                    else if (type == "3")
                        bInfoRefVal.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                    else if (type == "4")
                        bInfoRefVal.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                    else if (type == "5")
                        bInfoRefVal.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                    else if (type == "6")
                        bInfoRefVal.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);
                    else if (type == "7")
                        bInfoRefVal.SelectCommand = String.Format("Select {0}.{1}, {0}.{2} from {0}", aFieldItem.ComboEntityName, aFieldItem.ComboTextField, aFieldItem.ComboValueField);

                    bInfoRefVal.ValueMember = aFieldItem.ComboValueField;
                    bInfoRefVal.DisplayMember = aFieldItem.ComboTextField;
                    ComboBoxColumn = FDesignerHost.CreateComponent(typeof(InfoDataGridViewComboBoxColumn), "dgcc" + BlockItem.ProviderName + aFieldItem.DataField) as InfoDataGridViewComboBoxColumn;
                    ComboBoxColumn.RefValue = bInfoRefVal;
                    ComboBoxColumn.DataPropertyName = aFieldItem.DataField;
                    ComboBoxColumn.DefaultCellStyle.Format = aFieldItem.EditMask;
                    ComboBoxColumn.HeaderText = aFieldItem.Description;
                    if (ComboBoxColumn.HeaderText.Trim() == "")
                        ComboBoxColumn.HeaderText = aFieldItem.DataField;
                    ComboBoxColumn.DisplayMember = aFieldItem.ComboTextField;
                    ComboBoxColumn.ValueMember = aFieldItem.ComboValueField;
                    Grid.Columns.Add(ComboBoxColumn);
                }
                else
                {
                    Column = FDesignerHost.CreateComponent(typeof(DataGridViewTextBoxColumn), "dgc" + BlockItem.ProviderName + aFieldItem.DataField) as DataGridViewTextBoxColumn;
                    Column.DataPropertyName = aFieldItem.DataField;
                    Column.DefaultCellStyle.Format = aFieldItem.EditMask;
                    Column.HeaderText = aFieldItem.Description;
                    Column.MaxInputLength = aFieldItem.Length;
                    if (Column.HeaderText.Trim() == "")
                        Column.HeaderText = aFieldItem.DataField;
                    Grid.Columns.Add(Column);
                }
            }
        }
Example #13
0
 private InfoBindingSource FindViewBindingSource(TBlockItem BlockItem)
 {
     foreach (InfoBindingSource ViewBindingSource in FBindingSourceList)
     {
         if (ViewBindingSource.text.CompareTo("ibsView" + BlockItem.ProviderName) == 0)
         {
             BlockItem.ViewBindingSource = ViewBindingSource;
             return ViewBindingSource;
         }
     }
     return null;
 }
Example #14
0
 private InfoBindingSource FindBindingSource(TBlockItem BlockItem)
 {
     foreach (InfoBindingSource BindingSource in FBindingSourceList)
     {
         if (BindingSource.text.CompareTo("ibs" + BlockItem.ProviderName) == 0)
         {
             BlockItem.BindingSource = BindingSource;
             return BindingSource;
         }
     }
     return null;
 }
Example #15
0
 private void SetBlockFieldControls(TBlockItem BlockItem)
 {
     if (BlockItem.Name == "View")
     {
         GenViewBlockControl(BlockItem);
     }
     else if (BlockItem.Name == "Main" || BlockItem.Name == "Master")
     {
         if (FClientData.BaseFormName == "WSingle")
         {
             GenMainBlockControl(BlockItem);
         }
         if (FClientData.BaseFormName == "WSingle1" || FClientData.BaseFormName == "WSingle0")
         {
             GenMainBlockControl_3(BlockItem, "WebFormView1");  //因為RefreshSchema要等Detail.DataMember全部設定完
         }
         if (FClientData.BaseFormName == "WMasterDetail1" || FClientData.BaseFormName == "WMasterDetail3"
             || FClientData.BaseFormName == "WMasterDetail4" || FClientData.BaseFormName == "WMasterDetail6"
             || FClientData.BaseFormName == "WMasterDetail7" || FClientData.BaseFormName == "WMasterDetail8"
             || FClientData.BaseFormName == "WMasterDetail5")
         {
             GenMainBlockControl_3(BlockItem, "wfvMaster");  //因為RefreshSchema要等Detail.DataMember全部設定完
         }
         if (FClientData.BaseFormName == "WSingle2" || FClientData.BaseFormName == "WSingle3" || FClientData.BaseFormName == "WSingle4"
             || FClientData.BaseFormName == "WSingle5" || FClientData.BaseFormName == "VBWebSingle5" || FClientData.BaseFormName == "VBWebSingle2"
             || FClientData.BaseFormName == "VBWebSingle3" || FClientData.BaseFormName == "VBWebSingle4")
         {
             GenMainBlockControl_3(BlockItem, "WebFormView1");  //因為RefreshSchema要等Detail.DataMember全部設定完
         }
         if (FClientData.BaseFormName == "WMasterDetail2")
         {
             GenMainBlockControl_2(BlockItem);
         }
         if (FClientData.BaseFormName == "WQuery" || FClientData.BaseFormName == "WQuery1")
         {
             GenMainBlockControl(BlockItem);
         }
         if (FClientData.BaseFormName == "VBWebSingle")
         {
             GenMainBlockControl(BlockItem);
         }
         if (FClientData.BaseFormName == "VBWSingle1" || FClientData.BaseFormName == "VBWebSingle0")
         {
             GenMainBlockControl_3(BlockItem, "WebFormView1");  //因為RefreshSchema要等Detail.DataMember全部設定完
         }
         if (FClientData.BaseFormName == "VBWebCMasterDetail_FG" || FClientData.BaseFormName == "VBWebCMasterDetail_VFG"
             || FClientData.BaseFormName == "VBWebCMasterDetail4" || FClientData.BaseFormName == "VBWebCMasterDetail8"
             || FClientData.BaseFormName == "VBWebMasterDetail6" || FClientData.BaseFormName == "VBWebMasterDetail7")
         {
             GenMainBlockControl_3(BlockItem, "wfvMaster");
         }
         if (FClientData.BaseFormName == "VBWebCMasterDetail_DG")
         {
             GenMainBlockControl_2(BlockItem);
         }
         if (FClientData.BaseFormName == "VBWebQuery")
         {
             GenMainBlockControl(BlockItem);
         }
     }
 }
Example #16
0
 public TNodeObject(TreeNode aTreeNode, TExtClientData ClientData, Control Container)
 {
     Node = aTreeNode;
     aTreeNode.Tag = this;
     FBlockItem = new TBlockItem();
     FBlockItem.Name = Container.Name;
     FBlockItem.ContainerControl = Container;
     ClientData.Blocks.Add(FBlockItem);
 }
Example #17
0
        private string GenTempateHTML(string template, string controlType, TBlockItem BlockItem, TBlockFieldItem BFI)
        {
            bool isAjaxPage = false;
            object obj = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxScriptManager1", 0);
            if (obj != null)
                isAjaxPage = true;

            StringBuilder builder = new StringBuilder();
            String FormatStyle = this.FormatEditMask(BFI.EditMask);
            if (template == "edit")
            {
                switch (controlType)
                {
                    case "RefValBox":
                        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);

                        DataSet aDataSet = new DataSet();
                        StringBuilder RefColumns = new StringBuilder("<Columns>");
                        aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", BFI.RefValNo);
                        WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, aDataSet, BFI.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("");
                        }

                        String DataSourceID = GenWebDataSource(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "RefVal", "");
                        String refvalHTML = String.Empty;
                        if (isAjaxPage)
                        {
                            refvalHTML = String.Format("<AjaxTools:AjaxRefVal ID=\"{0}\" runat=\"server\" BindingValue='<%# Bind(\"[{1}]\"{5}) %>' " +
                                        "DataSourceID=\"{2}\" " +
                                        "DataTextField=\"{3}\" DataValueField=\"{4}\" ResxDataSet=\"\">" +
                                         RefColumns.ToString() +
                                        "</AjaxTools:AjaxRefVal>",
                                        WzdUtils.RemoveSpecialCharacters("arv" + BlockItem.TableName + BFI.DataField + "E"),
                                        BFI.DataField,
                                        DataSourceID,
                                        FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                        FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                        FormatStyle
                                        );
                        }
                        else
                        {
                            refvalHTML = 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>",
                                        WzdUtils.RemoveSpecialCharacters("wrv" + BlockItem.TableName + BFI.DataField + "E"),
                                        BFI.DataField,
                                        DataSourceID,
                                        FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                        FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                        FormatStyle
                                        );
                        }
                        builder.AppendLine(refvalHTML);
                        break;
                    case "ComboBox":
                        String comboHTML = string.Format("<InfoLight:WebDropDownList runat=\"server\" ID=\"{0}\" DataSourceID=\"{1}\" DataTextField=\"{2}\" DataValueField=\"{3}\" DataMember=\"{4}\" SelectedValue='<%# Bind(\"[{5}]\"{6}) %>'></InfoLight:WebDropDownList>",
                            WzdUtils.RemoveSpecialCharacters("wdd" + BlockItem.TableName + BFI.DataField + "E"),
                            GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", ""),
                            BFI.ComboTextField,
                            BFI.ComboValueField,
                            BFI.ComboEntityName,
                            BFI.DataField,
                            FormatStyle);
                        builder.AppendLine(comboHTML);
                        break;
                    case "ValidateBox":
                        String validateHTML = String.Format("<InfoLight:WebValidateBox ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"[{1}]\"{3}) %>' ValidateField=\"{1}\" WebValidateID=\"{2}\"></InfoLight:WebValidateBox>",
                                    WzdUtils.RemoveSpecialCharacters("wvb" + BlockItem.TableName + BFI.DataField + "E"),
                                    BFI.DataField,
                                    "wv" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName),
                                    FormatStyle);
                        builder.AppendLine(validateHTML);
                        break;
                    case "CheckBox":
                        String checkHTML = String.Format("<asp:CheckBox ID=\"{0}\" runat=\"server\" Checked='<%# Bind(\"[{1}]\"{2}) %>'></asp:CheckBox>",
                                    WzdUtils.RemoveSpecialCharacters("cb" + BlockItem.TableName + BFI.DataField + "E"),
                                    BFI.DataField,
                                    FormatStyle);
                        builder.AppendLine(checkHTML);
                        break;
                    case "DateTimeBox":
                        String dtHTML = String.Empty;
                        if (isAjaxPage)
                        {
                            dtHTML = String.Format("<AjaxTools:AjaxDateTimePicker runat=\"server\" DateFormat=\"{0}\" DateTimeType=\"{1}\" Localize=\"False\" MinYear=\"1950\" MaxYear=\"2050\" ToolTip=\"{2}\" Width=\"100px\" ID=\"{3}\" {4}='<%# Bind(\"[{5}]\"{6}) %>'></AjaxTools:AjaxDateTimePicker>",
                                "None",
                                (BFI.DataType == typeof(DateTime)) ? "DateTime" : "Varchar",
                                BFI.DataField,
                                WzdUtils.RemoveSpecialCharacters("wdt" + BlockItem.TableName + BFI.DataField + "E"),
                                (BFI.DataType == typeof(DateTime)) ? "Text" : "DateString",
                                BFI.DataField,
                                FormatStyle);
                        }
                        else
                        {
                            dtHTML = String.Format("<InfoLight:WebDateTimePicker runat=\"server\" UseButtonImage=\"True\" DateFormat=\"{0}\" DateTimeType=\"{1}\" Localize=\"False\" MinYear=\"1950\" MaxYear=\"2050\" ToolTip=\"{2}\" Width=\"100px\" ID=\"{3}\" {4}='<%# Bind(\"[{5}]\"{6}) %>'></InfoLight:WebDateTimePicker>",
                                "None",
                                (BFI.DataType == typeof(DateTime)) ? "DateTime" : "Varchar",
                                BFI.DataField,
                                WzdUtils.RemoveSpecialCharacters("wdt" + BlockItem.TableName + BFI.DataField + "E"),
                                (BFI.DataType == typeof(DateTime)) ? "Text" : "DateString",
                                BFI.DataField,
                                FormatStyle);
                        }
                        builder.AppendLine(dtHTML);
                        break;
                }
            }
            else if (template == "footer")
            {
                switch (controlType)
                {
                    case "RefValBox":
                        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);

                        DataSet aDataSet = new DataSet();
                        StringBuilder RefColumns = new StringBuilder("<Columns>");
                        aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", BFI.RefValNo);
                        WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, aDataSet, BFI.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("");
                        }

                        String DataSourceID = GenWebDataSource(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "RefVal", "");
                        String refvalHTML = String.Empty;
                        if (isAjaxPage)
                        {
                            refvalHTML = String.Format("<AjaxTools:AjaxRefVal ID=\"{0}\" runat=\"server\" BindingValue='<%# Bind(\"[{1}]\"{5}) %>' " +
                                        "DataSourceID=\"{2}\" " +
                                        "DataTextField=\"{3}\" DataValueField=\"{4}\" ResxDataSet=\"\">" +
                                         RefColumns.ToString() +
                                        "</AjaxTools:AjaxRefVal>",
                                        WzdUtils.RemoveSpecialCharacters("arv" + BlockItem.TableName + BFI.DataField + "F"),
                                        BFI.DataField,
                                        DataSourceID,
                                        FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                        FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                        FormatStyle
                                        );
                        }
                        else
                        {
                            refvalHTML = 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>",
                                        WzdUtils.RemoveSpecialCharacters("wrv" + BlockItem.TableName + BFI.DataField + "F"),
                                        BFI.DataField,
                                        DataSourceID,
                                        FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                        FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                        FormatStyle
                                        );
                        }
                        builder.AppendLine(refvalHTML);
                        break;
                    case "ComboBox":
                        string comboHTML = string.Format("<InfoLight:WebDropDownList runat=\"server\" ID=\"{0}\" DataSourceID=\"{1}\" DataTextField=\"{2}\" DataValueField=\"{3}\" DataMember=\"{4}\"></InfoLight:WebDropDownList>",
                            WzdUtils.RemoveSpecialCharacters("wdd" + BlockItem.TableName + BFI.DataField + "F"),
                            GenWebDataSource(BFI, BFI.ComboEntityName, "ComboBox", ""),
                            BFI.ComboTextField,
                            BFI.ComboValueField,
                            BFI.ComboEntityName);
                        builder.AppendLine(comboHTML);
                        break;
                    case "ValidateBox":
                        String validateHTML = String.Format("<InfoLight:WebValidateBox ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"[{1}]\"{3}) %>' ValidateField=\"{1}\" WebValidateID=\"{2}\"></InfoLight:WebValidateBox>",
                                    WzdUtils.RemoveSpecialCharacters("wvb" + BlockItem.TableName + BFI.DataField + "F"),
                                    BFI.DataField,
                                    "wv" + WzdUtils.RemoveSpecialCharacters(BlockItem.TableName),
                                    FormatStyle);
                        builder.AppendLine(validateHTML);
                        break;
                    case "CheckBox":
                        String checkHTML = String.Format("<asp:CheckBox ID=\"{0}\" runat=\"server\" Checked='<%# Bind(\"[{1}]\"{2}) %>'></asp:CheckBox>",
                                    WzdUtils.RemoveSpecialCharacters("cb" + BlockItem.TableName + BFI.DataField + "F"),
                                    BFI.DataField,
                                    FormatStyle);
                        builder.AppendLine(checkHTML);
                        break;
                    case "DateTimeBox":
                        String dtHTML = String.Empty;
                        if (isAjaxPage)
                        {
                            dtHTML = String.Format("<AjaxTools:AjaxDateTimePicker runat=\"server\" DateFormat=\"{0}\" DateTimeType=\"{1}\" Localize=\"False\" MinYear=\"1950\" MaxYear=\"2050\" ToolTip=\"{2}\" Width=\"100px\" ID=\"{3}\" {4}='<%# Bind(\"[{5}]\"{6}) %>'></AjaxTools:AjaxDateTimePicker>",
                                "None",
                                (BFI.DataType == typeof(DateTime)) ? "DateTime" : "Varchar",
                                BFI.DataField,
                                WzdUtils.RemoveSpecialCharacters("wdt" + BlockItem.TableName + BFI.DataField + "F"),
                                (BFI.DataType == typeof(DateTime)) ? "Text" : "DateString",
                                BFI.DataField,
                                FormatStyle);
                        }
                        else
                        {
                            dtHTML = string.Format("<InfoLight:WebDateTimePicker runat=\"server\" UseButtonImage=\"True\" DateFormat=\"{0}\" DateTimeType=\"{1}\" Localize=\"False\" MinYear=\"1950\" MaxYear=\"2050\" ToolTip=\"{2}\" Width=\"100px\" ID=\"{3}\"></InfoLight:WebDateTimePicker>",
                                "None",
                                (BFI.DataType == typeof(DateTime)) ? "DateTime" : "Varchar",
                                BFI.DataField,
                                WzdUtils.RemoveSpecialCharacters("wdt" + BlockItem.TableName + BFI.DataField + "F"));
                        }
                        builder.AppendLine(dtHTML);
                        break;
                }
            }
            else if (template == "item")
            {
                switch (controlType)
                {
                    case "RefValBox":
                        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);

                        DataSet aDataSet = new DataSet();
                        StringBuilder RefColumns = new StringBuilder("<Columns>");
                        aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", BFI.RefValNo);
                        WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, aDataSet, BFI.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("");
                        }

                        String DataSourceID = GenWebDataSource(BFI, WzdUtils.RemoveSpecialCharacters(BlockItem.TableName), "RefVal", "");
                        String refvalHTML = 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\" BorderStyle=\"None\" ResxDataSet=\"\" " +
                                    "ResxFilePath=\"\" UseButtonImage=\"True\" Width=\"100px\" BackColor=\"Transparent\"> " +
                                     RefColumns.ToString() +
                                    "</InfoLight:WebRefVal>",
                                    WzdUtils.RemoveSpecialCharacters("wrv" + BlockItem.TableName + BFI.DataField + "E"),
                                    BFI.DataField,
                                    DataSourceID,
                                    FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString(),
                                    FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString(),
                                    FormatStyle
                                    );
                        builder.AppendLine(refvalHTML);
                        break;
                    default:
                        string labelHTML = string.Format("<asp:Label runat=\"server\" ToolTip=\"{0}\" ID=\"{1}\" Text='<%# Bind(\"[{2}]\"{3}) %>'></asp:Label>",
                            BFI.DataField,
                            WzdUtils.RemoveSpecialCharacters("l" + BlockItem.TableName + BFI.DataField),
                            BFI.DataField,
                            FormatStyle);
                        builder.AppendLine(labelHTML);
                        break;
                }
            }
            return builder.ToString();
        }
Example #18
0
 public TNodeObject(TreeNode aTreeNode, TExtWebClientData ClientData, Object Container)
 {
     Node = aTreeNode;
     aTreeNode.Tag = this;
     FBlockItem = new TBlockItem();
     PropertyInfo aInfo = Container.GetType().GetProperty("ID");
     if (aInfo != null)
     {
         FBlockItem.Name = aInfo.GetValue(Container, null) as String;
     }
     FBlockItem.WebContainerControl = Container;
     ClientData.Blocks.Add(FBlockItem);
 }
Example #19
0
        private void GenMainBlockControl_3(TBlockItem BlockItem, String FormViewName)
        {
            bool isAjaxPage = false;
            if (FPage.FindControl("AjaxScriptManager1") != null)
                isAjaxPage = true;

            WebDataSource Master = (WebDataSource)FPage.FindControl("Master");
            Master.DataMember = FClientData.ProviderName;
            Master.DataMember = Master.DataMember.Substring(Master.DataMember.IndexOf('.') + 1, Master.DataMember.Length -
                                Master.DataMember.IndexOf('.') - 1);

            if (FormViewName == "wfvMaster")
                Master.AutoApply = true;
            BlockItem.wDataSource = Master;
            WebFormView wfvMaster = (WebFormView)FPage.FindControl(FormViewName);
            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;
            Boolean Done = false;

            //Generate RESX
            WebGridView aGridView = (WebGridView)FPage.FindControl("WgView");
            if (aGridView == null)
                aGridView = (WebGridView)FPage.FindControl("WebGridView1");
            if (aGridView == null)
                aGridView = (WebGridView)FPage.FindControl("wgvMaster");
            if (aGridView != null)
                aGridView.WizardDesignMode = true;
            GenResx(Master);
            if (aGridView != null)
                aGridView.WizardDesignMode = false;
            if (FClientData.BaseFormName == "WSingle3" || FClientData.BaseFormName == "WSingle4" || FClientData.BaseFormName == "WMasterDetail3"
                || FClientData.BaseFormName == "WMasterDetail8" || FClientData.BaseFormName == "VBWebCMasterDetail8")
            {
                aGridView = null;
            }

            //DataSet Dset = new DataSet();
            //if (FPage.Site.DesignMode)
            //{
            //    Dset = GetDD(wfvMaster);
            //}

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

            foreach (TBlockFieldItem aFieldItem in BlockItem.BlockFieldItems)
            {
                if (!Done)
                {
                    GenDefault(aFieldItem, aDefault, aValidate);
                    CreateQueryField(aFieldItem, "", null, BlockItem.TableName);
                }
            }
            Done = true;

            //GridView
            System.Web.UI.WebControls.BoundField aBoundField = null;
            System.Web.UI.WebControls.TemplateField aTemplateField = null;
            List<string> KeyFields = new List<string>();
            if (aGridView != null)
            {
                while (aGridView.Columns.Count > 1)
                    aGridView.Columns.RemoveAt(1);

                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, aGridView, FLabelList);
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewAjaxRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, aGridView, FLabelList);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewAjaxRefValFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FAjaxRefValList, FClientData.DatabaseType, aGridView, FLabelList);
                        }
                        else
                        {
                            aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewRefValEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, aGridView);
                            aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewRefValItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, aGridView);
                            aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewRefValFooterItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList, FClientData.DatabaseType, aGridView);
                        }
                        aGridView.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);
                        aGridView.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);
                        aGridView.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);
                        aGridView.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, aGridView);
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, aGridView);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewAjaxDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FAjaxDateTimePickerList, FLabelList, aGridView);
                            }
                            else
                            {
                                aTemplateField.EditItemTemplate = new WebControlTemplate("WebGridViewDateTimeEditItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, aGridView);
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewDateTimeItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, aGridView);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewDateTimeFooterItemTemplate", BFI, BlockItem.TableName, FWebDateTimePickerList, FLabelList, aGridView);
                            }
                            aGridView.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, aGridView);
                                aTemplateField.ItemTemplate = new WebControlTemplate("WebGridViewTextBoxItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, aGridView);
                                aTemplateField.FooterTemplate = new WebControlTemplate("WebGridViewTextBoxFooterItemTemplate", BFI, BlockItem.TableName, FWebTextBoxList, FLabelList, aGridView);
                                aGridView.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;
                                aGridView.Columns.Add(aBoundField);
                            }
                        }
                    }
                }
            }
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));

            //AjaxTools.AjaxGridView aAjaxGridView = (AjaxTools.AjaxGridView)FPage.FindControl("AjaxGridView1");
            //if (aAjaxGridView != null)
            //{
            //    DataTable srcTable = GetDesignTable(Master);
            //    bool flag = true;
            //    foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
            //    {
            //        AjaxTools.ExtGridColumn extCol = new AjaxTools.ExtGridColumn();
            //        extCol.AllowSort = false;
            //        extCol.ColumnName = string.Format("col{0}", BFI.DataField);
            //        extCol.DataField = BFI.DataField;
            //        extCol.ExpandColumn = true;
            //        extCol.HeaderText = BFI.Description;
            //        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;
            //        this.FieldTypeSelector(BFI.DataType, extCol);

            //        aAjaxGridView.Columns.Add(extCol);
            //        flag = !flag;
            //    }
            //    NotifyRefresh(200);
            //    FComponentChangeService.OnComponentChanged(aAjaxGridView, null, "", "M");
            //}

            if (wfvMaster != null)
            {

                //wfvMaster.EditItemTemplate = new MyTemplate("WebFormViewEditItemTemplate", BFI, BlockItem.TableName, DataSourceID, FClientData.Owner.GlobalConnection, FWebRefValList);
                FormViewDesigner aDesigner = FDesignerHost.GetDesigner(wfvMaster) as FormViewDesigner;

                //FormView
                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());
                            //Control[] ctrls = ControlParser.ParseControls(host, content);
                            int i = 0;
                            int j = 0;
                            int m = wfvMaster.LayOutColNum * 2;

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

                            foreach (TBlockFieldItem aFieldItem in BlockItem.BlockFieldItems)
                            {
                                String FormatStyle = FormatEditMask(aFieldItem.EditMask);

                                if (!Done)
                                {
                                    GenDefault(aFieldItem, aDefault, aValidate);
                                    CreateQueryField(aFieldItem, "", null, BlockItem.TableName);
                                }

                                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 = "wrv" + BlockItem.TableName + aFieldItem.DataField + ExtraName;
                                                aViewField.FieldName = aFieldItem.DataField;
                                                wfvMaster.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 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>",
                                                "wrv" + 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 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>",
                                                                "arv" + 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>",
                                                "wrv" + 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 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>",
                                                "wdd" + 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>",
                                                "wdd" + 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 = "wdd" + BlockItem.TableName + aFieldItem.DataField + ExtraName;
                                                aViewField.FieldName = aFieldItem.DataField;
                                                wfvMaster.Fields.Add(aViewField);
                                            }
                                            break;
                                        case "ItemTemplate":
                                            ExtraName = "";
                                            S5 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                            break;
                                    }
                                    lists.Add(S5);
                                }
                                else if (aFieldItem.ControlType == "ValidateBox")
                                {
                                    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>",
                                                "wvb" + 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 = "wdd" + BlockItem.TableName + aFieldItem.DataField + ExtraName;
                                                aViewField.FieldName = aFieldItem.DataField;
                                                wfvMaster.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>",
                                                "wvb" + 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>", "l" + aFieldItem.DataField, aFieldItem.DataField, FormatStyle);
                                            break;
                                    }
                                    lists.Add(S6);
                                }
                                else if (aFieldItem.ControlType == "CheckBox")
                                {
                                    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>",
                                                "cb" + 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>",
                                                "wvb" + 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>", "l" + 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 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>",
                                                            "wdtp" + 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>",
                                                            "wdtp" + 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>",
                                                            "wdtp" + 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>",
                                                            "wdtp" + 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>",
                                                            "wdtp" + 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>",
                                                            "wdtp" + 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>",
                                                            "wdtp" + 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>",
                                                            "wdtp" + 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;
                                            }
                                        }
                                        lists.Add(S4);
                                    }
                                    else
                                    {
                                        if (tempDefin.Name == "ItemTemplate")
                                        {
                                            String S3 = String.Format("<asp:Label ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>'></asp:Label>", "l" + 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 = "tb" + aFieldItem.DataField;
                                                    aViewField.FieldName = aFieldItem.DataField;
                                                    wfvMaster.Fields.Add(aViewField);
                                                }
                                            }
                                            String S4 = String.Format("<asp:TextBox ID=\"{0}\" runat=\"server\" Text='<%# Bind(\"{1}\"{2}) %>' MaxLength=\"{3}\"></asp:TextBox>", "tb" + 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();
                        }
                    }
                }
            }

            Object aAjaxLayout = FPage.FindControl("AjaxLayout1");
            if (aAjaxLayout != null)
            {
                aAjaxLayout.GetType().GetProperty("Title").SetValue(aAjaxLayout, FClientData.FormTitle, null);
                FComponentChangeService.OnComponentChanged(aAjaxLayout, null, "", "M");
            }
            Object aAjaxFormView = FPage.FindControl("AjaxFormView1");
            if (aAjaxFormView != null)
            {
                bool flag = true;
                DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName];
                IList iFields = aAjaxFormView.GetType().GetProperty("Fields").GetValue(aAjaxFormView, null) as IList;
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    Type fieldsType = aAjaxFormView.GetType().GetProperty("Fields").PropertyType.GetProperties()[0].PropertyType;
                    object extCol = Activator.CreateInstance(fieldsType);
                    if (BFI.CheckNull == "Y")
                        extCol.GetType().GetProperty("AllowNull").SetValue(extCol, false, null);
                    else
                        extCol.GetType().GetProperty("AllowNull").SetValue(extCol, true, null);
                    if (BFI.Description != null && BFI.Description != String.Empty)
                        extCol.GetType().GetProperty("Caption").SetValue(extCol, BFI.Description, null);
                    else
                        extCol.GetType().GetProperty("Caption").SetValue(extCol, BFI.DataField, null);
                    extCol.GetType().GetProperty("DataField").SetValue(extCol, BFI.DataField, null);
                    extCol.GetType().GetProperty("DefaultValue").SetValue(extCol, BFI.DefaultValue, null);
                    extCol.GetType().GetProperty("FieldControlId").SetValue(extCol, string.Format("ctrl{0}", 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, 140, 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);
                    iFields.Add(extCol);
                    flag = !flag;
                }
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(aAjaxFormView, null, "", "M");
            }

            FWebDefaultList.Add(aDefault);
            FWebValidateList.Add(aValidate);
            NotifyRefresh(200);
            FComponentChangeService.OnComponentChanged(wfvMaster, null, "", "M");
            FComponentChangeService.OnComponentChanged(Master, null, "", "M");
            FComponentChangeService.OnComponentChanged(aGridView, null, "", "M");
        }
Example #20
0
        private void DisplaySelection(TBlockItem BlockItem)
        {
            cbBindingSource.SelectedIndexChanged -= cbBindingSource_SelectedIndexChanged;
            cbViewBindingSource.SelectedIndexChanged -= cbViewBindingSource_SelectedIndexChanged;
            cbControlType.SelectedIndexChanged -= cbControlType_SelectedIndexChanged;
            cbBindingSource.Text = "";
            cbViewBindingSource.Text = "";
            cbControlType.Text = "";
            EnableBindingInformation(BlockItem);
            if (BlockItem.BindingSource != null)
                cbBindingSource.Text = BlockItem.BindingSource.Site.Name;
            if (BlockItem.ViewBindingSource != null)
                cbViewBindingSource.Text = BlockItem.ViewBindingSource.Site.Name;
            if (BlockItem.LayoutKind == TLayoutType.ltTextBox)
                cbControlType.Text = "TextBox";
            if (BlockItem.LayoutKind == TLayoutType.ltDataGridView)
                cbControlType.Text = "Grid";

            //Columns
            foreach (TBlockFieldItem BlockFieldItem in BlockItem.BlockFieldItems)
            {
                ListViewItem ListItem = lvSelectedFields.Items.Add(BlockFieldItem.DataField);
                ListItem.SubItems.Add(BlockFieldItem.Description);
                ListViewItem.ListViewSubItem LVSI = ListItem.SubItems.Add("");
                CreateRefValButton(ListItem, LVSI, btnRefVal_Click);
                ListItem.Tag = BlockFieldItem;
            }
            cbBindingSource.SelectedIndexChanged += cbBindingSource_SelectedIndexChanged;
            cbViewBindingSource.SelectedIndexChanged += cbViewBindingSource_SelectedIndexChanged;
            cbControlType.SelectedIndexChanged += cbControlType_SelectedIndexChanged;
        }
Example #21
0
 private void GenBlock(TBlockItem BlockItem, string DataSetName, bool GenField)
 {
     SetBlockFieldControls(BlockItem);
 }
Example #22
0
 private void EnableBindingInformation(TBlockItem BlockItem)
 {
     cbBindingSource.Enabled = false;
     cbControlType.Enabled = false;
     cbViewBindingSource.Enabled = false;
     ClearRefValButton(lvSelectedFields);
     lvSelectedFields.Items.Clear();
     btnAddField.Enabled = false;
     btnDeleteField.Enabled = false;
     if (BlockItem.ContainerControl is Form || BlockItem.ContainerControl is Panel ||
         BlockItem.ContainerControl is TabPage)
     {
         cbBindingSource.Enabled = true;
         cbControlType.Enabled = true;
         btnAddField.Enabled = true;
         btnDeleteField.Enabled = true;
     }
     if (BlockItem.ContainerControl is DataGridView || BlockItem.ContainerControl is DataGrid)
     {
         cbBindingSource.Enabled = true;
         btnAddField.Enabled = true;
         btnDeleteField.Enabled = true;
     }
     if (BlockItem.ContainerControl is InfoNavigator)
     {
         cbBindingSource.Enabled = true;
         cbViewBindingSource.Enabled = true;
     }
 }
Example #23
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
        }
Example #24
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
        }
Example #25
0
 private string GetDDText(string ControlText, TBlockItem BlockItem, String TemplateName)
 {
     int Index1 = ControlText.IndexOf("Bind(\"");
     if (Index1 < 0)
     {
         foreach (TBlockFieldItem FieldItem in BlockItem.BlockFieldItems)
         {
             if (String.Compare(ControlText, FieldItem.DataField) == 0)
             {
                 // <asp:Label ID="CaptionGROUPID" runat="server" Text="群組編號:"></asp:Label>
                 String Description = FieldItem.Description;
                 if (Description == null || Description == "")
                     Description = FieldItem.DataField;
                 String ExtraName = "";
                 if (TemplateName == "ItemTemplate")
                     ExtraName = "I";
                 return String.Format("<asp:Label ID=\"Caption{0}\" runat=\"server\" Text=\"{1}:\"></asp:Label>",
                     ExtraName + FieldItem.DataField, Description);
             }
         }
         return ControlText + ":";
     }
     else
     {
         return ControlText;
     }
 }
Example #26
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
        }
Example #27
0
 private void SetBlockFieldDataComponent(TBlockItem BlockItem, string DataSetName)
 {
     InfoBindingSource aBindingSource = FDesignerHost.CreateComponent(typeof(InfoBindingSource), "ibs" + BlockItem.TableName) as InfoBindingSource;
     if (BlockItem.ParentItemName == "")
     {
         aBindingSource.DataSource = FDataSet;
         aBindingSource.DataMember = BlockItem.TableName;
     }
     else
     {
         TBlockItem ParentItem = ((TBlockItems)BlockItem.Collection).FindItem(BlockItem.ParentItemName);
         aBindingSource.DataSource = ParentItem.BindingSource;
         aBindingSource.DataMember = BlockItem.RelationName;
     }
     BlockItem.BindingSource = aBindingSource;
 }
Example #28
0
        private void GenViewBlockControl(TBlockItem BlockItem)
        {
            #if VS90
            object oView = FDesignerDocument.webControls.item("View", 0);
            if (oView == null)
                oView = FDesignerDocument.webControls.item("Master", 0);

            WebDevPage.IHTMLElement eView = null;
            WebDevPage.IHTMLElement eWebView1 = null;

            if (oView == null || !(oView is WebDevPage.IHTMLElement))
                return;
            eView = (WebDevPage.IHTMLElement)oView;
            BlockItem.wDataSource = new WebDataSource();
            String viewDataMember = FClientData.ViewProviderName.Substring(FClientData.ViewProviderName.IndexOf('.') + 1, FClientData.ViewProviderName.Length -
                                                    FClientData.ViewProviderName.IndexOf('.') - 1);
            if (eView != null)
            {
                eView.setAttribute("DataMember", viewDataMember, 0);
            }

            object oWebView1 = FDesignerDocument.webControls.item("WgView", 0);
            if (oWebView1 != null)
            {
                eWebView1 = (WebDevPage.IHTMLElement)oWebView1;
                //eWebView1.setAttribute("DataMember", viewDataMember, 0);
            }

            if (oWebView1 == null)
                oWebView1 = FDesignerDocument.webControls.item("WebGridView1", 0);

            if (oWebView1 != null)
            {
                eWebView1 = (WebDevPage.IHTMLElement)oWebView1;

                //这里本来想再往下找Columns节点的,可是找不到,只能先这样写了
                StringBuilder sb = new StringBuilder(eWebView1.innerHTML);
                int idx = eWebView1.innerHTML.IndexOf("</Columns>");
                List<string> KeyFields = new List<string>();
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    idx = sb.ToString().IndexOf("</Columns>");
                    sb.Insert(idx, "\r            <asp:BoundField DataField=\"" + BFI.DataField + "\" HeaderText=\"" + (string.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description) + "\" SortExpression=\"" + BFI.DataField + "\" />\r\n            ");
                }
                eWebView1.innerHTML = sb.ToString();
            }

            AjaxTools.ExtGridColumnCollection aExtGridColumnCollection = new AjaxTools.ExtGridColumnCollection(new AjaxTools.AjaxGridView(), typeof(AjaxTools.ExtColumnMatch));
            AjaxTools.ExtQueryFieldCollection aExtQueryFieldCollection = new ExtQueryFieldCollection(new AjaxTools.AjaxGridView(), typeof(AjaxTools.ExtQueryField));
            bool flag = true;
            DataTable srcTable = FWizardDataSet.RealDataSet.Tables[BlockItem.TableName];
            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;
                extCol.ReadOnly = true;
                if (BFI.QueryMode == "Normal")
                {
                    AjaxTools.ExtQueryField aExtQueryField = new AjaxTools.ExtQueryField();
                    aExtQueryField.Condition = "And";
                    aExtQueryField.Id = BFI.DataField;
                    aExtQueryField.DataField = BFI.DataField;
                    aExtQueryField.Caption = BFI.Description;
                    if (BFI.DataType == typeof(int) || BFI.DataType == typeof(float) || BFI.DataType == typeof(double))
                    {
                        aExtQueryField.Operator = "=";
                    }
                    else
                    {
                        aExtQueryField.Operator = "%";
                    }
                    aExtQueryFieldCollection.Add(aExtQueryField);
                }
                else if (BFI.QueryMode == "Range")
                {
                    AjaxTools.ExtQueryField aExtQueryField = new AjaxTools.ExtQueryField();
                    aExtQueryField.Id = BFI.DataField;
                    aExtQueryField.DataField = BFI.DataField;
                    aExtQueryField.Caption = BFI.Description;
                    aExtQueryField.Condition = "And";
                    aExtQueryField.Operator = ">=";
                    aExtQueryFieldCollection.Add(aExtQueryField);

                    AjaxTools.ExtQueryField aExtQueryField2 = new AjaxTools.ExtQueryField();
                    aExtQueryField2.Id = BFI.DataField + "2";
                    aExtQueryField2.DataField = BFI.DataField;
                    aExtQueryField2.Caption = BFI.Description;
                    aExtQueryField2.Condition = "And";
                    aExtQueryField2.Operator = "<=";
                    aExtQueryFieldCollection.Add(aExtQueryField2);
                }
                this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType);

                aExtGridColumnCollection.Add(extCol);
                flag = !flag;
            }

            WebDevPage.IHTMLElement AjaxGridView1 = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("AjaxGridView1", 0);
            if (AjaxGridView1 != null)
            {
                SetCollectionValue(AjaxGridView1, typeof(AjaxTools.AjaxGridView).GetProperty("Columns"), aExtGridColumnCollection);
            }
            if (AjaxGridView1 != null && aExtQueryFieldCollection.Count > 0)
            {
                SetCollectionValue(AjaxGridView1, typeof(AjaxTools.AjaxGridView).GetProperty("QueryFields"), aExtQueryFieldCollection);
            }
            #else

            WebDataSource View = (WebDataSource)FPage.FindControl("View");
            if (View == null)
                View = (WebDataSource)FPage.FindControl("Master");
            BlockItem.wDataSource = View;
            View.DataMember = FClientData.ViewProviderName;
            if (View.DataMember == null || View.DataMember == "")
                View.DataMember = FClientData.ProviderName;
            View.DataMember = View.DataMember.Substring(View.DataMember.IndexOf('.') + 1, View.DataMember.Length -
                View.DataMember.IndexOf('.') - 1);
            IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
            FComponentChangeService.OnComponentChanged(View, null, "", "M");
            WebGridView WgView = (WebGridView)FPage.FindControl("WgView");
            if (WgView == null)
                WgView = (WebGridView)FPage.FindControl("WebGridView1");
            //???WebGridView2.Columns.Clear();
            if (WgView != null)
            {
                System.Web.UI.WebControls.BoundField Field = null;
                List<string> KeyFields = new List<string>();
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    Field = new System.Web.UI.WebControls.BoundField();
                    Field.DataField = BFI.DataField;
                    Field.SortExpression = BFI.DataField;
                    Field.HeaderText = BFI.Description;
                    //Field.HeaderStyle.Width = BFI.Length * ColumnWidthPixel;
                    if (Field.HeaderText == "")
                        Field.HeaderText = BFI.DataField;
                    if (BFI.IsKey)
                        KeyFields.Add(Field.DataField);
                    WgView.Columns.Add(Field);
                }
                FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
                FComponentChangeService.OnComponentChanged(WgView, null, "", "M");
            }

            //AjaxTools.AjaxGridView aAjaxGridView = FPage.FindControl("AjaxGridView1") as AjaxTools.AjaxGridView;
            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);
                    if (BFI.QueryMode == "Normal")
                    {
                        IList iQueryFields = aAjaxGridView.GetType().GetProperty("QueryFields").GetValue(aAjaxGridView, null) as IList;
                        Type queryFieldsType = aAjaxGridView.GetType().GetProperty("QueryFields").PropertyType.GetProperties()[0].PropertyType;
                        object aQueryField = Activator.CreateInstance(queryFieldsType);
                        aQueryField.GetType().GetProperty("Condition").SetValue(aQueryField, "And", null);
                        aQueryField.GetType().GetProperty("DataField").SetValue(aQueryField, BFI.DataField, null);
                        aQueryField.GetType().GetProperty("Caption").SetValue(aQueryField, BFI.Description, null);
                        if (BFI.DataType == typeof(int) || BFI.DataType == typeof(float) || BFI.DataType == typeof(double))
                        {
                            aQueryField.GetType().GetProperty("Operator").SetValue(aQueryField, "=", null);
                        }
                        else
                        {
                            aQueryField.GetType().GetProperty("Operator").SetValue(aQueryField, "%", null);
                        }
                        iQueryFields.Add(aQueryField);
                    }
                    else if (BFI.QueryMode == "Range")
                    {
                        IList iQueryFields = aAjaxGridView.GetType().GetProperty("QueryFields").GetValue(aAjaxGridView, null) as IList;
                        Type queryFieldsType = aAjaxGridView.GetType().GetProperty("QueryFields").PropertyType.GetProperties()[0].PropertyType;
                        object aQueryField = Activator.CreateInstance(queryFieldsType);
                        aQueryField.GetType().GetProperty("Condition").SetValue(aQueryField, "And", null);
                        aQueryField.GetType().GetProperty("DataField").SetValue(aQueryField, BFI.DataField, null);
                        aQueryField.GetType().GetProperty("Caption").SetValue(aQueryField, BFI.Description, null);
                        aQueryField.GetType().GetProperty("Condition").SetValue(aQueryField, "And", null);
                        aQueryField.GetType().GetProperty("Operator").SetValue(aQueryField, ">=", null);
                        iQueryFields.Add(aQueryField);

                        object aQueryField2 = Activator.CreateInstance(queryFieldsType);
                        aQueryField2.GetType().GetProperty("Condition").SetValue(aQueryField2, "And", null);
                        aQueryField2.GetType().GetProperty("DataField").SetValue(aQueryField2, BFI.DataField, null);
                        aQueryField2.GetType().GetProperty("Caption").SetValue(aQueryField2, BFI.Description, null);
                        aQueryField2.GetType().GetProperty("Condition").SetValue(aQueryField2, "And", null);
                        aQueryField2.GetType().GetProperty("Operator").SetValue(aQueryField2, "<=", null);
                        iQueryFields.Add(aQueryField2);

                    }
                    this.FieldTypeSelector(BFI.DataType, extCol, BFI.ControlType);
                    iColumns.Add(extCol);
                    //AjaxTools.ExtGridColumn extCol = new AjaxTools.ExtGridColumn();
                    //extCol.AllowSort = false;
                    //extCol.ColumnName = string.Format("col{0}", BFI.DataField);
                    //extCol.DataField = BFI.DataField;
                    //extCol.ExpandColumn = true;
                    //extCol.HeaderText = BFI.Description;
                    //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;
                    //this.FieldTypeSelector(BFI.DataType, extCol);

                    //aAjaxGridView.Columns.Add(extCol);
                    flag = !flag;
                }
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(aAjaxGridView, null, "", "M");
            }

            /*
            WebGridView2.DataKeyNames = new string[KeyFields.Count];
            for (int I = 0; I < KeyFields.Count; I++)
                WebGridView2.DataKeyNames[I] = KeyFields[I];
             *
             */

            /*
            if (FClientData.IsMasterDetailBaseForm())
            {
                InfoDataSet ViewDataSet = FDesignerHost.CreateComponent(typeof(InfoDataSet), "idView") as InfoDataSet;
                ViewDataSet.RemoteName = FClientData.ViewProviderName;
                if (ViewDataSet.RemoteName.Trim() == "")
                {
                    ViewDataSet.RemoteName = FClientData.ProviderName;
                }
                ViewDataSet.Active = true;
                InfoBindingSource ViewBindingSource = FDesignerHost.CreateComponent(typeof(InfoBindingSource),
                    "ibsView") as InfoBindingSource;
                ViewBindingSource.DataSource = ViewDataSet;
                ViewBindingSource.DataMember = ViewDataSet.RealDataSet.Tables[0].TableName;
                BlockItem.BindingSource = ViewBindingSource;
                InfoNavigator navigator1 = FRootForm.Controls["infoNavigator1"] as InfoNavigator;
                if (navigator1 != null)
                    navigator1.ViewBindingSource = ViewBindingSource;
                InfoRelation Relation = new InfoRelation();
                Relation.RelationDataSet = FDataSet;
                InfoKeyField KeyField;
                KeyField = new InfoKeyField();
                KeyField.FieldName = ViewDataSet.RealDataSet.Tables[0].Columns[0].ColumnName;
                Relation.SourceKeyFields.Add(KeyField);
                KeyField = new InfoKeyField();
                KeyField.FieldName = ViewDataSet.RealDataSet.Tables[0].Columns[0].ColumnName;
                Relation.TargetKeyFields.Add(KeyField);
                Relation.Active = true;
                ViewBindingSource.Relations.Add(Relation);
            }

            TBlockFieldItem FieldItem;
            System.Windows.Forms.SplitContainer scMaster = FRootForm.Controls["scMaster"] as System.Windows.Forms.SplitContainer;
            FViewGrid = FDesignerHost.CreateComponent(typeof(InfoDataGridView), "grdView") as InfoDataGridView;
            FViewGrid.Parent = scMaster.Panel1;
            FViewGrid.Dock = DockStyle.Fill;
            FViewGrid.TabIndex = 0;
            FViewGrid.DataSource = BlockItem.BindingSource;

            if (FClientData.IsMasterDetailBaseForm())
            {
                //???FViewGrid.Columns.Clear();
                DataGridViewColumn Column;
                int I, Index;
                for (I = 0; I < BlockItem.BlockFieldItems.Count; I++)
                {
                    FieldItem = BlockItem.BlockFieldItems[I] as TBlockFieldItem;
                    if (FieldItem.Description == "")
                        Index = FViewGrid.Columns.Add(FieldItem.DataField, FieldItem.DataField);
                    else
                        Index = FViewGrid.Columns.Add(FieldItem.DataField, FieldItem.Description);
                    Column = FViewGrid.Columns[Index];
                    Column.DataPropertyName = FieldItem.DataField;
                    if (Column.HeaderText.Trim() == "")
                        Column.HeaderText = FieldItem.DataField;
                }
            }
             */
            #endif
        }
Example #29
0
 private void LoadBlocks(XmlNode Node)
 {
     int I;
     TBlockItem BI;
     XmlNode BlockNode, BlockFieldItemsNode;
     for (I = 0; I < Node.ChildNodes.Count; I++)
     {
         BlockNode = Node.ChildNodes[I];
         BI = new TBlockItem();
         BI.Name = BlockNode.Attributes["Name"].Value;
         BI.ProviderName = BlockNode.Attributes["ProviderName"].Value;
         BI.TableName = BlockNode.Attributes["TableName"].Value;
         BlockFieldItemsNode = WzdUtils.FindNode(null, BlockNode, "BlockFieldItems");
         LoadBlockFieldItems(BlockFieldItemsNode, BI.BlockFieldItems);
         Blocks.Add(BI);
     }
 }
Example #30
0
        private void SetBlockFieldControls(TBlockItem BlockItem)
        {
            int columnCount = 0;
            if (BlockItem.Name == "View")
            {
                if (FClientData.BaseFormName == "SL3DCard" || FClientData.BaseFormName == "SL3DCardMasterDetail"
                    || FClientData.BaseFormName == "SLFormList" || FClientData.BaseFormName == "SLFormListMasterDetail")
                    columnCount = 1;
                else
                    columnCount = 2;
                if (FClientData.ColumnCount != 0)
                    columnCount = FClientData.ColumnCount;
                GenViewBlockControl(BlockItem, columnCount);

                if (FClientData.BaseFormName == "SLFormList" || FClientData.BaseFormName == "SLFormListMasterDetail")
                {
                    int itemHeight = 46 + BlockItem.BlockFieldItems.Count * 30 + 34;
                    WriteToXaml(FClientData.FullXamlName,
                                "Name=\"formlist1\" ItemHeight=\"150\"",
                                String.Format("Name=\"formlist1\" ItemHeight=\"{0}\" FormListItemTitle=\"{1}\"",
                                itemHeight.ToString(),
                                FClientData.FormTitle));
                }
                else if (FClientData.BaseFormName == "SL3DCard" || FClientData.BaseFormName == "SL3DCardMasterDetail")
                {
                    WriteToXaml(FClientData.FullXamlName,
                                "Name=\"slcardMaster\"",
                                String.Format("Name=\"slcardMaster\" CardItemTitle=\"{0}\"",
                                FClientData.FormTitle));
                }
            }
            else if (BlockItem.Name == "Main" || BlockItem.Name == "Master")
            {
                if (FClientData.BaseFormName == "SLSingle" || FClientData.BaseFormName == "SLQuery"
                    || FClientData.BaseFormName == "SLMasterDetail" || FClientData.BaseFormName == "SLMasterDetail2"
                    || FClientData.BaseFormName == "SLMasterDetail3"
                    || FClientData.BaseFormName == "SLFormList" || FClientData.BaseFormName == "SLFormListMasterDetail")
                {
                    columnCount = 2;

                }
                else if (FClientData.BaseFormName == "SL3DCard" || FClientData.BaseFormName == "SL3DCardMasterDetail")
                {
                    columnCount = 2;
                    //GenMainBlockControlFor3DCard(BlockItem, columnCount);
                }
                if (FClientData.ColumnCount != 0)
                    columnCount = FClientData.ColumnCount;
                GenMainBlockControl(BlockItem, columnCount);
            }
        }