Exemplo n.º 1
0
        void _biblio_GetEntityDefault(object sender, GetDefaultItemEventArgs e)
        {
            // 获得册登记缺省值。快速册登记
            e.Xml = this.MainForm.AppInfo.GetString(
"entityform_optiondlg",
"quickRegister_default",
"<root />");
#if NO
            string strQuickDefault = this.MainForm.AppInfo.GetString(
    "entityform_optiondlg",
    "quickRegister_default",
    "<root />");
#endif
        }
Exemplo n.º 2
0
        // 新添加一个实体事项
        public int AddNewEntity(string strItemBarcode,
            bool bAutoSetFocus,
            out EntityEditControl control,
            out string strError)
        {
            strError = "";
            control = null;
            int nRet = 0;

            string strQuickDefault = "<root />";
            if (this.GetEntityDefault != null)
            {
                GetDefaultItemEventArgs e = new GetDefaultItemEventArgs();
                this.GetEntityDefault(this, e);
                if (string.IsNullOrEmpty(e.ErrorInfo) == false)
                {
                    strError = e.ErrorInfo;
                    return -1;
                }
                strQuickDefault = e.Xml;
            }
            // 根据缺省值,构造最初的 XML
            XmlDocument dom = new XmlDocument();
            try
            {
                dom.LoadXml(strQuickDefault);
            }
            catch (Exception ex)
            {
                strError = "缺省册记录装入 XMLDOM 时出错: " + ex.Message;
                return -1;
            }

            DomUtil.SetElementText(dom.DocumentElement, "barcode", strItemBarcode);
            DomUtil.SetElementText(dom.DocumentElement, "refID", Guid.NewGuid().ToString());

            string strErrorInfo = "";
            // 兑现 @price 宏,如果有书目记录的话
            // TODO: 当书目记录切换的时候,是否还要重新兑现一次宏?

            // 记录路径可以保持为空,直到保存前才构造
            nRet = ReplaceEntityMacro(dom,
                out strError);
            if (nRet == -1)
            {
                // return -1;
                strErrorInfo = strError;
            }
            // 添加一个新的册对象
            nRet = NewEntity(dom.DocumentElement.OuterXml,
                bAutoSetFocus,
                out control,
                out strError);
            if (nRet == -1)
                return -1;

            if (string.IsNullOrEmpty(strErrorInfo) == false)
            {
                SetEditErrorInfo(control, strErrorInfo);
            }
            return 0;
        }