예제 #1
0
        // 添加一个新的册对象
        public int NewEntity(string strItemBarcode,
            out string strError)
        {
            strError = "";

            EntityEditControl control = new EntityEditControl();
            control.Barcode = strItemBarcode;
            control.AutoScroll = false;
            control.DisplayMode = "simple_register";
            control.Width = 120;
            control.AutoSize = true;
            control.Font = this.Font;
            control.Initializing = false;
            control.PaintContent += new PaintEventHandler(control_PaintContent);
            this.flowLayoutPanel_entities.Controls.Add(control);
            this.flowLayoutPanel_entities.ScrollControlIntoView(control);

            return 0;
        }
예제 #2
0
 void SetControlColor(EntityEditControl control)
 {
     control.BackColor = _entityBackColor;
     control.MemberForeColor = _entityCaptionForeColor;
     control.SetAllEditColor(_entityEditBackColor, _entityEditForeColor);
     control.FocusedEditBackColor = _focusedEditBackColor;
 }
예제 #3
0
 // 添加一个新的册对象
 public int NewEntity(string strXml,
     bool bAutoSetFocus,
     out EntityEditControl control,
     out string strError)
 {
     return this.NewEntity("",
         null,
         strXml,
         true,
         bAutoSetFocus,
         out control,
         out strError);
 }
