示例#1
0
        private void GenDetailBlock(String TemplateName)
        {
            MWizard.TBlockItem BlockItem = null;
            foreach (TBlockItem B in FClientData.Blocks)
            {
                if (B.wDataSource == null)
                {
                    BlockItem = B;
                    break;
                }
            }

            #if VS90

            JQDefault Default = new JQDefault();
            Default.ID = "defaultDetail"; // +BlockItem.TableName;
            Default.BindingObjectID = "dataGridDetail";

            JQValidate Validate = new JQValidate();
            Validate.ID = "validateDetail"; // +BlockItem.TableName;
            Validate.BindingObjectID = "dataGridDetail";

            WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField));
            WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns));
            foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems)
            {
                GenDefault(fielditem, Default, Validate);
                //GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName);
            }

            WebDevPage.IHTMLElement eJQDataGridDetail = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("dataGridDetail", 0);
            if (eJQDataGridDetail != null)
            {
                ((WebDevPage.IHTMLElement)eJQDataGridDetail).setAttribute("RemoteName", FClientData.ProviderName, 0);
                ((WebDevPage.IHTMLElement)eJQDataGridDetail).setAttribute("DataMember", BlockItem.TableName, 0);
                StringBuilder sb = new StringBuilder(eJQDataGridDetail.innerHTML);
                //sb.Append("<Columns>");
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    int idx = sb.ToString().LastIndexOf("</Columns>");
                    if (idx == -1)
                    {
                        sb.AppendLine("<Columns></Columns>");
                        idx = sb.ToString().LastIndexOf("</Columns>");
                    }
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;

                    var relationOptions = string.Empty;
                    if ((BFI.ControlType == "RefValBox" || BFI.ControlType == "ComboBox") && !string.IsNullOrEmpty(BFI.ComboValueField) && !string.IsNullOrEmpty(BFI.ComboTextField)
                        && !string.IsNullOrEmpty(BFI.ComboRemoteName) && !string.IsNullOrEmpty(BFI.ComboEntityName))
                    {
                        relationOptions = string.Format("RelationOptions=\"{{RemoteName:'{0}',DisplayMember:'{1}',ValueMember:'{2}'}}\""
                            , BFI.ComboRemoteName, BFI.ComboTextField, BFI.ComboValueField);
                    }

                    sb.Insert(idx, String.Format("<JQMobileTools:JQGridColumn Alignment=\"left\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, relationOptions, BFI.EditMask));
                }
                //sb.Append("</Columns>");
                eJQDataGridDetail.innerHTML = sb.ToString();
            }

            WebDevPage.IHTMLElement eJQDataFormDetail = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("dataFormDetail", 0);
            if (eJQDataFormDetail != null)
            {
                StringBuilder sb = new StringBuilder();
                ((WebDevPage.IHTMLElement)eJQDataFormDetail).setAttribute("RemoteName", FClientData.ProviderName, 0);
                ((WebDevPage.IHTMLElement)eJQDataFormDetail).setAttribute("DataMember", BlockItem.TableName, 0);

                sb.Append("<Columns>");
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    JQControl control = null;
                    string editor = "text";
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;
                    if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox")
                        && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField)
                        || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName)))
                    {
                        BFI.ControlType = "TextBox";
                    }

                    if (BFI.ControlType == "ComboBox")
                    {
                        control = new JQSelects() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField };
                        editor = "selects";

                    }
                    else if (BFI.ControlType == "RefValBox")
                    {
                        control = new JQRefval() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField };
                        //(control as JQRefval).Columns.Add(new JQRefValColumn() { FieldName = BFI.ComboValueField, Caption = BFI.ComboValueFieldCaption });
                        editor = "refval";
                    }
                    else if (BFI.ControlType == "RadioButton")
                    {
                        control = new JQRadioButtons() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField };
                        editor = "radiobuttons";
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        JQCollection<JQDataItem> items = new JQCollection<JQDataItem>(control);
                        JQDataItem item1 = new JQDataItem();
                        item1.Text = "Yes"; item1.Value = "Yes";
                        JQDataItem item2 = new JQDataItem();
                        item2.Text = "No"; item2.Value = "No";
                        items.Add(item1);
                        items.Add(item2);
                        control = new JQCheckBoxes() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField, Items = items };
                        editor = "checkboxes";
                    }
                    else if (BFI.ControlType == "DateTimeBox")
                    {
                        control = new JQDate();
                        editor = "date";
                    }
                    else
                    {
                        control = new JQTextBox();

                    }
                    sb.AppendFormat("<{0}:{1} Caption=\"{2}\" FieldName=\"{3}\" Editor=\"{4}\" Width=\"120\" EditorOptions=\"{5}\"></{0}:{1}>"
                        , "JQMobileTools", "JQFormColumn", sHeaderText, BFI.DataField, editor, control.Options);
                }
                sb.Append("</Columns>");

                if (BlockItem.Relation != null && BlockItem.Relation.ChildColumns.Length > 0)
                {
                    sb.Append("<RelationColumns>");
                    for (int i = 0; i < BlockItem.Relation.ChildColumns.Length; i++)
                    {
                        sb.AppendFormat("<JQMobileTools:JQRelationColumn FieldName=\"{0}\" ParentFieldName=\"{1}\" />", BlockItem.Relation.ChildColumns[i].ColumnName, BlockItem.Relation.ParentColumns[i].ColumnName);
                    }
                    sb.Append("</RelationColumns>");
                }
                eJQDataFormDetail.innerHTML = sb.ToString();

                WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement;
                Default.BindingObjectID = "dataFormDetail";
                InsertControl(Page, Default);
                Validate.BindingObjectID = "dataFormDetail";
                InsertControl(Page, Validate);
            }
            #else

            #endif
        }
