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

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

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

            WebDefault Default = new WebDefault();
            Default.ID = "wd" + 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
        }
Ejemplo n.º 2
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
        }
Ejemplo n.º 3
0
        private void GenRefValTemplate(String ExtraName)
        {
            //WebRefVal
            WebRefVal aWebRefVal = new WebRefVal();
            aWebRefVal.ID = "wrv" + FTableName + FFieldItem.DataField + ExtraName + "GridView";
            aWebRefVal.DataSourceID = FDataSourceID;
            //if (ExtraName != "F")
            aWebRefVal.DataBindingField = FFieldItem.DataField;
            if (ExtraName == "")
            {
                aWebRefVal.ReadOnly = true;
                aWebRefVal.BackColor = Color.Transparent;
                aWebRefVal.BorderStyle = System.Web.UI.WebControls.BorderStyle.None;
            }
            aWebRefVal.Width = 130;

            if (FFieldItem.RefField != null)
            {
                aWebRefVal.DataValueField = FFieldItem.RefField.ValueMember;
                aWebRefVal.DataTextField = FFieldItem.RefField.DisplayMember;
                foreach (RefColumns aColumn in FFieldItem.RefField.LookupColumns)
                {
                    WebRefColumn RC = new WebRefColumn();
                    RC.ColumnName = aColumn.Column;
                    RC.HeadText = aColumn.HeaderText;
                    aWebRefVal.Columns.Add(RC);
                }
            }
            else
            {
                InfoCommand aInfoCommand = new InfoCommand(DatabaseType);
                //aInfoCommand.Connection = WzdUtils.AllocateConnection(DatabaseName, DatabaseType, true);
                aInfoCommand.Connection = FConnection;
                IDbDataAdapter DA = DBUtils.CreateDbDataAdapter(aInfoCommand);
                DataSet aDataSet = new DataSet();
                //SYS_REFVAL
                aDataSet.Clear();
                aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL where REFVAL_NO = '{0}'", FFieldItem.RefValNo);
                WzdUtils.FillDataAdapter(FDatabaseType, DA, aDataSet, FFieldItem.RefValNo);
                aWebRefVal.DataValueField = aDataSet.Tables[0].Rows[0]["VALUE_MEMBER"].ToString();
                aWebRefVal.DataTextField = aDataSet.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString();
                //aWebRefVal.BindingValue = "'<%# + Bind(\"" + FFieldItem.DataField + "\") %>'";
                //SYS_REFVSL_D1 --> Columns
                aDataSet.Clear();
                aInfoCommand.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", FFieldItem.RefValNo);
                WzdUtils.FillDataAdapter(FDatabaseType, DA, aDataSet, FFieldItem.RefValNo);
                foreach (DataRow DR in aDataSet.Tables[0].Rows)
                {
                    WebRefColumn RC = new WebRefColumn();
                    RC.ColumnName = DR["FIELD_NAME"].ToString();
                    RC.HeadText = DR["HEADER_TEXT"].ToString();
                    aWebRefVal.Columns.Add(RC);
                }
            }

            FContainer.Controls.Add(aWebRefVal);
            Boolean Found = false;
            foreach (WebRefVal bWebRefVal in aWebRefValList)
            {
                if (String.Compare(bWebRefVal.ID, aWebRefVal.ID) == 0)
                {
                    Found = true;
                    break;
                }
            }
            if (!Found)
                aWebRefValList.Add(aWebRefVal);

            //Add AddNewRowControlItem to WebGridView
            if (ExtraName == "F")
            {
                if (FWebGridView != null)
                {
                    Found = false;
                    foreach (AddNewRowControlItem aControlItem in FWebGridView.AddNewRowControls)
                    {
                        if (aControlItem.FieldName.CompareTo(FFieldItem.DataField) == 0)
                        {
                            Found = true;
                            break;
                        }
                    }
                    if (!Found)
                    {
                        AddNewRowControlItem aItem = new AddNewRowControlItem();
                        aItem.ControlID = "wrv" + FTableName + FFieldItem.DataField + ExtraName;
                        aItem.ControlType = WebGridView.AddNewRowControlType.RefVal;
                        aItem.FieldName = FFieldItem.DataField;
                        FWebGridView.AddNewRowControls.Add(aItem);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void CreateQueryField(TBlockFieldItem aFieldItem, String Range, InfoComboBox aComboBox, String TableName)
        {
            if (aFieldItem.QueryMode == null)
                return;
            WebNavigator navigator2 = FPage.FindControl("WebNavigator1") as WebNavigator;
            if (navigator2 != null)
            {
                if (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE")
                {
                    WebQueryField qField = new WebQueryField();
                    qField.FieldName = aFieldItem.DataField;
                    qField.Caption = aFieldItem.Description;
                    if (qField.Caption == "")
                        qField.Caption = aFieldItem.DataField;
                    if (aFieldItem.QueryMode.ToUpper() == "NORMAL")
                    {
                        if (aFieldItem.DataType == typeof(DateTime))
                            qField.Condition = "=";
                        if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) ||
                            aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16))
                            qField.Condition = "=";
                        if (aFieldItem.DataType == typeof(String))
                            qField.Condition = "%";
                    }
                    if (aFieldItem.QueryMode.ToUpper() == "RANGE")
                    {
                        if (Range == "")
                        {
                            qField.Condition = "<=";
                            CreateQueryField(aFieldItem, ">=", aComboBox, TableName);
                        }
                        else
                        {
                            qField.Condition = Range;
                        }
                        navigator2.QueryMode = WebNavigator.QueryModeType.ClientQuery;
                    }
                    switch (aFieldItem.ControlType.ToUpper())
                    {
                        case "TEXTBOX":
                            qField.Mode = "TextBox";
                            break;
                        case "COMBOBOX":
                            qField.Mode = "ComboBox";
                            qField.RefVal = "wrv" + TableName + aFieldItem.DataField + "QF";
                            break;
                        case "REFVALBOX":
                            qField.Mode = "RefVal";
                            qField.RefVal = "wrv" + TableName + aFieldItem.DataField + "QF";
                            break;
                        case "DATETIMEBOX":
                            qField.Mode = "Calendar";
                            break;
                    }
                    navigator2.QueryFields.Add(qField);
                }
                IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(navigator2, null, "", "M");
            }

            WebClientQuery WebClientQuery1 = (WebClientQuery)FPage.FindControl("WebClientQuery1");
            if (WebClientQuery1 != null)
            {
                if (aFieldItem.QueryMode.ToUpper() == "NORMAL" || aFieldItem.QueryMode.ToUpper() == "RANGE")
                {
                    WebQueryColumns qColumns = new WebQueryColumns();
                    qColumns.Column = aFieldItem.DataField;
                    qColumns.Caption = aFieldItem.Description;
                    if (qColumns.Caption == "")
                        qColumns.Caption = aFieldItem.DataField;
                    qColumns.Condition = "And";
                    if (aFieldItem.QueryMode.ToUpper() == "NORMAL")
                    {
                        if (aFieldItem.DataType == typeof(DateTime))
                            qColumns.Operator = "=";
                        if (aFieldItem.DataType == typeof(int) || aFieldItem.DataType == typeof(float) ||
                            aFieldItem.DataType == typeof(double) || aFieldItem.DataType == typeof(Int16))
                            qColumns.Operator = "=";
                        if (aFieldItem.DataType == typeof(String))
                            qColumns.Operator = "%";
                    }
                    if (aFieldItem.QueryMode.ToUpper() == "RANGE")
                    {
                        qColumns.Condition = "And";
                        if (Range == "")
                        {
                            qColumns.Operator = "<=";
                            CreateQueryField(aFieldItem, ">=", aComboBox, TableName);
                        }
                        else
                        {
                            qColumns.Operator = Range;
                        }
                    }
                    switch (aFieldItem.ControlType.ToUpper())
                    {
                        case "TEXTBOX":
                            qColumns.ColumnType = "ClientQueryTextBoxColumn";
                            break;
                        case "COMBOBOX":
                            qColumns.ColumnType = "ClientQueryComboBoxColumn";
                            qColumns.WebRefVal = "wrv" + TableName + aFieldItem.DataField + "QF";
                            break;
                        case "REFVALBOX":
                            qColumns.ColumnType = "ClientQueryRefValColumn";
                            qColumns.WebRefVal = "wrv" + TableName + aFieldItem.DataField + "QF";

                            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}'", aFieldItem.RefValNo);
                            WzdUtils.FillDataAdapter(FClientData.DatabaseType, DA, FSYS_REFVAL, aFieldItem.RefValNo);

                            WebRefVal aWebRefVal = new WebRefVal();
                            aWebRefVal.ID = qColumns.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}", TableName, aFieldItem.DataField);
                            aWebRefVal.Visible = false;
                            FWebRefValListPage.Add(aWebRefVal);
                            break;
                        case "DATETIMEBOX":
                            qColumns.ColumnType = "ClientQueryCalendarColumn";
                            break;
                        case "CHECKBOX":
                            qColumns.ColumnType = "ClientQueryCheckBoxColumn";
                            break;
                    }
                    WebClientQuery1.Columns.Add(qColumns);
                }
                IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
                NotifyRefresh(200);
                FComponentChangeService.OnComponentChanged(WebClientQuery1, null, "", "M");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 取得Control对应的xml
        /// </summary>
        /// <param name="item">blockfielditem</param>
        /// <param name="tableName">tablename</param>
        /// <param name="id">控件的id</param>
        /// <returns>xml</returns>
        private string GetControlXml(TBlockFieldItem item, string tableName, ref string id)
        {
            WebControl control = null;
            PropertyInfo info = null;

            #region DropDownList
            if (string.Compare(item.ControlType, "combobox", true) == 0)
            {
                control = new WebDropDownList();
                control.ID = string.Format("{0}DropDownList", item.DataField);
                control.Width = new Unit(130, UnitType.Pixel);
                (control as WebDropDownList).DataSourceID = GenWebDataSource(item, tableName, "ComboBox", string.Empty);
                (control as WebDropDownList).DataMember = item.ComboEntityName;
                (control as WebDropDownList).DataTextField = item.ComboTextField;
                (control as WebDropDownList).DataValueField = item.ComboValueField;
                info = control.GetType().GetProperty("SelectedValue");
            }
            #endregion

            #region RefVal
            else if (string.Compare(item.ControlType, "refvalbox", true) == 0)
            {
            #warning GenWebDataSource未完成FSYS_REFVAL部分
                control = new WebRefVal();
                control.ID = string.Format("{0}RefVal", item.DataField);
                if (!string.IsNullOrEmpty(item.RefValNo) || (item.RefField != null))
                {
                    (control as WebRefVal).DataSourceID = GenWebDataSource(item, tableName, "RefVal", string.Empty);
                    (control as WebRefVal).DataBindingField = item.DataField;
                    (control as WebRefVal).DataTextField = FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString();
                    (control as WebRefVal).DataValueField = FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString();
                    if (!string.IsNullOrEmpty(item.RefValNo))
                    {
                        IDbConnection conn = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, false);
                        InfoCommand command = new InfoCommand(FClientData.DatabaseType);
                        command.Connection = WzdUtils.AllocateConnection(FClientData.DatabaseName, FClientData.DatabaseType, true);
                        //command.Connection = conn;
                        command.CommandText = String.Format("Select * from SYS_REFVAL_D1 where REFVAL_NO = '{0}'", item.RefValNo);
                        IDbDataAdapter adapter = WzdUtils.AllocateDataAdapter(FClientData.DatabaseType);
                        adapter.SelectCommand = command.GetInternalCommand();
                        DataSet dataset = new DataSet();
                        WzdUtils.FillDataAdapter(FClientData.DatabaseType, adapter, dataset, item.RefValNo);
                        if (dataset != null && dataset.Tables.Count > 0 && dataset.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow DR in dataset.Tables[0].Rows)
                            {
                                WebRefColumn refcolumn = new WebRefColumn();
                                refcolumn.ColumnName = DR["FIELD_NAME"].ToString();
                                refcolumn.HeadText = DR["HEADER_TEXT"].ToString();
                                refcolumn.Width = 100;
                                (control as WebRefVal).Columns.Add(refcolumn);
                            }
                        }
                    }
                    info = control.GetType().GetProperty("BindingValue");
                }
                else
                {
                    control = new TextBox();
                    control.ID = string.Format("{0}TextBox", item.DataField);
                    (control as TextBox).MaxLength = item.Length;
                    info = control.GetType().GetProperty("Text");
                }

            }
            #endregion

            #region DateTimePicker
            else if (string.Compare(item.ControlType, "datetimebox", true) == 0)
            {
                control = new WebDateTimePicker();
                control.ID = string.Format("{0}DateTimePicker", item.DataField);
                (control as WebDateTimePicker).MaxLength = item.Length;
                if (string.IsNullOrEmpty(item.EditMask))
                {
                    (control as WebDateTimePicker).DateFormat = dateFormat.ShortDate;
                }
                if (item.DataType == typeof(DateTime))
                {
                    info = control.GetType().GetProperty("Text");
                }
                else if (item.DataType == typeof(string))
                {
                    (control as WebDateTimePicker).DateTimeType = dateTimeType.VarChar;
                    info = control.GetType().GetProperty("DataString");
                }
            }
            #endregion

            #region ValidateBox
            else if (string.Compare(item.ControlType, "validatebox", true) == 0)
            {
                control = new WebValidateBox();
                control.ID = string.Format("{0}ValidateBox", item.DataField);
                (control as WebValidateBox).WebValidateID = string.Format("wv{0}", tableName);
                (control as WebValidateBox).ValidateField = item.DataField;
                (control as WebValidateBox).MaxLength = item.Length;
                info = control.GetType().GetProperty("Text");
            }
            #endregion

            #region CheckBox
            else if (string.Compare(item.ControlType, "checkbox", true) == 0)
            {
                control = new CheckBox();
                control.ID = string.Format("{0}CheckBox", item.DataField);
                info = control.GetType().GetProperty("Checked");
            }
            #endregion

            #region TextBox
            else
            {
                control = new TextBox();
                control.ID = string.Format("{0}TextBox", item.DataField);
                (control as TextBox).MaxLength = item.Length;
                info = control.GetType().GetProperty("Text");
            }
            #endregion

            control.ID = string.Format("{0}{1}", control.ID, id);
            id = control.ID;
            item.EditMask = FormatEditMask(item.EditMask);
            return GetControlXml(control, info, item.DataField, item.EditMask);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 取得label对应的xml
        /// </summary>
        /// <param name="item">blockfielditem</param>
        /// <returns>xml</returns>
        private string GetLabelXml(TBlockFieldItem item, String tableName, ref String id)
        {
            String strLabel = String.Empty;
            if (string.Compare(item.ControlType, "refvalbox", true) == 0)
            {
                WebControl control = null;
                PropertyInfo info = null;
                if (!string.IsNullOrEmpty(item.RefValNo) || (item.RefField != null))
                {
                    control = new WebRefVal();
                    control.ID = string.Format("{0}RefVal", item.DataField);
                    (control as WebRefVal).DataSourceID = GenWebDataSource(item, tableName, "RefVal", string.Empty);
                    (control as WebRefVal).DataBindingField = item.DataField;
                    (control as WebRefVal).DataTextField = FSYS_REFVAL.Tables[0].Rows[0]["DISPLAY_MEMBER"].ToString();
                    (control as WebRefVal).DataValueField = FSYS_REFVAL.Tables[0].Rows[0]["VALUE_MEMBER"].ToString();
                    (control as WebRefVal).BackColor = System.Drawing.Color.Transparent;
                    (control as WebRefVal).BorderStyle = BorderStyle.None;
                    (control as WebRefVal).ReadOnly = true;
                    (control as WebRefVal).Width = 100;
                    info = control.GetType().GetProperty("BindingValue");
                    //id = control.ID;
                    strLabel = GetControlXml(control, info, item.DataField, item.EditMask);
                }
                else
                {
                    control = new Label();
                    control.ID = string.Format("{0}Label", item.DataField);
                    strLabel = GetControlXml(control, control.GetType().GetProperty("Text"), item.DataField, item.EditMask);
                }
                //control.ID = string.Format("{0}{1}", control.ID, id);

                int i = strLabel.IndexOf("runat=\"server\"");
                strLabel = strLabel.Insert(i + 14, " Width=\"100\" BackColor=\"Transparent\"");
            }
            else
            {
                //用上面的方法实现
                Label label = new Label();
                label.ID = string.Format("{0}Label", item.DataField);
                strLabel = GetControlXml(label, label.GetType().GetProperty("Text"), item.DataField, item.EditMask);
            }
            return strLabel;
        }
Ejemplo n.º 7
0
    private void IntialEditItem()
    {
        int columnNum = arrEditColumn.Length;
        labels = new Label[columnNum];
        dropDownlists = new DropDownList[columnNum];
        textBoxes = new TextBox[columnNum];
        webRefVals = new WebRefVal[columnNum];
        webDateTimePickers = new WebDateTimePicker[columnNum];
        TableRow[] trText= new TableRow[columnNum];
        int cmdIndex = 0;

        for (int i = 0; i < columnNum; i++)
        {
            TableCell tcLabel = new TableCell();
            TableCell tcText = new TableCell();
            tcLabel.HorizontalAlign = HorizontalAlign.Center;
            tcLabel.VerticalAlign = VerticalAlign.Top;
            tcText.HorizontalAlign = HorizontalAlign.Left;
            tcText.VerticalAlign = VerticalAlign.Top;

            //create captionlabel
            labels[i] = new Label();
            labels[i].ID = "lbl" + i.ToString();
            labels[i].Width = 48;
            labels[i].Text = arrEditCation[i];
            tcLabel.Controls.Add(labels[i]);
            switch (arrEditColumnType[i])
            {
                case "TextBoxColumn":
                    {
                        textBoxes[i] = new TextBox();
                        textBoxes[i].ID = "txt" + i.ToString();
                        textBoxes[i].Width = 112;
                        if (string.Compare(strMode, "update", true) == 0)//IgnoreCase
                        {
                            textBoxes[i].Text = GetText(arrEditColumn[i]);
                        }
                        else
                        {
                            textBoxes[i].Text = arrDefaultValue[i];
                        }
                        tcText.Controls.Add(textBoxes[i]);
                        break;

                    }

                case "ComboBoxColumn":
                    {
                        dropDownlists[i] = new DropDownList();
                        dropDownlists[i].ID = "txt" + i.ToString();
                        dropDownlists[i].Width = 112;
                        int dsidnum = lstDataSetID.IndexOf(arrRefValDSID[i]);
                        if (dsidnum >= 0)
                        {
                            dropDownlists[i].DataSourceID = "refvalds" + dsidnum.ToString();
                        }
                        else
                        {
                            refValDateSourcecmd[cmdIndex] = new WebDataSource();
                            refValDateSourcecmd[cmdIndex].SelectAlias = arrRefValAlias[i];
                            refValDateSourcecmd[cmdIndex].SelectCommand = arrRefValCMD[i];
                            refValDateSourcecmd[cmdIndex].ID = "refvalcmd" + cmdIndex.ToString();
                            this.Form.Controls.Add(refValDateSourcecmd[cmdIndex]);
                            dropDownlists[i].DataSourceID = "refvalcmd" + cmdIndex.ToString();
                            cmdIndex++;
                        }
                        dropDownlists[i].DataTextField = arrRefValTF[i];
                        dropDownlists[i].DataValueField = arrRefValVF[i];

                        if (string.Compare(strMode, "update", true) == 0)//IgnoreCase
                        {
                            if (GetText(arrEditColumn[i]) != "")
                            {
                                try
                                {
                                    dropDownlists[i].SelectedValue = GetText(arrEditColumn[i]);
                                }
                                catch
                                { }
                            }
                        }
                        else
                        {
                            try
                            {
                                if (arrDefaultValue[i] != "")
                                {
                                    dropDownlists[i].SelectedValue = arrDefaultValue[i];
                                }
                            }
                            catch
                            { }
                        }
                        tcText.Controls.Add(dropDownlists[i]);
                        break;
                    }
                case "RefValColumn":
                    {
                        webRefVals[i] = new WebRefVal();
                        webRefVals[i].ID = "txt" + i.ToString();
                        webRefVals[i].Width = 112;
                        int dsidnum = lstDataSetID.IndexOf(arrRefValDSID[i]);
                        if (dsidnum >= 0)
                        {
                            webRefVals[i].DataSourceID = "refvalds" + dsidnum.ToString();
                            webRefVals[i].ResxDataSet = arrRefValDSID[i];
                            webRefVals[i].ResxFilePath = psyPath + ".vi-VN.resx";
                        }
                        else
                        {
                            refValDateSourcecmd[cmdIndex] = new WebDataSource();
                            refValDateSourcecmd[cmdIndex].SelectAlias = arrRefValAlias[i];
                            refValDateSourcecmd[cmdIndex].SelectCommand = arrRefValCMD[i];
                            refValDateSourcecmd[cmdIndex].ID = "refvalcmd" + cmdIndex.ToString();
                            this.Form.Controls.Add(refValDateSourcecmd[cmdIndex]);
                            webRefVals[i].DataSourceID = "refvalcmd" + cmdIndex.ToString();
                            cmdIndex++;
                        }
                        webRefVals[i].DataTextField = arrRefValTF[i];
                        webRefVals[i].DataValueField = arrRefValVF[i];

                        #region Add WebRefval other properties
                        if (arrRefValColumnMatch[i] != string.Empty)
                        {
                            string[] columnmatch = arrRefValColumnMatch[i].Split(':');
                            WebColumnMatch[] wcm = new WebColumnMatch[columnmatch.Length];
                            for (int j = 0; j < columnmatch.Length; j++)
                            {
                                string[] columnmatchcontext = columnmatch[j].Split(',');
                                wcm[j] = new WebColumnMatch(columnmatchcontext[1], columnmatchcontext[2], columnmatchcontext[0]);
                                webRefVals[i].ColumnMatch.Add(wcm[j]);
                            }
                        }
                        if (arrRefValColumns[i] != string.Empty)
                        {
                            string[] columns = arrRefValColumns[i].Split(':');
                            WebRefColumn[] wrc = new WebRefColumn[columns.Length];
                            for (int j = 0; j < columns.Length; j++)
                            {
                                string[] columnscontext = columns[j].Split(',');
                                wrc[j] = new WebRefColumn(columnscontext[0], columnscontext[1], int.Parse(columnscontext[2]));
                                webRefVals[i].Columns.Add(wrc[j]);
                            }
                        }
                        if (arrRefValWhereItem[i] != string.Empty)
                        {
                            string[] whereitem = arrRefValWhereItem[i].Split(':');
                            WebWhereItem[] wwi = new WebWhereItem[whereitem.Length];
                            for (int j = 0; j < whereitem.Length; j++)
                            {
                                string[] whereitemcontext = whereitem[j].Split(',');
                                wwi[j] = new WebWhereItem(whereitemcontext[1], whereitemcontext[0], whereitemcontext[2]);
                                webRefVals[i].WhereItem.Add(wwi[j]);
                            }
                        }
                        #endregion

                        if (string.Compare(strMode, "update", true) == 0)//IgnoreCase
                        {
                            if (GetText(arrEditColumn[i]) != "")
                            {
                                try
                                {
                                    webRefVals[i].BindingValue = GetText(arrEditColumn[i]);
                                }
                                catch
                                { }
                            }
                        }
                        else
                        {
                            try
                            {
                                webRefVals[i].BindingValue = arrDefaultValue[i];
                            }
                            catch
                            { }

                        }

                        tcText.Controls.Add(webRefVals[i]);

                        break;
                    }
                case "CalendarColumn":
                    {
                        webDateTimePickers[i] = new WebDateTimePicker();
                        webDateTimePickers[i].ID = "txt" + i.ToString();
                        webDateTimePickers[i].DateFormat = dateFormat.ShortDate;
                        webDateTimePickers[i].Width = 112;

                        if (string.Compare(strMode, "update", true) == 0)//IgnoreCase
                        {
                            if (GetText(arrEditColumn[i]) != "")
                            {
                                try
                                {
                                    webDateTimePickers[i].Text = GetText(arrEditColumn[i]);
                                }
                                catch
                                { }
                            }
                        }
                        else
                        {
                            try
                            {
                                webDateTimePickers[i].Text = arrDefaultValue[i];
                            }
                            catch
                            { }
                        }

                        tcText.Controls.Add(webDateTimePickers[i]);

                        break;
                    }
                case "RadioButtonColumn":
                    {

                        break;
                    }
            }

            trText[i] = new TableRow();
            trText[i].Cells.Add(tcLabel);
            trText[i].Cells.Add(tcText);
            table.Controls.Add(trText[i]);

        }
        pnTreeView.Controls.Add(table);
    }
Ejemplo n.º 8
0
        private void GenMainBlockControl_3(TBlockItem blockItem, String formViewName)
        {
            WebDevPage.IHTMLElement Master = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("Master", 0);
            string mastertablename = string.Empty;
            if (Master != null)
            {
                mastertablename = FClientData.ProviderName.Split('.')[1];
                Master.setAttribute("DataMember", mastertablename, 0);
                if (formViewName == "wfvMaster")
                {
                    Master.setAttribute("AutoApply", "true", 0);
                }
            }
            blockItem.wDataSource = new WebDataSource();
            WebDevPage.IHTMLElement Page = FDesignerDocument.pageContentElement;

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

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

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

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

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

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

            WebDevPage.IHTMLElement Navigator = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("WebNavigator1", 0);
            if (Navigator != null)
            {
                SetCollectionValue(Navigator, typeof(WebNavigator).GetProperty("QueryFields"), QueryFields);
            }
            WebDevPage.IHTMLElement ClientQuery = (WebDevPage.IHTMLElement)FDesignerDocument.webControls.item("WebClientQuery1", 0);
            if (ClientQuery != null)
            {
                SetCollectionValue(ClientQuery, typeof(WebClientQuery).GetProperty("Columns"), QueryColumns);
            }
            //刷不了Schema所以直接用写的

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

                SetCollectionValue(AjaxFromView1, typeof(AjaxTools.AjaxFormView).GetProperty("Fields"), aAjaxFormFieldCollection);
            }
        }
