示例#1
0
        private void CreateGridPicker(HtmlTableCell cell, int rowIndex, string defaultView)
        {
            GridPicker ucGridPicker = this.LoadControl("GridPicker.ascx") as GridPicker;

            ucGridPicker.BusinessObjectViewName = defaultView;
            ucGridPicker.ID    = "__ucGridPicker_" + rowIndex.ToString();
            ucGridPicker.Width = "45%";
            cell.Controls.Add(ucGridPicker);
            cell.Attributes.Add("onclick", "QueryItemClicked();");
        }
示例#2
0
        /// <summary>
        /// Generate filter according to each query item(along with filter description)
        /// </summary>
        public BusinessFilter GetBusinessFilter(out string filterDescription)
        {
            BusinessFilter queryFilter    = new BusinessFilter(this.BusinessObjectView.BusinessObjectName);
            HtmlTable      queryTable     = this.queryHolder.FindControl("__queryTable") as HtmlTable;
            AndOr          filterJunction = GetFilterJunction(queryTable);
            StringBuilder  queryDesc      = new StringBuilder();

            // queryTable的最后一行是queryType(满足全部、满足任一)
            for (int i = 0; i < queryTable.Rows.Count - 1; i++)
            {
                HtmlTableRow      queryItem = queryTable.FindControl("__queryitem_" + i.ToString()) as HtmlTableRow;
                HtmlInputCheckBox checkbox  = queryTable.FindControl("__checkbox_" + i.ToString()) as HtmlInputCheckBox;

                if (checkbox.Checked)
                {
                    LiteralControl      desc     = queryTable.FindControl("__desc_" + i.ToString()) as LiteralControl;
                    ViewItemDisplayType itemType = (ViewItemDisplayType)int.Parse(queryItem.Attributes["displayType"]);

                    if (itemType == ViewItemDisplayType.CheckBox)
                    {
                        // Filter
                        HtmlInputCheckBox boolCtl = queryTable.FindControl("__bool_" + i.ToString()) as HtmlInputCheckBox;

                        if (queryItem.Attributes["isVirtual"] != "true")
                        {
                            queryFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                                                      Convert.ToInt32(boolCtl.Checked).ToString(), Operation.Equal, FilterType.NumberType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                        }
                        else
                        {
                            queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + "=" + Convert.ToInt32(boolCtl.Checked).ToString(), queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                        }

                        // Desc
                        queryDesc.AppendFormat("{0}:{1}.", desc.Text, boolCtl.Checked);
                    }
                    else if (itemType == ViewItemDisplayType.Literal)
                    {
                        // Filter
                        HtmlInputText textbox = queryTable.FindControl("__textbox_" + i.ToString()) as HtmlInputText;
                        if (textbox.Value != string.Empty)
                        {
                            GlobalFacade.PageContext pgCtx = GlobalFacade.SystemContext.GetContext().GetPageContext(this.openerId);
                            pgCtx.Parms.Clear();
                            RadioButtonList FuzzyEnquiry = queryTable.FindControl("__Fuzzytxt_" + i.ToString()) as RadioButtonList;
                            if (queryItem.Attributes["isVirtual"] != "true")
                            {
                                if (FuzzyEnquiry != null)
                                {
                                    if (FuzzyEnquiry.SelectedIndex == 0)
                                    {
                                        queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], textbox.Value.Replace("'", "''"), Operation.Like, FilterType.StringType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                    else
                                    {
                                        queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], textbox.Value.Replace("'", "''"), Operation.Equal, FilterType.StringType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                }
                                else
                                {
                                    queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], textbox.Value.Replace("'", "''"), Operation.Like, FilterType.StringType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                }
                            }
                            else
                            {
                                if (FuzzyEnquiry != null)
                                {
                                    if (FuzzyEnquiry.SelectedIndex == 0)
                                    {
                                        queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                    else
                                    {
                                        queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " = '" + textbox.Value.Replace("'", "''") + "'", queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                    }
                                }
                                else
                                {
                                    queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                                }
                            }

                            //							if(queryItem.Attributes["isVirtual"] != "true")
                            //								queryFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                            //									textbox.Value.Replace("'", "''"), Operation.Like, FilterType.StringType, filterJunction);	// 2007-4-5, Tony, 将单引号替换成两个单引号,避免查询时报错
                            //							else
                            //							{
                            //								/* Andy Modify 2008-07-30 只有Client的Mobile、TelePhone、ChineseName、EnglishName用前匹配模糊查询 */
                            //								if(this.BusinessObjectView.BusinessObjectName.ToLower() == "client")
                            //								{
                            //									if( queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("mobile") == -1 &&
                            //										queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("telephone") == -1 &&
                            //										queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("chinesename") == -1 &&
                            //										queryItem.Attributes["fieldName"].ToLower().Trim().IndexOf("englishname") == -1)
                            //									{
                            //										queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", filterJunction);// 2007-4-5, Tony, 将单引号替换成两个单引号,避免查询时报错
                            //									}
                            //									else
                            //										queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '" + textbox.Value.Replace("'", "''") + "%'", filterJunction);
                            //								}
                            //								else
                            //									queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " LIKE '%" + textbox.Value.Replace("'", "''") + "%'", filterJunction);// 2007-4-5, Tony, 将单引号替换成两个单引号,避免查询时报错
                            //							}

                            // Desc
                            queryDesc.AppendFormat("{0}:{1}.", desc.Text, textbox.Value);
                        }
                    }
                    else if (itemType == ViewItemDisplayType.DateTime)
                    {
                        // Filter
                        HtmlInputText  beginTime = queryTable.FindControl("__beginTime_" + i.ToString()) as HtmlInputText;
                        HtmlInputText  endTime   = queryTable.FindControl("__endTime_" + i.ToString()) as HtmlInputText;
                        BusinessFilter subFilter = new BusinessFilter(this.BusinessObjectView.BusinessObjectName);

                        if (queryItem.Attributes["isVirtual"] != "true")
                        {
                            if (beginTime.Value != string.Empty)
                            {
                                subFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                                                        beginTime.Value, Operation.NotSmaller, FilterType.StringType, AndOr.AND);
                            }


                            if (endTime.Value != string.Empty)
                            {
                                subFilter.AddFilterItem(queryItem.Attributes["fieldName"],
                                                        endTime.Value, Operation.Smaller, FilterType.StringType, AndOr.AND);
                            }
                            //endTime.Value, Operation.NotLarger, FilterType.StringType, AndOr.AND);
                        }
                        else
                        {
                            if (beginTime.Value != string.Empty)
                            {
                                subFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + ">= '" + beginTime.Value + "'", AndOr.AND);
                            }

                            if (endTime.Value != string.Empty)
                            {
                                subFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + "< '" + endTime.Value + "'", AndOr.AND);
                            }
                            //subFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + "<= '" + endTime.Value + "'", AndOr.AND);
                        }
                        queryFilter.AddFilter(subFilter, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);

                        if (beginTime.Value != string.Empty || endTime.Value != string.Empty)
                        {
                            // Desc
                            queryDesc.AppendFormat("{0}:从{1}至{2}.", desc.Text, beginTime.Value, endTime.Value);
                        }
                    }
                    else if (itemType == ViewItemDisplayType.SingleObject)
                    {
                        // Filter
                        GridPicker ucGridPicker = queryTable.FindControl("__ucGridPicker_" + i.ToString()) as GridPicker;
                        if (ucGridPicker.SelectedValue != string.Empty)
                        {
                            if (queryItem.Attributes["isVirtual"] != "true")
                            {
                                queryFilter.AddFilterItem(queryItem.Attributes["fieldName"], ucGridPicker.SelectedValue, Operation.Equal, FilterType.NumberType, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                            }
                            else
                            {
                                queryFilter.AddCustomerFilter(queryItem.Attributes["fieldName"] + " = " + ucGridPicker.SelectedValue, queryFilter.Filter != string.Empty ? filterJunction : AndOr.AND);
                            }
                            // Desc
                            queryDesc.AppendFormat("{0}:{1}.", desc.Text, ucGridPicker.SelectedText);
                        }
                    }
                }
            }

            if (queryDesc.Length != 0)
            {
                filterDescription = queryDesc.AppendFormat("({0})", (filterJunction == AndOr.AND) ? "满足全部条件" : "满足任一条件").ToString();
            }
            else
            {
                filterDescription = string.Empty;
            }

            BusinessFilter parentQueryFilter = new BusinessFilter(this.BusinessObjectView.BusinessObjectName);

            parentQueryFilter.AddCustomerFilter("1=1", AndOr.AND);
            parentQueryFilter.AddFilter(queryFilter, AndOr.AND);

            this.SaveQueryStatus();
            return(parentQueryFilter);
        }
