示例#1
0
        void submit_button_Click(object sender, EventArgs e)
        {
            string strError = "";

            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            string strCreator = sessioninfo.UserID;

            // 先创建一条书目记录
            TextBox biblio_title     = (TextBox)this.FindControl("edit_biblio_title");
            TextBox biblio_author    = (TextBox)this.FindControl("edit_biblio_author");
            TextBox biblio_publisher = (TextBox)this.FindControl("edit_biblio_publisher");
            TextBox biblio_isbn      = (TextBox)this.FindControl("edit_biblio_isbn");
            TextBox biblio_price     = (TextBox)this.FindControl("edit_biblio_price");
            TextBox biblio_summary   = (TextBox)this.FindControl("edit_biblio_summary");

            // 检查必备字段
            if (String.IsNullOrEmpty(biblio_title.Text) == true)
            {
                strError = "尚未输入书名/刊名";
                goto ERROR1;
            }

            DropDownList store_dbname = (DropDownList)this.FindControl("store_dbname");

            string strBiblioDbName = store_dbname.SelectedValue;

            if (String.IsNullOrEmpty(strBiblioDbName) == true)
            {
                strError = "尚未选定目标库";
                goto ERROR1;
            }

            string strBiblioRecPath = "";
            string strMarcSyntax    = "";
            string strMARC          = "";

            // 得到目标书目库的MARC格式
            ItemDbCfg cfg = app.GetBiblioDbCfg(strBiblioDbName);

            if (cfg == null)
            {
                strError = "目标库 '" + strBiblioDbName + "' 不是系统定义的的书目库";
                goto ERROR1;
            }

            strMarcSyntax = cfg.BiblioDbSyntax;

            int nRet = BuildBiblioRecord(
                strMarcSyntax,
                biblio_title.Text,
                biblio_author.Text,
                biblio_publisher.Text,
                biblio_isbn.Text,
                biblio_price.Text,
                biblio_summary.Text,
                strCreator,
                out strMARC,
                out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            // 保存
            // 将MARC格式转换为XML格式
            nRet = MarcUtil.Marc2Xml(
                strMARC,
                strMarcSyntax,
                out string strXml,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

#if NO
            SessionInfo temp_sessioninfo = new SessionInfo(app);
            temp_sessioninfo.UserID   = app.ManagerUserName;
            temp_sessioninfo.Password = app.ManagerPassword;
            temp_sessioninfo.IsReader = false;
#endif

            string strOutputBiblioRecPath = "";

            LibraryChannel channel = sessioninfo.GetChannel(true);
            try
            {
                strBiblioRecPath = strBiblioDbName + "/?";


                long lRet = // temp_sessioninfo.Channel.
                            channel.SetBiblioInfo(
                    null,
                    "new",
                    strBiblioRecPath,
                    "xml",
                    strXml,
                    null,
                    "",
                    out strOutputBiblioRecPath,
                    out byte[] baOutputTimestamp,
                    out strError);
                if (lRet == -1)
                {
                    strError = "创建书目记录发生错误: " + strError;
                    goto ERROR1;
                }
            }
            finally
            {
#if NO
                temp_sessioninfo.CloseSession();
                temp_sessioninfo = null;
#endif
                sessioninfo.ReturnChannel(channel);
            }

            // 清除每个输入域的内容
            biblio_title.Text     = "";
            biblio_author.Text    = "";
            biblio_publisher.Text = "";
            biblio_isbn.Text      = "";
            biblio_summary.Text   = "";
            biblio_price.Text     = "";

            strBiblioRecPath = strOutputBiblioRecPath;

            CommentControl commentcontrol = (CommentControl)this.FindControl("commentcontrol");
            // 创建评注记录
            if (String.IsNullOrEmpty(commentcontrol.EditTitle) == false ||
                String.IsNullOrEmpty(commentcontrol.EditContent) == false)
            {
                string strWarning = "";
                commentcontrol.BiblioRecPath = strBiblioRecPath;

                nRet = commentcontrol.DoSubmit(
                    out strWarning,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
                if (String.IsNullOrEmpty(strWarning) == false)
                {
                    this.SetDebugInfo("warninginfo", strWarning);
                }
            }

            string strUrl = "./book.aspx?bibliorecpath="
                            + HttpUtility.UrlEncode(strBiblioRecPath);
            string strText = "新的荐购书目记录创建成功。点击此处可查看:<a href='"
                             + strUrl
                             + "' target='_blank'>"
                             + strUrl
                             + "</a>";
            SetInfo(strText);
            this.SetDebugInfo("succeedinfo", strText);
            return;

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