Ejemplo n.º 9
0
        public void Execute(string user, int d, string Key)
        {
            if ((this.ParentAutoTest != "" && this.ParentAutoTest != null) && (this.KeyField == "" || this.KeyField == null)) return;
            bool temp = new bool(); ;
            deep = d;
            string KeyValue = "";
            if (this.DataSourceID != "" && this.DataSourceID != null)
            {
                List<string> listKey = new List<string>();
                for (int times = 0; times < this.Rows; times++)
                {
                    Hashtable ht = new Hashtable();
                    DataSet ds = new DataSet();
                    foreach (System.Web.UI.Control c in this.Page.Form.Controls)
                    {
                        if (c is WebDataSource && (c as WebDataSource).ID == this.DataSourceID)
                        {
                            ws = c as WebDataSource;
                            ds = (c as WebDataSource).InnerDataSet;
                            break;
                        }
                    }
                    if (ws != null && ds != null)
                    {
                        string fieldName;
                        for (int i = 0; i < ds.Tables[deep].Columns.Count; i++)
                        {
                            fieldName = ds.Tables[deep].Columns[i].ToString();
                            if (fieldName == ds.Tables[0].PrimaryKey[0].ToString() && deep == 0)
                            {
                                KeyValue = user + sequence++;
                                ht.Add(fieldName, KeyValue);
                            }
                            else if (fieldName == ds.Tables[0].PrimaryKey[0].ToString())
                            {
                                ht.Add(fieldName, Key);
                            }
                            else
                            {
                                foreach (webColumn wc in this.Columns)
                                {
                                    if (wc.ColumnName == fieldName && wc.ColumnName == this.KeyField && wc.Value != null)
                                    {
                                        bool flag = true;
                                        for (int j = 0; j < wc.Value.Length; j++)
                                            if (wc.Value[j] < 48 || wc.Value[j] > 57)
                                                flag = false;
                                        for (int j = 0; j < wc.RandomTo.Length; j++)
                                            if (wc.RandomTo[j] < 48 || wc.RandomTo[j] > 57)
                                                flag = false;
                                        if (flag == false)
                                        {
                                            int length;
                                            if (wc.Value.Length < wc.RandomTo.Length)
                                                length = wc.Value.Length;
                                            else
                                                length = wc.RandomTo.Length;
                                            StringBuilder sb = new StringBuilder(length);

                                        Label1:
                                            if (sb.Length > 0)
                                                sb.Remove(0, sb.Length);
                                            for (int x = 0; x < length; x++)
                                                sb.Append(getRandomChar(wc.Value[x], wc.RandomTo[x]));
                                            for (int x = 0; x < wc.RandomTo.Length - wc.Value.Length; x++)
                                                sb.Append(getRandomChar(wc.RandomTo[x]));
                                            bool isHave = false;
                                            foreach (string strKey in listKey)
                                                if (sb.ToString() == strKey) isHave = true;
                                            if (isHave == false)
                                            {
                                                listKey.Add(sb.ToString());
                                                ht.Add(wc.ColumnName, sb.ToString());
                                            }
                                            else
                                                goto Label1;
                                        }
                                        else
                                        {
                                            int begin, end;
                                            Random m_rnd = new Random();
                                            int value;
                                            begin = this.getRandomInt(wc.Value);
                                            end = this.getRandomInt(wc.RandomTo);
                                        Label2:
                                            value = this.m_rnd.Next(begin, end);
                                            bool isHave = false;
                                            foreach (string strKey in listKey)
                                                if (value.ToString() == strKey) isHave = true;
                                            if (isHave == false)
                                            {
                                                listKey.Add(value.ToString());
                                                ht.Add(wc.ColumnName, value);
                                            }
                                            else
                                                goto Label2;
                                        }
                                    }
                                    else if (wc.ColumnName == fieldName)
                                    {
                                        if (wc.valueMode == ValueMode.Fixed)
                                            ht.Add(wc.ColumnName, wc.Value);
                                        else if (wc.valueMode == ValueMode.Random)
                                        {
                                            bool flag = true;
                                            for (int j = 0; j < wc.Value.Length; j++)
                                                if (wc.Value[j] < 48 || wc.Value[j] > 57)
                                                    flag = false;
                                            for (int j = 0; j < wc.RandomTo.Length; j++)
                                                if (wc.RandomTo[j] < 48 || wc.RandomTo[j] > 57)
                                                    flag = false;
                                            if (flag == false)
                                            {
                                                int length;
                                                if (wc.Value.Length < wc.RandomTo.Length)
                                                    length = wc.Value.Length;
                                                else
                                                    length = wc.RandomTo.Length;
                                                StringBuilder sb = new StringBuilder(length);

                                                if (sb.Length > 0)
                                                    sb.Remove(0, sb.Length);
                                                for (int x = 0; x < length; x++)
                                                    sb.Append(getRandomChar(wc.Value[x], wc.RandomTo[x]));
                                                for (int x = 0; x < wc.RandomTo.Length - wc.Value.Length; x++)
                                                    sb.Append(getRandomChar(wc.RandomTo[x]));
                                                ht.Add(wc.ColumnName, sb.ToString());
                                            }
                                            else
                                            {
                                                int begin, end;
                                                Random m_rnd = new Random();
                                                int value;
                                                begin = this.getRandomInt(wc.Value);
                                                end = this.getRandomInt(wc.RandomTo);
                                                value = this.m_rnd.Next(begin, end);
                                                ht.Add(wc.ColumnName, value);
                                            }
                                        }
                                        else if (wc.valueMode == ValueMode.RefRandom)
                                        {
                                            if (wc.RefVal != null)
                                            {
                                                DataSet R_ds = new DataSet();
                                                WebRefVal wrv = new WebRefVal();
                                                foreach (System.Web.UI.Control ctrl in this.Page.Form.Controls)
                                                    if (ctrl is WebRefVal && (ctrl as WebRefVal).ID == wc.RefVal)
                                                        foreach (System.Web.UI.Control c in this.Page.Form.Controls)
                                                            if (c is WebDataSource && (c as WebDataSource).ID == (ctrl as WebRefVal).DataSourceID)
                                                                if ((c as WebDataSource).WebDataSetID == null || (c as WebDataSource).WebDataSetID == "")
                                                                {
                                                                    wrv = (WebRefVal)ctrl;
                                                                    Random rnd = new Random();
                                                                    int x = rnd.Next((c as WebDataSource).CommandTable.Rows.Count);
                                                                    DataRow r_dr = (c as WebDataSource).CommandTable.Rows[x];
                                                                    ht.Add(wc.ColumnName, r_dr[wrv.DataValueField]);
                                                                }
                                                                else
                                                                {
                                                                    R_ds = (c as WebDataSource).InnerDataSet;
                                                                    wrv = (WebRefVal)ctrl;
                                                                    Random rnd = new Random();
                                                                    int x = rnd.Next(R_ds.Tables[0].Rows.Count);
                                                                    DataRow r_dr = R_ds.Tables[0].Rows[x];
                                                                    ht.Add(wc.ColumnName, r_dr[wrv.DataValueField]);
                                                                }
                                            }
                                        }
                                        else
                                            ht.Add(wc.ColumnName, user + sequence++);
                                    }
                                }
                            }
                        }

                        DataRow dr = ds.Tables[deep].NewRow();
                        for (int j = 0; j < dr.Table.Columns.Count; j++)
                        {
                            if (ht[dr.Table.Columns[j].Caption] != null)
                            {
                                dr[dr.Table.Columns[j].Caption] = ht[dr.Table.Columns[j].Caption];
                            }
                        }
                        ds.Tables[deep].Rows.Add(dr);
                    }

                    if (this.ChildAutoTest.Count > 0)
                    {
                        int childCount = 0;
                        for (; childCount < this.ChildAutoTest.Count; childCount++)
                        {
                            deep = 1 + childCount;
                            WebAutoTest wat = (WebAutoTest)this.ChildAutoTest[childCount];
                            wat.Execute(user, deep, KeyValue);
                        }
                        deep = 0;
                    }

                    if (this.ParentAutoTest == null || this.ParentAutoTest == "")
                    {
                        temp = ws.AutoApply;
                        ws.AutoApply = true;
                        //ws.Insert(ht);
                        ws.ApplyUpdates();
                        SubmitFlow(ht);
                        ws.AutoApply = temp;
                    }

                }
            }
        }
