实验室网站:后台绘制专利页面的HTML并前台打印输出的方法

2017-07-09 16:37:35  访问(2043) 赞(0) 踩(0)



    /// <summary>
    /// 获得专利
    /// </summary>
    /// <param name="xdbHelper"></param>
    /// <returns></returns>
    protected string ToZL(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_ZL
                bll
                =
                ZJL.LabLib.Business.LAB.UTB_ZJL_LAB_ZL.instance;

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

            IOrderByDriver iorder = entity;
            IQueryDriver iq = entity;

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

            iq.InitIQueryItemWithShow();

            if (kw != null && kw.Length > 0)
            {
                string searchName
                    =
                    entity._TheName._Name
                    + "|" + entity._TheCode._Name;

                iq.AddIQueryItemAdvSearch
                    (
                        searchName, 
                        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);



            //rp_List.DataSource = theList;
            //rp_List.DataBind();




            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:95px;\">授权日期</th>");
            theResult.Append("<th class=\"DL\" style=\"min-width:85px;\">发明人</th>");
            theResult.AppendLine("</tr>");

            bool bClassFlag = true;
            string className = null;
            int idx = pageIndex * pageSize;
            foreach (ZJL.LabLib.Model.LAB.UTB_ZJL_LAB_ZL
                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 + "\">" + ToHighLightStr(model.TheCode, kw) + "</td>");
                theResult.Append("<td class=\"" + className + "\">" + model.SQRQ + "</td>");
                theResult.Append("<td class=\"" + className + "\">" + model.FMR + "</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)