示例#3
0
        private void SaveQueryStatus()
        {
            if (!this.IsNeedQueryStatus())
            {
                return;
            }

            GlobalFacade.PageContext pgCtx = GlobalFacade.SystemContext.GetContext().GetPageContext(this.openerId);

            HtmlTable       queryTable = this.queryHolder.FindControl("__queryTable") as HtmlTable;
            RadioButtonList queryType  = queryTable.FindControl("__queryType") as RadioButtonList;

            pgCtx.Parms[queryType.UniqueID] = queryType.SelectedIndex;

            // queryTable的最后一行是queryType(满足全部、满足任一)
            for (int i = 0; i < queryTable.Rows.Count - 1; i++)
            {
                HtmlTableRow      queryItem = queryTable.FindControl("__queryitem_" + i.ToString()) as HtmlTableRow;
                HtmlInputCheckBox checkbox  = queryTable.FindControl("__checkbox_" + i.ToString()) as HtmlInputCheckBox;
                LiteralControl    desc      = queryTable.FindControl("__desc_" + i.ToString()) as LiteralControl;

                HtmlInputCheckBox boolCtl      = queryTable.FindControl("__bool_" + i.ToString()) as HtmlInputCheckBox;
                HtmlInputText     textbox      = queryTable.FindControl("__textbox_" + i.ToString()) as HtmlInputText;
                HtmlInputText     beginTime    = queryTable.FindControl("__beginTime_" + i.ToString()) as HtmlInputText;
                HtmlInputText     endTime      = queryTable.FindControl("__endTime_" + i.ToString()) as HtmlInputText;
                GridPicker        ucGridPicker = queryTable.FindControl("__ucGridPicker_" + i.ToString()) as GridPicker;

                //ViewItemDisplayType itemType = (ViewItemDisplayType)int.Parse(queryItem.Attributes["displayType"]);

                pgCtx.Parms[checkbox.UniqueID] = checkbox.Checked;

                if (boolCtl != null)
                {
                    pgCtx.Parms[boolCtl.UniqueID] = boolCtl.Checked;
                    continue;
                }

                if (textbox != null)
                {
                    pgCtx.Parms[textbox.UniqueID] = textbox.Value;

                    RadioButtonList FuzzyEnquiry = queryTable.FindControl("__Fuzzytxt_" + i.ToString()) as RadioButtonList;
                    if (FuzzyEnquiry != null)
                    {
                        pgCtx.Parms[FuzzyEnquiry.UniqueID] = Convert.ToInt32(FuzzyEnquiry.SelectedIndex);
                    }
                    continue;
                }

                if (beginTime != null && endTime != null)
                {
                    pgCtx.Parms[beginTime.UniqueID] = beginTime.Value;
                    pgCtx.Parms[endTime.UniqueID]   = endTime.Value;
                    continue;
                }

                if (ucGridPicker != null)
                {
                    pgCtx.Parms[ucGridPicker.UniqueID] = ucGridPicker.SelectedValue;
                    continue;
                }
            }
            GlobalFacade.SystemContext.GetContext().SavePageContext(this.openerId, pgCtx);
        }