c# 编写的sato条码打印程序,有时在打印时会跳纸,少出来几个条码,有时是连续几个不出来,有时是少出来第一个或中间的几个条码,请帮忙看看这程序有什么问题,或者哪里可以改进避免这类问题发生。 for (int i = 0; i <= printcount - 1; i++)
{ string seqNo = GetSeq().ToString("d4");
string reelNo = textBox2.Text + YM + day + seqNo;
textBox7.Text = reelNo;
string ReelNo = receiveDate + seqNo;
string ipAddress = "10.3.14.42";
int hPort = 9100;
String c, stx, etx;
c = ((char)27).ToString();
stx = ((char)2).ToString();
etx = ((char)3).ToString();
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
client.Connect(ipAddress, hPort);
System.IO.StreamWriter writer = new System.IO.StreamWriter(client.GetStream());
StringBuilder SEND = new StringBuilder();
SEND.Append(stx + c + "A");
SEND.Append(c + "H600" + c + "V0005" + c + "L0102" + c + "XM" + textBox2.Text);
SEND.Append(c + "H600" + c + "V0050" + c + "L0102" + c + "XMINT Qty: " + textBox3.Text);
SEND.Append(c + "H600" + c + "V0100" + c + "L0102" + c + "XMBox Qty: " + textBox5.Text);
SEND.Append(c + "H600" + c + "V0155" + c + "L0102" + c + "XMLot: " + textBox1.Text);
SEND.Append(c + "H600" + c + "V0205" + c + "L0102" + c + "XMPrinted: " + DateTime.Now.ToString());
SEND.Append(c + "H600" + c + "V0260" + c + "L0102" + c + "XMSeq: " + seqNo);
SEND.Append(c + "H900" + c + "V0260" + c + "L0102" + c + "XMRecDate: " + receiveDate);
SEND.Append(c + "H600" + c + "V0315" + c + "L0102" + c + "XMExp: " + firstExpire);
SEND.Append(c + "H347" + c + "V0260" + c + "L0203" + c + "XM" + ing);
SEND.Append(c + "H1000" + c + "V0005" + c + "L0203" + c + "XM" + textBox8.Text);
SEND.Append(c + "H1100" + c + "V0100" + c + "L0408" + c + "XM" + MM);
string strqr = "," + textBox2.Text + "," + textBox5.Text + "," + DateTime.Now.ToString() + "," + ReelNo;
SEND.Append(c + "H347" + c + "V0040" + c + "BQ1005,0" + strqr);
SEND.Append(c + "Q1" + c + "Z" + etx); //Open connection;
writer.Write(SEND);
writer.Flush();
writer.Close();
client.Close();C#sato
{ string seqNo = GetSeq().ToString("d4");
string reelNo = textBox2.Text + YM + day + seqNo;
textBox7.Text = reelNo;
string ReelNo = receiveDate + seqNo;
string ipAddress = "10.3.14.42";
int hPort = 9100;
String c, stx, etx;
c = ((char)27).ToString();
stx = ((char)2).ToString();
etx = ((char)3).ToString();
System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
client.Connect(ipAddress, hPort);
System.IO.StreamWriter writer = new System.IO.StreamWriter(client.GetStream());
StringBuilder SEND = new StringBuilder();
SEND.Append(stx + c + "A");
SEND.Append(c + "H600" + c + "V0005" + c + "L0102" + c + "XM" + textBox2.Text);
SEND.Append(c + "H600" + c + "V0050" + c + "L0102" + c + "XMINT Qty: " + textBox3.Text);
SEND.Append(c + "H600" + c + "V0100" + c + "L0102" + c + "XMBox Qty: " + textBox5.Text);
SEND.Append(c + "H600" + c + "V0155" + c + "L0102" + c + "XMLot: " + textBox1.Text);
SEND.Append(c + "H600" + c + "V0205" + c + "L0102" + c + "XMPrinted: " + DateTime.Now.ToString());
SEND.Append(c + "H600" + c + "V0260" + c + "L0102" + c + "XMSeq: " + seqNo);
SEND.Append(c + "H900" + c + "V0260" + c + "L0102" + c + "XMRecDate: " + receiveDate);
SEND.Append(c + "H600" + c + "V0315" + c + "L0102" + c + "XMExp: " + firstExpire);
SEND.Append(c + "H347" + c + "V0260" + c + "L0203" + c + "XM" + ing);
SEND.Append(c + "H1000" + c + "V0005" + c + "L0203" + c + "XM" + textBox8.Text);
SEND.Append(c + "H1100" + c + "V0100" + c + "L0408" + c + "XM" + MM);
string strqr = "," + textBox2.Text + "," + textBox5.Text + "," + DateTime.Now.ToString() + "," + ReelNo;
SEND.Append(c + "H347" + c + "V0040" + c + "BQ1005,0" + strqr);
SEND.Append(c + "Q1" + c + "Z" + etx); //Open connection;
writer.Write(SEND);
writer.Flush();
writer.Close();
client.Close();C#sato
解决方案 »
- 新手请教简单问题。
- lock对性能有影响,那如何让多线程尽可能并发的输出不重复的数字呢?
- 求一TeeChart的属性设置,谢谢谢谢啊
- 一切正常,突然 Stop !!
- 窗体中的timer start后在一个触发事件中stop,然后再start,timer.tick事件就不执行了。
- 在C#的代码编辑状态下,怎样得到 javascript 中 confirm 的返回值
- 关于除法运算,非常简单的问题
- 在combobox的textupdate事件响应里,如何把EventArgs变成一个有用的类型?
- 想实现Delphi里的DbGrid的功能,在C#能实现吗?
- supersocket缓存配置
- C# socket发送结构体数组
- 【求助】如何在UI界面中等待另一个线程结束后再继续执行下面的程序,UI界面不能挂死
是在结尾添加一句 System.Threading.Thread.Sleep(1000); 吗
Socket .发送太快造成丢包了吧