Beispiel #1
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="noteId"></param>
        /// -1 出错
        /// 0 取消打印
        /// 1 成功
        private int Print(Note note, out string strError)
        {
            strError = "";

            // 鼠标设为等待状态
            Cursor oldCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            // 输出打印文件
            this.OutputPrintFile(note);

            CardPrintForm form = new CardPrintForm();

            form.PrinterInfo   = new PrinterInfo();
            form.CardFilename  = this._printFilename; // 卡片文件名
            form.ShowInTaskbar = false;
            form.WindowState   = FormWindowState.Minimized;
            form.Show();  // 必须这样写 2020/2/21 增加备注
            try
            {
                return(form.PrintFromCardFile(false,
                                              out strError));
            }
            finally
            {
                form.Close();
                this.Cursor = oldCursor;
            }
        }
Beispiel #2
0
        private void toolStripMenuItem_print_Click(object sender, EventArgs e)
        {
            string strError = "";

            outputPrintFile();

            CardPrintForm form = new CardPrintForm();

            form.PrinterInfo  = new PrinterInfo();
            form.CardFilename = "print.xml";  // 卡片文件名

            form.WindowState = FormWindowState.Minimized;
            form.Show();
            int nRet = form.PrintFromCardFile(false);

            if (nRet == -1)
            {
                form.WindowState = FormWindowState.Normal;
                strError         = strError + "\r\n\r\n以下内容未能成功打印:\r\n";
                goto ERROR1;
            }
            form.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Beispiel #3
0
        private void toolStripMenuItem_printPreview_Click(object sender, EventArgs e)
        {
            Cursor oldCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            outputPrintFile();
            CardPrintForm dlg = new CardPrintForm();

            dlg.CardFilename = printFilename;  // 卡片文件名
            dlg.PrintPreviewFromCardFile();

            this.Cursor = oldCursor;
        }
Beispiel #4
0
        /// <summary>
        /// 测试打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ToolStripMenuItem_test_Click(object sender, EventArgs e)
        {
            string strError = "";

            string        line = null;
            StringBuilder sb   = new StringBuilder();

            string printFile = Application.StartupPath + "//print.txt";

            if (File.Exists(printFile) == false)
            {
                MessageBox.Show(this, "打印不存在");
                return;
            }

            using (StreamReader reader = new StreamReader("print.txt", Encoding.UTF8))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    sb.Append("<p>").Append(line).Append("</p>").AppendLine();
                }
            }

            using (StreamWriter writer = new StreamWriter("print.xml", false, Encoding.UTF8))
            {
                writer.Write(WrapString(sb.ToString()));
            }

            CardPrintForm form = new CardPrintForm();

            form.PrinterInfo  = new PrinterInfo();
            form.CardFilename = "print.xml";  // 卡片文件名

            form.WindowState = FormWindowState.Minimized;
            form.Show();
            int nRet = form.PrintFromCardFile(false, out strError);

            if (nRet == -1)
            {
                form.WindowState = FormWindowState.Normal;
                strError         = strError + "\r\n\r\n以下内容未能成功打印:\r\n" + sb.ToString();
                goto ERROR1;
            }
            form.Close();
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Beispiel #5
0
        /// <summary>
        /// 打印预约
        /// </summary>
        /// <param name="noteId"></param>
        private void PrintPreview(Note note)
        {
            Cursor oldCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            string printTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            this.OutputPrintFile(note);
            CardPrintForm dlg = new CardPrintForm();

            dlg.CardFilename = this._printFilename;  // 卡片文件名
            dlg.PrintPreviewFromCardFile();

            this.Cursor = oldCursor;
        }
Beispiel #6
0
        private void toolStripMenuItem_print_Click(object sender, EventArgs e)
        {
            Cursor oldCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;

            string strError = "";

            outputPrintFile();

            CardPrintForm form = new CardPrintForm();

            form.PrinterInfo   = new PrinterInfo();
            form.CardFilename  = printFilename; // 卡片文件名
            form.ShowInTaskbar = false;

            form.WindowState = FormWindowState.Minimized;
            form.Show();
            int nRet = form.PrintFromCardFile(false);

            if (nRet == -1)
            {
                form.WindowState = FormWindowState.Normal;
                strError         = strError + "\r\n\r\n以下内容未能成功打印:\r\n";
                goto ERROR1;
            }
            form.Close();

            ListViewItem[] items = new ListViewItem[this.listView_results.SelectedItems.Count];
            this.listView_results.SelectedItems.CopyTo(items, 0);
            changeAcctiveItemPrintState(items);

            this.Cursor = oldCursor;
            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Beispiel #7
0
        private void toolStripMenuItem_printPreview_Click(object sender, EventArgs e)
        {
            CardPrintForm dlg = new CardPrintForm();

            dlg.CardFilename = "print.xml";  // 卡片文件名
            dlg.PrintPreviewFromCardFile();


            /*
             * if (printDialog_prep.ShowDialog(this) != DialogResult.OK)
             *  return;
             *
             * try
             * {
             *  outputPrintFile();
             *  printDocument_prep.PrinterSettings.PrinterName = printDialog_prep.PrinterSettings.PrinterName;
             *  printPreviewDialog_prep.ShowDialog(this);
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show(ex.Message);
             * }
             */
        }