Exemple #1
0
        void FillList()
        {
            this.listView_papers.Items.Clear();

            if (this.Document == null)
            {
                return;
            }

            foreach (PaperSize ps in this.Document.PrinterSettings.PaperSizes)
            {
                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, COLUMN_PAPERNAME, ps.PaperName);
                ListViewUtil.ChangeItemText(item, COLUMN_KIND, ps.Kind.ToString());
                ListViewUtil.ChangeItemText(item, COLUMN_WIDTH, ps.Width.ToString());
                ListViewUtil.ChangeItemText(item, COLUMN_HEIGHT, ps.Height.ToString());
                this.listView_papers.Items.Add(item);
            }

            if (this.listView_papers.Items.Count > 0)
            {
                ListViewItem select = ListViewUtil.FindItem(this.listView_papers, this.textBox_paperName.Text, COLUMN_PAPERNAME);
                if (select != null)
                {
                    ListViewUtil.SelectLine(select, true);
                }
                else
                {
                    ListViewUtil.SelectLine(this.listView_papers, 0, true);
                }
            }
        }
Exemple #2
0
        // 勾选值事项。本函数须要在BuildList()后调用
        // 本函数能自动添加strValue中具备、但是ListView中尚未存在的事项行
        void SetValue(string strValue)
        {
            // 清除先前的全部checked状态
            for (int i = 0; i < this.listView1.Items.Count; i++)
            {
                ListViewItem item = this.listView1.Items[i];
                if (item.Checked == true)
                {
                    item.Checked = false;
                }
                item.Tag = null;    // 清除原来残留的序号
            }

            this.m_nIndex = 0;  // 序号

            string[] parts = strValue.Split(new char[] { ',' });

            for (int i = 0; i < parts.Length; i++)
            {
                string strLine = parts[i].Trim();
                if (String.IsNullOrEmpty(strLine) == true)
                {
                    continue;
                }

                // 根据\t分为若干部分
                string[] columns = strLine.Split(new char[] { '\t' });
                if (columns.Length == 0)
                {
                    continue;
                }

                // 只用第一部分来进行匹配勾选
                string strFirstColumn = columns[0].Trim();

                ListViewItem item = ListViewUtil.FindItem(
                    this.listView1,
                    strFirstColumn, 0);

                // 如果事项居然不存在
                if (item == null)
                {
                    item = new ListViewItem();

                    for (int j = 0; j < columns.Length; j++)
                    {
                        ListViewUtil.ChangeItemText(item, j, columns[j].Trim());
                    }
                    this.listView1.Items.Add(item);
                }

                item.Checked = true;

                // 保留原始序号
                ItemInfo iteminfo = new ItemInfo();
                iteminfo.Index   = this.m_nIndex++;
                iteminfo.OldItem = true;
                item.Tag         = iteminfo;
            }
        }
Exemple #3
0
        internal int GetRemoteBiblioDbNames(
            string strRemoveServer,
            out List <string> dbnames,
            out string strError)
        {
            strError = "";
            dbnames  = new List <string>();

            // 根据中心服务器名,找到 URL 用户名 密码
            ListViewItem item = ListViewUtil.FindItem(this.listView_center, strRemoveServer, 0);

            if (item == null)
            {
                strError = "中心服务器 '" + strRemoveServer + "' 尚未定义";
                return(-1);
            }

            string strUrl      = ListViewUtil.GetItemText(item, 1);
            string strUserName = ListViewUtil.GetItemText(item, 2);
            string strPassword = (string)item.Tag;

            return(GetRemoteBiblioDbNames(
                       strUrl,
                       strUserName,
                       strPassword,
                       out dbnames,
                       out strError));
        }
Exemple #4
0
        // 查找一个实例名。返回在 ListView 中的 index
        public int FindInstanceName(string strInstanceName)
        {
            ListViewItem item = ListViewUtil.FindItem(this.listView_instance, strInstanceName, 0);

            if (item == null)
            {
                return(-1);
            }
            return(this.listView_instance.Items.IndexOf(item));
        }
Exemple #5
0
        // 移走一行
        void RemoveItem(TagAndData tag)
        {
            var item = ListViewUtil.FindItem(this.listView_tags, tag.OneTag.UID, COLUMN_UID);

            if (item == null)
            {
                return;
            }
            this.listView_tags.Items.Remove(item);
        }
Exemple #6
0
        //
        /// <summary>
        /// 获得一个报表的频率
        /// </summary>
        /// <param name="strReportName">报表名</param>
        /// <returns></returns>
        public List <string> GetReportFreq(string strReportName)
        {
            ListViewItem item = ListViewUtil.FindItem(this.listView_reports, strReportName, COLUMN_REPORT_NAME);

            if (item == null)
            {
                return(new List <string>());
            }
            return(StringUtil.SplitList(ListViewUtil.GetItemText(item, COLUMN_REPORT_FREQ)));
        }
Exemple #7
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();

            GuiUtil.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 #8
0
        // 刷新一行的显示
        void RefreshLine(int id, RequestItem request_item)
        {
            // 先定位到这一行
            ListViewItem item = ListViewUtil.FindItem(this.listView_records, id.ToString(), COLUMN_ID);

            if (item == null)
            {
                return;
            }
            SetLine(item, request_item);
        }