Ejemplo n.º 10
0
    private void InitializeQueryConditionItem()
    {
        labels = new Label[columnNum];
        dropDownlists = new WebDropDownList[columnNum];
        textBoxes = new TextBox[columnNum];
        checkBoxes = new CheckBox[columnNum];
        webRefVals = new WebRefVal[columnNum];
        webRefButtons = new WebRefButton[columnNum];
        webDateTimePickers = new WebDateTimePicker[columnNum];

        TableRow[] trQuery = new TableRow[columnNum];
        int intRowCount = 0;
        int cmdIndex = 0;
        trQuery[0] = new TableRow();

        table.HorizontalAlign = HorizontalAlign.Center;

        for (int i = 0; i < columnNum; i++)
        {
            TableCell tcLabel = new TableCell();
            TableCell tcQueryText = new TableCell();
            tcLabel.HorizontalAlign = HorizontalAlign.Right;
            tcLabel.VerticalAlign = VerticalAlign.Middle;
            tcQueryText.HorizontalAlign = HorizontalAlign.Left;
            tcQueryText.VerticalAlign = VerticalAlign.Middle;

            //create captionlabel
            labels[i] = new Label();
            labels[i].ID = "lbl" + i.ToString() + arrColumn[i];
            labels[i].Text = arrCaption[i];
            labels[i].ForeColor = forecolor;
            SetTextFont(labels[i].Font);
            tcLabel.Controls.Add(labels[i]);

            //create querytext
            switch (arrColumnType[i])
            {
                case "ClientQueryComboBoxColumn":
                    {
                        dropDownlists[i] = new WebDropDownList();

                        dropDownlists[i].ID = "ddl" + i.ToString();
                        dropDownlists[i].Width = Unit.Pixel(int.Parse(arrTextWidth[i]));
                        dropDownlists[i].ForeColor = textcolor;

                        int dsidnum = lstDataSetID.IndexOf(arrRefValDSID[i]);
                        if (dsidnum >= 0)
                        {
                            dropDownlists[i].DataSourceID = "refvalds" + dsidnum.ToString();
                            if (arrRefValWhereItem[i] != "")
                            {
                                string filter = WhereItemToFileter(arrRefValWhereItem[i], "refvalds" + dsidnum.ToString());
                                (this.FindControl("refvalds" + dsidnum.ToString()) as WebDataSource).SetWhere(filter);
                            }
                        }
                        else
                        {
                            refValDateSourcecmd[cmdIndex] = new WebDataSource();
                            refValDateSourcecmd[cmdIndex].SelectAlias = arrRefValAlias[i];
                            refValDateSourcecmd[cmdIndex].SelectCommand = arrRefValCMD[i];
                            refValDateSourcecmd[cmdIndex].ID = "refvalcmd" + cmdIndex.ToString();
                            this.Form.Controls.Add(refValDateSourcecmd[cmdIndex]);
                            dropDownlists[i].DataSourceID = "refvalcmd" + cmdIndex.ToString();
                            cmdIndex++;
                        }
                        dropDownlists[i].DataTextField = arrRefValTF[i];
                        dropDownlists[i].DataValueField = arrRefValVF[i];
                        dropDownlists[i].AppendDataBoundItems = true;
                        dropDownlists[i].AutoInsertEmptyData = true;
                        SetTextFont(dropDownlists[i].Font);

                        if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                        {
                            if (arrText[i] != "")
                            {
                                dropDownlists[i].SelectedValue = arrText[i];
                            }
                        }
                        else
                        {
                            try
                            {
                                if (arrDefaultValue[i] != "")
                                {
                                    dropDownlists[i].SelectedValue = arrDefaultValue[i];
                                }
                            }
                            catch
                            { }
                        }

                        tcQueryText.Controls.Add(dropDownlists[i]);
                        break;
                    }
                case "ClientQueryTextBoxColumn":
                    {
                        textBoxes[i] = new TextBox();
                        textBoxes[i].ID = "txt" + i.ToString();
                        textBoxes[i].Width = Unit.Pixel(int.Parse(arrTextWidth[i]));
                        textBoxes[i].ForeColor = textcolor;
                        SetTextFont(textBoxes[i].Font);

                        if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                        {
                            textBoxes[i].Text = arrText[i];
                        }
                        else
                        {
                            textBoxes[i].Text = arrDefaultValue[i];
                        }

                        tcQueryText.Controls.Add(textBoxes[i]);
                        break;
                    }
                case "ClientQueryCheckBoxColumn":
                    {
                        checkBoxes[i] = new CheckBox();
                        checkBoxes[i].ID = "txt" + i.ToString();
                        checkBoxes[i].Text = string.Empty;
                        checkBoxes[i].Width = Unit.Pixel(int.Parse(arrTextWidth[i]));
                        if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                        {
                            if (arrText[i] != "")
                            {
                                checkBoxes[i].Checked = Convert.ToBoolean(arrText[i]);
                            }
                        }
                        else
                        {
                            if (string.Compare(arrDefaultValue[i].Trim(), "true", true) == 0 || string.Compare(arrDefaultValue[i].Trim(), "1") == 0)
                            {
                                checkBoxes[i].Checked = true;
                            }
                            else
                            {
                                checkBoxes[i].Checked = false;
                            }
                        }
                        tcQueryText.Controls.Add(checkBoxes[i]);
                        break;
                    }
                case "ClientQueryRefValColumn":
                    {
                        webRefVals[i] = new WebRefVal();
                        webRefVals[i].ID = "wrf" + i.ToString();
                        webRefVals[i].Width = Unit.Pixel(int.Parse(arrTextWidth[i]));
                        webRefVals[i].ForeColor = textcolor;
                        SetTextFont(webRefVals[i].Font);

                        int dsidnum = lstDataSetID.IndexOf(arrRefValDSID[i]);
                        if (dsidnum >= 0)
                        {
                            webRefVals[i].DataSourceID = "refvalds" + dsidnum.ToString();

                            webRefVals[i].ResxDataSet = arrRefValDSID[i];
                            webRefVals[i].ResxFilePath = psyPagePath + ".vi-VN.resx";
                        }
                        else
                        {
                            refValDateSourcecmd[cmdIndex] = new WebDataSource();
                            refValDateSourcecmd[cmdIndex].SelectAlias = arrRefValAlias[i];
                            refValDateSourcecmd[cmdIndex].SelectCommand = arrRefValCMD[i];
                            refValDateSourcecmd[cmdIndex].ID = "refvalcmd" + cmdIndex.ToString();
                            this.Form.Controls.Add(refValDateSourcecmd[cmdIndex]);
                            webRefVals[i].DataSourceID = "refvalcmd" + cmdIndex.ToString();
                            cmdIndex++;
                        }
                        webRefVals[i].DataTextField = arrRefValTF[i];
                        webRefVals[i].DataValueField = arrRefValVF[i];
                        webRefVals[i].CheckData = Convert.ToBoolean(arrRefValCD[i]);

                        string[] arrsize = arrRefValSize[i].Split(',');
                        if (arrsize.Length == 4)
                        {
                            webRefVals[i].OpenRefHeight = int.Parse(arrsize[0]);
                            webRefVals[i].OpenRefLeft = int.Parse(arrsize[1]);
                            webRefVals[i].OpenRefTop = int.Parse(arrsize[2]);
                            webRefVals[i].OpenRefWidth = int.Parse(arrsize[3]);
                        }

                        #region Add WebRefval other properties
                        if (arrRefValColumnMatch[i] != string.Empty)
                        {
                            string[] columnmatch = arrRefValColumnMatch[i].Split(':');
                            WebColumnMatch[] wcm = new WebColumnMatch[columnmatch.Length];
                            for (int j = 0; j < columnmatch.Length; j++)
                            {
                                string[] columnmatchcontext = columnmatch[j].Split(',');
                                wcm[j] = new WebColumnMatch(columnmatchcontext[1], columnmatchcontext[2], columnmatchcontext[0]);
                                webRefVals[i].ColumnMatch.Add(wcm[j]);
                            }
                        }
                        if (arrRefValColumns[i] != string.Empty)
                        {
                            string[] columns = arrRefValColumns[i].Split(':');
                            WebRefColumn[] wrc = new WebRefColumn[columns.Length];
                            for (int j = 0; j < columns.Length; j++)
                            {
                                string[] columnscontext = columns[j].Split(',');
                                wrc[j] = new WebRefColumn(columnscontext[0], columnscontext[1], int.Parse(columnscontext[2]));
                                if (columnscontext.Length >= 4)
                                {
                                    wrc[j].IsNvarChar = bool.Parse(columnscontext[3]);
                                }
                                webRefVals[i].Columns.Add(wrc[j]);
                            }
                        }
                        if (arrRefValWhereItem[i] != string.Empty)
                        {
                            string[] whereitem = arrRefValWhereItem[i].Split(':');
                            WebWhereItem[] wwi = new WebWhereItem[whereitem.Length];
                            for (int j = 0; j < whereitem.Length; j++)
                            {
                                string[] whereitemcontext = whereitem[j].Split(',');
                                wwi[j] = new WebWhereItem(whereitemcontext[1], whereitemcontext[0], whereitemcontext[2]);
                                webRefVals[i].WhereItem.Add(wwi[j]);
                            }
                        }
                        #endregion

                        if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                        {
                            if (arrText[i] != "")
                            {
                                webRefVals[i].BindingValue = arrText[i];
                            }
                        }
                        else
                        {
                            try
                            {
                                webRefVals[i].BindingValue = arrDefaultValue[i];
                            }
                            catch
                            { }
                        }

                        tcQueryText.Controls.Add(webRefVals[i]);
                        break;
                    }
                case "ClientQueryRefButtonColumn":
                    {
                        textBoxes[i] = new TextBox();
                        textBoxes[i].ID = "txt" + i.ToString();
                        if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                        {
                            textBoxes[i].Text = arrText[i];
                        }
                        else
                        {
                            textBoxes[i].Text = arrDefaultValue[i];
                        }
                        textBoxes[i].Width = Unit.Pixel(int.Parse(arrTextWidth[i]));
                        textBoxes[i].ForeColor = textcolor;
                        SetTextFont(textBoxes[i].Font);
                        webRefButtons[i] = new WebRefButton();
                        webRefButtons[i].ID = "btn" + i.ToString();
                        webRefButtons[i].Caption = arrRefButtonCaption[i];
                        webRefButtons[i].RefURL = arrRefButtonURL[i];

                        string[] arrsize = arrRefButtonURLSize[i].Split(',');
                        if (arrsize.Length == 4)
                        {
                            webRefButtons[i].RefURLHeight = int.Parse(arrsize[0]);
                            webRefButtons[i].RefURLLeft = int.Parse(arrsize[1]);
                            webRefButtons[i].RefURLTop = int.Parse(arrsize[2]);
                            webRefButtons[i].RefURLWidth = int.Parse(arrsize[3]);
                        }

                        MatchControl mc = new MatchControl();
                        mc.ControlID = "txt" + i.ToString();
                        webRefButtons[i].MatchControls.Add(mc);
                        tcQueryText.Controls.Add(textBoxes[i]);
                        tcQueryText.Controls.Add(webRefButtons[i]);
                        break;
                    }

                case "ClientQueryCalendarColumn":
                    {
                        webDateTimePickers[i] = new WebDateTimePicker();
                        webDateTimePickers[i].ID = "wdt" + i.ToString();
                        webDateTimePickers[i].Width = Unit.Pixel(int.Parse(arrTextWidth[i]));
                        webDateTimePickers[i].ForeColor = textcolor;
                        webDateTimePickers[i].DateFormat = dateFormat.ShortDate;
                        webDateTimePickers[i].CheckDate = false;
                        SetTextFont(webDateTimePickers[i].Font);

                        if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                        {
                            webDateTimePickers[i].Text = arrText[i];
                        }
                        else
                        {
                            webDateTimePickers[i].Text = arrDefaultValue[i];
                        }

                        tcQueryText.Controls.Add(webDateTimePickers[i]);
                        break;
                    }
            }
            if (arrTextWidth[i] == "0")
            {
                foreach (Control ctrl in tcQueryText.Controls)
                {
                    ctrl.Visible = false;
                    Panel1.Controls.Add(ctrl);
                }
                continue;
            }

            //is newline
            if (string.Compare(arrNewLine[i], "true", true) == 0)//IgnoreCase
            {
                if (trQuery[intRowCount].Cells.Count > 0)
                {
                    table.Controls.Add(trQuery[intRowCount]);
                    TableRow trEmpty = new TableRow();
                    trEmpty.Height = Unit.Pixel(gapvertical);
                    table.Controls.Add(trEmpty);
                    intRowCount++;
                    trQuery[intRowCount] = new TableRow();
                }

                trQuery[intRowCount].Cells.Add(tcLabel);
                trQuery[intRowCount].Cells.Add(tcQueryText);
            }
            else
            {
                if (trQuery[intRowCount].Cells.Count > 0)
                {
                    TableCell tcEmpty = new TableCell();
                    tcEmpty.Width = Unit.Pixel(gaphorizontal);
                    trQuery[intRowCount].Cells.Add(tcEmpty);
                }
                trQuery[intRowCount].Cells.Add(tcLabel);
                trQuery[intRowCount].Cells.Add(tcQueryText);
            }
        }

        table.Controls.Add(trQuery[intRowCount]);
        TableRow trEmptylast = new TableRow();
        trEmptylast.Height = 15;
        table.Controls.Add(trEmptylast);

        this.Panel1.Controls.Add(table);

        Table tableBtn = new Table();
        TableRow trBtn = new TableRow();
        TableCell tcBtnOk = new TableCell();
        TableCell tcBtnCancel = new TableCell();

        tableBtn.CellSpacing = 15;
        tableBtn.HorizontalAlign = HorizontalAlign.Center;

        String message = SysMsg.GetSystemMessage(CliUtils.fClientLang,
                                  "Srvtools",
                                  "WebNavigator",
                                  "ButtonName", true);
        string[] strbuttons = message.Split(';');

        Button btnOK = new Button();
        btnOK.ID = "btnOK";
        //btnOK.Width = 65;
        btnOK.Text = strbuttons[0];
        btnOK.Click += new EventHandler(btnOK_Click);
        tcBtnOk.HorizontalAlign = HorizontalAlign.Right;
        tcBtnOk.Controls.Add(btnOK);

        Button btnCancel = new Button();
        btnCancel.ID = "btnCancel";
        //btnCancel.Width = 65;
        btnCancel.Text = strbuttons[1];
        btnCancel.Click += new EventHandler(btnCancel_Click);
        tcBtnCancel.HorizontalAlign = HorizontalAlign.Left;
        tcBtnCancel.Controls.Add(btnCancel);
        //2009/09/09 modify by eva 無論是否為VS2008還是VS2005都可以套用Css
        //if (ConfigurationManager.AppSettings["VS90"] != null && string.Compare(ConfigurationManager.AppSettings["VS90"], "true", true) == 0)//IgnoreCase
        //{
        btnOK.CssClass = "btn_mouseout";
        btnOK.Attributes.Add("onmouseout", "this.className='btn_mouseout';");
        btnOK.Attributes.Add("onmouseover", "this.className='btn_mouseover';");
        btnCancel.CssClass = "btn_mouseout";
        btnCancel.Attributes.Add("onmouseout", "this.className='btn_mouseout';");
        btnCancel.Attributes.Add("onmouseover", "this.className='btn_mouseover';");
        //}
        //End Modify
        tcBtnCancel.HorizontalAlign = HorizontalAlign.Left;
        tcBtnCancel.Controls.Add(btnCancel);

        trBtn.Cells.Add(tcBtnOk);
        trBtn.Cells.Add(tcBtnCancel);
        tableBtn.Controls.Add(trBtn);

        this.Panel1.Controls.Add(tableBtn);
    }
