コード例 #1
0
        private void MenuModfiy_Click(object sender, EventArgs e)
        {
            FormTagAdd formOpt;
            string     selectText = selectedBox.SelectedItem.ToString();

            if (selectedBox.Tag.ToString() == "Group")
            {
                formOpt = new FormTagAdd("修改标签组", true, selectText, cap_map_tag_group[selectText].unique == 0 ? false : true);
                if (formOpt.ShowDialog() == DialogResult.OK)
                {
                    string newTagGroup = formOpt.textString;
                    int    isUnique    = formOpt.isChecked ? 1 : 0;

                    string sqlcmd = string.Format("UPDATE tag_group_def set caption='{0}' , is_unique = {1} where id = {2} ;", newTagGroup, isUnique, cap_map_tag_group[selectText].id);
                    if (globalDB.ExeUpdate(sqlcmd) == 0)
                    {
                        MessageBox.Show("update fail!");
                    }
                    loadListBox();
                }
            }
            else
            {
                formOpt = new FormTagAdd("修改标签", false, selectText);
                if (formOpt.ShowDialog() == DialogResult.OK)
                {
                    int    seletIdx     = ListBoxTagGroup.SelectedIndex;
                    int    tagId        = cap_map_tag[selectText].id;
                    string newTag       = formOpt.textString;
                    string tagGroupName = ListBoxTagGroup.SelectedItem.ToString();
                    int    group_id     = cap_map_tag_group[tagGroupName].id; //TODO::
                    string sqlcmd       = string.Format("UPDATE tag_def set caption='{0}' , group_id = {1} where id = {2} ;", newTag, group_id, tagId);
                    if (globalDB.ExeUpdate(sqlcmd) == 0)
                    {
                        MessageBox.Show("update fail!");
                    }
                    loadListBox();
                    ListBoxTagGroup.SelectedIndex = seletIdx;
                }
            }
            formOpt.Close();
            GlobalVar.UpdateDBList();
        }
コード例 #2
0
        private void MenuAdd_Click(object sender, EventArgs e)
        {
            FormTagAdd formOpt;

            if (selectedBox.Tag.ToString() == "Group")
            {
                formOpt = new FormTagAdd("增添标签组", true);
                if (formOpt.ShowDialog() == DialogResult.OK)
                {
                    string newTagGroup = formOpt.textString;
                    int    isUnique    = formOpt.isChecked ? 1 : 0;

                    string sqlcmd = string.Format("INSERT INTO tag_group_def (`caption`, `is_unique`) VALUES ('{0}', {1} );", newTagGroup, isUnique);
                    if (globalDB.ExeUpdate(sqlcmd) == 0)
                    {
                        MessageBox.Show("insert fail!");
                    }
                    loadListBox();
                }
            }
            else
            {
                formOpt = new FormTagAdd("增添标签", false);
                if (formOpt.ShowDialog() == DialogResult.OK)
                {
                    int    seletIdx     = ListBoxTagGroup.SelectedIndex;
                    string newTag       = formOpt.textString;
                    string tagGroupName = ListBoxTagGroup.SelectedItem.ToString();
                    int    group_id     = cap_map_tag_group[tagGroupName].id;
                    string sqlcmd       = string.Format("INSERT INTO tag_def (`caption`, `group_id`) VALUES ('{0}', {1} );", newTag, group_id);
                    if (globalDB.ExeUpdate(sqlcmd) == 0)
                    {
                        MessageBox.Show("insert fail!");
                    }
                    loadListBox();
                    ListBoxTagGroup.SelectedIndex = seletIdx;
                }
            }
            formOpt.Close();
        }