Exemple #1
0
        // 修改名字和注释
        void menu_modify(object sender, System.EventArgs e)
        {
            string strError = "";

            if (listView1.SelectedItems.Count == 0)
            {
                strError = "尚未选择拟修改的模板记录事项...";
                goto ERROR1;
            }

            ListViewItem item = listView1.SelectedItems[0];

            TemplateRecordDlg dlg = new TemplateRecordDlg();

            MainForm.SetControlFont(dlg, this.Font, false);

            string strOldName = ListViewUtil.GetItemText(item, 0);

            dlg.TemplateName = ListViewUtil.GetItemText(item, 0);
            dlg.Comment      = ListViewUtil.GetItemText(item, 1);

REDO_INPUT:
            dlg.ShowDialog(this);
            if (dlg.DialogResult != DialogResult.OK)
            {
                return;
            }

            // 查重 2014/6/21
            ListViewItem dup = ListViewUtil.FindItem(this.listView1, dlg.TemplateName, 0);

            if (dup != null && dup != item)
            {
                strError = "模板名 '" + dlg.TemplateName + "' 已经被使用了,不允许重复出现。请重新输入模板名";
                MessageBox.Show(this, strError);
                goto REDO_INPUT;
            }

            int nRet = ChangeRecordProperty(strOldName,
                                            dlg.TemplateName,
                                            dlg.Comment,
                                            out strError);

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

            FillList(false);
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Exemple #2
0
		// 修改名字和注释
		void menu_modify(object sender, System.EventArgs e)
		{
            string strError = "";

            if (listView1.SelectedItems.Count == 0)
			{
                strError = "尚未选择拟修改的模板记录事项...";
                goto ERROR1;
			}

            ListViewItem item = listView1.SelectedItems[0];

			TemplateRecordDlg dlg = new TemplateRecordDlg();
            MainForm.SetControlFont(dlg, this.Font, false);

            string strOldName = ListViewUtil.GetItemText(item, 0);

            dlg.TemplateName = ListViewUtil.GetItemText(item, 0);
            dlg.Comment = ListViewUtil.GetItemText(item, 1);

        REDO_INPUT:
            dlg.ShowDialog(this);
            if (dlg.DialogResult != DialogResult.OK)
                return;

            // 查重 2014/6/21
            ListViewItem dup = ListViewUtil.FindItem(this.listView1, dlg.TemplateName, 0);
            if (dup != null && dup != item)
            {
                strError = "模板名 '"+dlg.TemplateName+"' 已经被使用了,不允许重复出现。请重新输入模板名";
                MessageBox.Show(this, strError);
                goto REDO_INPUT;
            }

			int nRet = ChangeRecordProperty(strOldName,
                dlg.TemplateName,
				dlg.Comment,
				out strError);
            if (nRet == -1)
                goto ERROR1;

			FillList(false);
            return;
        ERROR1:
            MessageBox.Show(this, strError);
		}