Ejemplo n.º 11
0
    void InnerPages_frmAnyQuery_dllOperator_SelectedIndexChanged(object sender, EventArgs e)
    {
        int count = 0;
        object cValue1 = null;
        object cValue2 = null;
        ControlCollection ccValue1 = null;
        ControlCollection ccValue2 = null;
        String[] temp = (sender as DropDownList).ID.Split(new String[] { "Web", "AnyQuery" }, StringSplitOptions.RemoveEmptyEntries);
        count = Convert.ToInt16(temp[0]);
        //for (int i = 0; i < (sender as DropDownList).ID.Length; i++)
        //{
        //    if (Char.IsDigit((sender as DropDownList).ID[i]))
        //    {
        //        count = count * Convert.ToInt16(Math.Pow(10, i)) + Convert.ToInt16(Char.ToString((sender as DropDownList).ID[i]));
        //    }
        //}

        foreach (Control c in table.Controls)
        {
            object[] value1 = FindTableControl(c, count, "AnyQueryValue1");
            if (value1 != null)
            {
                cValue1 = value1[0];
                ccValue1 = value1[1] as ControlCollection;
            }

            object[] value2 = FindTableControl(c, count, "AnyQueryValue2");
            if (value2 != null)
            {
                cValue2 = value2[0];
                ccValue2 = value2[1] as ControlCollection;
            }
        }

        TableCell tcValue2 = new TableCell();
        tcValue2.HorizontalAlign = HorizontalAlign.Left;
        tcValue2.VerticalAlign = VerticalAlign.Middle;
        if (cValue1 != null && (sender as DropDownList).Text == "<->" || (sender as DropDownList).Text == "!<->")
        {
            if (cValue2 == null)
            {
                if (cValue1.GetType() == typeof(TextBox))
                {
                    cValue2 = new TextBox();
                    (cValue2 as TextBox).ID = (cValue1 as TextBox).ID.Replace("Value1", "Value2");
                    (cValue2 as TextBox).Text = (cValue1 as TextBox).Text;
                    (cValue2 as TextBox).Width = (cValue1 as TextBox).Width;
                    (cValue2 as TextBox).Enabled = (cValue1 as TextBox).Enabled;
                    tcValue2.Controls.Add((cValue2 as TextBox));
                }
                else if (cValue1.GetType() == typeof(WebDropDownList))
                {
                    cValue2 = new WebDropDownList();
                    (cValue2 as WebDropDownList).ID = (cValue1 as WebDropDownList).ID.Replace("Value1", "Value2");
                    (cValue2 as WebDropDownList).Width = (cValue1 as WebDropDownList).Width;
                    (cValue2 as WebDropDownList).Enabled = (cValue1 as WebDropDownList).Enabled;

                    (cValue2 as WebDropDownList).DataSourceID = (cValue1 as WebDropDownList).DataSourceID;
                    (cValue2 as WebDropDownList).DataTextField = (cValue1 as WebDropDownList).DataTextField;
                    (cValue2 as WebDropDownList).DataValueField = (cValue1 as WebDropDownList).DataValueField;
                    (cValue2 as WebDropDownList).AppendDataBoundItems = true;
                    (cValue2 as WebDropDownList).AutoInsertEmptyData = true;
                    (cValue2 as WebDropDownList).SelectedValue = (cValue1 as WebDropDownList).SelectedValue;

                    tcValue2.Controls.Add((cValue2 as WebDropDownList));

                }
                else if (cValue1.GetType() == typeof(WebRefVal))
                {
                    cValue2 = new WebRefVal();
                    (cValue2 as WebRefVal).ID = (cValue1 as WebRefVal).ID.Replace("Value1", "Value2");
                    (cValue2 as WebRefVal).Width = (cValue1 as WebRefVal).Width;

                    (cValue2 as WebRefVal).DataSourceID = (cValue1 as WebRefVal).DataSourceID;
                    (cValue2 as WebRefVal).ResxDataSet = (cValue1 as WebRefVal).ResxDataSet;
                    (cValue2 as WebRefVal).ResxFilePath = (cValue1 as WebRefVal).ResxFilePath;
                    (cValue2 as WebRefVal).DataTextField = (cValue1 as WebRefVal).DataTextField;
                    (cValue2 as WebRefVal).DataValueField = (cValue1 as WebRefVal).DataValueField;
                    (cValue2 as WebRefVal).CheckData = (cValue1 as WebRefVal).CheckData;

                    (cValue2 as WebRefVal).OpenRefHeight = (cValue1 as WebRefVal).OpenRefHeight;
                    (cValue2 as WebRefVal).OpenRefLeft = (cValue1 as WebRefVal).OpenRefLeft;
                    (cValue2 as WebRefVal).OpenRefTop = (cValue1 as WebRefVal).OpenRefTop;
                    (cValue2 as WebRefVal).OpenRefWidth = (cValue1 as WebRefVal).OpenRefWidth;

                    if ((cValue1 as WebRefVal).ColumnMatch.Count > 0)
                    {
                        for (int j = 0; j < (cValue1 as WebRefVal).ColumnMatch.Count; j++)
                        {
                            (cValue2 as WebRefVal).ColumnMatch[j] = (cValue1 as WebRefVal).ColumnMatch[j];
                        }
                    }
                    if ((cValue1 as WebRefVal).Columns.Count > 0)
                    {
                        for (int j = 0; j < (cValue1 as WebRefVal).Columns.Count; j++)
                        {
                            (cValue2 as WebRefVal).Columns[j] = (cValue1 as WebRefVal).Columns[j];
                        }
                    }
                    if ((cValue1 as WebRefVal).WhereItem.Count > 0)
                    {
                        for (int j = 0; j < (cValue1 as WebRefVal).WhereItem.Count; j++)
                        {
                            (cValue2 as WebRefVal).WhereItem[j] = (cValue1 as WebRefVal).WhereItem[j];
                        }
                    }

                    (cValue2 as WebRefVal).BindingValue = (cValue1 as WebRefVal).BindingValue;
                    (cValue2 as WebRefVal).ReadOnly = (cValue1 as WebRefVal).ReadOnly;
                    tcValue2.Controls.Add((cValue2 as WebRefVal));
                }
                else if (cValue1.GetType() == typeof(WebDateTimePicker))
                {
                    cValue2 = new WebDateTimePicker();
                    (cValue2 as WebDateTimePicker).ID = (cValue1 as WebDateTimePicker).ID.Replace("Value1", "Value2");
                    (cValue2 as WebDateTimePicker).Text = (cValue1 as WebDateTimePicker).Text;
                    (cValue2 as WebDateTimePicker).Width = (cValue1 as WebDateTimePicker).Width;
                    (cValue2 as WebDateTimePicker).Enabled = (cValue1 as WebDateTimePicker).Enabled;
                    (cValue2 as WebDateTimePicker).DateFormat = (cValue1 as WebDateTimePicker).DateFormat;
                    tcValue2.Controls.Add((cValue2 as WebDateTimePicker));
                }
                else if (cValue1.GetType() == typeof(WebRefButton))
                {
                    //tbValue2RB.ID = count + "WebAnyQueryValue2WebRefButtonTextBox" + dr["Enabled"].ToString();
                    //tbValue2RB.Text = dr["DefaultValue"].ToString();
                    //tbValue2RB.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                    //if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    //    tbValue2RB.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                    //else
                    //    tbValue2RB.Enabled = Convert.ToBoolean(dr["AutoSelect"]);

                    //wrbValue2.ID = count + "WebAnyQueryValue1WebRefButton" + dr["Enabled"].ToString();
                    //wrbValue2.Caption = dr["RefButtonCaption"].ToString();
                    //wrbValue2.RefURL = dr["RefButtonURL"].ToString();
                    //if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    //    wrbValue2.Visible = Convert.ToBoolean(dr["Enabled"].ToString());
                    //else
                    //    wrbValue2.Visible = Convert.ToBoolean(dr["AutoSelect"]);

                    //string[] arrsize = dr["RefButtonURLSize"].ToString().Split(',');
                    //if (arrsize.Length == 4)
                    //{
                    //    wrbValue2.RefURLHeight = int.Parse(arrsize[0]);
                    //    wrbValue2.RefURLLeft = int.Parse(arrsize[1]);
                    //    wrbValue2.RefURLTop = int.Parse(arrsize[2]);
                    //    wrbValue2.RefURLWidth = int.Parse(arrsize[3]);
                    //}

                    //MatchControl mc = new MatchControl();
                    //mc.ControlID = count + "WebAnyQueryValue2WebRefButtonTextBox" + dr["Enabled"].ToString();
                    //wrbValue2.MatchControls.Add(mc);
                    //tcValue2.Controls.Add(tbValue2RB);
                    //tcValue2.Controls.Add(wrbValue2);
                }

                allControls.Rows[count]["Operators"] = (sender as DropDownList).Text;
                ccValue1.Add(tcValue2);
            }
        }
        else
        {
            if (cValue2 != null)
            {
                allControls.Rows[count]["Operators"] = (sender as DropDownList).Text;

                foreach (Control c in table.Controls)
                {
                    RemoveTableControl(c, count, "AnyQueryValue2");
                }
            }
        }
    }