Exemple #9
0
        // 修改一个事项
        private void toolStripButton_modifyItem_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_list.SelectedItems.Count == 0)
            {
                strError = "尚未选定要修改的事项";
                goto ERROR1;
            }

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

            OrderOutputItemDialog dlg = new OrderOutputItemDialog();

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

            dlg.ScriptManager = this.ScriptManager;
            dlg.AppInfo       = this.AppInfo;

            dlg.ExcludeSellers = GetUsedSellers(item);

            dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);

            dlg.Seller        = ListViewUtil.GetItemText(item, 0);
            dlg.OutputFormat  = ListViewUtil.GetItemText(item, 1);
            dlg.StartPosition = FormStartPosition.CenterScreen;

REDO_INPUT:
            dlg.ShowDialog(this);

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

            // TODO: 渠道名查重
            ListViewItem dup = ListViewUtil.FindItem(this.listView_list, dlg.Seller, 0);

            if (dup != null && dup != item)
            {
                MessageBox.Show(this, "修改后的渠道名 '" + dlg.Seller + "' 在当前列表中已经存在。请重新输入...");
                goto REDO_INPUT;
            }

            ListViewUtil.ChangeItemText(item, 0, dlg.Seller);
            ListViewUtil.ChangeItemText(item, 1, dlg.OutputFormat);
            // ListViewUtil.SelectLine(item, true);
            this.m_bChanged = true;
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Exemple #10
0
        // 更新一行内容
        ListViewItem UpdateItem(TagAndData tag)
        {
            var item = ListViewUtil.FindItem(this.listView_tags, tag.OneTag.UID, COLUMN_UID);

            if (item == null)
            {
                return(AddItem(tag));
            }
            RefreshItem(item, tag);
            return(item);
        }
Exemple #11
0
 void SelectItems(List <string> value)
 {
     ListViewUtil.ClearSelection(this.listView_records);
     foreach (string s in value)
     {
         ListViewItem item = ListViewUtil.FindItem(this.listView_records, s, 0);
         if (item != null)
         {
             item.Selected = true;
         }
     }
 }
Exemple #12
0
        private void button_groupContents_new_Click(object sender, EventArgs e)
        {
            CellLineDialog dlg = new CellLineDialog();

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

            dlg.FillGroupFieldNameTable();
            dlg.StartPosition = FormStartPosition.CenterScreen;
            dlg.ShowDialog(this);

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

            // 查重?
            // 名称查重
            ListViewItem dup = ListViewUtil.FindItem(this.listView_groupContents_lines, dlg.FieldName, 0);

            if (dup != null)
            {
                // 让操作者能看见已经存在的行
                ListViewUtil.SelectLine(dup, true);
                dup.EnsureVisible();

                DialogResult result = MessageBox.Show(this,
                                                      "当前已经存在名为 '" + dlg.FieldName + "' 的内容行。继续新增?",
                                                      "BindingOptionDialog",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button2);
                if (result == DialogResult.No)
                {
                    return;
                }
            }



            ListViewItem item = new ListViewItem();

            item.Text = dlg.FieldName;
            ListViewUtil.ChangeItemText(item, 1, dlg.Caption);

            this.listView_groupContents_lines.Items.Add(item);
            ListViewUtil.SelectLine(item, true);
            item.EnsureVisible();

            listView_groupContents_lines_SelectedIndexChanged(sender, null);

            this.m_bGroupContentsChanged = true;
        }
Exemple #13
0
        void StartOrStopOneInstance(string strInstanceName,
                                    string strAction)
        {
            ListViewItem item = null;

            if (this.Visible)
            {
                item = ListViewUtil.FindItem(this.listView_instance, strInstanceName, COLUMN_NAME);
                if (item == null)
                {
                    MessageBox.Show(this, "名为 '" + strInstanceName + "' 实例在列表中没有找到");
                    return;
                }
            }
            List <string> errors = new List <string>();

            this.EnableControls(false);
            try
            {
                string strError = "";

                {
                    int nRet = dp2capo_serviceControl(
                        strAction,
                        strInstanceName,
                        out strError);
                    if (nRet == -1)
                    {
                        errors.Add(strError);
                    }
                    else
                    {
                        if (item != null)
                        {
                            item.ImageIndex = strAction == "stop" ? IMAGEINDEX_STOPPED : IMAGEINDEX_RUNNING;
                        }
                    }
                }
            }
            finally
            {
                this.EnableControls(true);
            }

            if (errors.Count > 0)
            {
                MessageBox.Show(this, StringUtil.MakePathList(errors, "; "));
            }
        }
