实验室网站绑定列表的参考代码

2017-05-30 10:21:50  访问(1333) 赞(0) 踩(0)


    /// <summary>
    /// 获得专著
    /// </summary>
    /// <param name="xdbHelper"></param>
    /// <returns></returns>
    protected string ToZZ(DBHelper xdbHelper)
    {
        string kw = Request.QueryString["kw"];

        if (kw != null)
        {
            kw = kw.Trim();
            kw = Server.UrlDecode(kw);
        }

        txt_Search.Text = kw;
        int pageIndex = HttpContextSlowXFunctions.GetIntParameter("pageindex", 1);

        if (pageIndex >= 1)
            pageIndex = pageIndex - 1;


        StringBuilder theResult = new StringBuilder();
        bool bIsCreate = true;

        if (xdbHelper == null)
        {
            xdbHelper = SlowX.DAL.Helpers.DBHelper.CreateDBHelper();
        }
        else
        {
            // 没有打开链接 //
            bIsCreate = xdbHelper.IsNotOpen();
        }

        try
        {
            if (bIsCreate)
                xdbHelper.OpenDBHelper();

            ZJL.LabLib.Business.LAB.UTB_ZJL_LAB_ZZ
                bll
                =
                ZJL.LabLib.Business.LAB.UTB_ZJL_LAB_ZZ.instance;

            ZJL.LabLib.Entity.LAB.UTB_ZJL_LAB_ZZ
                entity
                =
                new ZJL.LabLib.Entity.LAB.UTB_ZJL_LAB_ZZ();

            IOrderByDriver iorder = entity;
            IQueryDriver iq = entity;

            iorder.AddOrderDesc(entity._ItemSeq);
            iorder.AddOrderDesc(entity._CBRQ);
            iorder.AddOrderAsc(entity._TheName);
            iorder.AddOrderAsc(entity._ID);

            iq.InitIQueryItemWithShow();

            if (kw != null && kw.Length > 0)
            {
                iq.AddIQueryItemAdvSearch(entity._TheName._Name, kw.ToLower());
            }


            int pageSize = detailAspNetPager.PageSize;
            int iRowCount = -1;

            if (pageSize <= 0)
            {
                pageSize = int.MaxValue;
                detailAspNetPager.PageSize = pageSize;
                pageIndex = 0;
                detailAspNetPager.CurrentPageIndex = 1;
            }

            List<BaseModel>
                theList
                =
                bll.PageListBaseModel
                (
                    pageIndex,
                    pageSize,
                    ref iRowCount,
                    entity,
                    xdbHelper
                );


            SetAspNetPagerPageMessage(detailAspNetPager, pageIndex, iRowCount);





            theResult.AppendLine("<table class=\"DL\">");
            theResult.AppendLine("<tr class=\"DL\">");
            theResult.Append("<th class=\"DL\" style=\"width:40px;\">序号</th>");
            theResult.Append("<th class=\"DL\">著作名称</th>");
            theResult.Append("<th class=\"DL\">作者</th>");
            theResult.Append("<th class=\"DL\" style=\"min-width:80px;\">出版单位</th>");
            theResult.Append("<th class=\"DL\" style=\"min-width:85px;\">出版日期</th>");
            theResult.AppendLine("</tr>");

            bool bClassFlag = true;
            string className = null;
            int idx = 0;

            foreach (ZJL.LabLib.Model.LAB.UTB_ZJL_LAB_ZZ
                model in theList)
            {
                bClassFlag = !bClassFlag;

                if (bClassFlag)
                    className = "DL";
                else
                    className = "DLA";

                ++idx;
                theResult.AppendLine("<tr class=\"DL\">");
                theResult.Append("<td class=\"" + className + "\">" + idx.ToString() + "</td>");
                theResult.Append("<td class=\"" + className + "\">" + ToHighLightStr(model.TheName, kw) + "</td>");
                theResult.Append("<td class=\"" + className + "\">" + model.TheAuthor + "</td>");
                theResult.Append("<td class=\"" + className + "\">" + model.CBDW + "</td>");
                theResult.Append("<td class=\"" + className + "\">" + model.CBRQ + "</td>");
                theResult.AppendLine("</tr>");
            }

            theResult.AppendLine("</table>");


            if (bIsCreate)
                xdbHelper.EndDBHelper();

        }
        catch (Exception err)
        {
            if (bIsCreate)
                xdbHelper.TranDBHelper();

            throw err;
        }
        finally
        {
            if (bIsCreate)
                xdbHelper.FinallyDBHelper();
        }

        return theResult.ToString();
    }


上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)