Ejemplo n.º 12
0
    private TableRow CreateColumn(int count, DataRow dr)
    {
        CheckBox cbActive = new CheckBox();
        DropDownList ddlCondition = new DropDownList();
        DropDownList ddlColumn = new DropDownList();
        DropDownList dllOperator = new DropDownList();
        TextBox tbValue1 = new TextBox();
        WebDateTimePicker wdtpValue1 = new WebDateTimePicker();
        CheckBox cbValue1 = new CheckBox();
        WebDropDownList wddlValue1 = new WebDropDownList();
        WebRefVal wrvValue1 = new WebRefVal();
        TextBox tbValue1RB = new TextBox();
        WebRefButton wrbValue1 = new WebRefButton();

        TextBox tbValue2 = new TextBox();
        WebDateTimePicker wdtpValue2 = new WebDateTimePicker();
        CheckBox cbValue2 = new CheckBox();
        WebDropDownList wddlValue2 = new WebDropDownList();
        WebRefVal wrvValue2 = new WebRefVal();
        TextBox tbValue2RB = new TextBox();
        WebRefButton wrbValue2 = new WebRefButton();

        TableRow tr = new TableRow();

        TableCell tcActive = new TableCell();
        tcActive.HorizontalAlign = HorizontalAlign.Right;
        tcActive.VerticalAlign = VerticalAlign.Middle;

        //create CheckBoxActive
        cbActive = new CheckBox();
        cbActive.ID = "Web" + count + "AnyQueryActiveCheckBox";
        if (autoDisableColumns == false && !(bool)dr["AutoSelect"])
            cbActive.Checked = false;
        else
            cbActive.Checked = (bool)dr["AutoSelect"];
        cbActive.AutoPostBack = true;
        cbActive.CheckedChanged += new EventHandler(InnerPages_frmAnyQuery_cbActive_CheckedChanged);
        tcActive.Controls.Add(cbActive);

        if (autoDisableColumns == false)
            dr["AutoSelect"] = "True";

        TableCell tcCondition = new TableCell();
        tcCondition.HorizontalAlign = HorizontalAlign.Right;
        tcCondition.VerticalAlign = VerticalAlign.Middle;

        //create ConditionDropDownList
        ddlCondition = new DropDownList();
        ddlCondition.ID = "Web" + count + "AnyQueryConditionDropDownList";
        ddlCondition.Width = 60;
        ddlCondition.Items.Add("AND");
        ddlCondition.Items.Add("OR");
        ddlCondition.Text = dr["Condition"].ToString().ToUpper();
        ddlCondition.Enabled = Convert.ToBoolean(dr["AutoSelect"]);
        tcCondition.Controls.Add(ddlCondition);

        TableCell tcColumn = new TableCell();
        tcColumn.HorizontalAlign = HorizontalAlign.Right;
        tcColumn.VerticalAlign = VerticalAlign.Middle;

        //create ColumnDropDownList
        ddlColumn = new DropDownList();
        ddlColumn.ID = "Web" + count + "AnyQuery" + dr["Column"].ToString();
        alColumn = CreateArrayListColumn();
        for (int j = 0; j < alColumn.Count; j++)
            ddlColumn.Items.Add(alColumn[j].ToString());
        if (ddlColumn.Items.Contains(new ListItem(dr["Caption"].ToString())))
            ddlColumn.Text = dr["Caption"].ToString();
        else
            ddlColumn.Text = dr["Column"].ToString();
        ddlColumn.AutoPostBack = true;
        ddlColumn.Enabled = Convert.ToBoolean(dr["AutoSelect"]);
        ddlColumn.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
        ddlColumn.SelectedIndexChanged += new EventHandler(InnerPages_frmAnyQuery_ddlColumn_SelectedIndexChanged);
        tcColumn.Controls.Add(ddlColumn);

        TableCell tcOperator = new TableCell();
        tcOperator.HorizontalAlign = HorizontalAlign.Left;
        tcOperator.VerticalAlign = VerticalAlign.Middle;

        //create OperatDropDownList
        dllOperator = new DropDownList();
        dllOperator.ID = "Web" + count + "AnyQueryOperatorDropDownList";
        ArrayList op = new ArrayList();
        op.AddRange(new String[] { "=", "!=", ">", "<", ">=", "<=", "%**", "**%", "%%", "!%%", "<->", "!<->", "IN", "NOT IN" });
        if (!this.displayAllOperator)
        {
            if (dr["DataType"].ToString() == typeof(Char).ToString() || dr["DataType"].ToString() == typeof(String).ToString())
            {
                op.Clear();
                op.AddRange(new String[] { "=", "!=", "%**", "**%", "%%", "!%%", "IN", "NOT IN" });
            }
            else if (dr["DataType"].ToString() == typeof(int).ToString() || dr["DataType"].ToString() == typeof(float).ToString()
                    || dr["DataType"].ToString() == typeof(double).ToString() || dr["DataType"].ToString() == typeof(DateTime).ToString())
            {
                op.Clear();
                op.AddRange(new String[] { "=", "!=", "<", ">", "<=", ">=", "<->", "!<->", "IN", "NOT IN" });
            }
        }
        for (int j = 0; j < op.Count; j++)
            dllOperator.Items.Add(op[j].ToString());
        if (dr["Operators"].ToString() == "%")
            dllOperator.Text = "**%";
        else
            dllOperator.Text = dr["Operators"].ToString();
        dllOperator.Width = 60;
        dllOperator.AutoPostBack = true;
        dllOperator.Enabled = Convert.ToBoolean(dr["AutoSelect"]);
        dllOperator.SelectedIndexChanged += new EventHandler(InnerPages_frmAnyQuery_dllOperator_SelectedIndexChanged);
        tcOperator.Controls.Add(dllOperator);

        TableCell tcValue1 = new TableCell();
        tcValue1.HorizontalAlign = HorizontalAlign.Left;
        tcValue1.VerticalAlign = VerticalAlign.Middle;

        //create Value
        int dsidnum;
        switch (dr["ColumnType"].ToString())
        {
            case "AnyQueryTextBoxColumn":
                tbValue1 = new TextBox();
                tbValue1.ID = "Web" + count + "AnyQueryValue1TextBox" + dr["Enabled"].ToString();
                tbValue1.Text = dr["DefaultValue"].ToString();
                tbValue1.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    tbValue1.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                else
                    tbValue1.Enabled = Convert.ToBoolean(dr["AutoSelect"]);
                tcValue1.Controls.Add(tbValue1);
                break;
            case "AnyQueryComboBoxColumn":
                wddlValue1 = new WebDropDownList();
                wddlValue1.ID = "Web" + count + "AnyQueryValue1WebDropDownList" + dr["Enabled"].ToString();
                wddlValue1.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    wddlValue1.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                else
                    wddlValue1.Enabled = Convert.ToBoolean(dr["AutoSelect"]);

                dsidnum = lstDataSetID.IndexOf(dr["RefValDSID"].ToString());
                if (dsidnum >= 0)
                {
                    wddlValue1.DataSourceID = "refvalds" + dsidnum.ToString();
                    if (dr["RefValWhereItem"].ToString() != "")
                    {
                        string filter = WhereItemToFileter(dr["RefValWhereItem"].ToString(), "refvalds" + dsidnum.ToString());
                        (this.FindControl("refvalds" + dsidnum.ToString()) as WebDataSource).SetWhere(filter);
                    }
                    wddlValue1.DataTextField = dr["RefValTF"].ToString();
                    wddlValue1.DataValueField = dr["RefValVF"].ToString();
                    wddlValue1.AppendDataBoundItems = true;
                    wddlValue1.AutoInsertEmptyData = true;
                }
                else if (dr["RefValAlias"].ToString() != String.Empty && dr["RefValCMD"].ToString() != String.Empty)
                {
                    refValDateSourcecmd[cmdIndex] = new WebDataSource();
                    refValDateSourcecmd[cmdIndex].SelectAlias = dr["RefValAlias"].ToString();
                    refValDateSourcecmd[cmdIndex].SelectCommand = dr["RefValCMD"].ToString();
                    refValDateSourcecmd[cmdIndex].ID = "refvalcmd" + cmdIndex.ToString();
                    this.Form.Controls.Add(refValDateSourcecmd[cmdIndex]);
                    wddlValue1.DataSourceID = "refvalcmd" + cmdIndex.ToString();
                    cmdIndex++;
                    wddlValue1.DataTextField = dr["RefValTF"].ToString();
                    wddlValue1.DataValueField = dr["RefValVF"].ToString();
                    wddlValue1.AppendDataBoundItems = true;
                    wddlValue1.AutoInsertEmptyData = true;
                }
                else
                {
                    //String[] item = arrItems.Split('!');
                    //foreach (String temp in item)
                    //    wddlValue1.Items.Add(temp);
                }

                if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                {
                    if (dr["Text"].ToString() != "")
                    {
                        wddlValue1.SelectedValue = dr["Text"].ToString();
                    }
                }
                else
                {
                    try
                    {
                        if (dr["DefaultValue"].ToString() != "")
                        {
                            wddlValue1.SelectedValue = dr["DefaultValue"].ToString();
                        }
                    }
                    catch
                    { }
                }
                tcValue1.Controls.Add(wddlValue1);
                break;
            case "AnyQueryCheckBoxColumn":
                cbValue1 = new CheckBox();
                cbValue1.ID = "Web" + count + "AnyQueryValue1CheckBox" + dr["Enabled"].ToString();
                if (dr["DefaultValue"].ToString() == "1")
                    cbValue1.Checked = true;
                cbValue1.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    cbValue1.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                else
                    cbValue1.Enabled = Convert.ToBoolean(dr["AutoSelect"]);
                tcValue1.Controls.Add(cbValue1);
                break;
            case "AnyQueryRefValColumn":
                wrvValue1 = new WebRefVal();
                wrvValue1.ID = "Web" + count + "AnyQueryValue1RefVal" + dr["Enabled"].ToString();
                wrvValue1.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));

                dsidnum = lstDataSetID.IndexOf(dr["RefValDSID"].ToString());
                if (dsidnum >= 0)
                {
                    wrvValue1.DataSourceID = "refvalds" + dsidnum.ToString();

                    wrvValue1.ResxDataSet = dr["RefValDSID"].ToString();
                    wrvValue1.ResxFilePath = psyPagePath + ".vi-VN.resx";
                }
                else
                {
                    int refCount = cmdIndex;
                    for (int i = 0; i < refValDateSourcecmd.Length; i++)
                    {
                        if (refValDateSourcecmd[i] != null)
                        {
                            if (refValDateSourcecmd[i].SelectAlias == dr["RefValAlias"].ToString()
                            && refValDateSourcecmd[i].SelectCommand == dr["RefValCMD"].ToString()
                            && refValDateSourcecmd[i].ID == "refvalcmd" + i.ToString())
                            {
                                refCount = i;
                                break;
                            }
                        }
                    }

                    refValDateSourcecmd[refCount] = new WebDataSource();
                    refValDateSourcecmd[refCount].SelectAlias = dr["RefValAlias"].ToString();
                    refValDateSourcecmd[refCount].SelectCommand = dr["RefValCMD"].ToString();
                    refValDateSourcecmd[refCount].ID = "refvalcmd" + refCount.ToString();
                    object obj = this.Form.FindControl(refValDateSourcecmd[refCount].ID);
                    if (obj == null)
                        this.Form.Controls.Add(refValDateSourcecmd[refCount]);
                    wrvValue1.DataSourceID = "refvalcmd" + refCount.ToString();
                    cmdIndex++;
                }
                wrvValue1.DataTextField = dr["RefValTF"].ToString();
                wrvValue1.DataValueField = dr["RefValVF"].ToString();
                wrvValue1.CheckData = Convert.ToBoolean(dr["RefValCD"].ToString());

                string[] aSize = dr["RefValSize"].ToString().Split(',');
                if (aSize.Length == 4)
                {
                    wrvValue1.OpenRefHeight = int.Parse(aSize[0]);
                    wrvValue1.OpenRefLeft = int.Parse(aSize[1]);
                    wrvValue1.OpenRefTop = int.Parse(aSize[2]);
                    wrvValue1.OpenRefWidth = int.Parse(aSize[3]);
                }

                #region Add WebRefval other properties
                if (dr["RefValColumnMatch"].ToString() != string.Empty)
                {
                    string[] columnmatch = dr["RefValColumnMatch"].ToString().Split(':');
                    WebColumnMatch[] wcm = new WebColumnMatch[columnmatch.Length];
                    for (int j = 0; j < columnmatch.Length; j++)
                    {
                        string[] columnmatchcontext = columnmatch[j].Split(',');
                        wcm[j] = new WebColumnMatch(columnmatchcontext[1], columnmatchcontext[2], columnmatchcontext[0]);
                        wrvValue1.ColumnMatch.Add(wcm[j]);
                    }
                }
                if (dr["RefValColumns"].ToString() != string.Empty)
                {
                    string[] columns = dr["RefValColumns"].ToString().Split(':');
                    WebRefColumn[] wrc = new WebRefColumn[columns.Length];
                    for (int j = 0; j < columns.Length; j++)
                    {
                        string[] columnscontext = columns[j].Split(',');
                        wrc[j] = new WebRefColumn(columnscontext[0], columnscontext[1], int.Parse(columnscontext[2]));
                        wrvValue1.Columns.Add(wrc[j]);
                    }
                }
                if (dr["RefValWhereItem"].ToString() != string.Empty)
                {
                    string[] whereitem = dr["RefValWhereItem"].ToString().Split(':');
                    WebWhereItem[] wwi = new WebWhereItem[whereitem.Length];
                    for (int j = 0; j < whereitem.Length; j++)
                    {
                        string[] whereitemcontext = whereitem[j].Split(',');
                        wwi[j] = new WebWhereItem(whereitemcontext[1], whereitemcontext[0], whereitemcontext[2]);
                        wrvValue1.WhereItem.Add(wwi[j]);
                    }
                }
                #endregion

                if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                {
                    if (dr["Text"].ToString() != "")
                    {
                        wrvValue1.BindingValue = dr["Text"].ToString();
                    }
                }
                else
                {
                    try
                    {
                        wrvValue1.BindingValue = dr["DefaultValue"].ToString();
                    }
                    catch
                    { }
                }
                if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    wrvValue1.ReadOnly = !Convert.ToBoolean(dr["Enabled"].ToString());
                else
                    wrvValue1.ReadOnly = !Convert.ToBoolean(dr["AutoSelect"]);
                tcValue1.Controls.Add(wrvValue1);
                break;
            case "AnyQueryCalendarColumn":
                wdtpValue1 = new WebDateTimePicker();
                wdtpValue1.ID = "Web" + count + "AnyQueryValue1WebDateTimePicker" + dr["Enabled"].ToString();
                wdtpValue1.Text = dr["DefaultValue"].ToString();
                wdtpValue1.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                wdtpValue1.CheckDate = false;
                wdtpValue1.DateFormat = dateFormat.ShortDate;
                if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    wdtpValue1.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                else
                    wdtpValue1.Enabled = Convert.ToBoolean(dr["AutoSelect"]);

                tcValue1.Controls.Add(wdtpValue1);
                break;
            case "AnyQueryRefButtonColumn":
                tbValue1RB.ID = "Web" + count + "AnyQueryValue1WebRefButtonTextBox" + dr["Enabled"].ToString();
                tbValue1RB.Text = dr["DefaultValue"].ToString();
                tbValue1RB.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    tbValue1RB.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                else
                    tbValue1RB.Enabled = Convert.ToBoolean(dr["AutoSelect"]);

                wrbValue1.ID = "Web" + count + "AnyQueryValue1WebRefButton" + dr["Enabled"].ToString();
                wrbValue1.Caption = dr["RefButtonCaption"].ToString();
                wrbValue1.RefURL = dr["RefButtonURL"].ToString();
                if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                    wrbValue1.Visible = Convert.ToBoolean(dr["Enabled"].ToString());
                else
                    wrbValue1.Visible = Convert.ToBoolean(dr["AutoSelect"]);

                string[] arrsize = dr["RefButtonURLSize"].ToString().Split(',');
                if (arrsize.Length == 4)
                {
                    wrbValue1.RefURLHeight = int.Parse(arrsize[0]);
                    wrbValue1.RefURLLeft = int.Parse(arrsize[1]);
                    wrbValue1.RefURLTop = int.Parse(arrsize[2]);
                    wrbValue1.RefURLWidth = int.Parse(arrsize[3]);
                }

                MatchControl mc = new MatchControl();
                mc.ControlID = "Web" + count + "AnyQueryValue1WebRefButtonTextBox" + dr["Enabled"].ToString();
                wrbValue1.MatchControls.Add(mc);
                tcValue1.Controls.Add(tbValue1RB);
                tcValue1.Controls.Add(wrbValue1);
                break;
        }

        TableCell tcValue2 = new TableCell();
        tcValue2.HorizontalAlign = HorizontalAlign.Left;
        tcValue2.VerticalAlign = VerticalAlign.Middle;
        if (dllOperator.Text == "<->" || dllOperator.Text == "!<->")
        {
            switch (dr["ColumnType"].ToString())
            {
                case "AnyQueryTextBoxColumn":
                    tbValue2 = new TextBox();
                    tbValue2.ID = "Web" + count + "AnyQueryValue2TextBox" + dr["Enabled"].ToString();
                    tbValue2.Text = dr["DefaultValue"].ToString();
                    tbValue2.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                    if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                        tbValue2.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                    else
                        tbValue2.Enabled = Convert.ToBoolean(dr["AutoSelect"]);

                    tcValue2.Controls.Add(tbValue2);
                    break;
                case "AnyQueryComboBoxColumn":
                    wddlValue2 = new WebDropDownList();
                    wddlValue2.ID = "Web" + count + "AnyQueryValue2WebDropDownList" + dr["Enabled"].ToString();
                    wddlValue2.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                    if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                        wddlValue2.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                    else
                        wddlValue2.Enabled = Convert.ToBoolean(dr["AutoSelect"]);

                    dsidnum = lstDataSetID.IndexOf(dr["RefValDSID"].ToString());
                    if (dsidnum >= 0)
                    {
                        wddlValue2.DataSourceID = "refvalds" + dsidnum.ToString();
                        if (dr["RefValWhereItem"].ToString() != "")
                        {
                            string filter = WhereItemToFileter(dr["RefValWhereItem"].ToString(), "refvalds" + dsidnum.ToString());
                            (this.FindControl("refvalds" + dsidnum.ToString()) as WebDataSource).SetWhere(filter);
                        }
                        wddlValue2.DataTextField = dr["RefValTF"].ToString();
                        wddlValue2.DataValueField = dr["RefValVF"].ToString();
                        wddlValue2.AppendDataBoundItems = true;
                        wddlValue2.AutoInsertEmptyData = true;
                    }
                    else if (dr["RefValAlias"].ToString() != String.Empty && dr["RefValCMD"].ToString() != String.Empty)
                    {
                        refValDateSourcecmd[cmdIndex] = new WebDataSource();
                        refValDateSourcecmd[cmdIndex].SelectAlias = dr["RefValAlias"].ToString();
                        refValDateSourcecmd[cmdIndex].SelectCommand = dr["RefValCMD"].ToString();
                        refValDateSourcecmd[cmdIndex].ID = "refvalcmd" + cmdIndex.ToString();
                        this.Form.Controls.Add(refValDateSourcecmd[cmdIndex]);
                        wddlValue2.DataSourceID = "refvalcmd" + cmdIndex.ToString();
                        cmdIndex++;
                        wddlValue2.DataTextField = dr["RefValTF"].ToString();
                        wddlValue2.DataValueField = dr["RefValVF"].ToString();
                        wddlValue2.AppendDataBoundItems = true;
                        wddlValue2.AutoInsertEmptyData = true;
                    }
                    else
                    {
                        //String[] item = arrItems.Split('!');
                        //foreach (String temp in item)
                        //    wddlValue2.Items.Add(temp);
                    }

                    if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                    {
                        if (dr["Text"].ToString() != "")
                        {
                            wddlValue2.SelectedValue = dr["Text"].ToString();
                        }
                    }
                    else
                    {
                        try
                        {
                            if (dr["DefaultValue"].ToString() != "")
                            {
                                wddlValue2.SelectedValue = dr["DefaultValue"].ToString();
                            }
                        }
                        catch
                        { }
                    }
                    tcValue2.Controls.Add(wddlValue2);
                    break;
                case "AnyQueryCheckBoxColumn":
                    cbValue2 = new CheckBox();
                    cbValue2.ID = "Web" + count + "AnyQueryValue2CheckBox" + dr["Enabled"].ToString();
                    if (dr["DefaultValue"].ToString() == "1")
                        cbValue2.Checked = true;
                    cbValue2.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                    if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                        cbValue2.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                    else
                        cbValue2.Enabled = Convert.ToBoolean(dr["AutoSelect"]);
                    tcValue2.Controls.Add(cbValue2);
                    break;
                case "AnyQueryRefValColumn":
                    wrvValue2 = new WebRefVal();
                    wrvValue2.ID = "Web" + count + "AnyQueryValue2RefVal" + dr["Enabled"].ToString();
                    wrvValue2.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));

                    dsidnum = lstDataSetID.IndexOf(dr["RefValDSID"].ToString());
                    if (dsidnum >= 0)
                    {
                        wrvValue2.DataSourceID = "refvalds" + dsidnum.ToString();

                        wrvValue2.ResxDataSet = dr["RefValDSID"].ToString();
                        wrvValue2.ResxFilePath = psyPagePath + ".vi-VN.resx";
                    }
                    else
                    {
                        refValDateSourcecmd[cmdIndex] = new WebDataSource();
                        refValDateSourcecmd[cmdIndex].SelectAlias = dr["RefValAlias"].ToString();
                        refValDateSourcecmd[cmdIndex].SelectCommand = dr["RefValCMD"].ToString();
                        refValDateSourcecmd[cmdIndex].ID = "refvalcmd" + cmdIndex.ToString();
                        this.Form.Controls.Add(refValDateSourcecmd[cmdIndex]);
                        wrvValue2.DataSourceID = "refvalcmd" + cmdIndex.ToString();
                        cmdIndex++;
                    }
                    wrvValue2.DataTextField = dr["RefValTF"].ToString();
                    wrvValue2.DataValueField = dr["RefValVF"].ToString();
                    wrvValue2.CheckData = Convert.ToBoolean(dr["RefValCD"].ToString());

                    string[] aSize = dr["RefValSize"].ToString().Split(',');
                    if (aSize.Length == 4)
                    {
                        wrvValue2.OpenRefHeight = int.Parse(aSize[0]);
                        wrvValue2.OpenRefLeft = int.Parse(aSize[1]);
                        wrvValue2.OpenRefTop = int.Parse(aSize[2]);
                        wrvValue2.OpenRefWidth = int.Parse(aSize[3]);
                    }

                    #region Add WebRefval other properties
                    if (dr["RefValColumnMatch"].ToString() != string.Empty)
                    {
                        string[] columnmatch = dr["RefValColumnMatch"].ToString().Split(':');
                        WebColumnMatch[] wcm = new WebColumnMatch[columnmatch.Length];
                        for (int j = 0; j < columnmatch.Length; j++)
                        {
                            string[] columnmatchcontext = columnmatch[j].Split(',');
                            wcm[j] = new WebColumnMatch(columnmatchcontext[1], columnmatchcontext[2], columnmatchcontext[0]);
                            wrvValue2.ColumnMatch.Add(wcm[j]);
                        }
                    }
                    if (dr["RefValColumns"].ToString() != string.Empty)
                    {
                        string[] columns = dr["RefValColumns"].ToString().Split(':');
                        WebRefColumn[] wrc = new WebRefColumn[columns.Length];
                        for (int j = 0; j < columns.Length; j++)
                        {
                            string[] columnscontext = columns[j].Split(',');
                            wrc[j] = new WebRefColumn(columnscontext[0], columnscontext[1], int.Parse(columnscontext[2]));
                            wrvValue2.Columns.Add(wrc[j]);
                        }
                    }
                    if (dr["RefValWhereItem"].ToString() != string.Empty)
                    {
                        string[] whereitem = dr["RefValWhereItem"].ToString().Split(':');
                        WebWhereItem[] wwi = new WebWhereItem[whereitem.Length];
                        for (int j = 0; j < whereitem.Length; j++)
                        {
                            string[] whereitemcontext = whereitem[j].Split(',');
                            wwi[j] = new WebWhereItem(whereitemcontext[1], whereitemcontext[0], whereitemcontext[2]);
                            wrvValue2.WhereItem.Add(wwi[j]);
                        }
                    }
                    #endregion

                    if (string.Compare(keepcondition, "true", true) == 0)//IgnoreCase
                    {
                        if (dr["Text"].ToString() != "")
                        {
                            wrvValue2.BindingValue = dr["Text"].ToString();
                        }
                    }
                    else
                    {
                        try
                        {
                            wrvValue2.BindingValue = dr["DefaultValue"].ToString();
                        }
                        catch
                        { }
                    }
                    if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                        wrvValue2.ReadOnly = !Convert.ToBoolean(dr["Enabled"].ToString());
                    else
                        wrvValue2.ReadOnly = !Convert.ToBoolean(dr["AutoSelect"]);
                    tcValue2.Controls.Add(wrvValue2);
                    break;
                case "AnyQueryCalendarColumn":
                    wdtpValue2 = new WebDateTimePicker();
                    wdtpValue2.ID = "Web" + count + "AnyQueryValue2WebDateTimePicker" + dr["Enabled"].ToString();
                    wdtpValue2.Text = dr["DefaultValue"].ToString();
                    wdtpValue2.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                    wdtpValue2.DateFormat = dateFormat.ShortDate;
                    if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                        wdtpValue2.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                    else
                        wdtpValue2.Enabled = Convert.ToBoolean(dr["AutoSelect"]);
                    tcValue2.Controls.Add(wdtpValue2);
                    break;
                case "AnyQueryRefButtonColumn":
                    tbValue2RB.ID = "Web" + count + "AnyQueryValue2WebRefButtonTextBox" + dr["Enabled"].ToString();
                    tbValue2RB.Text = dr["DefaultValue"].ToString();
                    tbValue2RB.Width = Unit.Pixel(int.Parse(dr["TextWidth"].ToString()));
                    if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                        tbValue2RB.Enabled = Convert.ToBoolean(dr["Enabled"].ToString());
                    else
                        tbValue2RB.Enabled = Convert.ToBoolean(dr["AutoSelect"]);

                    wrbValue2.ID = "Web" + count + "AnyQueryValue2WebRefButton" + dr["Enabled"].ToString();
                    wrbValue2.Caption = dr["RefButtonCaption"].ToString();
                    wrbValue2.RefURL = dr["RefButtonURL"].ToString();
                    if (Convert.ToBoolean(dr["Enabled"].ToString()) == false)
                        wrbValue2.Visible = Convert.ToBoolean(dr["Enabled"].ToString());
                    else
                        wrbValue2.Visible = Convert.ToBoolean(dr["AutoSelect"]);

                    string[] arrsize = dr["RefButtonURLSize"].ToString().Split(',');
                    if (arrsize.Length == 4)
                    {
                        wrbValue2.RefURLHeight = int.Parse(arrsize[0]);
                        wrbValue2.RefURLLeft = int.Parse(arrsize[1]);
                        wrbValue2.RefURLTop = int.Parse(arrsize[2]);
                        wrbValue2.RefURLWidth = int.Parse(arrsize[3]);
                    }

                    MatchControl mc = new MatchControl();
                    mc.ControlID = "Web" + count + "AnyQueryValue2WebRefButtonTextBox" + dr["Enabled"].ToString();
                    wrbValue2.MatchControls.Add(mc);
                    tcValue2.Controls.Add(tbValue2RB);
                    tcValue2.Controls.Add(wrbValue2);
                    break;
            }
        }

        tr.Cells.Add(tcActive);
        tr.Cells.Add(tcCondition);
        tr.Cells.Add(tcColumn);
        tr.Cells.Add(tcOperator);
        tr.Cells.Add(tcValue1);
        tr.Cells.Add(tcValue2);

        //if (autoDisableColumns)
        //{
        //    InnerPages_frmAnyQuery_cbActive_CheckedChanged(cbActive, new EventArgs());
        //}

        return tr;
    }