Exemple #14
0
        void menu_newReport_Click(object sender, EventArgs e)
        {
            ReportApplyForm dlg = new ReportApplyForm();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.MainForm    = this.MainForm;
            dlg.ReportForm  = this.ReportForm;
            dlg.LibraryCode = ReportForm.GetOriginLibraryCode(this.comboBox_general_libraryCode.Text);
            dlg.CfgFileDir  = Path.Combine(this.MainForm.UserDir, "report_def"); //  Path.Combine(this.MainForm.UserDir, "report_def");
REDO_INPUT:
            this.MainForm.AppInfo.LinkFormState(dlg, "ReportApplyForm_state");
            dlg.UiState = this.MainForm.AppInfo.GetString("libraryreportconfig_form", "reportapplyform_ui_state", "");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.SetString("libraryreportconfig_form", "reportapplyform_ui_state", dlg.UiState);
            this.MainForm.AppInfo.UnlinkFormState(dlg);

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

            // 对报表文件名进行查重
            ListViewItem dup = ListViewUtil.FindItem(this.listView_reports, dlg.ReportName, COLUMN_REPORT_NAME);

            if (dup != null)
            {
                ListViewUtil.SelectLine(dup, true);
                MessageBox.Show(this, "报表名为 '" + dlg.ReportName + "' 的事项已经存在,不允许重复创建。请修改报表名");
                goto REDO_INPUT;
            }

            ListViewItem item = new ListViewItem();

            ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAME, dlg.ReportName);
            ListViewUtil.ChangeItemText(item, COLUMN_REPORT_FREQ, dlg.Freguency);
            ListViewUtil.ChangeItemText(item, COLUMN_REPORT_TYPE, dlg.ReportType);
            ListViewUtil.ChangeItemText(item, COLUMN_REPORT_CFGFILE, dlg.ReportCfgFileName);
            ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAMETABLE, dlg.NameTable);
            this.listView_reports.Items.Add(item);

            ListViewUtil.SelectLine(item, true);

            this.Changed = true;
        }
Exemple #15
0
        void FillList(bool bAutoSelect)
        {
            listView1.Items.Clear();

            XmlNodeList nodes = dom.DocumentElement.SelectNodes("template");

            for (int i = 0; i < nodes.Count; i++)
            {
                string strName    = DomUtil.GetAttr(nodes[i], "name");
                string strComment = DomUtil.GetAttr(nodes[i], "comment");

                ListViewItem item = new ListViewItem(strName, 0);

                listView1.Items.Add(item);

                item.SubItems.Add(strComment);
            }

            // 选择第一项
            if (bAutoSelect == true)
            {
                if (String.IsNullOrEmpty(this.SelectedName) == false)
                {
                    if (listView1.Items.Count != 0)
                    {
                        ListViewItem item = ListViewUtil.FindItem(this.listView1, this.SelectedName, 0);
                        if (item != null)
                        {
                            ListViewUtil.SelectLine(item, true);
                        }
                    }
                }
                else
                {
                    if (listView1.Items.Count != 0)
                    {
                        listView1.Items[0].Selected = true;
                    }
                }
            }

            listView1_SelectedIndexChanged(null, null);
        }
Exemple #16
0
        void menu_newItem_Click(object sender, EventArgs e)
        {
            int index = -1;

            if (this.listView1.SelectedIndices.Count > 0)
            {
                index = this.listView1.SelectedIndices[0];
            }

            TwoStringDialog dlg = new TwoStringDialog();

REDO:
            dlg.ShowDialog(this);
            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            ListViewItem dup = ListViewUtil.FindItem(this.listView1, dlg.SourceString, 0);

            if (dup != null)
            {
                MessageBox.Show(this, "源字符串为 '" + dlg.SourceString + "' 的事项在列表中已经存在了,不允许重复。请修改");
                goto REDO;
            }

            ListViewItem item = new ListViewItem();

            ListViewUtil.ChangeItemText(item, 0, dlg.SourceString);
            ListViewUtil.ChangeItemText(item, 1, dlg.TargetString);

            if (index == -1)
            {
                this.listView1.Items.Add(item);
            }
            else
            {
                this.listView1.Items.Insert(index, item);
            }
            ListViewUtil.ClearSelection(this.listView1);
            ListViewUtil.SelectLine(item, true);
        }
Exemple #17
0
        // 新增一个事项
        private void toolStripButton_newItem_Click(object sender, EventArgs e)
        {
            OrderOutputItemDialog dlg = new OrderOutputItemDialog();

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

            dlg.ScriptManager = this.ScriptManager;
            dlg.AppInfo       = this.AppInfo;

            dlg.ExcludeSellers = GetUsedSellers(null);

            dlg.GetValueTable -= new GetValueTableEventHandler(dlg_GetValueTable);
            dlg.GetValueTable += new GetValueTableEventHandler(dlg_GetValueTable);

            dlg.StartPosition = FormStartPosition.CenterScreen;

REDO_INPUT:
            dlg.ShowDialog(this);

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

            // TODO: 渠道名查重
            ListViewItem dup = ListViewUtil.FindItem(this.listView_list, dlg.Seller, 0);

            if (dup != null)
            {
                MessageBox.Show(this, "渠道名 '" + dlg.Seller + "' 在当前列表中已经存在。请重新输入...");
                goto REDO_INPUT;
            }

            ListViewItem item = new ListViewItem();

            item.Text = dlg.Seller;
            item.SubItems.Add(dlg.OutputFormat);

            this.listView_list.Items.Add(item);
            ListViewUtil.SelectLine(item, true);
            this.m_bChanged = true;
        }
