Ejemplo n.º 1
0
    private MyColumnInfoCollection ParseColumnInfos(string valueList)
    {
        MyColumnInfoCollection columnInfos = new MyColumnInfoCollection();

        if (String.IsNullOrEmpty(valueList))
        {
            return(columnInfos);
        }

        string[] valuePears = valueList.Split(';');
        if (valuePears == null)
        {
            return(columnInfos);
        }

        foreach (string valuePeer in valuePears)
        {
            string[] keyvalue = valuePeer.Split(':');
            if (keyvalue == null || keyvalue.Length != 2)
            {
                continue;
            }

            string key   = keyvalue[0];
            string value = keyvalue[1];
            key   = key.Trim();
            value = value.Trim();

            MyColumnInfo columnInfo = new MyColumnInfo(key, value);

            columnInfos.Add(columnInfo);
        }

        return(columnInfos);
    }
Ejemplo n.º 2
0
    private BPMDBParameterCollection GetSelectParameters(MyColumnInfoCollection columnInfos)
    {
        BPMDBParameterCollection selectParameters = new BPMDBParameterCollection();

        //添加过滤条件
        foreach (MyColumnInfo column in columnInfos)
        {
            if (!column.FixFilter)
            {
                continue;
            }

            BPMDBParameter parameter = new BPMDBParameter(column.ColumnName, TypeCode.String, column.FixFilterValue);
            parameter.ParameterCompareType = ParameterCompareType.FullCompare | ParameterCompareType.NecessaryCondition;
            selectParameters.Add(parameter);
        }

        //添加搜索条件
        string sch = this.Page.Request.QueryString["sch"];

        if (!String.IsNullOrEmpty(sch))
        {
            sch = sch.Trim();
            string schtype = this.Page.Request.QueryString["schtype"];

            if (String.IsNullOrEmpty(schtype) || schtype == "all")
            {
                foreach (MyColumnInfo column in columnInfos)
                {
                    if (!column.Display)
                    {
                        continue;
                    }

                    BPMDBParameter parameter = new BPMDBParameter(column.ColumnName, TypeCode.String, sch);
                    parameter.ParameterCompareType = ParameterCompareType.LikeCompare | ParameterCompareType.OptionCondition;
                    selectParameters.Add(parameter);
                }
            }
            else
            {
                BPMDBParameter parameter = new BPMDBParameter(schtype, TypeCode.String, sch);
                parameter.ParameterCompareType = ParameterCompareType.LikeCompare | ParameterCompareType.OptionCondition;
                selectParameters.Add(parameter);
            }
        }

        return(selectParameters);
    }
Ejemplo n.º 3
0
    private HyperLink CreateSetValueLink(string value, MyColumnInfoCollection columns, FlowDataRow row, int index)
    {
        HyperLink link = new HyperLink();

        link.Text = value;

        link.ID          = "row" + index.ToString();
        link.NavigateUrl = String.Format("javascript:SetOwnerBtnValue({0},document.getElementById('{1}').data);",
                                         Request.QueryString["idx"],
                                         link.ID);

        link.Attributes.Add("data",
                            GetMapValue(columns, row));

        return(link);
    }
