コード例 #1
0
        protected override void Render(HtmlTextWriter output)
        {
            int    nRet     = 0;
            string strError = "";

            // return:
            //      -1  出错
            //      0   成功
            //      1   尚未登录
            nRet = this.LoadReaderXml(out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (nRet == 1)
            {
                sessioninfo.LoginCallStack.Push(this.Page.Request.RawUrl);
                this.Page.Response.Redirect("login.aspx", true);
                return;
            }

            LiteralControl text       = null;
            string         strBarcode = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                               "barcode");

            // 显示名
            string strDisplayName = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                           "displayName");
            TextBox edit = (TextBox)this.FindControl("displayName");

            edit.Text = strDisplayName;

#if NO
            OpacApplication app = (OpacApplication)this.Page.Application["app"];

            if (string.IsNullOrEmpty(strBarcode) == false)
            {
                // 读者证号二维码
                string strCode = "";
                // 获得读者证号二维码字符串
                nRet = app.GetPatronTempId(
                    strBarcode,
                    out strCode,
                    out strError);
                if (nRet == -1)
                {
                    strCode = strError;
                }
                text      = (LiteralControl)this.FindControl("qrcode");
                text.Text = strCode;
            }
#endif
            text = (LiteralControl)this.FindControl("qrcode");
            if (text != null)
            {
                text.Text = "<img src='./getphoto.aspx?action=pqri&barcode=" + HttpUtility.UrlEncode(strBarcode) + "' alt='QRCode image'></img>";
            }

            // 姓名
            string strName = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                    "name");
            text      = (LiteralControl)this.FindControl("name");
            text.Text = strName;

            // 性别
            string strGender = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                      "gender");
            text      = (LiteralControl)this.FindControl("gender");
            text.Text = strGender;

            // 出生日期
            string strDateOfBirth = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                           "dateOfBirth");
            if (string.IsNullOrEmpty(strDateOfBirth) == true)
            {
                strDateOfBirth = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                        "birthday");
            }

            strDateOfBirth = DateTimeUtil.LocalDate(strDateOfBirth);
            text           = (LiteralControl)this.FindControl("dateOfBirth");
            text.Text      = strDateOfBirth;

            // 证号 2008/11/11
            string strCardNumber = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "cardNumber");
            if (String.IsNullOrEmpty(strCardNumber) == true)
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("cardNumber_holder");
                holder.Visible = false;
            }
            else
            {
                text      = (LiteralControl)this.FindControl("cardNumber");
                text.Text = strCardNumber;
            }

            // 身份证号
            string strIdCardNumber = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                            "idCardNumber");
            text      = (LiteralControl)this.FindControl("idCardNumber");
            text.Text = strIdCardNumber;

            // 单位
            string strDepartment = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "department");
            text      = (LiteralControl)this.FindControl("department");
            text.Text = strDepartment;

            // 职务
            string strPost = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                    "post");
            text      = (LiteralControl)this.FindControl("post");
            text.Text = strPost;

            // 地址
            string strAddress = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                       "address");
            text      = (LiteralControl)this.FindControl("address");
            text.Text = strAddress;

            // 电话
            string strTel = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                   "tel");
            text      = (LiteralControl)this.FindControl("tel");
            text.Text = strTel;

            // email
            string strEmail = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                     "email");
            text      = (LiteralControl)this.FindControl("email");
            text.Text = strEmail;

            // 证条码号

            text      = (LiteralControl)this.FindControl("barcode");
            text.Text = strBarcode;

            // 读者类型
            string strReaderType = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "readerType");
            text      = (LiteralControl)this.FindControl("readerType");
            text.Text = strReaderType;

            // 证状态
            string strState = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                     "state");
            text      = (LiteralControl)this.FindControl("state");
            text.Text = strState;

            // 发证日期
            string strCreateDate = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "createDate");
            strCreateDate = DateTimeUtil.LocalDate(strCreateDate);
            text          = (LiteralControl)this.FindControl("createDate");
            text.Text     = strCreateDate;

            // 证失效期
            string strExpireDate = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                          "expireDate");
            strExpireDate = DateTimeUtil.LocalDate(strExpireDate);
            text          = (LiteralControl)this.FindControl("expireDate");
            text.Text     = strExpireDate;

            // 租金 2008/11/11
            string  strHireExpireDate = "";
            string  strHirePeriod     = "";
            XmlNode nodeHire          = ReaderDom.DocumentElement.SelectSingleNode("hire");
            if (nodeHire != null)
            {
                strHireExpireDate = DomUtil.GetAttr(nodeHire, "expireDate");
                strHirePeriod     = DomUtil.GetAttr(nodeHire, "period");

                strHireExpireDate = DateTimeUtil.LocalDate(strHireExpireDate);
                strHirePeriod     = app.GetDisplayTimePeriodStringEx(strHirePeriod);


                text      = (LiteralControl)this.FindControl("hire");
                text.Text = this.GetString("周期")
                            + ": " + strHirePeriod + "; "
                            + this.GetString("失效期")
                            + ": " + strHireExpireDate;
            }
            else
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("hire_holder");
                holder.Visible = false;
            }

            // 押金 2008/11/11
            string strForegift = DomUtil.GetElementText(ReaderDom.DocumentElement,
                                                        "foregift");
            if (String.IsNullOrEmpty(strForegift) == false)
            {
                text      = (LiteralControl)this.FindControl("foregift");
                text.Text = strForegift;
            }
            else
            {
                PlaceHolder holder = (PlaceHolder)this.FindControl("foregift_holder");
                holder.Visible = false;
            }

            Image photo = (Image)this.FindControl("photo");
            photo.ImageUrl = "./getphoto.aspx?barcode=" + strBarcode;

            LoginState loginstate = GlobalUtil.GetLoginState(this.Page);

            Button      submit_button       = (Button)this.FindControl("submit");
            PlaceHolder upload_photo_holder = (PlaceHolder)this.FindControl("upload_photo_holder");


            if (loginstate == LoginState.Reader &&
                sessioninfo.ReaderInfo.Barcode == strBarcode)
            {
                submit_button.Visible       = true;
                upload_photo_holder.Visible = true;
            }
            else
            {
                submit_button.Visible       = false;
                upload_photo_holder.Visible = false;
            }

            base.Render(output);
            return;

ERROR1:
            this.SetDebugInfo("errorinfo", strError);
        }