Exemple #18
0
        // return:
        //      true    发生过修改
        //      false   没有发生修改
        bool SearchDup(ref string name, ListViewItem exclude)
        {
            bool changed = false;

            while (true)
            {
                ListViewItem dup = ListViewUtil.FindItem(this.listView1, name, COLUMN_NAME);
                if (dup == null)
                {
                    return(changed);
                }
                if (dup == exclude)
                {
                    return(changed);
                }
                // 修改一下 name
                name    = ModifyName(name);
                changed = true;
            }
        }
        private void GetOpacMemberDatabaseNameDialog_Load(object sender, EventArgs e)
        {
            string strError = "";
            int    nRet     = ListAllDatabases(this.AllDatabaseInfoXml,
                                               out strError);

            if (nRet == -1)
            {
                MessageBox.Show(this, strError);
            }

            // 选中第一个
            if (this.listView_databases.Items.Count > 0)
            {
                if (this.SelectedDatabaseName != "")
                {
                    ListViewItem item = ListViewUtil.FindItem(this.listView_databases,
                                                              this.SelectedDatabaseName,
                                                              0);
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }
                else
                {
                    // 选中第一个不是灰色的item
                    for (int i = 0; i < this.listView_databases.Items.Count; i++)
                    {
                        ListViewItem item = this.listView_databases.Items[i];
                        if (item.ImageIndex == 0)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                }
            }
        }
Exemple #20
0
        void menu_modifyItem_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView1.SelectedItems.Count == 0)
            {
                strError = "尚未选择要修改的事项";
                goto ERROR1;
            }

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

            TwoStringDialog dlg = new TwoStringDialog();

            dlg.SourceString = ListViewUtil.GetItemText(item, 0);
            dlg.TargetString = ListViewUtil.GetItemText(item, 1);
REDO:
            dlg.ShowDialog(this);
            if (dlg.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }

            ListViewItem dup = ListViewUtil.FindItem(this.listView1, dlg.SourceString, 0);

            if (dup != null && dup != item)
            {
                MessageBox.Show(this, "源字符串为 '" + dlg.SourceString + "' 的事项在列表中已经存在了,不允许重复。请修改");
                goto REDO;
            }
            ListViewUtil.ChangeItemText(item, 0, dlg.SourceString);
            ListViewUtil.ChangeItemText(item, 1, dlg.TargetString);
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Exemple #21
0
        // 新增栏目
        private void button_columns_new_Click(object sender, EventArgs e)
        {
            PrintColumnDlg dlg = new PrintColumnDlg();

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

            if (this.ColumnItems != null)
            {
                dlg.ColumnItems = this.ColumnItems;
            }

            if (this.MainForm != null)
            {
                this.MainForm.AppInfo.LinkFormState(dlg, "printorderdlg_formstate");
            }
            dlg.ShowDialog(this);
            if (this.MainForm != null)
            {
                this.MainForm.AppInfo.UnlinkFormState(dlg);
            }


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

            // 名称查重
            ListViewItem dup = ListViewUtil.FindItem(this.listView_columns, dlg.ColumnName, 0);

            if (dup != null)
            {
                // 让操作者能看见已经存在的行
                ListViewUtil.SelectLine(dup, true);
                dup.EnsureVisible();

                DialogResult result = MessageBox.Show(this,
                                                      "当前已经存在名为 '" + dlg.ColumnName + "' 的栏目。继续新增?",
                                                      "PrintOptionDlg",
                                                      MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Question,
                                                      MessageBoxDefaultButton.Button2);
                if (result == DialogResult.No)
                {
                    return;
                }
            }

            ListViewItem item = new ListViewItem();

#if NO
            item.Text = dlg.ColumnName;
            item.SubItems.Add(dlg.ColumnCaption);
            item.SubItems.Add(dlg.MaxChars.ToString());
#endif
            ListViewUtil.ChangeItemText(item, COLUMN_NAME, dlg.ColumnName);
            ListViewUtil.ChangeItemText(item, COLUMN_CAPTION, dlg.ColumnCaption);
            ListViewUtil.ChangeItemText(item, COLUMN_WIDTHCHARS, dlg.WidthChars.ToString());
            ListViewUtil.ChangeItemText(item, COLUMN_MAXCHARS, dlg.MaxChars.ToString());
            ListViewUtil.ChangeItemText(item, COLUMN_EVALUE, dlg.ColumnEvalue);


            this.listView_columns.Items.Add(item);

            // 让操作者能看见新插入的行
            ListViewUtil.SelectLine(item, true);
            item.EnsureVisible();

            // 新增事项后,当前已选择事项的上下移动的可能性会有所改变
            listView_columns_SelectedIndexChanged(sender, null);
        }