Ejemplo n.º 13
0
        private Table GenTable()
        {
            Table table = new Table();
            table.CellPadding = 0;
            table.CellSpacing = 5;
            table.CssClass = "ajaxtree_insert_or_udpate_table";
            language = CliUtils.fClientLang;
            string message = SysMsg.GetSystemMessage(language, "Srvtools", "WebTreeView", "Caption", true);
            string[] captions = message.Split(';');

            TableRow rowKey = new TableRow();
            TableCell cellKey1 = new TableCell();
            Label lblKey = new Label();
            lblKey.ID = "lblKey";
            lblKey.Width = new Unit(50);
            lblKey.Text = string.IsNullOrEmpty(this.KeyCaption) ? captions[0] : this.KeyCaption;
            cellKey1.Controls.Add(lblKey);
            TableCell cellKey2 = new TableCell();
            TextBox txtKey = new TextBox();
            txtKey.Width = new Unit(120);
            txtKey.ID = "txtKey";
            cellKey2.Controls.Add(txtKey);
            rowKey.Cells.AddRange(new TableCell[] { cellKey1, cellKey2 });

            TableRow rowParent = new TableRow();
            TableCell cellParent1 = new TableCell();
            Label lblParent = new Label();
            lblParent.ID = "lblParent";
            lblParent.Width = new Unit(50);
            lblParent.Text = string.IsNullOrEmpty(this.ParentCaption) ? captions[1] : this.ParentCaption;
            cellParent1.Controls.Add(lblParent);
            TableCell cellParent2 = new TableCell();
            DropDownList ddlParent = new DropDownList();
            ddlParent.ID = "ddlParent";
            ddlParent.Width = new Unit(125);
            cellParent2.Controls.Add(ddlParent);
            rowParent.Cells.AddRange(new TableCell[] { cellParent1, cellParent2 });

            TableRow rowCaption = new TableRow();
            TableCell cellCaption1 = new TableCell();
            Label lblCaption = new Label();
            lblCaption.ID = "lblCaption";
            lblCaption.Width = new Unit(50);
            lblCaption.Text = string.IsNullOrEmpty(this.TextCaption) ? captions[2] : this.TextCaption;
            cellCaption1.Controls.Add(lblCaption);
            TableCell cellCaption2 = new TableCell();
            TextBox txtCaption = new TextBox();
            txtCaption.ID = "txtCaption";
            txtCaption.Width = new Unit(120);
            cellCaption2.Controls.Add(txtCaption);
            rowCaption.Cells.AddRange(new TableCell[] { cellCaption1, cellCaption2 });

            table.Rows.AddRange(new TableRow[] { rowKey, rowParent, rowCaption });

            foreach (AjaxTreeViewItem item in this.EditColumn)
            {
                TableRow row = new TableRow();
                TableCell cell1 = new TableCell();
                Label lbl = new Label();
                lbl.ID = "lbl" + item.Column;
                lbl.Width = new Unit(50);
                lbl.Text = item.Caption;
                cell1.Controls.Add(lbl);
                TableCell cell2 = new TableCell();
                switch (item.ColumnType)
                {
                    case AjaxTreeViewColumnType.TextBoxColumn:
                        TextBox txt = new TextBox();
                        txt.ID = "txt" + item.Column;
                        txt.Width = new Unit(120);
                        cell2.Controls.Add(txt);
                        break;
                    case AjaxTreeViewColumnType.ComboBoxColumn:
                        DropDownList ddl = new DropDownList();
                        ddl.ID = "ddl" + item.Column;
                        ddl.Width = new Unit(125);
                        ddl.DataSourceID = item.DataSourceID;
                        ddl.DataTextField = item.DataTextField;
                        ddl.DataValueField = item.DataValueField;
                        cell2.Controls.Add(ddl);
                        break;
                    case AjaxTreeViewColumnType.RefValColumn:
                        WebRefVal refval = new WebRefVal();
                        refval.ID = "ref" + item.Column;
                        refval.Width = new Unit(125);
                        refval.DataSourceID = item.DataSourceID;
                        refval.DataTextField = item.DataTextField;
                        refval.DataValueField = item.DataValueField;
                        cell2.Controls.Add(refval);
                        break;
                    case AjaxTreeViewColumnType.CalendarColumn:
                        AjaxCalendar cal = new AjaxCalendar();
                        cal.ID = "cal" + item.Column;
                        cal.Width = new Unit(120);
                        cal.Format = "yyyy/MM/dd";
                        cell2.Controls.Add(cal);
                        break;
                    case AjaxTreeViewColumnType.RadioButtonColumn:
                        break;
                }
                row.Cells.AddRange(new TableCell[] { cell1, cell2 });
                table.Rows.Add(row);
            }

            TableRow buttonRow = new TableRow();
            TableCell cellButton = new TableCell();
            cellButton.ColumnSpan = 2;
            cellButton.CssClass = "ajaxtree_buttonContainer";
            Button btnOK = new Button();
            btnOK.ID = "btnOK";
            btnOK.Text = "OK";
            btnOK.OnClientClick = "var behavior = $find('" + this.ClientID + "_treeShowModalBehavior');if (behavior) {behavior.hide();}";
            btnOK.CssClass = "ajaxtree_btn_rect_mouseout";
            btnOK.Attributes.Add("onmouseout", "this.className='_ajaxtree_btn_rect_mouseout'");
            btnOK.Attributes.Add("onmouseover", "this.className='_ajaxtree_btn_rect_mouseover'");
            btnOK.Click += new EventHandler(btnOK_Click);
            cellButton.Controls.Add(btnOK);
            Button btnCancel = new Button();
            btnCancel.ID = "btnCancel";
            btnCancel.Text = "Cancel";
            btnCancel.OnClientClick = "var behavior = $find('" + this.ClientID + "_treeShowModalBehavior');if (behavior) {behavior.hide();}return false;";
            btnCancel.CssClass = "ajaxtree_btn_rect_mouseout";
            btnCancel.Attributes.Add("onmouseout", "this.className='_ajaxtree_btn_rect_mouseout'");
            btnCancel.Attributes.Add("onmouseover", "this.className='_ajaxtree_btn_rect_mouseover'");
            cellButton.Controls.Add(btnCancel);
            buttonRow.Cells.Add(cellButton);

            table.Rows.Add(buttonRow);

            return table;
        }
