Пример #1
0
        void menu_modify_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_actions.SelectedIndices.Count == 0)
            {
                strError = "尚未选定要修改的行";
                goto ERROR1;
            }

            ListViewItem item = this.listView_actions.SelectedItems[0];

            List <string> used_fieldnames = GetUsedFieldNames();

            used_fieldnames.Remove(ListViewUtil.GetItemText(item, 0));  // 去掉当前事项已经使用的名字

            OneActionDialog dlg = new OneActionDialog();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.ElementCaption   = this.ElementCaption;
            dlg.UserDir          = this.MainForm.UserDir;
            dlg.DataDir          = this.MainForm.DataDir;
            dlg.CfgDom           = this.CfgDom;
            dlg.UsedFieldNames   = used_fieldnames;
            dlg.FieldName        = ListViewUtil.GetItemText(item, 0);
            dlg.FieldValue       = ListViewUtil.GetItemText(item, 1);
            dlg.FieldValueAdd    = ListViewUtil.GetItemText(item, 2);
            dlg.FieldValueRemove = ListViewUtil.GetItemText(item, 3);

            // dlg.Additional = ListViewUtil.GetItemText(item, 4);

            dlg.RefDbName = this.RefDbName;
            // dlg.AddOrRemoveListDropDown += dlg_AddOrRemoveListDropDown;
            dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.StartPosition  = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            ListViewUtil.ChangeItemText(item, 0, dlg.FieldName);
            ListViewUtil.ChangeItemText(item, 1, dlg.FieldValue);
            ListViewUtil.ChangeItemText(item, 2, dlg.FieldValueAdd);
            ListViewUtil.ChangeItemText(item, 3, dlg.FieldValueRemove);
            ListViewUtil.ChangeItemText(item, 4, dlg.Additional);

            ListViewUtil.SelectLine(item, true);
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #2
0
        void menu_new_Click(object sender, EventArgs e)
        {
            OneActionDialog dlg = new OneActionDialog();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.ElementCaption = this.ElementCaption;
            dlg.UserDir        = this.MainForm.UserDir;
            dlg.DataDir        = this.MainForm.DataDir;
            dlg.CfgDom         = this.CfgDom;
            dlg.UsedFieldNames = GetUsedFieldNames();
            dlg.RefDbName      = this.RefDbName;
            // dlg.AddOrRemoveListDropDown += dlg_AddOrRemoveListDropDown;
            dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.StartPosition  = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            int index = -1;

            if (this.listView_actions.SelectedIndices.Count > 0)
            {
                index = this.listView_actions.SelectedIndices[0] + 1;
            }
            else
            {
                index = this.listView_actions.Items.Count;  // 追加
            }
            ListViewItem item = new ListViewItem();

            ListViewUtil.ChangeItemText(item, 0, dlg.FieldName);
            ListViewUtil.ChangeItemText(item, 1, dlg.FieldValue);
            ListViewUtil.ChangeItemText(item, 2, dlg.FieldValueAdd);
            ListViewUtil.ChangeItemText(item, 3, dlg.FieldValueRemove);
            ListViewUtil.ChangeItemText(item, 4, dlg.Additional);

            this.listView_actions.Items.Insert(index, item);
            ListViewUtil.SelectLine(item, true);
        }
Пример #3
0
        void menu_modify_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_actions.SelectedIndices.Count == 0)
            {
                strError = "尚未选定要修改的行";
                goto ERROR1;
            }

            ListViewItem item = this.listView_actions.SelectedItems[0];

            List<string> used_fieldnames = GetUsedFieldNames();
            used_fieldnames.Remove(ListViewUtil.GetItemText(item, 0));  // 去掉当前事项已经使用的名字

            OneActionDialog dlg = new OneActionDialog();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.ElementCaption = this.ElementCaption;
            dlg.UserDir = this.MainForm.UserDir;
            dlg.DataDir = this.MainForm.DataDir;
            dlg.CfgDom = this.CfgDom;
            dlg.UsedFieldNames = used_fieldnames;
            dlg.FieldName = ListViewUtil.GetItemText(item, 0);
            dlg.FieldValue = ListViewUtil.GetItemText(item, 1);
            dlg.FieldValueAdd = ListViewUtil.GetItemText(item, 2);
            dlg.FieldValueRemove = ListViewUtil.GetItemText(item, 3);

            // dlg.Additional = ListViewUtil.GetItemText(item, 4);

            dlg.RefDbName = this.RefDbName;
            // dlg.AddOrRemoveListDropDown += dlg_AddOrRemoveListDropDown;
            dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != System.Windows.Forms.DialogResult.OK)
                return;

            ListViewUtil.ChangeItemText(item, 0, dlg.FieldName);
            ListViewUtil.ChangeItemText(item, 1, dlg.FieldValue);
            ListViewUtil.ChangeItemText(item, 2, dlg.FieldValueAdd);
            ListViewUtil.ChangeItemText(item, 3, dlg.FieldValueRemove);
            ListViewUtil.ChangeItemText(item, 4, dlg.Additional);

            ListViewUtil.SelectLine(item, true);
            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #4
0
        void menu_new_Click(object sender, EventArgs e)
        {
            OneActionDialog dlg = new OneActionDialog();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.ElementCaption = this.ElementCaption;
            dlg.UserDir = this.MainForm.UserDir;
            dlg.DataDir = this.MainForm.DataDir;
            dlg.CfgDom = this.CfgDom;
            dlg.UsedFieldNames = GetUsedFieldNames();
            dlg.RefDbName = this.RefDbName;
            // dlg.AddOrRemoveListDropDown += dlg_AddOrRemoveListDropDown;
            dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != System.Windows.Forms.DialogResult.OK)
                return;
            int index = -1;

            if (this.listView_actions.SelectedIndices.Count > 0)
                index = this.listView_actions.SelectedIndices[0] + 1;
            else
                index = this.listView_actions.Items.Count;  // 追加

            ListViewItem item = new ListViewItem();
            ListViewUtil.ChangeItemText(item, 0, dlg.FieldName);
            ListViewUtil.ChangeItemText(item, 1, dlg.FieldValue);
            ListViewUtil.ChangeItemText(item, 2, dlg.FieldValueAdd); 
            ListViewUtil.ChangeItemText(item, 3, dlg.FieldValueRemove);
            ListViewUtil.ChangeItemText(item, 4, dlg.Additional);

            this.listView_actions.Items.Insert(index, item);
            ListViewUtil.SelectLine(item, true);
        }