Exemple #22
0
        // 新增模板
        int NewTemplate(string strName,
                        Stream stream,
                        out string strError)
        {
            strError = "";

            if (String.IsNullOrEmpty(strName) == true)
            {
                strError = "模板名不能为空";
                return(-1);
            }

            // 查重
            ListViewItem dup = ListViewUtil.FindItem(this.listView_templates, strName, 0);

            if (dup != null)
            {
                strError = "模板名 '" + strName + "' 在列表中已经存在,不能重复加入";
                return(-1);
            }

            string strFilePath = "";
            int    nRedoCount  = 0;
            string strDir      = PathUtil.MergePath(this.DataDir, // 老用法
                                                    "print_templates");

            PathUtil.TryCreateDir(strDir);  // 确保目录存在
            // 找到一个可用的文件名
            for (int i = 0; ; i++)
            {
                strFilePath = PathUtil.MergePath(strDir, "template_" + (i + 1).ToString());
                if (File.Exists(strFilePath) == false)
                {
                    try
                    {
                        // File.Create(strFilePath).Close();
                        using (Stream target = File.Create(strFilePath))
                        {
                            stream.Seek(0, SeekOrigin.Begin);
                            StreamUtil.DumpStream(stream, target);
                        }
                    }
                    catch (Exception /* ex*/)
                    {
                        if (nRedoCount > 10)
                        {
                            strError = "创建文件 '" + strFilePath + "' 失败...";
                            return(-1);
                        }
                        nRedoCount++;
                        continue;
                    }
                    break;
                }
            }

            // 清除原来已有的选择
            this.listView_templates.SelectedItems.Clear();

            ListViewItem item = new ListViewItem();

            item.Text = strName;
            item.SubItems.Add(strFilePath);
            this.listView_templates.Items.Add(item);
            item.Selected            = true; // 选上新增的事项
            this.m_bTempaltesChanged = true;

            item.EnsureVisible();   // 滚入视野

            this.m_newCreateTemplateFiles.Add(strFilePath);
            return(0);
        }
        // 只填充和SourceBiblioDbName具有相同syntax的、相同出版物类型的书目库名
        // SourceBiblioDbName自己被排除在外
        int FillDbNames(out string strError)
        {
            strError = "";
            string strSourceSyntax = "";

            bool bSourceIsIssueDb = false;

            if (String.IsNullOrEmpty(this.SourceBiblioDbName) == false)
            {
                strSourceSyntax = Program.MainForm.GetBiblioSyntax(this.SourceBiblioDbName);
                if (strSourceSyntax == null)
                {
                    strError = "源书目库名 '" + this.SourceBiblioDbName + "' 居然不存在";
                    return(-1);
                }

                if (String.IsNullOrEmpty(strSourceSyntax) == true)
                {
                    strSourceSyntax = "unimarc";
                }

                string strSourceIssueDbName = Program.MainForm.GetIssueDbName(this.SourceBiblioDbName);
                if (String.IsNullOrEmpty(strSourceIssueDbName) == false)
                {
                    bSourceIsIssueDb = true;
                }
                else
                {
                    bSourceIsIssueDb = false;
                }
            }

            if (Program.MainForm.BiblioDbProperties != null)
            {
                for (int i = 0; i < Program.MainForm.BiblioDbProperties.Count; i++)
                {
                    BiblioDbProperty prop = Program.MainForm.BiblioDbProperties[i];

                    // 需要具备实体库
                    if (String.IsNullOrEmpty(prop.ItemDbName) == true)
                    {
                        continue;
                    }

                    // 排除this.SourcBibliDbName
                    if (prop.DbName == this.SourceBiblioDbName)
                    {
                        continue;
                    }

                    // 判断syntax
                    if (String.IsNullOrEmpty(strSourceSyntax) == false)
                    {
                        string strTempSyntax = prop.Syntax;
                        if (String.IsNullOrEmpty(strTempSyntax) == true)
                        {
                            strTempSyntax = "unimarc";
                        }

                        if (prop.Syntax != strSourceSyntax)
                        {
                            continue;
                        }
                    }

                    // 判断出版类型
                    if (String.IsNullOrEmpty(prop.IssueDbName) == false &&
                        bSourceIsIssueDb == false)
                    {
                        continue;   // 出版物类型不一致
                    }
                    ListViewItem item = new ListViewItem();
                    item.Text = prop.DbName;
                    this.listView_dbNames.Items.Add(item);
                }
            }

            ListViewItem selected_item = ListViewUtil.FindItem(this.listView_dbNames, this.textBox_dbName.Text, 0);

            if (selected_item != null)
            {
                selected_item.Selected = true;
            }

            return(0);
        }