Ejemplo n.º 14
0
        public void Show(Panel pn)
        {
            Label[] labels;
            TextBox[] textBoxes;
            CheckBox[] checkBoxes;
            WebDropDownList[] dropDownlists;
            WebRefVal[] webRefVals;
            WebDateTimePicker[] webDateTimePickers;
            WebRefButton[] webRefButtons;

            Table table = new Table();
            table.CellSpacing = 0;
            if (this.InnerTable)
            {
                table.CellSpacing = 1;
                table.BackColor = this.BorderColor;
                table.BorderWidth = 1;
                table.BorderColor = this.BorderColor;
                table.BorderStyle = BorderStyle.Solid;
            }

            //WebDataSource wds = new WebDataSource();
            //wds = (WebDataSource)GetObjByID(this.DataSourceID);

            if (!this.isShow.Contains(pn.ID))
            {
                int columnNum = this.Columns.Count;
                if (columnNum == 0)
                {
                    return;
                }
                labels = new Label[columnNum];
                dropDownlists = new WebDropDownList[columnNum];
                textBoxes = new TextBox[columnNum];
                checkBoxes = new CheckBox[columnNum];
                webRefVals = new WebRefVal[columnNum];
                webDateTimePickers = new WebDateTimePicker[columnNum];
                webRefButtons = new WebRefButton[columnNum];

                pn.ScrollBars = ScrollBars.Auto;

                TableRow[] trQuery = new TableRow[columnNum];
                int intRowCount = 0;
                trQuery[0] = new TableRow();
                //trQuery[0].BackColor = pn.BackColor;

                for (int i = 0; i < columnNum; i++)
                {
                    if (((WebQueryColumns)this.Columns[i]).Column == string.Empty)
                    {
                        throw new Exception(string.Format("The columnname of column[{0}] is empty", i.ToString()));
                    }

                    TableCell tcLabel = new TableCell();
                    TableCell tcQueryText = new TableCell();
                    if (this.InnerTable)
                    {
                        if (!pn.BackColor.IsEmpty)
                        {
                            tcLabel.BackColor = pn.BackColor;
                            tcQueryText.BackColor = pn.BackColor;
                        }
                        else
                        {
                            tcLabel.BackColor = Color.White;
                            tcQueryText.BackColor = Color.White;
                        }

                    }
                    tcLabel.HorizontalAlign = HorizontalAlign.Right;
                    tcLabel.VerticalAlign = VerticalAlign.Middle;
                    tcLabel.Wrap = false;
                    tcQueryText.HorizontalAlign = HorizontalAlign.Left;
                    tcQueryText.VerticalAlign = VerticalAlign.Middle;
                    if (InnerTable)
                    {
                        tcLabel.BorderStyle = this.BorderStyle;
                        tcQueryText.BorderStyle = this.BorderStyle;
                    }

                    //create captionlabel
                    labels[i] = new Label();
                    labels[i].ID = "lbl" + i.ToString();
                    labels[i].Text = ((WebQueryColumns)this.Columns[i]).Caption;
                    labels[i].ForeColor = this.LabelColor;
                    labels[i].Font.CopyFrom(this.TextFont);
                    tcLabel.Controls.Add(labels[i]);

                    switch (((WebQueryColumns)this.Columns[i]).ColumnType)
                    {
                        case "ClientQueryComboBoxColumn":
                            {
                                dropDownlists[i] = new WebDropDownList();
                                dropDownlists[i].ID = "txt" + i.ToString();
                                dropDownlists[i].Width = ((WebQueryColumns)this.Columns[i]).Width;
                                dropDownlists[i].ForeColor = this.TextColor;
                                WebRefVal wrv = (WebRefVal)GetObjByID(((WebQueryColumns)this.Columns[i]).WebRefVal);
                                dropDownlists[i].DataSourceID = wrv.DataSourceID;

                                dropDownlists[i].DataTextField = wrv.DataTextField;
                                dropDownlists[i].DataValueField = wrv.DataValueField;
                                dropDownlists[i].AppendDataBoundItems = true;
                                dropDownlists[i].AutoInsertEmptyData = true;
                                if (wrv.WhereItem.Count > 0)
                                {
                                    dropDownlists[i].Filter = WhereItemToFileter(wrv);
                                    //dropDownlists[i].DataBind();
                                }

                                if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                {
                                    try
                                    {
                                        if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                        {
                                            dropDownlists[i].SelectedValue = GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue).ToString();
                                        }
                                    }
                                    catch
                                    { }
                                }
                                dropDownlists[i].Font.CopyFrom(this.TextFont);
                                tcQueryText.Controls.Add(dropDownlists[i]);
                                break;
                            }
                        case "ClientQueryTextBoxColumn":
                            {
                                textBoxes[i] = new TextBox();
                                textBoxes[i].ID = "txt" + i.ToString();
                                textBoxes[i].Width = ((WebQueryColumns)this.Columns[i]).Width;
                                if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                {
                                    textBoxes[i].Text = GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue).ToString();
                                }
                                textBoxes[i].ForeColor = this.TextColor;
                                if (((WebQueryColumns)this.Columns[i]).NotNull)
                                {
                                    textBoxes[i].BackColor = ((WebQueryColumns)this.Columns[i]).NotNullBackColor;
                                }
                                textBoxes[i].Font.CopyFrom(this.TextFont);
                                tcQueryText.Controls.Add(textBoxes[i]);
                                break;
                            }
                        case "ClientQueryCheckBoxColumn":
                            {
                                checkBoxes[i] = new CheckBox();
                                checkBoxes[i].ID = "txt" + i.ToString();
                                checkBoxes[i].Text = string.Empty;
                                checkBoxes[i].Width = ((WebQueryColumns)this.Columns[i]).Width;
                                object defaultvalue = GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue);
                                if (defaultvalue != null)
                                {
                                    if (string.Compare(defaultvalue.ToString(), "true", true) == 0 || string.Compare(defaultvalue.ToString(), "1") == 0)
                                    {
                                        checkBoxes[i].Checked = true;
                                    }
                                    else
                                    {
                                        checkBoxes[i].Checked = false;
                                    }
                                }
                                else
                                {
                                    checkBoxes[i].Checked = false;
                                }
                                tcQueryText.Controls.Add(checkBoxes[i]);
                                break;
                            }
                        case "ClientQueryRefValColumn":
                            {
                                webRefVals[i] = new WebRefVal();
                                webRefVals[i].ID = "txt" + i.ToString();
                                webRefVals[i].Width = ((WebQueryColumns)this.Columns[i]).Width;
                                //       webRefVals[i].ForeColor = this.TextColor;
                                webRefVals[i].Font.CopyFrom(this.TextFont);

                                WebRefVal wrv = (WebRefVal)GetObjByID(((WebQueryColumns)this.Columns[i]).WebRefVal);
                                webRefVals[i].DataSourceID = wrv.DataSourceID;
                                webRefVals[i].MultiLanguage = wrv.MultiLanguage;
                                webRefVals[i].DataTextField = wrv.DataTextField;
                                webRefVals[i].DataValueField = wrv.DataValueField;
                                webRefVals[i].CheckData = wrv.CheckData;
                                webRefVals[i].OpenRefHeight = wrv.OpenRefHeight;
                                webRefVals[i].OpenRefLeft = wrv.OpenRefLeft;
                                webRefVals[i].OpenRefTop = wrv.OpenRefTop;
                                webRefVals[i].OpenRefWidth = wrv.OpenRefWidth;
                                webRefVals[i].PostBackButonClick = wrv.PostBackButonClick;
                                webRefVals[i].UpdatePanelID = wrv.UpdatePanelID;
                                webRefVals[i].SessionMode = true;

                                foreach (WebColumnMatch wcm in wrv.ColumnMatch)
                                {
                                    webRefVals[i].ColumnMatch.Add(wcm);
                                }
                                foreach (WebRefColumn wrc in wrv.Columns)
                                {
                                    webRefVals[i].Columns.Add(wrc);
                                }
                                foreach (WebWhereItem wwi in wrv.WhereItem)
                                {
                                    webRefVals[i].WhereItem.Add(wwi);
                                }
                                if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                {
                                    try
                                    {
                                        if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                        {
                                            webRefVals[i].BindingValue = GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue).ToString();
                                        }
                                    }
                                    catch
                                    { }
                                }

                                tcQueryText.Controls.Add(webRefVals[i]);

                                break;
                            }
                        case "ClientQueryRefButtonColumn":
                            {
                                textBoxes[i] = new TextBox();
                                textBoxes[i].ID = "txt" + i.ToString();
                                if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                {
                                    textBoxes[i].Text = GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue).ToString();
                                }
                                textBoxes[i].Width = ((WebQueryColumns)this.Columns[i]).Width;
                                textBoxes[i].ForeColor = this.TextColor;
                                textBoxes[i].Font.CopyFrom(this.TextFont);
                                webRefButtons[i] = new WebRefButton();
                                webRefButtons[i].ID = "btn" + i.ToString();
                                WebRefButton wrf = (WebRefButton)GetObjByID(((WebQueryColumns)this.Columns[i]).WebRefButton);
                                webRefButtons[i].Caption = wrf.Caption;
                                webRefButtons[i].RefURL = wrf.RefURL;
                                webRefButtons[i].RefURLHeight = wrf.RefURLHeight;
                                webRefButtons[i].RefURLWidth = wrf.RefURLWidth;
                                webRefButtons[i].RefURLLeft = wrf.RefURLLeft;
                                webRefButtons[i].RefURLTop = wrf.RefURLTop;
                                MatchControl mc = new MatchControl();
                                mc.ControlID = "txt" + i.ToString();
                                webRefButtons[i].MatchControls.Add(mc);
                                tcQueryText.Controls.Add(textBoxes[i]);
                                tcQueryText.Controls.Add(webRefButtons[i]);
                                break;
                            }
                        case "ClientQueryCalendarColumn":
                            {
                                webDateTimePickers[i] = new WebDateTimePicker();
                                webDateTimePickers[i].ID = "txt" + i.ToString();
                                webDateTimePickers[i].Width = ((WebQueryColumns)this.Columns[i]).Width;
                                webDateTimePickers[i].CheckDate = true;
                                webDateTimePickers[i].ForeColor = this.TextColor;
                                webDateTimePickers[i].Font.CopyFrom(this.TextFont);
                                if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                {
                                    try
                                    {
                                        if (GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue) != null)
                                        {
                                            webDateTimePickers[i].Text = GetDefaultValue(((WebQueryColumns)this.Columns[i]).DefaultValue).ToString();
                                        }
                                    }
                                    catch
                                    {
                                        webDateTimePickers[i].Text = DateTime.Now.ToShortDateString();
                                    }
                                }
                                webDateTimePickers[i].DateFormat = dateFormat.ShortDate;
                                webDateTimePickers[i].DateFormatString = this.DateFormatString;
                                tcQueryText.Controls.Add(webDateTimePickers[i]);
                                break;
                            }
                    }
                    if (!((WebQueryColumns)this.Columns[i]).Visible)
                    {
                        foreach (Control ctrl in tcQueryText.Controls)
                        {
                            ctrl.Visible = false;
                            pn.Controls.Add(ctrl);
                        }
                        continue;
                    }

                    //is newline
                    if (((WebQueryColumns)this.Columns[i]).NewLine == true)
                    {
                        if (trQuery[intRowCount].Cells.Count > 0)
                        {
                            table.Controls.Add(trQuery[intRowCount]);
                            if (!this.InnerTable)
                            {
                                TableRow trEmpty = new TableRow();
                                trEmpty.Height = this.GapVertical;
                                if (GapVertical > 0)
                                {
                                    table.Controls.Add(trEmpty);
                                }
                            }
                            intRowCount++;
                            trQuery[intRowCount] = new TableRow();
                            //trQuery[intRowCount].BackColor = pn.BackColor;
                        }

                        trQuery[intRowCount].Cells.Add(tcLabel);
                        trQuery[intRowCount].Cells.Add(tcQueryText);
                    }
                    else
                    {
                        if (trQuery[intRowCount].Cells.Count > 0)
                        {
                            if (!this.InnerTable)
                            {
                                TableCell tcEmpty = new TableCell();
                                tcEmpty.Width = this.GapHorizontal;
                                if (GapHorizontal > 0)
                                {
                                    trQuery[intRowCount].Cells.Add(tcEmpty);
                                }
                            }

                        }
                        trQuery[intRowCount].Cells.Add(tcLabel);
                        trQuery[intRowCount].Cells.Add(tcQueryText);

                    }
                }

                table.Controls.Add(trQuery[intRowCount]);
                //new add to fill tr

                int maxcontrol = 0;
                for (int i = 0; i < intRowCount + 1; i++)
                {
                    maxcontrol = Math.Max(maxcontrol, trQuery[i].Controls.Count);
                }
                for (int i = 0; i < table.Controls.Count; i++)
                {
                    if (table.Controls[i].Controls.Count < maxcontrol)
                    {
                        TableCell tccolspan = new TableCell();
                        if (this.InnerTable)
                        {
                            if (!pn.BackColor.IsEmpty)
                            {
                                tccolspan.BackColor = pn.BackColor;
                            }
                            else
                            {
                                tccolspan.BackColor = Color.White;
                            }
                            tccolspan.BorderColor = tccolspan.BackColor;
                            //tccolspan.BorderStyle = this.BorderStyle;
                        }
                        tccolspan.ColumnSpan = maxcontrol - table.Controls[i].Controls.Count;
                        table.Controls[i].Controls.Add(tccolspan);
                    }
                }

                pn.Controls.Add(table);
                if (!Page.IsPostBack)//postback do not add item again
                {
                    foreach (WebDropDownList wdl in dropDownlists)
                    {
                        if (wdl != null)
                        {
                            wdl.DataBind();
                        }
                    }
                }
                this.isShow.Add(pn.ID);
            }
        }
