Пример #1
0
        void RenderBorrow(
            OpacApplication app,
            SessionInfo sessioninfo,
            XmlDocument dom)
        {
            string strReaderType = DomUtil.GetElementText(dom.DocumentElement,
                                                          "readerType");

            // 获得日历
            string strError = "";

            /*
             * Calendar calendar = null;
             * int nRet = app.GetReaderCalendar(strReaderType, out calendar, out strError);
             * if (nRet == -1)
             * {
             *  this.SetDebugInfo("warninginfo", strError);
             *  calendar = null;
             * }
             * */

            // return:
            //      null    xml文件不存在,或者<borrowInfoControl>元素不存在
            string strColumnStyle = GetColumnStyle(app);

            if (strColumnStyle == null)
            {
                strColumnStyle = "";    // 2009/11/23 防止ToLower()抛出异常
            }
            // 借阅的册
            PlaceHolder borrowinfo = (PlaceHolder)this.FindControl("borrowinfo");

            // 清空集合
            this.BorrowBarcodes = new List <string>();

            string strReaderBarcode = DomUtil.GetElementText(dom.DocumentElement,
                                                             "barcode");

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("borrows/borrow");

            this.BorrowLineCount = nodes.Count;
            for (int i = 0; i < nodes.Count; i++)
            {
                PlaceHolder line = (PlaceHolder)borrowinfo.FindControl("borrowinfo_line" + Convert.ToString(i));
                if (line == null)
                {
                    Control insertpos = borrowinfo.FindControl("borrowinfo_insertpos");
                    line = NewBorrowLine(insertpos.Parent, i, insertpos);
                    // this.BorrowLineCount++;
                }
                line.Visible = true;

                LiteralControl left     = (LiteralControl)line.FindControl("borrowinfo_line" + Convert.ToString(i) + "left");
                CheckBox       checkbox = (CheckBox)line.FindControl("borrowinfo_line" + Convert.ToString(i) + "checkbox");
                LiteralControl right    = (LiteralControl)line.FindControl("borrowinfo_line" + Convert.ToString(i) + "right");


                XmlNode node = nodes[i];

                string strBarcode = DomUtil.GetAttr(node, "barcode");

                // 添加到集合
                this.BorrowBarcodes.Add(strBarcode);

                string strNo           = DomUtil.GetAttr(node, "no");
                string strBorrowDate   = DomUtil.GetAttr(node, "borrowDate");
                string strPeriod       = DomUtil.GetAttr(node, "borrowPeriod");
                string strOperator     = DomUtil.GetAttr(node, "operator");
                string strRenewComment = DomUtil.GetAttr(node, "renewComment");

                string strOverDue = "";
                bool   bOverdue   = false; // 是否超期

                DateTime timeReturning = DateTime.MinValue;
                string   strTips       = "";
#if NO
                if (strColumnStyle.ToLower() == "style1")
                {
                    DateTime timeNextWorkingDay;
                    long     lOver         = 0;
                    string   strPeriodUnit = "";

                    // 获得还书日期
                    // return:
                    //      -1  数据格式错误
                    //      0   没有发现超期
                    //      1   发现超期   strError中有提示信息
                    //      2   已经在宽限期内,很容易超期
                    nRet = app.GetReturningTime(
                        calendar,
                        strBorrowDate,
                        strPeriod,
                        out timeReturning,
                        out timeNextWorkingDay,
                        out lOver,
                        out strPeriodUnit,
                        out strError);
                    if (nRet == -1)
                    {
                        strOverDue = strError;
                    }
                    else
                    {
                        strTips = strError;
                        if (nRet == 1)
                        {
                            bOverdue   = true;
                            strOverDue = " ("
                                         + string.Format(this.GetString("已超期s"), // 已超期 {0}
                                                         app.GetDisplayTimePeriodStringEx(lOver.ToString() + " " + strPeriodUnit))
                                         + ")";

                            /*
                             * strOverDue = " (已超期 "
                             + lOver.ToString()
                             + " "
                             + app.GetDisplayTimeUnitLang(strPeriodUnit)
                             + ")";
                             * */
                        }
                    }
                }
                else
                {
                    // string strError = "";
                    // 检查超期情况。
                    // return:
                    //      -1  数据格式错误
                    //      0   没有发现超期
                    //      1   发现超期   strError中有提示信息
                    nRet = app.CheckPeriod(
                        calendar,
                        strBorrowDate,
                        strPeriod,
                        out strError);
                    if (nRet == -1)
                    {
                        strOverDue = strError;
                    }
                    else
                    {
                        if (nRet == 1)
                        {
                            bOverdue = true;
                        }
                        strOverDue = strError;  // 其他无论什么情况都显示出来
                    }
                }
#endif

                string strResult = "";

                string strTrClass = " class='dark' ";

                if ((i % 2) == 1)
                {
                    strTrClass = " class='light' ";
                }

                strResult += "<tr " + strTrClass + " nowrap><td class='barcode' nowrap>";
                // 左
                left.Text = strResult;

                // checkbox
                // checkbox.Text = Convert.ToString(i + 1);

                // 右开始
                strResult = "&nbsp;";

                strResult += "<a href='book.aspx?barcode=" + strBarcode + "&borrower=" + strReaderBarcode + "'>"
                             + strBarcode + "</a></td>";

#if NO
                // 获得摘要
                string strSummary       = "";
                string strBiblioRecPath = "";
                long   lRet             = sessioninfo.Channel.GetBiblioSummary(
                    null,
                    strBarcode,
                    null,
                    null,
                    out strBiblioRecPath,
                    out strSummary,
                    out strError);
                if (lRet == -1 || lRet == 0)
                {
                    strSummary = strError;
                }

                /*
                 * LibraryServerResult result = app.GetBiblioSummary(
                 *  sessioninfo,
                 *  strBarcode,
                 *  null,
                 *  null,
                 *  out strBiblioRecPath,
                 *  out strSummary);
                 * if (result.Value == -1 || result.Value == 0)
                 *  strSummary = result.ErrorInfo;
                 * */
#endif

                strResult += "<td class='summary pending' width='50%'>" + strBarcode + "</td>";
                strResult += "<td class='no' nowrap align='right'>" + strNo + "</td>";  // 续借次

                strResult += "<td class='borrowdate' nowrap>" + OpacApplication.LocalDateOrTime(strBorrowDate, strPeriod) + "</td>";
                strResult += "<td class='borrowperiod' nowrap>" + app.GetDisplayTimePeriodStringEx(strPeriod) + "</td>";

                strOverDue = DomUtil.GetAttr(node, "overdueInfo");
                string strOverdue1  = DomUtil.GetAttr(node, "overdueInfo1");
                string strIsOverdue = DomUtil.GetAttr(node, "isOverdue");
                if (strIsOverdue == "yes")
                {
                    bOverdue = true;
                }

                string strTimeReturning = DomUtil.GetAttr(node, "timeReturning");
                if (String.IsNullOrEmpty(strTimeReturning) == false)
                {
                    timeReturning = DateTimeUtil.FromRfc1123DateTimeString(strTimeReturning).ToLocalTime();
                }

                if (strColumnStyle.ToLower() == "style1")
                {
                    strTips    = strOverDue;
                    strOverDue = strOverdue1;

                    if (bOverdue == true)
                    {
                        strResult += "<td class='returningdate overdue'>"
                                     + "<a title=\"" + strTips.Replace("\"", "'") + "\">"
                                     + OpacApplication.LocalDateOrTime(timeReturning, strPeriod)
                                     // + timeReturning.ToString("d")
                                     + strOverDue
                                     + "</a>"
                                     + "</td>";
                    }
                    else
                    {
                        strResult += "<td class='returningdate'>"
                                     + "<a title=\"" + strTips.Replace("\"", "'") + "\">"
                                     + OpacApplication.LocalDateOrTime(timeReturning, strPeriod)
                                     // + timeReturning.ToString("d")
                                     + strOverDue
                                     + "</a>"
                                     + "</td>";
                    }
                }
                else
                {
                    if (bOverdue == true)
                    {
                        strResult += "<td class='overdue'>" + strOverDue + "</td>";
                    }
                    else
                    {
                        strResult += "<td class='notoverdue'>" + strOverDue + "</td>";
                    }
                }
                strResult += "<td class='renewcomment'>" + strRenewComment.Replace(";", "<br/>") +

                             "</td>";
                strResult += "<td class='operator' nowrap>" + strOperator + "</td>";
                strResult += "</tr>";

                right.Text = strResult;
            }

            // 把多余的行隐藏起来
            for (int i = nodes.Count; ; i++)
            {
                PlaceHolder line = (PlaceHolder)borrowinfo.FindControl("borrowinfo_line" + Convert.ToString(i));
                if (line == null)
                {
                    break;
                }

                line.Visible = false;
            }

            if (nodes.Count == 0)
            {
                Control insertpos = borrowinfo.FindControl("borrowinfo_insertpos");
                int     pos       = insertpos.Parent.Controls.IndexOf(insertpos);
                if (pos == -1)
                {
                    // text-level: 内部错误
                    throw new Exception("插入参照对象没有找到");
                }

                LiteralControl literal = new LiteralControl();
                literal.Text = "<tr class='dark'><td colspan='8'>" + this.GetString("(无借阅信息)") + "<td></tr>";

                insertpos.Parent.Controls.AddAt(pos, literal);
            }
        }