Exemple #24
0
        // 将 textbox 的修改兑现到内存中
        int UpdateData(out string strError)
        {
            strError = "";

            if (this.m_nIndex == -1)
            {
                return(0);
            }

            if (this.m_bTextChanged == false)
            {
                return(0);
            }

            int index = this.m_nIndex;

            InputBookItem book_item = this.BookItems[index];

            string strCurrentBarcode = book_item.BookItem.Barcode;

            if (strCurrentBarcode != this.textBox_itemBarcode.Text)
            {
                if (string.IsNullOrEmpty(this.textBox_itemBarcode.Text) == false)
                {
                    // 2015/7/22
                    // 在 listview 内对册条码号进行查重
                    ListViewItem dup = ListViewUtil.FindItem(this.listView_barcodes, this.textBox_itemBarcode.Text, 0);
                    if (dup != null)
                    {
                        strError = "册条码号 '" + this.textBox_itemBarcode.Text + "' 在当前列表中已经存在,不允许重复登入";
                        return(-1);
                    }
                }

                // 校验barcode合法性
                if (this.VerifyBarcode != null &&
                    this.textBox_itemBarcode.Text != "")    // 2009/1/15
                {
                    this.SetFloatMessage("waiting", "正在验证册条码号,请稍候 ...");
                    Application.DoEvents();
                    // Thread.Sleep(5000);
                    try
                    {
                        VerifyBarcodeEventArgs e = new VerifyBarcodeEventArgs();
                        e.Barcode     = this.textBox_itemBarcode.Text;
                        e.LibraryCode = Global.GetLibraryCode(StringUtil.GetPureLocation(book_item.BookItem.Location)); // 2016/4/18
                        this.VerifyBarcode(this, e);
                        // return:
                        //      -2  服务器没有配置校验方法,无法校验
                        //      -1  error
                        //      0   不是合法的条码号
                        //      1   是合法的读者证条码号
                        //      2   是合法的册条码号
                        if (e.Result != -2)
                        {
                            if (e.Result != 2)
                            {
                                if (String.IsNullOrEmpty(strError) == false)
                                {
                                    strError = e.ErrorInfo;
                                }
                                else
                                {
                                    // 如果从服务器端没有得到出错信息,则补充
                                    //      -1  error
                                    if (e.Result == -1)
                                    {
                                        strError = "在校验条码号 '" + e.Barcode + "' 时出错";
                                    }
                                    //      0   不是合法的条码号
                                    else if (e.Result == 0)
                                    {
                                        strError = "'" + e.Barcode + "' 不是合法的条码号";
                                    }
                                    //      1   是合法的读者证条码号
                                    else if (e.Result == 1)
                                    {
                                        strError = "'" + e.Barcode + "' 是读者证条码号(而不是册条码号)";
                                    }
                                }
                                return(-1);
                            }
                        }
                    }
                    finally
                    {
                        this.SetFloatMessage("", "");
                    }
                }

                book_item.BookItem.Barcode = this.textBox_itemBarcode.Text;
                this.Changed = true;
                ListViewItem item = this.listView_barcodes.Items[index];
                item.Font = new Font(item.Font, FontStyle.Bold);    // 加粗字体表示内容被改变了

                book_item.BookItem.Changed = true;
                book_item.BookItem.RefreshListView();

                // 修改ListViewItem显示
                this.listView_barcodes.Items[index].Text = this.textBox_itemBarcode.Text;

                this.m_bTextChanged = false;
                return(1);
            }

            return(0);
        }
Exemple #25
0
        // 列出要创建的dp2数据库。对其中已经存在的,要进行警告
        // 执行本函数前,请先执行ListAllExistingDp2Databases()
        int ListCreatingDp2Databases(out string strError)
        {
            strError = "";

            int index = 0;  // 插入的位置

            for (int i = 0; i < listView_dtlpDatabases.CheckedItems.Count; i++)
            {
                ListViewItem dtlp_item = listView_dtlpDatabases.CheckedItems[i];

                string strCreatingType = ListViewUtil.GetItemText(dtlp_item, 1);

                // 2008/11/30 new add
                string strInCirculation = ListViewUtil.GetItemText(dtlp_item, 2);
                if (strInCirculation == "是")
                {
                    if (String.IsNullOrEmpty(strCreatingType) == false)
                    {
                        strCreatingType += ",";
                    }
                    strCreatingType += "参与流通";
                }

                // 看看名字是否在dp2中已经存在
                ListViewItem dp2_item = ListViewUtil.FindItem(this.listView_creatingDp2DatabaseList,
                                                              dtlp_item.Text, 0);
                if (dp2_item != null)
                {
                    dp2_item.ImageIndex = 2;    // 2表示原来已经存在,又再次要求创建的

                    // 设置新的type。TODO: 原有type值怎么办?是否放在另外一列来参考?
                    ListViewUtil.ChangeItemText(dp2_item, 1, strCreatingType);

                    // 把位置提前
                    this.listView_creatingDp2DatabaseList.Items.Remove(dp2_item);
                    this.listView_creatingDp2DatabaseList.Items.Insert(index, dp2_item);
                }
                else
                {
                    dp2_item = new ListViewItem(dtlp_item.Text, 0); // 0表示不存在,而需要新创建的

                    // 设置新的type。
                    ListViewUtil.ChangeItemText(dp2_item, 1, strCreatingType);

                    this.listView_creatingDp2DatabaseList.Items.Insert(index, dp2_item);
                }

                index++;
            }

            // 设置好事项的颜色
            for (int i = 0; i < this.listView_creatingDp2DatabaseList.Items.Count; i++)
            {
                ListViewItem item = this.listView_creatingDp2DatabaseList.Items[i];

                if (item.ImageIndex == 0)
                {
                    // 需要新创建的,已经并不存在,黄色底
                    item.BackColor = Color.LightYellow;
                }
                if (item.ImageIndex == 1)
                {
                    // 以前已经存在的,和本次创建无关的,灰色文字
                    item.ForeColor = SystemColors.GrayText;
                }
                if (item.ImageIndex == 2)
                {
                    // 需要新创建的,但是已经存在的,红色底,白色字
                    item.BackColor = Color.Red;
                    item.ForeColor = Color.White;
                }
            }

            return(0);
        }
