示例#1
0
        private void LoadDataGrid()
        {
            try
            {
                string projectName = this.txtProjectNname.Value;

                int kgYear = 0;

                int jgYear = 0;

                if (this.txtKgYear.Value.Trim().Length > 0)
                {
                    kgYear = int.Parse(this.txtKgYear.Value);
                }
                else


                if (this.txtJgYear.Value.Trim().Length > 0)
                {
                    jgYear = int.Parse(this.txtJgYear.Value);
                }

                RmsPM.DAL.QueryStrategy.ProjectStrategyBuilder ssb = new RmsPM.DAL.QueryStrategy.ProjectStrategyBuilder();
                if (projectName.Length > 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.ProjectNameLike, projectName));
                }
                if (kgYear > 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.kgYear, kgYear.ToString()));
                }
                if (jgYear > 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.jgYear, jgYear.ToString()));
                }

                if (this.SelectStatus.Value != "")
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.Status, this.SelectStatus.Value));
                }

                ssb.AddOrder("kgDate", false);
                //ssb.AddOrder("Status",true);
                string sql = ssb.BuildMainQueryString();

                Rms.ORMap.QueryAgent qa = new QueryAgent();
                DataSet ds = qa.ExecSqlForDataSet(sql);
                qa.Dispose();

                this.dgList.DataSource = new DataView(ds.Tables[0], "", "", DataViewRowState.CurrentRows);
                this.dgList.DataBind();
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "加载项目列表错误。");
            }
        }
示例#2
0
        private void LoadDataGrid()
        {
            try
            {
                string access = this.txtAccess.Value;
                int    kgYear = 0;
                int    jgYear = 0;

                if (this.txtSearchKgYear.Value.Trim().Length > 0)
                {
                    kgYear = BLL.ConvertRule.ToInt(this.txtSearchKgYear.Value);
                }

                if (this.txtSearchJgYear.Value.Trim().Length > 0)
                {
                    jgYear = BLL.ConvertRule.ToInt(this.txtSearchJgYear.Value);
                }

                RmsPM.DAL.QueryStrategy.ProjectStrategyBuilder ssb = new RmsPM.DAL.QueryStrategy.ProjectStrategyBuilder();
                if (this.txtSearchProjectName.Value.Length > 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.ProjectNameLike, this.txtSearchProjectName.Value));
                }
                if (kgYear != 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.kgYear, kgYear.ToString()));
                }
                if (jgYear != 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.jgYear, jgYear.ToString()));
                }

                if (this.sltSearchStatus.Value != "")
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.Status, this.sltSearchStatus.Value));
                }

                //只列出当前用户有权访问的项目
                if (access.ToLower() == "canaccess")
                {
                    string ProjectCodes = "";
                    foreach (DataRow dr in user.m_EntityDataAccessProject.CurrentTable.Rows)
                    {
                        ProjectCodes += BLL.ConvertRule.ToString(dr["ProjectCode"]) + ",";
                    }

                    if (ProjectCodes.Length > 0)
                    {
                        ProjectCodes = ProjectCodes.Substring(0, ProjectCodes.Length - 1);
                    }

                    if (ProjectCodes.Length > 0)
                    {
                        ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.ProjectCodeIn, ProjectCodes));
                    }
                    else
                    {
                        ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.False));
                    }
                }

                //排序
                string sortsql = BLL.GridSort.GetSortSQL(ViewState);
                if (sortsql == "")
                {
                    //缺省排序
                    ssb.AddOrder("kgDate", false);
                    ssb.AddOrder("ProjectName", true);
                    //ssb.AddOrder("Status",true);
                }

                string sql = ssb.BuildMainQueryString();

                if (sortsql != "")
                {
                    //点列标题排序
                    sql = sql + " order by " + sortsql;
                }

                Rms.ORMap.QueryAgent qa = new QueryAgent();
                DataTable            tb = qa.ExecSqlForDataSet(sql).Tables[0];
                qa.Dispose();

                this.dgList.DataSource = tb;
                this.dgList.DataBind();
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "加载项目列表错误");
                Response.Write(Rms.Web.JavaScript.Alert(true, "加载项目列表错误:" + ex.Message));
            }
        }
示例#3
0
        private void LoadDataGrid()
        {
            try
            {
                int kgYear = 0;
                int jgYear = 0;

                if (this.txtSearchKgYear.Value.Trim().Length > 0)
                {
                    kgYear = BLL.ConvertRule.ToInt(this.txtSearchKgYear.Value);
                }

                if (this.txtSearchJgYear.Value.Trim().Length > 0)
                {
                    jgYear = BLL.ConvertRule.ToInt(this.txtSearchJgYear.Value);
                }

                RmsPM.DAL.QueryStrategy.ProjectStrategyBuilder ssb = new RmsPM.DAL.QueryStrategy.ProjectStrategyBuilder();
                if (this.txtSearchProjectName.Value.Length > 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.ProjectNameLike, this.txtSearchProjectName.Value));
                }
                if (kgYear != 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.kgYear, kgYear.ToString()));
                }
                if (jgYear != 0)
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.jgYear, jgYear.ToString()));
                }

                if (this.sltSearchStatus.Value != "")
                {
                    ssb.AddStrategy(new Strategy(RmsPM.DAL.QueryStrategy.ProjectStrategyName.Status, this.sltSearchStatus.Value));
                }

                //排序
                string sortsql = BLL.GridSort.GetSortSQL(ViewState);
                if (sortsql == "")
                {
                    //缺省排序
                    ssb.AddOrder("kgDate", false);
                    ssb.AddOrder("ProjectName", true);
                    //ssb.AddOrder("Status",true);
                }

                string sql = ssb.BuildMainQueryString();

                if (sortsql != "")
                {
                    //点列标题排序
                    sql = sql + " order by " + sortsql;
                }

                Rms.ORMap.QueryAgent qa = new QueryAgent();
                DataTable            tb = qa.ExecSqlForDataSet(sql).Tables[0];
                qa.Dispose();

                this.dgList.DataSource = new DataView(tb, "", "", DataViewRowState.CurrentRows);
                this.dgList.DataBind();
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "加载项目列表错误。");
                Response.Write(Rms.Web.JavaScript.Alert(true, "加载项目列表错误。"));
            }
        }