Ejemplo n.º 15
0
        //这个....
        private string WhereItemToFileter(WebRefVal wrf)
        {
            WebDataSource wds = GetObjByID(wrf.DataSourceID) as WebDataSource;
            string sqlcmd = DBUtils.GetCommandText(wds);
            string filter = "";
            foreach (WebWhereItem wi in wrf.WhereItem)
            {
                string strOperator = wi.Condition;

                if (filter != "")
                {
                    filter += " and ";
                }
                string type = wds.InnerDataSet.Tables[wds.DataMember].Columns[wi.FieldName].DataType.ToString().ToLower();
                if (strOperator != "%" && strOperator != "%%")
                {
                    if (type == "system.uint" || type == "system.uint16" || type == "system.uint32"
                       || type == "system.int64" || type == "system.int" || type == "system.int16"
                       || type == "system.int32" || type == "system.uint64" || type == "system.single"
                       || type == "system.double" || type == "system.decimal")
                    {
                        filter += CliUtils.GetTableNameForColumn(sqlcmd, wi.FieldName) + strOperator + " " + wi.Value;
                    }
                    else
                    {
                        filter += CliUtils.GetTableNameForColumn(sqlcmd, wi.FieldName) + strOperator + " '" + wi.Value + "'";
                    }
                }
                else
                {
                    if (strOperator == "%")
                    {
                        filter += CliUtils.GetTableNameForColumn(sqlcmd, wi.FieldName) + "like '" + wi.Value + "%'";
                    }
                    if (strOperator == "%%")
                    {
                        filter += CliUtils.GetTableNameForColumn(sqlcmd, wi.FieldName) + "like '%" + wi.Value + "%'";
                    }
                }
            }
            return filter;
        }