示例#2
0
        private void GenMainBlockControl(TBlockItem BlockItem)
        {
            #if VS90
            //object oMaster = FDesignerDocument.webControls.item("Master", 0);

            //WebDevPage.IHTMLElement eMaster = null;

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

            JQDefault Default = new JQDefault();
            Default.ID = "defaultMaster"; // +BlockItem.TableName;
            Default.BindingObjectID = "dataGridMaster";

            JQValidate Validate = new JQValidate();
            Validate.ID = "validateMaster"; // +BlockItem.TableName;
            Validate.BindingObjectID = "dataGridMaster";

            WebQueryFiledsCollection QueryFields = new WebQueryFiledsCollection(null, typeof(QueryField));
            WebQueryColumnsCollection QueryColumns = new WebQueryColumnsCollection(null, typeof(QueryColumns));
            foreach (TBlockFieldItem fielditem in BlockItem.BlockFieldItems)
            {
                GenDefault(fielditem, Default, Validate);
                GenQuery(fielditem, QueryFields, QueryColumns, BlockItem.TableName);
            }

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

                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    int idx = sb.ToString().LastIndexOf("</Columns>");
                    if (idx == -1)
                    {
                        sb.AppendLine("<Columns></Columns>");
                        idx = sb.ToString().LastIndexOf("</Columns>");
                    }
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;
                    var relationOptions = string.Empty;
                    if ((BFI.ControlType == "RefValBox" || BFI.ControlType == "ComboBox") && !string.IsNullOrEmpty(BFI.ComboValueField) && !string.IsNullOrEmpty(BFI.ComboTextField)
                        && !string.IsNullOrEmpty(BFI.ComboRemoteName) && !string.IsNullOrEmpty(BFI.ComboEntityName))
                    {
                        relationOptions = string.Format("RelationOptions=\"{{RemoteName:'{0}',DisplayMember:'{1}',ValueMember:'{2}'}}\""
                            , BFI.ComboRemoteName, BFI.ComboTextField, BFI.ComboValueField);
                    }

                    sb.Insert(idx, String.Format("<JQMobileTools:JQGridColumn Alignment=\"left\" FieldName=\"{0}\" Caption=\"{1}\" Width=\"120\" {2} Format=\"{3}\"/>", BFI.DataField, sHeaderText, relationOptions, BFI.EditMask));
                }

                var toolItems = new List<JQMobileTools.JQToolItem>();
                if (FClientData.BaseFormName == "JQMobileQuery" || FClientData.BaseFormName == "VBJQMobileQuery")
                {
                    toolItems.Add(JQMobileTools.JQToolItem.PreviousPageItem);
                    toolItems.Add(JQMobileTools.JQToolItem.NextPageItem);
                    toolItems.Add(JQMobileTools.JQToolItem.QueryItem);
                    toolItems.Add(JQMobileTools.JQToolItem.RefreshItem);
                }
                else
                {
                    toolItems.Add(JQMobileTools.JQToolItem.InsertItem);
                    toolItems.Add(JQMobileTools.JQToolItem.PreviousPageItem);
                    toolItems.Add(JQMobileTools.JQToolItem.NextPageItem);
                    toolItems.Add(JQMobileTools.JQToolItem.QueryItem);
                    toolItems.Add(JQMobileTools.JQToolItem.RefreshItem);
                    toolItems.Add(JQMobileTools.JQToolItem.BackItem);
                }

                int idxTool = sb.ToString().LastIndexOf("</ToolItems>");
                if (idxTool != -1)
                {
                    foreach (var item in toolItems)
                    {
                        idxTool = sb.ToString().LastIndexOf("</ToolItems>");
                        sb.Insert(idxTool, String.Format("<JQMobileTools:JQToolItem Icon=\"{0}\" Name=\"{1}\" Text=\"{2}\" Visible=\"True\" />", item.Icon, item.Name, item.Text));
                    }
                }

                int idxQuery = sb.ToString().LastIndexOf("</QueryColumns>");
                if (idxQuery != -1)
                {
                    foreach (WebQueryField item in QueryFields)
                    {
                        idxQuery = sb.ToString().LastIndexOf("</QueryColumns>");
                        sb.Insert(idxQuery, item.Mode);
                        //sb.Insert(idxQuery, String.Format("<JQTools:JQQueryColumn Caption=\"{0}\" Condition=\"{1}\" Editor=\"text\" FieldName=\"{2}\" />", item.Caption, item.Operator, item.Column));
                    }
                    //foreach (WebQueryColumns item in QueryColumns)
                    //{
                    //    idxQuery = sb.ToString().LastIndexOf("</QueryColumns>");
                    //    //sb.Insert(idxQuery, item.Mode);
                    //    sb.Insert(idxQuery, String.Format("<JQMobileTools:JQQueryColumn Caption=\"{0}\" Condition=\"{1}\" Editor=\"text\" FieldName=\"{2}\" />", item.Caption, item.Operator, item.Column));
                    //}
                }
                eJQGridViewMaster.innerHTML = sb.ToString();

            }

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

            object oJQFormViewMaster = FDesignerDocument.webControls.item("dataFormMaster", 0);
            WebDevPage.IHTMLElement eJQFormViewMaster = (WebDevPage.IHTMLElement)oJQFormViewMaster;
            if (eJQFormViewMaster != null)
            {
                StringBuilder sb = new StringBuilder();
                ((WebDevPage.IHTMLElement)oJQFormViewMaster).setAttribute("RemoteName", FClientData.ProviderName, 0);
                ((WebDevPage.IHTMLElement)oJQFormViewMaster).setAttribute("DataMember", FClientData.TableName, 0);
                ((WebDevPage.IHTMLElement)oJQFormViewMaster).setAttribute("Title", FClientData.FormTitle, 0);
                sb.Append("<Columns>");
                foreach (TBlockFieldItem BFI in BlockItem.BlockFieldItems)
                {
                    JQControl control = null;
                    string editor = "text";
                    String sHeaderText = String.IsNullOrEmpty(BFI.Description) ? BFI.DataField : BFI.Description;
                    if ((BFI.ControlType == "ComboBox" || BFI.ControlType == "ComboGrid" || BFI.ControlType == "RefValBox")
                        && (string.IsNullOrEmpty(BFI.ComboValueField) || string.IsNullOrEmpty(BFI.ComboTextField)
                        || string.IsNullOrEmpty(BFI.ComboRemoteName) || string.IsNullOrEmpty(BFI.ComboEntityName)))
                    {
                        BFI.ControlType = "TextBox";
                    }

                    if (BFI.ControlType == "ComboBox")
                    {
                        control = new JQSelects() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField };
                        editor = "selects";

                    }
                    else if (BFI.ControlType == "RefValBox")
                    {
                        control = new JQRefval() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField };
                        //(control as JQRefval).Columns.Add(new JQRefValColumn() { FieldName = BFI.ComboValueField, Caption = BFI.ComboValueFieldCaption });
                        editor = "refval";
                    }
                    else if (BFI.ControlType == "RadioButton")
                    {
                        control = new JQRadioButtons() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField };
                        editor = "radiobuttons";
                    }
                    else if (BFI.ControlType == "CheckBox")
                    {
                        JQCollection<JQDataItem> items = new JQCollection<JQDataItem>(control);
                        JQDataItem item1 = new JQDataItem();
                        item1.Text = "Yes"; item1.Value = "Yes";
                        JQDataItem item2 = new JQDataItem();
                        item2.Text = "No"; item2.Value = "No";
                        items.Add(item1);
                        items.Add(item2);
                        control = new JQCheckBoxes() { RemoteName = BFI.ComboRemoteName, DisplayMember = BFI.ComboTextField, ValueMember = BFI.ComboValueField, Items = items };
                        editor = "checkboxes";
                    }
                    else if (BFI.ControlType == "DateTimeBox")
                    {
                        control = new JQDate();
                        editor = "date";
                    }
                    else
                    {
                        control = new JQTextBox();

                    }
                    sb.AppendFormat("<{0}:{1} Caption=\"{2}\" FieldName=\"{3}\" Editor=\"{4}\" Width=\"120\" EditorOptions=\"{5}\"></{0}:{1}>"
                        , "JQMobileTools", "JQFormColumn", sHeaderText, BFI.DataField, editor, control.Options);
                }
                sb.Append("</Columns>");

                eJQFormViewMaster.innerHTML = sb.ToString();
                WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement;
                Default.BindingObjectID = "dataFormMaster";
                InsertControl(Page, Default);
                Validate.BindingObjectID = "dataFormMaster";
                InsertControl(Page, Validate);
            }
            //}
            //else
            //{
            //    if (FClientData.BaseFormName != "JQueryQuery1")
            //    {
            //        WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement;
            //        InsertControl(Page, Default);
            //        InsertControl(Page, Validate);
            //    }
            //}

            #else
            #endif
        }
示例#3
0
        private void GenDefault(TBlockFieldItem aFieldItem, JQDefault aDefault, JQValidate aValidate)
        {
            if (aFieldItem.DefaultValue != "" && aFieldItem.DefaultValue != null)
            {
                JQDefaultColumn aDefaultItem = new JQDefaultColumn();
                aDefaultItem.FieldName = aFieldItem.DataField;
                aDefaultItem.DefaultValue = aFieldItem.DefaultValue;
                aDefault.Columns.Add(aDefaultItem);
            }
            if (aFieldItem.CheckNull != null && aFieldItem.CheckNull.ToUpper() == "Y")
            {
                JQValidateColumn aValidateItem = new JQValidateColumn();
                aValidateItem.FieldName = aFieldItem.DataField;
                aValidateItem.CheckNull = aFieldItem.CheckNull.ToUpper() == "Y";
                //aValidateItem.ValidateLabelLink = "Caption" + aFieldItem.DataField;

                aValidate.Columns.Add(aValidateItem);
            }
        }