// 打开到 册窗 void menuItem_loadToItemInfoForm_Click(object sender, EventArgs e) { string strError = ""; if (this.dpTable_items.SelectedRows.Count == 0) { strError = "尚未选定要打开的册事项"; goto ERROR1; } DpRow selected_row = this.dpTable_items.SelectedRows[0]; string strItemBarcode = selected_row[COLUMN_ITEMBARCODE].Text; if (string.IsNullOrEmpty(strItemBarcode) == true) { strError = "所选定的册事项不具备册条码号信息"; goto ERROR1; } if (strItemBarcode.StartsWith("@biblioRecPath:") == true) { strError = "所选定的行是书目行,不具备册条码号信息"; goto ERROR1; } ItemInfoForm form = Program.MainForm.EnsureItemInfoForm(); Global.Activate(form); form.LoadRecord(strItemBarcode); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Close(); return; ERROR1: MessageBox.Show(this, strError); }
// 装入种册窗/实体窗,用册条码号/记录路径 // parameters: // strTargetFormType 目标窗口类型 "EntityForm" "ItemInfoForm" // strIdType 标识类型 "barcode" "recpath" // strOpenType 打开窗口的方式 "new" "exist" void LoadRecord(string strTargetFormType, string strIdType, string strOpenType) { string strTargetFormName = "种册窗"; if (strTargetFormType == "ItemInfoForm") strTargetFormName = "实体窗"; if (this.listView_number.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未在列表中选定要装入" + strTargetFormName + "的行"); return; } string strBarcodeOrRecPath = ""; if (strIdType == "barcode") { // barcode strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_number.SelectedItems[0], 1); } else { Debug.Assert(strIdType == "recpath", ""); // recpath strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_number.SelectedItems[0], 0); } if (strTargetFormType == "EntityForm") { EntityForm form = null; if (strOpenType == "exist") { form = MainForm.GetTopChildWindow<EntityForm>(); if (form != null) Global.Activate(form); } else { Debug.Assert(strOpenType == "new", ""); } if (form == null) { form = new EntityForm(); form.MdiParent = this.MainForm; form.MainForm = this.MainForm; form.Show(); } if (strIdType == "barcode") { // 装载一个册,连带装入种 // parameters: // bAutoSavePrev 是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示 // return: // -1 error // 0 not found // 1 found form.LoadItemByBarcode(strBarcodeOrRecPath, false); } else { Debug.Assert(strIdType == "recpath", ""); // parameters: // bAutoSavePrev 是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示 // return: // -1 error // 0 not found // 1 found form.LoadItemByRecPath(strBarcodeOrRecPath, false); } } else { Debug.Assert(strTargetFormType == "ItemInfoForm", ""); ItemInfoForm form = null; if (strOpenType == "exist") { form = MainForm.GetTopChildWindow<ItemInfoForm>(); if (form != null) Global.Activate(form); } else { Debug.Assert(strOpenType == "new", ""); } if (form == null) { form = new ItemInfoForm(); form.MdiParent = this.MainForm; form.MainForm = this.MainForm; form.Show(); } if (strIdType == "barcode") { form.LoadRecord(strBarcodeOrRecPath); } else { Debug.Assert(strIdType == "recpath", ""); form.LoadRecordByRecPath(strBarcodeOrRecPath, ""); } } }
// 装入种册窗/实体窗,用册条码号/记录路径 // parameters: // strTargetFormType 目标窗口类型 "EntityForm" "ItemInfoForm" // strIdType 标识类型 "barcode" "recpath" // strOpenType 打开窗口的方式 "new" "exist" void LoadRecord(string strTargetFormType, string strIdType, string strOpenType) { string strTargetFormName = "种册窗"; if (strTargetFormType == "ItemInfoForm") strTargetFormName = "实体窗"; if (this.listView_records.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未在列表中选定要装入" + strTargetFormName + "的行"); return; } string strBarcodeOrRecPath = ""; if (strIdType == "barcode") { // barcode // strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 1); string strError = ""; // 根据 ListViewItem 对象,获得册条码号列的内容 int nRet = GetItemBarcodeOrRefID( this.listView_records.SelectedItems[0], true, out strBarcodeOrRecPath, out strError); if (nRet == -1) { MessageBox.Show(this, strError); return; } } else { Debug.Assert(strIdType == "recpath", ""); // recpath strBarcodeOrRecPath = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 0); } if (strTargetFormType == "EntityForm") { EntityForm form = null; if (strOpenType == "exist") { form = MainForm.GetTopChildWindow<EntityForm>(); if (form != null) Global.Activate(form); } else { Debug.Assert(strOpenType == "new", ""); } if (form == null) { form = new EntityForm(); form.MdiParent = this.MainForm; form.MainForm = this.MainForm; form.Show(); } if (strIdType == "barcode") { // 装载一个册,连带装入种 // parameters: // bAutoSavePrev 是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示 // return: // -1 error // 0 not found // 1 found form.LoadItemByBarcode(strBarcodeOrRecPath, false); } else { Debug.Assert(strIdType == "recpath", ""); if (this.DbType == "item") { // parameters: // bAutoSavePrev 是否自动提交保存先前发生过的修改?如果==true,是;如果==false,则要出现MessageBox提示 // return: // -1 error // 0 not found // 1 found form.LoadItemByRecPath(strBarcodeOrRecPath, false); } else if (this.DbType == "comment") form.LoadCommentByRecPath(strBarcodeOrRecPath, false); else if (this.DbType == "order") form.LoadOrderByRecPath(strBarcodeOrRecPath, false); else if (this.DbType == "issue") form.LoadIssueByRecPath(strBarcodeOrRecPath, false); else throw new Exception("未知的DbType '" + this.DbType + "'"); } } else { Debug.Assert(strTargetFormType == "ItemInfoForm", ""); ItemInfoForm form = null; if (strOpenType == "exist") { form = MainForm.GetTopChildWindow<ItemInfoForm>(); if (form != null) Global.Activate(form); } else { Debug.Assert(strOpenType == "new", ""); } if (form == null) { form = new ItemInfoForm(); form.MdiParent = this.MainForm; form.MainForm = this.MainForm; form.Show(); } if (this.DbType == "arrive") form.DbType = "item"; else form.DbType = this.DbType; if (strIdType == "barcode") { Debug.Assert(this.DbType == "item" || this.DbType == "arrive", ""); form.LoadRecord(strBarcodeOrRecPath); } else { Debug.Assert(strIdType == "recpath", ""); // TODO: 需要改造为适应多种记录 form.LoadRecordByRecPath(strBarcodeOrRecPath, ""); } } }
void menu_loadToItemInfoFormByBarcode_Click(object sender, EventArgs e) { if (this.listView_records.SelectedItems.Count == 0) { MessageBox.Show(this, "尚未在列表中选定要装入册信息窗的册事项"); return; } string strBarcode = ListViewUtil.GetItemText(this.listView_records.SelectedItems[0], 1); ItemInfoForm form = null; if (this.LoadToExistDetailWindow == true) { form = MainForm.TopItemInfoForm; if (form != null) form.Activate(); } if (form == null) { form = new ItemInfoForm(); form.MdiParent = this.MainForm; form.MainForm = this.MainForm; form.Show(); } form.LoadRecord(strBarcode); }