Exemplo n.º 1
0
        private void Printed(IAsyncResult result)
        {
            AysnPrintDelegate aysnDelegate = result.AsyncState as AysnPrintDelegate;

            if (aysnDelegate != null)
            {
                string rtn = "";
                try
                {
                    rtn = aysnDelegate.EndInvoke(result);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    return;
                }
                int    index        = 0;
                string machine_name = rtn.Substring(0, rtn.IndexOf('^'));
                rtn = rtn.Substring(rtn.IndexOf('^') + 1);
                string sql = "";
                sql = "update device set status=0 where name='" + machine_name + "'";
                if (rtn.Length >= 4)
                {
                    MessageBox.Show(rtn);

                    OverOrErr = 2;
                    //this.listView1.Items[one.index].SubItems[7].Text = "打印结束";
                    thread_set_progress.Abort();
                }
                else
                {
                    OverOrErr = 1;
                    // index = Convert.ToInt32(rtn);
                    //this.label3.Text = ":空闲";
                    // sql = "update device set status=0 where name='" + this.listView1.Items[index].SubItems[8].Text + "'";
                    // thread_set_progress.Abort();
                }

                func.ExecuteSql(sql);
            }
            else
            {
                MessageBox.Show("打印失败");
            }
        }
Exemplo n.º 2
0
        public IAsyncResult BeginPrinting(string [] taskarray, List <string> listCode, PrintStatus one, int printer_type)
        {
            AysnPrintDelegate PrintDelegate = null;

            printer = new TtoPrinter();
            printer.initPrintData(taskarray, listCode, one);
            if (printer_type == 0)
            {
                PrintDelegate = new AysnPrintDelegate(printer.DuoMiNuo);
            }
            else if (printer_type == 1)
            {
                PrintDelegate = new AysnPrintDelegate(printer.WDJ);
            }
            else
            {
                PrintDelegate = new AysnPrintDelegate(printer.Markem);
            }
            return(PrintDelegate.BeginInvoke(Printed, PrintDelegate));
        }