예제 #4
0
        private void button_scan_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            this.textBox_input.SelectAll();
            this.textBox_input.Focus();

            if (this._step == Step.PrepareSearchBiblio)
            {
                this.BaseForm.QueryWord = this.textBox_input.Text;
                this._lastISBN = this.textBox_input.Text;
                // 显示“正在检索”
                this.SetStep(Step.SearchingBiblio);
                this.BaseForm.DoSearch(this.textBox_input.Text, "ISBN", false);
                this.SetStep(Step.SearchBiblioCompleted);
                // 如果检索命中,要选择后,切换到下一页。选择方面,可以提示输入 1 2 3 4 等用以选择
                // 如果检索没有命中,提示再次扫入相同的 ISBN,可以直接进入创建新记录流程
                if (this.BaseForm.SearchResultErrorCount > 0)
                {
                    this.SetStep(Step.SearchBiblioError);
                }
                else if (this.BaseForm.SearchResultCount > 0)
                {
                    if (this.BaseForm.SearchResultCount == 1)
                    {
                        // 命中唯一的一条
                        this.EditSelectedBrowseLine();
                        // 观察书目记录包含多少册记录。
                        this.SetStep(Step.EditEntity);
                        return;
                    }
                    this.textBox_input.Text = "1";
                    this.SetStep(Step.SelectSearchResult);
                }
                else
                {
                    Debug.Assert(this.BaseForm.SearchResultCount == 0, "");

                    // 没有命中。当再次输入同样的 ISBN, 表示创建新书目记录
                    this.SetStep(Step.SearchBiblioNotFound);
                }
                return;
            }

            if (this._step == Step.SelectSearchResult)
            {
                int index = 0;

                // 如果输入刚才用过的 ISBN ,表示选择第一个记录
                if (this.textBox_input.Text == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    index = 1;
                }
                else
                {
                    // 根据输入的数字挑选命中记录
                    if (StringUtil.IsPureNumber(this.textBox_input.Text) == false)
                    {
                        strError = "请输入一个数字";
                        goto ERROR1;
                    }

                    if (int.TryParse(this.textBox_input.Text, out index) == false)
                    {
                        strError = "输入的应该是一个数字";
                        goto ERROR1;
                    }

                    // TODO: 可以根据检索命中列表中事项的最大个数,探测 input 中输入达到这么多个字符后不需要按回车键就可以开始后续处理

                    if (index - 1 >= this.BaseForm.ResultListCount)
                    {
                        strError = "请输入一个 1-" + (this.BaseForm.ResultListCount + 1).ToString() + " 之间的数字";
                        goto ERROR1;
                    }
                }
                this.BaseForm.SelectBrowseLine(true, index - 1);
                this.EditSelectedBrowseLine();
                // 观察书目记录包含多少册记录。
                this.SetStep(Step.EditEntity);
                return;
            }

            if (this._step == Step.SearchBiblioNotFound)
            {
                // 如果输入刚才用过的 ISBN ,表示创建新书目记录
                if (this.textBox_input.Text == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    nRet = this.BaseForm.NewBiblio(false);
                    if (nRet == -1)
                    {
                        this.DisplayError("操作出错");
                        return;
                    }
                    this.SetStep(Step.EditBiblio);
                    return;
                }
                else
                {
                    string strText = this.textBox_input.Text;
                    this.SetStep(Step.PrepareSearchBiblio);
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action<object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                return;
            }

            if (this._step == Step.EditBiblio)
            {
                // 观察输入的字符串,如果和检索使用过的 ISBN 一致,则增加一个册(册条码号为空);
                // 如果是其他 ISBN,则回到检索画面自动启动检索书目;
                // 如果不是 ISBN,则当作为当前书目字段输入内容

                string strText = this.textBox_input.Text;

                if (strText == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    // 将上一个 EntityEditControl 中的蓝色行标记清除
                    if (this._currentEntityControl != null)
                    {
                        this.BaseForm.DisableWizardControl();
                        this._currentEntityControl.ClearActiveState();
                        this.BaseForm.EnableWizardControl();
                    }
                    this._currentEntityControl = this.BaseForm.AddNewEntity("", false);
                    this._currentEntityLine = null;
#if NO
                    // 越过第一个字段
                    this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);
#endif
                    return;
                }

                if (QuickChargingForm.IsISBN(ref strText) == true)
                {
                    this.SetStep(Step.PrepareSearchBiblio);
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action<object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                else
                {
                    // 为当前子字段添加内容,顺次进入下一子字段。等所有字段都输入完以后,自动进入 EditEntity 状态
                    if (this._currenBiblioLine != null)
                    {
                        if (string.IsNullOrEmpty(this.textBox_input.Text) == true)
                        {
                            List<EasyLine> selected_lines = new List<EasyLine>();
                            selected_lines.Add(this._currenBiblioLine);
                            EasyMarcControl container = this._currenBiblioLine.Container;
                            // 删除前要先找到上一个行。否则删除后查找将无法继续
                            this._currenBiblioLine = GetPrevBiblioLine(this._currenBiblioLine);
                            // 删除
                            container.DeleteElements(selected_lines);
                        }
                        else
                        {
                            this._currenBiblioLine.Content = this.textBox_input.Text;
                            this.textBox_input.Text = "";
                        }
                        SetStep(Step.EditBiblio);
                    }
                    else
                    {
                        this.textBox_input.Text = "";
                        SetStep(Step.EditEntity);
                    }
                    return;
                }
            }

            if (this._step == Step.EditEntity)
            {
                // 观察输入的字符串,如果和检索使用过的 ISBN 一致,则增加一个册(册条码号为空);
                // 如果是其他 ISBN,则回到检索画面自动启动检索书目;
                // 如果不是 ISBN,则当作册条码号增加一个册

                string strText = this.textBox_input.Text;

                if (strText == this._lastISBN && string.IsNullOrEmpty(this._lastISBN) == false)
                {
                    // 将上一个 EntityEditControl 中的蓝色行标记清除
                    if (this._currentEntityControl != null)
                    {
                        this.BaseForm.DisableWizardControl();
                        this._currentEntityControl.ClearActiveState();
                        this.BaseForm.EnableWizardControl();
                    }

                    this._currentEntityControl = this.BaseForm.AddNewEntity("", false);
                    this._currentEntityLine = null;
#if NO
                    // 越过第一个字段
                    this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);
#endif
                    this.BeginInvoke(new Func<Step, string, bool>(SetStep), Step.EditEntity, "");
                    return;
                }

                if (QuickChargingForm.IsISBN(ref strText) == true)
                {
                    // TODO: 连带引起保存书目和册记录可能会失败哟
                    if (this.SetStep(Step.PrepareSearchBiblio) == false)
                        return;
                    this.textBox_input.Text = strText;
                    this.BeginInvoke(new Action<object, EventArgs>(button_scan_Click), this, new EventArgs());
                    return;
                }
                else
                {
                    // 首次输入册条码号。还没有关联的 EntityEditControl
                    if (this._currentEntityControl == null)
                    {
                        this._currentEntityControl = this.BaseForm.AddNewEntity(strText, false);
                        this._currentEntityLine = null;
                        // 越过第一个字段
                        this._currentEntityLine = GetNextEntityLine(this._currentEntityLine);

                        this.BeginInvoke(new Func<Step, string, bool>(SetStep), Step.EditEntity, "");
                        return;
                    }
                    // 为册编辑器当前行输入内容,顺次进入下一行。等所有字段都输入完以后,自动进入 EditEntity 等待输入册条码号的状态
                    if (this._currentEntityLine != null)
                    {
                        this._currentEntityLine.Content = this.textBox_input.Text;
                        this.textBox_input.Text = "";

                        SetStep(Step.EditEntity);
                    }
                    else
                    {
                        // 进入首次等待输入册条码号的状态
                        this._currentEntityControl = null;
                        this._currentEntityLine = null;
                        this.textBox_input.Text = "";
                        SetStep(Step.EditEntity);
                    }
                    return;
                }
            }
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
예제 #5
0
 public static EditLine GetNextEntityLine(EntityEditControl control, EditLine ref_line)
 {
     return control.GetNextEditableLine(ref_line);
 }