Exemple #26
0
        // 自动增全报表配置
        // return:
        //      -1  出错
        //      >=0 新增的报表类型个数
        public int AutoAppend(
            out string strError)
        {
            strError = "";

            string strCfgFileDir = Path.Combine(this.MainForm.UserDir, "report_def");   //  Path.Combine(this.MainForm.UserDir, "report_def");

            DirectoryInfo di = new DirectoryInfo(strCfgFileDir);

            FileInfo[] fis = di.GetFiles("???.xml");
            Array.Sort(fis, new FileInfoCompare());

            List <string> types = new List <string>();

            foreach (FileInfo fi in fis)
            {
                string strName = Path.GetFileNameWithoutExtension(fi.Name);

                ListViewItem dup = ListViewUtil.FindItem(this.listView_reports, strName, COLUMN_REPORT_TYPE);
                if (dup != null)
                {
                    continue;
                }

                types.Add(strName);
            }

            int nCount = 0;
            int i      = 0;

            foreach (string strType in types)
            {
                string strFileName      = strType + ".xml";
                string strLocalFilePath = Path.Combine(this.MainForm.UserDir, "report_def\\" + strFileName);

                ReportConfigStruct config = null;

                // 从报表配置文件中获得各种配置信息
                // return:
                //      -1  出错
                //      0   没有找到配置文件
                //      1   成功
                int nRet = ReportDefForm.GetReportConfig(strLocalFilePath,
                                                         out config,
                                                         out strError);
                if (nRet == -1 || nRet == 0)
                {
                    return(-1);
                }

                string strReportName = "";
                if (string.IsNullOrEmpty(config.TypeName) == false &&
                    config.TypeName.Length > 3)
                {
                    strReportName = config.TypeName.Substring(3).Trim();
                }
                else
                {
                    strReportName = strType + "_" + (i + 1).ToString();
                }

                string strNameTable = "";
                if (strType == "102")
                {
                    strNameTable = "";  // TODO: 根据现有数据创建名称表
                }
                ListViewItem item = new ListViewItem();
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAME, strReportName);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_FREQ, config.CreateFreq);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_TYPE, strType);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_CFGFILE, strLocalFilePath);
                ListViewUtil.ChangeItemText(item, COLUMN_REPORT_NAMETABLE, strNameTable);
                this.listView_reports.Items.Add(item);

                i++;
                nCount++;
            }

            return(nCount);
        }
