Exemplo n.º 1
0
 public void LabelPrintSingleNP(NPBarCode[] NPNum)
 {
     try
     {
         openport("TSC TTP-243E Plus");
         sendcommand("SIZE 100 mm,35 mm");
         sendcommand("GAP 2 mm,0");
         sendcommand("SPEED 4");
         sendcommand("DENSITY 7");
         sendcommand("DIRECTION 0");
         sendcommand("OFFSET 0.00");
         sendcommand("REFERENCE 0,0");
         sendcommand("SET PEEL OFF");
         sendcommand("SET CUTTER OFF");
         sendcommand("HOME");
         clearbuffer();
         downloadpcx("Name.pcx", "NAME.PCX");
         for (int i = NPNum.GetLowerBound(0); i < (NPNum.GetUpperBound(0) + 1); i++)
         {
             int num3;
             clearbuffer();
             string s = "";
             string str2 = "";
             if (NPNum[i].bFrontPiece)
             {
                 int num2;
                 num3 = 1;
                 while (num3 < 7)
                 {
                     s = NPNum[i].strNPNum.Substring(num3, 1);
                     if (Encoding.Default.GetBytes(s).Length > 1)
                     {
                         str2 = str2 + "I";
                         windowsfont(70 + (num3 * 0x23), 0x94, 0x2d, 0, 0, 0, "黑体", s);
                     }
                     else
                     {
                         str2 = str2 + s;
                         num2 = 70 + (num3 * 0x23);
                         printerfont(num2.ToString(), "145", "5", "0", "1", "1", s);
                     }
                     num3++;
                 }
                 barcode("100", "50", "128", "99", "0", "0", "2", "4", NPNum[i].strNPTypeCode + str2);
                 windowsfont(20, 20, 20, 0, 0, 0, "黑体", NPNum[i].strNPTypeName);
                 windowsfont(320, 20, 20, 0, 0, 0, "黑体", NPNum[i].strNPTypeCode + "前");
                 num2 = 15 + (NPNum[i].strNPTypeName.Length * 0x17);
                 sendcommand("BOX 15,15," + num2.ToString() + ",45,3");
                 windowsfont(50, 140, 0x2d, 0, 0, 0, "黑体", NPNum[i].strNPNum.Substring(0, 1));
                 sendcommand("PUTPCX 25,210,\"NAME.PCX\"");
             }
             s = "";
             str2 = "";
             if (NPNum[i].bBackPiece)
             {
                 for (num3 = 1; num3 < 7; num3++)
                 {
                     s = NPNum[i].strNPNum.Substring(num3, 1);
                     if (Encoding.Default.GetBytes(s).Length > 1)
                     {
                         str2 = str2 + "I";
                         windowsfont(480 + (num3 * 0x23), 0x94, 0x2d, 0, 0, 0, "黑体", s);
                     }
                     else
                     {
                         str2 = str2 + s;
                         printerfont((480 + (num3 * 0x23)).ToString(), "145", "5", "0", "1", "1", s);
                     }
                 }
                 barcode("520", "50", "128", "99", "0", "0", "2", "4", NPNum[i].strNPTypeCode + str2);
                 windowsfont(440, 20, 20, 0, 0, 0, "黑体", NPNum[i].strNPTypeName);
                 windowsfont(740, 20, 20, 0, 0, 0, "黑体", NPNum[i].strNPTypeCode + "后");
                 sendcommand("BOX 435,15," + ((0x1b3 + (NPNum[i].strNPTypeName.Length * 0x17))).ToString() + ",45,3");
                 windowsfont(470, 140, 0x2d, 0, 0, 0, "黑体", NPNum[i].strNPNum.Substring(0, 1));
                 sendcommand("PUTPCX 445,210,\"NAME.PCX\"");
             }
             printlabel("1", "1");
         }
         closeport();
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
 private void btn_RePrintTask_Click(object sender, EventArgs e)
 {
     if ((this.dgv_Task.SelectedCells.Count > 0) && (this.dgv_Task.SelectedCells[0].ColumnIndex == 0))
     {
         DataSet npByTaskId = new Task().GetNpByTaskId(this.dgv_Task.SelectedCells[0].Value.ToString());
         TaskList list = new TaskList {
             TaskId = this.dgv_Task.SelectedCells[0].Value.ToString().Trim(),
             TaskUser = this.dgv_Task.Rows[this.dgv_Task.SelectedCells[0].RowIndex].Cells[2].Value.ToString().Trim(),
             TaskTime = this.dgv_Task.Rows[this.dgv_Task.SelectedCells[0].RowIndex].Cells[1].Value.ToString().Trim(),
             PrintArray = new string[npByTaskId.Tables[0].Rows.Count, 4]
         };
         NPBarCode[] nPNum = new NPBarCode[npByTaskId.Tables[0].Rows.Count];
         for (int i = 0; i < npByTaskId.Tables[0].Rows.Count; i++)
         {
             list.PrintArray[i, 0] = (i + 1).ToString();
             list.PrintArray[i, 1] = npByTaskId.Tables[0].Rows[i]["Description"].ToString().Trim();
             list.PrintArray[i, 2] = npByTaskId.Tables[0].Rows[i]["NpNo"].ToString().Trim();
             list.PrintArray[i, 3] = ((DateTime) npByTaskId.Tables[0].Rows[i]["DeadLine"]).ToShortDateString();
             nPNum[i].strNPNum = npByTaskId.Tables[0].Rows[i]["NpNo"].ToString().Trim();
             nPNum[i].strNPTypeCode = npByTaskId.Tables[0].Rows[i]["Code"].ToString().Trim();
             nPNum[i].strNPTypeDescription = npByTaskId.Tables[0].Rows[i]["Description"].ToString().Trim();
             nPNum[i].strNPTypeName = npByTaskId.Tables[0].Rows[i]["CodeName"].ToString().Trim();
             nPNum[i].bFrontPiece = npByTaskId.Tables[0].Rows[i]["IsFront"].ToString().Trim() == "√";
             nPNum[i].bBackPiece = npByTaskId.Tables[0].Rows[i]["IsBack"].ToString().Trim() == "√";
         }
         if (this.cbx_PrintView.Checked)
         {
             list.ShowTaskList();
         }
         else
         {
             list.PrintTaskList();
         }
         if (this.cbx_PrintCodeBar.Checked)
         {
             new Print().LabelPrintTaskNP(this.dgv_Task.SelectedCells[0].Value.ToString().Trim(), nPNum);
         }
     }
 }
Exemplo n.º 3
0
 private void btnNPOK_Click(object sender, EventArgs e)
 {
     NPBarCode code = new NPBarCode {
         strNPNum = this.textNPNum.Text.Trim(),
         strNPTypeCode = this.combNPType.SelectedValue.ToString(),
         strNPTypeDescription = this.combNPType.Text,
         strNPTypeName = this.htNPType[this.combNPType.SelectedValue].ToString()
     };
     if (!this.IsNPInTask(this.textTaskID.Text.Trim(), this.textNPNum.Text.Trim()))
     {
         MessageBox.Show(this, "该车牌不在该任务单内!", "输入错误!");
     }
     else
     {
         if (this.checkFrontPiece.Checked)
         {
             ListViewItem item = new ListViewItem();
             item.Text = (this.listVwNPDetails.Items.Count + 1).ToString();
             item.SubItems.Add(this.textNPNum.Text.Trim());
             item.SubItems.Add("前片");
             this.listVwNPDetails.Items.Add(item);
             code.bFrontPiece = true;
         }
         else
         {
             code.bFrontPiece = false;
         }
         if (this.checkBackPiece.Checked)
         {
             ListViewItem item2 = new ListViewItem();
             item2.Text = (this.listVwNPDetails.Items.Count + 1).ToString();
             item2.SubItems.Add(this.textNPNum.Text.Trim());
             item2.SubItems.Add("后片");
             this.listVwNPDetails.Items.Add(item2);
             code.bBackPiece = true;
         }
         else
         {
             code.bBackPiece = false;
         }
         this.NPList.Add(code);
     }
 }
Exemplo n.º 4
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     NPBarCode[] nPNum = new NPBarCode[this.NPList.Count];
     Print print = new Print();
     IEnumerator enumerator = this.NPList.GetEnumerator();
     for (int i = 0; enumerator.MoveNext(); i++)
     {
         nPNum[i] = (NPBarCode) enumerator.Current;
     }
     print.LabelPrintSingleNP(nPNum);
     this.clear();
 }
Exemplo n.º 5
0
 private void btn_Print_Click(object sender, EventArgs e)
 {
     if (this.Lvw_Task.CheckedItems.Count == 0)
     {
         MessageBox.Show("请选择要打印的生产任务单", "生产管理", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     else
     {
         try
         {
             foreach (ListViewItem item in this.Lvw_Task.CheckedItems)
             {
                 DataSet npByTaskId = new Task().GetNpByTaskId(item.Text.Trim());
                 TaskList list = new TaskList {
                     TaskId = item.Text.Trim(),
                     TaskUser = item.SubItems[2].Text.Trim(),
                     TaskTime = item.SubItems[1].Text.Trim(),
                     PrintArray = new string[npByTaskId.Tables[0].Rows.Count, 4]
                 };
                 NPBarCode[] nPNum = new NPBarCode[npByTaskId.Tables[0].Rows.Count];
                 for (int i = 0; i < npByTaskId.Tables[0].Rows.Count; i++)
                 {
                     list.PrintArray[i, 0] = (i + 1).ToString();
                     list.PrintArray[i, 1] = npByTaskId.Tables[0].Rows[i]["Description"].ToString().Trim();
                     list.PrintArray[i, 2] = npByTaskId.Tables[0].Rows[i]["NpNo"].ToString().Trim();
                     list.PrintArray[i, 3] = ((DateTime) npByTaskId.Tables[0].Rows[i]["DeadLine"]).ToShortDateString();
                     nPNum[i].strNPNum = npByTaskId.Tables[0].Rows[i]["NpNo"].ToString().Trim();
                     nPNum[i].strNPTypeCode = npByTaskId.Tables[0].Rows[i]["Code"].ToString().Trim();
                     nPNum[i].strNPTypeDescription = npByTaskId.Tables[0].Rows[i]["Description"].ToString().Trim();
                     nPNum[i].strNPTypeName = npByTaskId.Tables[0].Rows[i]["CodeName"].ToString().Trim();
                     nPNum[i].bFrontPiece = npByTaskId.Tables[0].Rows[i]["IsFront"].ToString().Trim() == "√";
                     nPNum[i].bBackPiece = npByTaskId.Tables[0].Rows[i]["IsBack"].ToString().Trim() == "√";
                 }
                 if (this.cbx_PrintView.Checked)
                 {
                     list.ShowTaskList();
                 }
                 else
                 {
                     list.PrintTaskList();
                 }
                 if (this.cbx_PrintCodeBar.Checked)
                 {
                     new Print().LabelPrintTaskNP(item.Text.Trim(), nPNum);
                 }
                 item.Checked = false;
                 MessageBox.Show("生产任务单:" + item.Text.Trim() + " 打印完毕", "打印条码", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             }
         }
         catch (Exception exception)
         {
             MessageBox.Show("打印时发生错误" + '\n' + exception.Message, "打印条码", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
 }