예제 #6
0
        void DeleteItem(RegisterLine line, EntityEditControl edit)
        {
            string strError = "";
            int nRet = 0;

            this.Progress.OnStop += new StopEventHandler(this.DoStop);
            this.Progress.BeginLoop();
            try
            {
#if NO
                this._currentAccount = this.GetAccountInfo(line._biblioRegister.ServerName);
                if (this._currentAccount == null)
                {
                    strError = "服务器名 '" + line._biblioRegister.ServerName + "' 没有配置";
                    goto ERROR1;
                }
#endif

                List<EntityEditControl> controls = new List<EntityEditControl>();
                controls.Add(edit);

                // line.SetDisplayMode("summary");

                // 删除下属的册记录
                {
                    EntityInfo[] entities = null;
                    // 构造用于保存的实体信息数组
                    nRet = line._biblioRegister.BuildSaveEntities(
                        "delete",
                        controls,
                        out entities,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    // 分批进行保存
                    // return:
                    //      -2  部分成功,部分失败
                    //      -1  出错
                    //      0   保存成功,没有错误和警告
                    nRet = SaveEntities(
                        line,
                        entities,
                        out strError);
                    if (nRet == -1 || nRet == -2)
                        goto ERROR1;

                    // 兑现视觉删除
                    line._biblioRegister.RemoveEditControl(edit);

                    // line._biblioRegister.EntitiesChanged = false;
                }

                return;
            }
            finally
            {
                this.Progress.EndLoop();
                this.Progress.OnStop -= new StopEventHandler(this.DoStop);
                // this.Progress.Initial("");
            }
        ERROR1:
            // line.SetDisplayMode("summary");
            // line.SetBiblioSearchState("error");
            // line.BiblioSummary = strError;
            BiblioRegisterControl.SetEditErrorInfo(edit, strError);
            line._biblioRegister.BarColor = "R";   // 红色
            this.SetColorList();
        }
예제 #7
0
        EntityEditControl GetPrevOrNextEdit(
    EntityEditControl current,
    bool bPrev)
        {
            int nIndex = this.flowLayoutPanel1.Controls.IndexOf(current);
            if (nIndex == -1)
            {
                // 居然在容器中没有找到
                Debug.Assert(false, "");
                return null;
            }

            if (bPrev == true)
                nIndex--;
            else
                nIndex++;

            if (nIndex <= -1)
                return null;

            if (nIndex >= this.flowLayoutPanel1.Controls.Count)
                return null;

            Control control = this.flowLayoutPanel1.Controls[nIndex];
            if (!(control is EntityEditControl))
                return null;

            return control as EntityEditControl;
        }
예제 #8
0
 // 要把指定的 Edit 控件后面的全部 Edit 控件 Invalidate 一遍,因为序号发生了变化
 // parameters:
 //      edit    从哪个 edit 控件开始刷新。如果为 null,表示全部刷新
 void InvalidateEditControls(EntityEditControl edit)
 {
     bool bBegin = false;
     foreach (Control control in this.flowLayoutPanel1.Controls)
     {
         if (control == edit || edit == null)
             bBegin = true;
         if (bBegin == true && control is EntityEditControl)
             control.Invalidate();
     }
 }
예제 #9
0
        int SetEditData(EntityEditControl edit,
            string strXml,
            string strRecPath,
            byte[] timestamp,
            out string strError)
        {
            if (this.easyMarcControl1.InvokeRequired)
            {
                Delegate_SetEditData d = new Delegate_SetEditData(SetEditData);
                object[] args = new object[5];
                args[0] = edit;
                args[1] = strXml;
                args[2] = strRecPath;
                args[3] = timestamp;
                args[4] = "";
                int result = (int)this.easyMarcControl1.Invoke(d, args);

                // 取出out参数值
                strError = (string)args[4];
                return result;
            }

            return edit.SetData(strXml, strRecPath, timestamp, out strError);
        }
예제 #10
0
        // 将册记录编辑控件加入末尾。注意末尾可能有 Button 控件,要插入在它前面
        void AddEditControl(EntityEditControl edit)
        {
            this.flowLayoutPanel1.SuspendLayout();

            List<Control> buttons = new List<Control>();
            // 先将 Button 标识出来
            foreach (Control control in this.flowLayoutPanel1.Controls)
            {
                if (control is Button)
                    buttons.Add(control);
            }

            // 移走 Button
            foreach (Control control in buttons)
            {
                this.flowLayoutPanel1.Controls.Remove(control);
            }

            // 追加 edit
            this.flowLayoutPanel1.Controls.Add(edit);

            // 将 Button 加到末尾
            foreach (Control control in buttons)
            {
                this.flowLayoutPanel1.Controls.Add(control);
            }

            // 注:edit 控件加入到末尾,不会改变前面已有的 edit 控件显示的序号

            // 重新设置 TabIndex
            int i = 0;
            foreach (Control control in this.flowLayoutPanel1.Controls)
            {
                control.TabIndex = i++;
            }

            this.flowLayoutPanel1.ResumeLayout(true);
        }
예제 #11
0
        // 删除一个册记录控件
        public void RemoveEditControl(EntityEditControl edit)
        {
            if (this.easyMarcControl1.InvokeRequired == true)
            {
                this.easyMarcControl1.Invoke(new Action<EntityEditControl>(RemoveEditControl), edit);
                return;
            }

            int index = this.flowLayoutPanel1.Controls.IndexOf(edit);
            if (index == -1)
            {
                Debug.Assert(false, "");
                return;
            }
            this.flowLayoutPanel1.Controls.Remove(edit);
            AddEditEvents(edit, false);
            edit.Dispose(); // 2015/9/16

            // 把删除后顶替被删除对象位置的 Control,滚入可见范围
            if (index < this.flowLayoutPanel1.Controls.Count)
            {
                Control ref_control = this.flowLayoutPanel1.Controls[index];
                this.flowLayoutPanel1.ScrollControlIntoView(ref_control);
            }
            else if (this.flowLayoutPanel1.Controls.Count > 0)
            {
                Control ref_control = this.flowLayoutPanel1.Controls[this.flowLayoutPanel1.Controls.Count - 1];
                this.flowLayoutPanel1.ScrollControlIntoView(ref_control);
            }

            InvalidateEditControls(index);
        }
예제 #12
0
        // 添加一个新的册对象
        // parameters:
        //      strRecPath  记录路径
        public int NewEntity(string strRecPath,
            byte[] timestamp,
            string strXml,
            bool ScrollIntoView,
            bool bAutoSetFocus,
            out EntityEditControl control,
            out string strError)
        {
            strError = "";
#if NO
            if (this.easyMarcControl1.InvokeRequired)
            {
                Delegate_NewEntity d = new Delegate_NewEntity(NewEntity);
                object[] args = new object[5];
                args[0] = strRecPath;
                args[1] = timestamp;
                args[2] = strXml;
                args[3] = ScrollIntoView;
                args[4] = strError;
                int result = (int)this.easyMarcControl1.Invoke(d, args);

                // 取出out参数值
                strError = (string)args[4];
                return result;
            }
#endif

            control = new EntityEditControl();
            control.DisplayMode = "simple_register";
            control.HideSelection = false;
            control.Width = 120;
            control.AutoScroll = false;
            control.AutoSize = true;
            control.Font = this.Owner.Font;
            control.BackColor = Color.Transparent;
            control.Margin = new Padding(8, 8, 8, 8);
            // control.TableMargin = new Padding(100);
            control.TablePadding = new Padding(64,12,24,12);

            // control.ErrorInfo = "测试文字 asdfasdf a asd fa daf a df af asdf asdf adf asdf asdf asf asdf asdf ---- ";

            if (string.IsNullOrEmpty(strXml) == false)
            {
                int nRet = control.SetData(strXml, strRecPath, timestamp, out strError);
                if (nRet == -1)
                    return -1;
            }
            else
            {
                control.Initializing = false;
                // control.Barcode = strItemBarcode;
                if (string.IsNullOrEmpty(control.RefID) == true)
                    control.RefID = Guid.NewGuid().ToString();
            }

            if (timestamp == null)
            {
                control.CreateState = ItemDisplayState.New;
                control.Changed = true;
                this.EntitiesChanged = true;    // 让外界能感知到含有新册事项
            }

            AddEditEvents(control, true);

            // ClearBlank();

            // control.BackColor = ControlPaint.Dark(this.flowLayoutPanel1.BackColor);
            SetControlColor(control);
#if NO
            control.BackColor = this.flowLayoutPanel1.BackColor;
            control.ForeColor = this.flowLayoutPanel1.ForeColor;
#endif
            
            // this.flowLayoutPanel1.Controls.Add(control);
            AddEditControl(control);

            // this.flowLayoutPanel1.PerformLayout();
            // this.tableLayoutPanel1.PerformLayout();

            // this.AdjustFlowLayoutHeight();

            if (bAutoSetFocus == true)
                control.Focus();    // 这一句让 Edit Control 部分可见,但不是全部可见

            if (ScrollIntoView)
                this.flowLayoutPanel1.ScrollControlIntoView(control);

            return 0;
        }
예제 #13
0
        // 删除一个册记录控件
        public void RemoveEditControl(EntityEditControl control)
        {
            if (this.InvokeRequired == true)
            {
                this.Invoke(new Action<EntityEditControl>(RemoveEditControl), control);
                return;
            }

            this.flowLayoutPanel1.Controls.Remove(control);
        }
예제 #14
0
        // 添加一个新的册对象
        // parameters:
        //      strRecPath  记录路径
        public int NewEntity(string strRecPath,
            byte [] timestamp,
            string strXml,
            bool ScrollIntoView,
            out string strError)
        {
            strError = "";

            if (this.InvokeRequired)
            {
                Delegate_NewEntity d = new Delegate_NewEntity(NewEntity);
                object[] args = new object[5];
                args[0] = strRecPath;
                args[1] = timestamp;
                args[2] = strXml;
                args[3] = ScrollIntoView;
                args[4] = strError;
                int result = (int)this.Invoke(d, args);

                // 取出out参数值
                strError = (string)args[4];
                return result;
            }

            EntityEditControl control = new EntityEditControl();
            control.DisplayMode = "simple_register";
            control.Width = 120;
            control.AutoScroll = false;
            control.AutoSize = true;
            control.Font = this.Font;
            control.BackColor = Color.Transparent;

            // control.ErrorInfo = "测试文字 asdfasdf a asd fa daf a df af asdf asdf adf asdf asdf asf asdf asdf ---- ";

            if (string.IsNullOrEmpty(strXml) == false)
            {
                int nRet = control.SetData(strXml, strRecPath, timestamp, out strError);
                if (nRet == -1)
                    return -1;
            }
            else
            {
                control.Initializing = false;
                // control.Barcode = strItemBarcode;
                if (string.IsNullOrEmpty(control.RefID) == true)
                    control.RefID = Guid.NewGuid().ToString();
            }

            if (timestamp == null)
            {
                control.CreateState = ItemDisplayState.New;
                control.Changed = true;
                this.EntitiesChanged = true;    // 让外界能感知到含有新册事项
            }

            control.PaintContent += new PaintEventHandler(control_PaintContent);
            control.ContentChanged += new DigitalPlatform.ContentChangedEventHandler(control_ContentChanged);
            control.GetValueTable += new DigitalPlatform.GetValueTableEventHandler(control_GetValueTable);
            control.AppendMenu += new ApendMenuEventHandler(control_AppendMenu);

            ClearBlank();

            this.flowLayoutPanel1.Controls.Add(control);

            // this.flowLayoutPanel1.PerformLayout();
            // this.tableLayoutPanel1.PerformLayout();

            this.AdjustFlowLayoutHeight();

            if (ScrollIntoView)
            {
                this.flowLayoutPanel1.ScrollControlIntoView(control);
                if (this.EnsureVisible != null)
                {
                    EnsureVisibleEventArgs e1 = new EnsureVisibleEventArgs();
                    e1.Control = control;
                    e1.Rect = new Rectangle(control.Location, control.Size);
                    e1.Rect.X += this.flowLayoutPanel1.Location.X;
                    e1.Rect.Y += this.flowLayoutPanel1.Location.Y;
                    this.EnsureVisible(this, e1);
                }
            }

            // this.BeginInvoke(new Action<Control>(EnsureVisible), control);

            return 0;
        }
예제 #15
0
        // 添加一个新的册对象
        // parameters:
        //      strRecPath  记录路径
        public int NewEntity(string strRecPath,
            byte[] timestamp,
            string strXml,
            bool ScrollIntoView,
            bool bAutoSetFocus,
            out EntityEditControl control,
            out string strError)
        {
            strError = "";

            control = new EntityEditControl();
            control.DisplayMode = "simple_register";
            control.HideSelection = false;
            control.Width = 120;
            control.AutoScroll = false;
            control.AutoSize = true;
            control.Font = this.Owner.Font;
            control.BackColor = Color.Transparent;
            control.Margin = new Padding(8, 8, 8, 8);
            // control.TableMargin = new Padding(100);
            control.TablePadding = new Padding(64, 12, 24, 12);

            // control.ErrorInfo = "测试文字 asdfasdf a asd fa daf a df af asdf asdf adf asdf asdf asf asdf asdf ---- ";

            if (string.IsNullOrEmpty(strXml) == false)
            {
                int nRet = control.SetData(strXml, strRecPath, timestamp, out strError);
                if (nRet == -1)
                    return -1;
            }
            else
            {
                control.Initializing = false;
                // control.Barcode = strItemBarcode;
                if (string.IsNullOrEmpty(control.RefID) == true)
                    control.RefID = Guid.NewGuid().ToString();
            }

            if (timestamp == null)
            {
                control.CreateState = ItemDisplayState.New;
                control.Changed = true;
                this.EntitiesChanged = true;    // 让外界能感知到含有新册事项
            }

            AddEditEvents(control, true);

            SetControlColor(control);

            AddEditControl(control);

            if (bAutoSetFocus == true)
                control.Focus();    // 这一句让 Edit Control 部分可见,但不是全部可见

            if (ScrollIntoView)
                this.flowLayoutPanel1.ScrollControlIntoView(control);

            return 0;
        }
예제 #16
0
        int GetEditData(EntityEditControl edit,
    string strBiblioRecPath,
    out string strXml,
    out string strError)
        {
            if (this.easyMarcControl1.InvokeRequired)
            {
                Delegate_GetEditData d = new Delegate_GetEditData(GetEditData);
                object[] args = new object[4];
                args[0] = edit;
                args[1] = strBiblioRecPath;
                args[2] = "";
                args[3] = "";
                int result = (int)this.easyMarcControl1.Invoke(d, args);

                // 取出out参数值
                strXml = (string)args[2];
                strError = (string)args[3];
                return result;
            }

            string strParentID = Global.GetRecordID(strBiblioRecPath);
            if (string.IsNullOrEmpty(strParentID) == true
                || StringUtil.IsNumber(strParentID) == false)
            {
                strXml = "";
                strError = "书目记录路径 '" + strBiblioRecPath + "' 中的记录 ID 部分格式错误";
                return -1;
            }
            edit.ParentId = strParentID;
            return edit.GetData(true, out strXml, out strError);
        }
예제 #17
0
 void AddEditEvents(EntityEditControl edit, bool bAdd)
 {
     if (bAdd)
     {
         edit.PaintContent += new PaintEventHandler(edit_PaintContent);
         edit.ContentChanged += new DigitalPlatform.ContentChangedEventHandler(edit_ContentChanged);
         edit.GetValueTable += new DigitalPlatform.GetValueTableEventHandler(edit_GetValueTable);
         edit.AppendMenu += new ApendMenuEventHandler(edit_AppendMenu);
         edit.MouseClick += edit_MouseClick;
         edit.GetAccessNoButton.Click += GetAccessNoButton_Click;
         edit.LocationStringChanged += edit_LocationStringChanged;
         edit.ControlKeyDown += edit_ControlKeyDown;
         edit.Enter += edit_Enter;
         edit.SelectionChanged += edit_SelectionChanged;
     }
     else
     {
         edit.PaintContent -= new PaintEventHandler(edit_PaintContent);
         edit.ContentChanged -= new DigitalPlatform.ContentChangedEventHandler(edit_ContentChanged);
         edit.GetValueTable -= new DigitalPlatform.GetValueTableEventHandler(edit_GetValueTable);
         edit.AppendMenu -= new ApendMenuEventHandler(edit_AppendMenu);
         edit.MouseClick -= edit_MouseClick;
         edit.GetAccessNoButton.Click -= GetAccessNoButton_Click;
         edit.LocationStringChanged -= edit_LocationStringChanged;
         edit.ControlKeyDown -= edit_ControlKeyDown;
         edit.Enter -= edit_Enter;
         edit.SelectionChanged -= edit_SelectionChanged;
     }
 }
예제 #18
0
        // 构造事项称呼
        static string GetEntitySummary(EntityEditControl control)
        {
            if (control.InvokeRequired)
            {
                return (string)control.Invoke(new Func<EntityEditControl, string>(GetEntitySummary), control);
            }

            string strBarcode = control.Barcode;

            if (String.IsNullOrEmpty(strBarcode) == false)
                return "册条码号为 '" + strBarcode + "' 的事项";

            string strRegisterNo = control.RegisterNo;

            if (String.IsNullOrEmpty(strRegisterNo) == false)
                return "登录号为 '" + strRegisterNo + "' 的事项";

            string strRecPath = control.RecPath;

            if (String.IsNullOrEmpty(strRecPath) == false)
                return "记录路径为 '" + strRecPath + "' 的事项";

            string strRefID = control.RefID;
            if (String.IsNullOrEmpty(strRefID) == false)
                return "参考ID为 '" + strRefID + "' 的事项";

            return "无任何定位信息的事项";
        }
예제 #19
0
        // return:
        //      错误信息字符串是否确实被改变
        public static bool SetEditErrorInfo(EntityEditControl edit,
            string strErrorInfo)
        {
            if (edit.InvokeRequired)
            {
                return (bool)edit.Invoke(new Func<EntityEditControl, string, bool>(SetEditErrorInfo), edit, strErrorInfo);
            }
            if (edit.ErrorInfo != strErrorInfo)
            {
                edit.ErrorInfo = strErrorInfo;
                return true;
            }

            return false;
        }
예제 #20
0
        // return:
        //      错误信息字符串是否确实被改变
        public bool SetEditErrorInfo(EntityEditControl edit,
            string strErrorInfo)
        {
            if (edit.InvokeRequired)
            {
                return (bool)edit.Invoke(new Func<EntityEditControl, string, bool>(SetEditErrorInfo), edit, strErrorInfo);
            }
            if (edit.ErrorInfo != strErrorInfo)
            {
                edit.ErrorInfo = strErrorInfo;
                AdjustFlowLayoutHeight();   // 2015.7.9
                return true;
            }

            return false;
        }
예제 #21
0
 public void AddDeleteItemTask(RegisterLine line, EntityEditControl edit)
 {
     this.AddTask(line, "delete_items", edit);
 }
예제 #22
0
 static string GetEditRefID(EntityEditControl edit)
 {
     if (edit.InvokeRequired)
     {
         return (string)edit.Invoke(new Func<EntityEditControl, string>(GetEditRefID), edit);
     }
     return edit.RefID;
 }
예제 #23
0
        void DeleteEntity(EntityEditControl edit)
        {
            string strError = "";
            int nRet = 0;

            this.Progress.OnStop += new StopEventHandler(this.DoStop);
            this.Progress.BeginLoop();
            try
            {
                List<EntityEditControl> controls = new List<EntityEditControl>();
                controls.Add(edit);

                // line.SetDisplayMode("summary");

                // 删除下属的册记录
                {
                    EntityInfo[] entities = null;
                    // 构造用于保存的实体信息数组
                    nRet = this._biblio.BuildSaveEntities(
                        "delete",
                        controls,
                        out entities,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    // 分批进行保存
                    // return:
                    //      -2  部分成功,部分失败
                    //      -1  出错
                    //      0   保存成功,没有错误和警告
                    nRet = SaveEntities(
                        entities,
                        out strError);
                    if (nRet == -1 || nRet == -2)
                        goto ERROR1;

                    // 兑现视觉删除
                    this._biblio.RemoveEditControl(edit);

                    // line._biblioRegister.EntitiesChanged = false;
                }

                return;
            }
            finally
            {
                this.Progress.EndLoop();
                this.Progress.OnStop -= new StopEventHandler(this.DoStop);
                // this.Progress.Initial("");
            }
        ERROR1:
            BiblioRegisterControl.SetEditErrorInfo(edit, strError);
            //line._biblioRegister.BarColor = "R";   // 红色
            //this.SetColorList();
        this.ShowMessage(strError, "red", true);
        }
예제 #24
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;
        }
예제 #25
0
 public static EditLine GetFocuedEntityLine(EntityEditControl control)
 {
     return control.GetFocuedLine();
 }
예제 #26
0
 public void SetCurrentEntityLine(EntityEditControl control, EditLine line)
 {
     this._currentEntityControl = control;
     this._currentEntityLine = line;
 }