예제 #1
0
파일: Frm_Query.cs 프로젝트: TGHGH/MES-CAR
 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);
         }
     }
 }
예제 #2
0
파일: Frm_Prod.cs 프로젝트: TGHGH/MES-CAR
 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);
         }
     }
 }