private PrintHelper.Report GenerateReport() { PrintHelper.Report report = new PrintHelper.Report(); try { report.ItemName = _item.Name; report.ItemCategory = "干化学"; report.User = LoginWindow._userAccount.UserName; report.Unit = _item.Unit; report.Date = _date.ToString("yyyy-MM-dd HH:mm:ss"); DataTable dt = _resultTable.GetAsDataTable(string.Empty, string.Empty, 6, _AllNumber); if (dt != null && dt.Rows.Count > 0) { List <tlsTtResultSecond> dtList = Global.TableToEntity <tlsTtResultSecond>(dt); if (dtList.Count > 0) { for (int i = dtList.Count - 1; i >= 0; i--) { report.SampleName.Add(dtList[i].FoodName); report.SampleNum.Add(String.Format("{0:D5}", dtList[i].SampleCode)); report.JudgmentTemp.Add(dtList[i].Result); report.Result.Add(dtList[i].CheckValueInfo); } } } } catch (Exception ex) { MessageBox.Show("异常(GenerateReport):\n" + ex.Message); } return(report); }
private void ButtonPrint_Click(object sender, RoutedEventArgs e) { try { PrintHelper.Report report = GenerateReport(); byte[] buffer = report.GeneratePrintBytes(); Message msg = new Message() { what = MsgCode.MSG_PRINT, str1 = Global.strPRINTPORT, data = buffer, arg1 = 0, arg2 = buffer.Length }; Global.printThread.SendMessage(msg, _msgThread); } catch (Exception ex) { MessageBox.Show("打印时出现异常:" + ex.Message, "系统提示"); } }
private PrintHelper.Report GenerateReport() { PrintHelper.Report report = new PrintHelper.Report() { ItemName = _item.Name, ItemCategory = "重金属", User = LoginWindow._userAccount.UserName, Unit = _item.Unit, Date = _date.ToString("yyyy-MM-dd HH:mm:ss") }; //report.Judgment = item.Hole[0].SampleName; int sampleNum = _item.SampleNum; for (int i = 0; i < 1; ++i) { report.SampleName.Add(_item.Hole[i].SampleName); report.SampleNum.Add(String.Format("{0:D5}", sampleNum++)); report.JudgmentTemp.Add(string.Empty + _UnqualifiedValue); report.Result.Add(string.Empty + _Value); } return(report); }