Ejemplo n.º 4
0
    private string GetMapValue(MyColumnInfoCollection columns, FlowDataRow row)
    {
        string mapvalue = String.Empty;

        foreach (MyColumnInfo column in columns)
        {
            if (!column.Map)
            {
                continue;
            }

            string item = column.ColumnName + "=" + FormatSetValue(row[column.ColumnName]);
            if (String.IsNullOrEmpty(mapvalue))
            {
                mapvalue = item;
            }
            else
            {
                mapvalue += ";" + item;
            }
        }

        return(mapvalue);
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            ClientScriptManager cs = this.Page.ClientScript;

            if (!cs.IsClientScriptIncludeRegistered("MyScript"))
            {
                cs.RegisterClientScriptInclude("MyScript", this.ResolveClientUrl("../Scripts/Main.js"));
            }

            if (!cs.IsClientScriptIncludeRegistered("FormScript"))
            {
                cs.RegisterClientScriptInclude("FormScript", this.Page.ResolveClientUrl("../Scripts/Form.js"));
            }

            if (!cs.IsClientScriptIncludeRegistered("XFormScript"))
            {
                cs.RegisterClientScriptInclude("XFormScript", this.Page.ResolveClientUrl("../Scripts/XForm.js"));
            }

            //获得ColumnInfo
            string datasourceName = this.Request.QueryString["ds"];
            string tableName      = this.Request.QueryString["table"];
            string orderBy        = this.Request.QueryString["orderby"];
            this._columnInfos = this.ParseColumnInfos(this.Request.QueryString["cinfs"]);
            this._columnInfos.ParseFixFilter(this.Page, this.Request.QueryString["fcols"]);
            bool ms         = this.Request.QueryString["ms"] == "1" ? true : false;
            bool hiddenlink = this.Request.QueryString["hl"] == "1" ? true : false;

            if (ms)
            {
                this._bs.Visible       = true;
                this._bs.OnClientClick = String.Format("F_CloseDialogNBat(mlist,{0},'{1}','');return false;",
                                                       this.Request.QueryString["idx"],
                                                       Resources.BPMResource.DataBrowser_Msg_AtleastSelOne);
            }
            else
            {
                this._bs.Visible = false;
            }

            //初始化页导航条
            this.Page.Header.Title = tableName;
            this._navigateBar.InitState();

            //获得数据
            TableRow  row;
            TableCell cell;

            BPMConnection cn       = new BPMConnection();
            FlowDataTable schema   = null;
            FlowDataTable table    = null;
            int           rowcount = 0;
            try
            {
                cn.WebOpen(Page);

                //获得表的Schema
                schema = DataSourceManager.LoadTableSchema(cn, datasourceName, tableName);

                //规则化显示行
                if (this._columnInfos.DisplayColumnCount == 0) //没有显示行
                {
                    //有map则显示map列
                    if (this._columnInfos.MapColumnCount != 0)
                    {
                        foreach (MyColumnInfo column in this._columnInfos)
                        {
                            if (column.Map)
                            {
                                column.Display = true;
                            }
                        }
                    }
                    else //没有则显示所有列
                    {
                        foreach (FlowDataColumn column in schema.Columns)
                        {
                            MyColumnInfo columnInfo = this._columnInfos.TryGetColumn(column.ColumnName);
                            if (columnInfo == null)
                            {
                                columnInfo = new MyColumnInfo(column.ColumnName, true, false, column.ColumnName);
                            }

                            columnInfo.Display = true;
                            this._columnInfos.Add(columnInfo);
                        }
                    }
                }

                foreach (MyColumnInfo column in this._columnInfos)
                {
                    FlowDataColumn dbcolumn = schema.Columns.TryGetItem(column.ColumnName);
                    if (dbcolumn != null)
                    {
                        column.AllowSearch = dbcolumn.AllowSearch;
                    }
                }

                BPMDBParameterCollection parameters = GetSelectParameters(this._columnInfos);

                //获得数据
                table = DataSourceManager.LoadTableDataPaged(cn, datasourceName, tableName, this._columnInfos.AllOutputColumnNames, parameters, orderBy, (this._navigateBar.CurPage - 1) * this._navigateBar.PageSize, this._navigateBar.PageSize, out rowcount);
                this._navigateBar.ItemCount = rowcount;
            }
            finally
            {
                cn.Close();
            }

            //建立ComboBox
            this._schType.Items.Add(new ListItem(Resources.BPMResource.Com_All, "all"));
            foreach (MyColumnInfo column in this._columnInfos)
            {
                if (!column.Display || column.FixFilter || !column.AllowSearch)
                {
                    continue;
                }

                this._schType.Items.Add(new ListItem(column.DisplayName, column.ColumnName));
            }

            //设置状态值
            this._schBox.Text           = this.Request.QueryString["sch"];
            this._schType.SelectedValue = this.Request.QueryString["schtype"];

            //建立List的Header
            row = CreateHeaderRow();
            this._table.Rows.Add(row);

            //获得按SELECT排序的DisplayColumn
            MyColumnInfoCollection displayColumnsOrdered = new MyColumnInfoCollection();
            foreach (FlowDataColumn tableColumn in schema.Columns)
            {
                MyColumnInfo columnInfo = this._columnInfos.TryGetColumn(tableColumn.ColumnName);
                if (columnInfo == null)
                {
                    continue;
                }

                if (!columnInfo.Display)
                {
                    continue;
                }

                displayColumnsOrdered.Add(columnInfo);
            }

            if (ms)
            {
                row.Cells.Add(CreateCheckColumn());
            }

            foreach (MyColumnInfo column in displayColumnsOrdered)
            {
                if (row.Cells.Count != 0)
                {
                    row.Cells.Add(CreateSepratorColumn());
                }

                cell = CreateColumn(column.DisplayName, -1);
                row.Cells.Add(cell);
            }

            //总记录数
            this._labCount.Text = rowcount.ToString();

            //添加行
            foreach (FlowDataRow dataRow in table.Rows)
            {
                row = CreateItemRow();
                this._table.Rows.Add(row);

                if (ms)
                {
                    cell            = new TableCell();
                    cell.Text       = "<input id=\"" + GetMapValue(this._columnInfos, dataRow) + "\" type=\"checkbox\" onclick=\"checkrow(this);\">";
                    cell.ColumnSpan = 1;

                    row.Cells.Add(cell);
                }

                foreach (MyColumnInfo column in displayColumnsOrdered)
                {
                    //列分割
                    if (row.Cells.Count != 0)
                    {
                        row.Cells.Add(CreateEmptyCell(1));
                    }

                    foreach (string key in dataRow.Keys)
                    {
                        object v = dataRow[key];
                    }

                    object value = dataRow[column.ColumnName];
                    if (row.Cells.Count == 0 && !hiddenlink)
                    {
                        HyperLink link = CreateSetValueLink(FormatValue(value), this._columnInfos, dataRow, this._table.Rows.Count - 1);
                        cell = CreateCell(String.Empty, 1);
                        cell.Controls.Add(link);
                    }
                    else
                    {
                        cell = CreateCell(FormatValue(value), 1);
                    }

                    //cell.Style.Add("text-align", "center");
                    row.Cells.Add(cell);
                }
            }
        }
    }