Beispiel #1
0
        // parameters:
        //      strDatabaseName 数据库名。如果不为空,则对话框会填写此名,但不让修改了
        // return:
        //      -1  errpr
        //      0   cancel
        //      1   created
        int CreateSimpleDatabase(string strType,
            string strDatabaseName,
            string strComment)
        {
            SimpleDatabaseDialog dlg = new SimpleDatabaseDialog();
            MainForm.SetControlFont(dlg, this.Font, false);

            string strTypeName = GetTypeName(strType);
            if (strTypeName == null)
                strTypeName = strType;

            if (String.IsNullOrEmpty(strDatabaseName) == false)
            {
                dlg.DatabaseName = strDatabaseName;
                dlg.DatabaseNameReadOnly = true;
            }

            if (String.IsNullOrEmpty(strComment) == false)
                dlg.Comment = strComment;

            dlg.DatabaseType = strType;
            dlg.Text = "创建新" + strTypeName + "库";
            dlg.ManagerForm = this;
            dlg.CreateMode = true;
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return 0;

            // 刷新库名列表
            string strError = "";
            int nRet = ListAllDatabases(out strError);
            if (nRet == -1)
            {
                MessageBox.Show(this, strError);
                return -1;
            }

            // 选定刚创建的数据库
            SelectDatabaseLine(dlg.DatabaseName);

            // 重新获得各种库名、列表
            this.MainForm.StartPrepareNames(false, false);
            return 1;
        }
Beispiel #2
0
        // 修改数据库特性
        private void toolStripButton_modifyDatabase_Click(object sender, EventArgs e)
        {
            string strError = "";
            int nRet = 0;

            if (this.listView_databases.SelectedItems.Count == 0)
            {
                strError = "尚未选定要修改的数据库";
                goto ERROR1;
            }
            ListViewItem item = this.listView_databases.SelectedItems[0];
            string strTypeName = ListViewUtil.GetItemText(item, 1);
            string strName = item.Text;

            string strType = GetTypeString(strTypeName);
            if (strType == null)
                strType = strTypeName;

            if (strType == "biblio")
            {
                BiblioDatabaseDialog dlg = new BiblioDatabaseDialog();
                MainForm.SetControlFont(dlg, this.Font, false);

                dlg.Text = "修改书目库特性";
                dlg.ManagerForm = this;
                dlg.CreateMode = false;
                dlg.StartPosition = FormStartPosition.CenterScreen;

                nRet = dlg.Initial((string)item.Tag,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                dlg.ShowDialog(this);

                if (dlg.DialogResult != DialogResult.OK)
                    return;

                // 刷新库名列表
                nRet = ListAllDatabases(out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                }

                // 选定刚修改的数据库
                SelectDatabaseLine(dlg.BiblioDatabaseName);

                RefreshOpacDatabaseList();
                RefreshOpacBrowseFormatTree();

                // 重新获得各种库名、列表
                this.MainForm.StartPrepareNames(false, false);
            }
            else if (strType == "reader")
            {
                ReaderDatabaseDialog dlg = new ReaderDatabaseDialog();
                MainForm.SetControlFont(dlg, this.Font, false);

                dlg.Text = "修改读者库特性";
                dlg.ManagerForm = this;
                dlg.LibraryCodeList = this.GetLibraryCodeList();
                dlg.CreateMode = false;
                dlg.StartPosition = FormStartPosition.CenterScreen;

                nRet = dlg.Initial((string)item.Tag,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                dlg.ShowDialog(this);

                if (dlg.DialogResult != DialogResult.OK)
                    return;

                // 刷新库名列表
                nRet = ListAllDatabases(out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                }

                // 选定刚修改的数据库
                SelectDatabaseLine(dlg.ReaderDatabaseName);

                // 重新获得各种库名、列表
                this.MainForm.StartPrepareNames(false, false);

                RefreshOpacDatabaseList();
                RefreshOpacBrowseFormatTree();
            }
            else if (strType == "message"
                || strType == "amerce"
                || strType == "invoice"
                || strType == "arrived"
                || strType == "zhongcihao"
                || strType == "publisher"
                || strType == "dictionary"
                || strType == "inventory")
            {
                SimpleDatabaseDialog dlg = new SimpleDatabaseDialog();
                MainForm.SetControlFont(dlg, this.Font, false);

                /*
                string strTypeName = GetTypeName(strType);
                if (strTypeName == null)
                    strTypeName = strType;
                 * */

                dlg.Text = "修改" + strTypeName + "库特性";
                dlg.ManagerForm = this;
                dlg.CreateMode = false;
                dlg.StartPosition = FormStartPosition.CenterScreen;

                nRet = dlg.Initial(
                    strType,
                    (string)item.Tag,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                dlg.ShowDialog(this);

                if (dlg.DialogResult != DialogResult.OK)
                    return;

                // 刷新库名列表
                nRet = ListAllDatabases(out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                }

                // 选定刚修改的数据库
                SelectDatabaseLine(dlg.DatabaseName);

                RefreshOpacDatabaseList();
                RefreshOpacBrowseFormatTree();

                // 重新获得各种库名、列表
                this.MainForm.StartPrepareNames(false, false);
            }

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