Exemple #27
0
        private void toolStripButton_center_modify_Click(object sender, EventArgs e)
        {
            string strError = "";

            if (this.listView_center.SelectedItems.Count == 0)
            {
                strError = "尚未选定要修改的服务器事项";
                goto ERROR1;
            }

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

            string strRefID = ListViewUtil.GetItemText(item, 3);

            if (string.IsNullOrEmpty(strRefID) == true)
            {
                strError = "所选定的事项缺乏参考 ID 值,无法请求服务器端进行修改";
                goto ERROR1;
            }

            CenterServerDialog dlg = new CenterServerDialog();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.Text       = "修改中心服务器";
            dlg.CreateMode = false;
            dlg.ServerName = ListViewUtil.GetItemText(item, 0);
            dlg.ServerUrl  = ListViewUtil.GetItemText(item, 1);
            dlg.UserName   = ListViewUtil.GetItemText(item, 2);
            dlg.RefID      = ListViewUtil.GetItemText(item, 3);
            dlg.Password   = (string)item.Tag;

            dlg.ShowDialog(this);

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

            // 修改
            XmlDocument dom = new XmlDocument();

            dom.LoadXml("<server />");
            DomUtil.SetAttr(dom.DocumentElement, "name", dlg.ServerName);
            DomUtil.SetAttr(dom.DocumentElement, "url", dlg.ServerUrl);
            DomUtil.SetAttr(dom.DocumentElement, "username", dlg.UserName);
            if (dlg.ChangePassword == true)
            {
                DomUtil.SetAttr(dom.DocumentElement, "password", dlg.Password);
            }
            DomUtil.SetAttr(dom.DocumentElement, "refid", dlg.RefID);

            int nRet = SetCenterInfo(
                "modify",
                dom.DocumentElement.OuterXml,
                out strError);

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

            // 刷新显示
            nRet = ListCenter(out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            // 选中刚刚修改的行
            item = ListViewUtil.FindItem(this.listView_center, dlg.RefID, 3);
            if (item != null)
            {
                item.Selected = true;
            }


            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Exemple #28
0
        private void toolStripButton_center_add_Click(object sender, EventArgs e)
        {
            string strError = "";

            int index = -1;

            if (this.listView_center.SelectedIndices.Count > 0)
            {
                index = this.listView_center.SelectedIndices[0];
            }

            string strRefID = Guid.NewGuid().ToString();

            CenterServerDialog dlg = new CenterServerDialog();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.Text       = "添加中心服务器";
            dlg.CreateMode = true;
            dlg.RefID      = strRefID;

            dlg.ShowDialog(this);

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

            // 创建
            XmlDocument dom = new XmlDocument();

            dom.LoadXml("<server />");
            DomUtil.SetAttr(dom.DocumentElement, "name", dlg.ServerName);
            DomUtil.SetAttr(dom.DocumentElement, "url", dlg.ServerUrl);
            DomUtil.SetAttr(dom.DocumentElement, "username", dlg.UserName);
            DomUtil.SetAttr(dom.DocumentElement, "password", dlg.Password);
            DomUtil.SetAttr(dom.DocumentElement, "refid", dlg.RefID);

            int nRet = SetCenterInfo(
                "create",
                dom.DocumentElement.OuterXml,
                out strError);

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

            // 刷新显示
            nRet = ListCenter(out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            // 选中新创建的行
            ListViewItem item = ListViewUtil.FindItem(this.listView_center, dlg.RefID, 3);

            if (item != null)
            {
                item.Selected = true;
            }

            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Exemple #29
0
        void _scanBarcodeForm_BarcodeScaned(object sender, ScanedEventArgs e)
        {
            string strError = "";
            int    nRet     = 0;

            if (string.IsNullOrEmpty(e.Barcode) == true)
            {
                Console.Beep();
                return;
            }

            // 自动切换到 登记 属性页,避免操作者看不到扫入了什么内容
            if (this.tabControl_main.SelectedTab != this.tabPage_register)
            {
                this.tabControl_main.SelectedTab = this.tabPage_register;
            }

            // 清除浮动的错误信息
            this._floatingMessage.Text = "";

            // 把册条码号直接加入行中,然后等待专门的线程来装载刷新
            // 要查重
#if NO
            ListViewItem dup = ListViewUtil.FindItem(this.listView_in, e.Barcode, COLUMN_BARCODE);
            if (dup != null)
            {
                Console.Beep();
                ListViewUtil.SelectLine(dup, true);
                MessageBox.Show(this, "您扫入的册条码号 ‘" + e.Barcode + "’ 在列表中已经存在了,请注意不要重复扫入");
                this._scanBarcodeForm.Activate();
                return;
            }

            ListViewItem item = new ListViewItem();
            ListViewUtil.ChangeItemText(item, COLUMN_BARCODE, e.Barcode);
            this.listView_in.Items.Add(item);
            ListViewUtil.SelectLine(item, true);
            item.EnsureVisible();
#endif
            string strText = e.Barcode;

            // 如果是 ISBN,则新装入一个书目记录
            // TODO: 装入前需要对整个 list 进行查重,如果前面已经有同样 ISBN 的书目,要提醒
            if (QuickChargingForm.IsISBN(ref strText) == true)
            {
#if NO
                RegisterLine line = new RegisterLine(this.entityRegisterControl1);
                line.BiblioBarcode = strText;

                this.entityRegisterControl1.InsertNewLine(0, line, true);
                line.label_color.Focus();

                this.entityRegisterControl1.SetColorList();

                this.entityRegisterControl1.AddTask(line, "search_biblio");

                // 选定刚新增的事项
                this.entityRegisterControl1.SelectItem(line, true);
                // 确保事项可见
                this.entityRegisterControl1.EnsureVisible(line);
#endif
                this.entityRegisterControl1.AddNewBiblio(strText);
            }
            else
            {
                // 当作册条码号进入
                nRet = this.entityRegisterControl1.AddNewEntity(strText,
                                                                out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
            }

            // this.entityRegisterControl1.ActivateThread();
            return;

ERROR1:
            MessageBox.Show(this, strError);
            this._scanBarcodeForm.Focus();
        }
Exemple #30
0
        // 新增模板
        void menu_newTemplatePage_Click(object sender, EventArgs e)
        {
            string strError = "";

REDO_INPUT:
            string strName = DigitalPlatform.InputDlg.GetInput(
                this,
                "请指定模板名",
                "模板名(&T):",
                "",
                this.Font);

            if (strName == null)
            {
                return;
            }

            if (String.IsNullOrEmpty(strName) == true)
            {
                MessageBox.Show(this, "模板名不能为空");
                goto REDO_INPUT;
            }

            // 查重
            ListViewItem dup = ListViewUtil.FindItem(this.listView_templates, strName, 0);

            if (dup != null)
            {
                strError = "模板名 '" + strName + "' 在列表中已经存在,不能重复加入";
                goto ERROR1;
            }

            string strFilePath = "";
            int    nRedoCount  = 0;
            string strDir      = PathUtil.MergePath(this.DataDir, "print_templates");

            PathUtil.CreateDirIfNeed(strDir);
            for (int i = 0; ; i++)
            {
                strFilePath = PathUtil.MergePath(strDir, "template_" + (i + 1).ToString());
                if (File.Exists(strFilePath) == false)
                {
                    // 创建一个0字节的文件
                    try
                    {
                        File.Create(strFilePath).Close();
                    }
                    catch (Exception /* ex*/)
                    {
                        if (nRedoCount > 10)
                        {
                            strError = "创建文件 '" + strFilePath + "' 失败...";
                            goto ERROR1;
                        }
                        nRedoCount++;
                        continue;
                    }
                    break;
                }
            }

            // 清除原来已有的选择
            this.listView_templates.SelectedItems.Clear();

            ListViewItem item = new ListViewItem();

            item.Text = strName;
            item.SubItems.Add(strFilePath);
            this.listView_templates.Items.Add(item);
            item.Selected            = true; // 选上新增的事项
            this.m_bTempaltesChanged = true;

            item.EnsureVisible();   // 滚入视野

            this.m_newCreateTemplateFiles.Add(strFilePath);

            return;

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