Print.cs 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. using Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using com.hnshituo.core.webapp.vo;
  11. namespace MeterPlugInLibrary
  12. {
  13. public class Print
  14. {
  15. //MeterWorkCarActualFirstService firstService = new MeterWorkCarActualFirstService();
  16. QRCode qr = new QRCode();
  17. /// <summary>
  18. /// 打印纸数量递减
  19. /// </summary>
  20. /// <param name="strPntID"></param>
  21. public void PrintNum(string strPntID)
  22. {//update jl_pointinfo t set t.remainpaper=t.remainpaper-1 where t.pointid='CAR04'
  23. try
  24. {
  25. MeterWorkMonitorService monitorService = new MeterWorkMonitorService();
  26. RESTfulResult<string> rm = monitorService.doUpdateWf(new MeterWorkMonitor { pointNo = strPntID, printNum = PbCache.monitor.printNum - 1 });
  27. if (!rm.Succeed)
  28. {
  29. string log = "打印纸数量递减错误!" + rm.ResultMessage;
  30. WriteLog(log);
  31. }
  32. }
  33. catch (Exception exp)
  34. {
  35. WriteLog("打印纸数量递减写入异常!" + exp.Message);
  36. }
  37. }
  38. /// <summary>
  39. /// 结净打印
  40. /// </summary>
  41. /// <param name="e"></param>
  42. /// <param name="_strCarNo"></param>
  43. public void PrintAllPage(System.Drawing.Printing.PrintPageEventArgs e, MeterWorkCarActual first, string strCode)
  44. {
  45. try
  46. {
  47. Image img = qr.rtImgQRCode(strCode);
  48. int oX = 0, oY = -2; //偏移量
  49. int[] xPos = { 0, 65, 140, 210, 280 };
  50. int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420 };
  51. Font headFont = new Font("Arial", 10);
  52. Font txtFont = new Font("Arial", 9);
  53. Font txtFont1 = new Font("Arial", 8);//注的字体
  54. Font MemoFont = new Font("Arial", 12);
  55. Font txtFont2 = new Font("Arial", 7);
  56. Font txtFontWeight = new Font("Arial", 9);
  57. Pen blackPen = new Pen(Color.Black, 2);
  58. StringFormat drawFormat1 = new StringFormat();
  59. drawFormat1.Alignment = StringAlignment.Center;
  60. drawFormat1.LineAlignment = StringAlignment.Center;
  61. StringFormat drawFormat3 = new StringFormat();//注的字体
  62. drawFormat3.Alignment = StringAlignment.Near;
  63. drawFormat3.LineAlignment = StringAlignment.Near;
  64. StringFormat drawFormat5 = new StringFormat();//注的字体
  65. drawFormat5.Alignment = StringAlignment.Center;
  66. drawFormat5.LineAlignment = StringAlignment.Near;
  67. StringFormat drawFormat2 = new StringFormat();
  68. drawFormat2.Alignment = StringAlignment.Near;
  69. drawFormat2.LineAlignment = StringAlignment.Center;
  70. StringFormat drawFormat4 = new StringFormat();//
  71. drawFormat4.Alignment = StringAlignment.Far;
  72. drawFormat4.LineAlignment = StringAlignment.Far;
  73. //*
  74. Rectangle rec = new Rectangle(oX + xPos[0], oY + yPos[0], xPos[4] - xPos[0], yPos[1] - yPos[0]);
  75. e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
  76. rec = new Rectangle(oX + xPos[0], oY + yPos[1], xPos[4] - xPos[0], yPos[2] - yPos[1]);
  77. e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
  78. //e.Graphics.DrawString("凌字311-005", txtFont2, Brushes.Black, rec, drawFormat4);
  79. //*/
  80. //-----------------------------
  81. //-----------------------正文
  82. rec.X = xPos[0] + oX; //35
  83. rec.Y = yPos[2] + oY;
  84. rec.Width = xPos[1] - xPos[0];
  85. rec.Height = 20;
  86. e.Graphics.DrawString("流水号", txtFont2, Brushes.Black, rec, drawFormat1); //35
  87. rec.X = xPos[1] + oX;
  88. rec.Y = yPos[2] + oY;
  89. rec.Width = xPos[2] - xPos[1];
  90. rec.Height = 20;
  91. e.Graphics.DrawString(first.actualNo, txtFont2, Brushes.Black, rec, drawFormat1); //流水号值
  92. rec.X = xPos[0] + oX;
  93. rec.Y = yPos[3] + oY;
  94. rec.Width = xPos[1] - xPos[0];
  95. rec.Height = 20;
  96. e.Graphics.DrawString("预报编号", txtFont2, Brushes.Black, rec, drawFormat1);
  97. rec.X = xPos[1] + oX;
  98. rec.Y = yPos[3] + oY;
  99. rec.Width = xPos[2] - xPos[1];
  100. rec.Height = 20;
  101. e.Graphics.DrawString(first.predictionNo, txtFont2, Brushes.Black, rec, drawFormat1); //预报编号值
  102. rec.X = xPos[0] + oX;
  103. rec.Y = yPos[4] + oY;
  104. rec.Width = xPos[1] - xPos[0];
  105. rec.Height = 20;
  106. e.Graphics.DrawString("车号", txtFont2, Brushes.Black, rec, drawFormat1);
  107. rec.X = xPos[1] + oX;
  108. rec.Y = yPos[4] + oY;
  109. rec.Width = xPos[2] - xPos[1];
  110. rec.Height = 20;
  111. e.Graphics.DrawString(first.carNo, txtFont2, Brushes.Black, rec, drawFormat1); //车号
  112. rec.X = xPos[0] + oX;
  113. rec.Y = yPos[5] + oY;
  114. rec.Width = xPos[1] - xPos[0];
  115. rec.Height = 20;
  116. e.Graphics.DrawString("检斤类型", txtFont2, Brushes.Black, rec, drawFormat1);
  117. rec.X = xPos[1] + oX;
  118. rec.Y = yPos[5] + oY;
  119. rec.Width = xPos[2] - xPos[1];
  120. rec.Height = 20;
  121. e.Graphics.DrawString(first.meterTypeName, txtFont2, Brushes.Black, rec, drawFormat1); //检斤类型值
  122. rec.X = xPos[0] + oX;
  123. rec.Y = yPos[6] + oY;
  124. rec.Width = xPos[1] - xPos[0];
  125. rec.Height = 20;
  126. e.Graphics.DrawString("毛重(t)", txtFont2, Brushes.Black, rec, drawFormat1);
  127. rec.X = xPos[1] + oX;
  128. rec.Y = yPos[6] + oY;
  129. rec.Width = xPos[2] - xPos[1];
  130. rec.Height = 20;
  131. //e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFont2, Brushes.Black, rec, drawFormat1); //车号
  132. switch (first.meterTypeNo)
  133. {
  134. case "0":
  135. e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
  136. break;
  137. case "x":
  138. e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
  139. break;
  140. default:
  141. e.Graphics.DrawString("", txtFontWeight, Brushes.Black, rec, drawFormat1);
  142. break;
  143. }
  144. rec.X = xPos[0] + oX;
  145. rec.Y = yPos[7] + oY;
  146. rec.Width = xPos[1] - xPos[0];
  147. rec.Height = 20;
  148. e.Graphics.DrawString("皮重(t)", txtFont2, Brushes.Black, rec, drawFormat1);
  149. rec.X = xPos[1] + oX;
  150. rec.Y = yPos[7] + oY;
  151. rec.Width = xPos[2] - xPos[1];
  152. rec.Height = 20;
  153. switch (first.meterTypeNo)
  154. {
  155. case "0":
  156. e.Graphics.DrawString("", txtFontWeight, Brushes.Black, rec, drawFormat1);
  157. break;
  158. case "x":
  159. e.Graphics.DrawString((first.tareWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
  160. break;
  161. default:
  162. e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
  163. break;
  164. }
  165. rec.X = xPos[0] + oX;
  166. rec.Y = yPos[8] + oY;
  167. rec.Width = xPos[1] - xPos[0];
  168. rec.Height = 20;
  169. e.Graphics.DrawString("净重(t)", txtFont2, Brushes.Black, rec, drawFormat1);
  170. rec.X = xPos[1] + oX;
  171. rec.Y = yPos[8] + oY;
  172. rec.Width = xPos[2] - xPos[1];
  173. rec.Height = 20;
  174. switch (first.meterTypeNo)
  175. {
  176. case "x":
  177. e.Graphics.DrawString((first.netWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1);
  178. break;
  179. default:
  180. e.Graphics.DrawString("", txtFontWeight, Brushes.Black, rec, drawFormat1);
  181. break;
  182. }
  183. #region 二维码部分
  184. /*
  185. rec.X = xPos[2] + oX + 2;
  186. rec.Y = yPos[2] + oY + 2;
  187. rec.Width = xPos[4] - xPos[2] - 4;
  188. rec.Height = 136; //140-4
  189. //*/
  190. e.Graphics.DrawImage(img, xPos[2] + oX + 5, yPos[2] + oY + 5, xPos[4] - xPos[2] - 10, 128);
  191. #endregion
  192. rec.X = xPos[0] + oX;
  193. rec.Y = yPos[9] + oY;
  194. rec.Width = xPos[1] - xPos[0];
  195. rec.Height = 20;
  196. e.Graphics.DrawString("附加重量(t)", txtFont2, Brushes.Black, rec, drawFormat1);
  197. rec.X = xPos[1] + oX;
  198. rec.Y = yPos[9] + oY;
  199. rec.Width = xPos[2] - xPos[1];
  200. rec.Height = 20;
  201. if (first.addWeight == null)
  202. {
  203. e.Graphics.DrawString("", txtFont2, Brushes.Black, rec, drawFormat1); //附加重量
  204. }
  205. else if (first.meterTypeNo == "x" || first.meterTypeNo == "0") //结净或者过毛
  206. {
  207. e.Graphics.DrawString((first.addWeight.Value / 1000) + "", txtFontWeight, Brushes.Black, rec, drawFormat1); //附加重量
  208. }
  209. rec.X = xPos[0] + oX;
  210. rec.Y = yPos[10] + oY;
  211. rec.Width = xPos[1] - xPos[0];
  212. rec.Height = 20;
  213. e.Graphics.DrawString("物资名称", txtFont2, Brushes.Black, rec, drawFormat1);
  214. rec.X = xPos[1] + oX;
  215. rec.Y = yPos[10] + oY;
  216. rec.Width = xPos[4] - xPos[1];
  217. rec.Height = 20;
  218. e.Graphics.DrawString(first.matterName, txtFont2, Brushes.Black, rec, drawFormat1); //物资名称
  219. rec.X = xPos[0] + oX;
  220. rec.Y = yPos[11] + oY;
  221. rec.Width = xPos[1] - xPos[0];
  222. rec.Height = 20;
  223. e.Graphics.DrawString("来源", txtFont2, Brushes.Black, rec, drawFormat1);
  224. rec.X = xPos[1] + oX;
  225. rec.Y = yPos[11] + oY;
  226. rec.Width = xPos[4] - xPos[1];
  227. rec.Height = 20;
  228. e.Graphics.DrawString(first.forwardingUnitName, txtFont2, Brushes.Black, rec, drawFormat1); //来源值
  229. rec.X = xPos[0] + oX;
  230. rec.Y = yPos[12] + oY;
  231. rec.Width = xPos[1] - xPos[0];
  232. rec.Height = 20;
  233. e.Graphics.DrawString("去向", txtFont2, Brushes.Black, rec, drawFormat1);
  234. rec.X = xPos[1] + oX;
  235. rec.Y = yPos[12] + oY;
  236. rec.Width = xPos[4] - xPos[1];
  237. rec.Height = 20;
  238. e.Graphics.DrawString(first.receivingUintName, txtFont2, Brushes.Black, rec, drawFormat1); //去向值
  239. rec.X = xPos[0] + oX;
  240. rec.Y = yPos[13] + oY;
  241. rec.Width = xPos[1] - xPos[0];
  242. rec.Height = 20;
  243. e.Graphics.DrawString("计量时间", txtFont2, Brushes.Black, rec, drawFormat1);
  244. rec.X = xPos[1] + oX;
  245. rec.Y = yPos[13] + oY;
  246. rec.Width = xPos[4] - xPos[1];
  247. rec.Height = 20;
  248. //first.meterTypeNo == "0" ? "毛重" : "皮重";
  249. switch (first.meterTypeNo)
  250. {
  251. case "0":
  252. e.Graphics.DrawString(first.grossTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont2, Brushes.Black, rec, drawFormat1);
  253. break;
  254. case "x":
  255. e.Graphics.DrawString(first.netTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont2, Brushes.Black, rec, drawFormat1);
  256. break;
  257. default:
  258. e.Graphics.DrawString(first.tareTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont2, Brushes.Black, rec, drawFormat1);
  259. break;
  260. }
  261. rec.X = xPos[0] + oX;
  262. rec.Y = yPos[14] + oY;
  263. rec.Width = xPos[1] - xPos[0];
  264. rec.Height = 20;
  265. e.Graphics.DrawString("规格", txtFont2, Brushes.Black, rec, drawFormat1);
  266. rec.X = xPos[1] + oX;
  267. rec.Y = yPos[14] + oY;
  268. rec.Width = xPos[4] - xPos[1];
  269. rec.Height = 20;
  270. e.Graphics.DrawString(first.specName, txtFont2, Brushes.Black, rec, drawFormat1);
  271. //*/
  272. rec.X = xPos[0] + oX;
  273. rec.Y = yPos[15] + oY;
  274. rec.Width = xPos[4] - xPos[0];
  275. rec.Height = 20;
  276. e.Graphics.DrawString("注:本小票不作为结算凭证,请注意保管!", txtFont2, Brushes.Black, rec, drawFormat3); //注意
  277. rec.X = xPos[0] + oX;
  278. rec.Y = yPos[16] + oY;
  279. rec.Width = xPos[4] - xPos[0];
  280. rec.Height = 20;
  281. e.Graphics.DrawString("打票时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtFont2, Brushes.Black, rec, drawFormat3);//注意//Now.ToString("yyyy-MM-dd HH:mm:ss")
  282. //打印横线
  283. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[4] + oX, yPos[2] + oY);
  284. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[3] + oY, xPos[2] + oX, yPos[3] + oY);
  285. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[4] + oY, xPos[2] + oX, yPos[4] + oY);
  286. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[5] + oY, xPos[2] + oX, yPos[5] + oY);
  287. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[6] + oY, xPos[2] + oX, yPos[6] + oY);
  288. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[7] + oY, xPos[2] + oX, yPos[7] + oY);
  289. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[8] + oY, xPos[2] + oX, yPos[8] + oY);
  290. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[9] + oY, xPos[4] + oX, yPos[9] + oY);
  291. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[10] + oY, xPos[4] + oX, yPos[10] + oY);
  292. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[11] + oY, xPos[4] + oX, yPos[11] + oY);
  293. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[12] + oY, xPos[4] + oX, yPos[12] + oY);
  294. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[13] + oY, xPos[4] + oX, yPos[13] + oY);
  295. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[14] + oY, xPos[4] + oX, yPos[14] + oY);
  296. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[15] + oY, xPos[4] + oX, yPos[15] + oY);
  297. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[16] + oY, xPos[4] + oX, yPos[16] + oY);
  298. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[17] + oY, xPos[4] + oX, yPos[17] + oY);
  299. //打印竖线
  300. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[0] + oX, yPos[17] + oY);
  301. e.Graphics.DrawLine(blackPen, xPos[1] + oX, yPos[2] + oY, xPos[1] + oX, yPos[15] + oY);
  302. e.Graphics.DrawLine(blackPen, xPos[2] + oX, yPos[2] + oY, xPos[2] + oX, yPos[9] + oY);
  303. e.Graphics.DrawLine(blackPen, xPos[4] + oX, yPos[2] + oY, xPos[4] + oX, yPos[17] + oY);
  304. PrintNum(PbCache.sportInfo.baseSpotNo);
  305. WriteLog("完成打印!" + PbCache.sportInfo.baseSpotNo);
  306. }
  307. catch (Exception exp)
  308. {
  309. WriteLog("计量打印异常!" + exp.Message);
  310. }
  311. }
  312. /// <summary>
  313. /// 结净打印
  314. /// </summary>
  315. /// <param name="e"></param>
  316. /// <param name="_strCarNo"></param>
  317. public void PrintPage(System.Drawing.Printing.PrintPageEventArgs e, MeterWorkCarActual first, string strCode)
  318. {
  319. try
  320. {
  321. Image img = qr.rtImgQRCode(strCode);
  322. int oX = 0, oY = -2; //偏移量
  323. int[] xPos = { 0, 65, 125, 205, 265 };
  324. int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 420, 440, 420, 440, 460 };
  325. //int[] xPos = { 0, 65, 110, 170, 220 };
  326. //int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 160, 180, 220, 240, 260, 280, 300, 320, 350, 390, 410, 430, 450, 470, 490 };
  327. Font headFont = new Font("Arial", 10);
  328. Font txtFont = new Font("Arial", 9);
  329. Font txtFont1 = new Font("Arial", 8);//注的字体
  330. Font MemoFont = new Font("Arial", 12);
  331. Font txtFont2 = new Font("Arial", 7);
  332. Pen blackPen = new Pen(Color.Black, 2);
  333. StringFormat drawFormat1 = new StringFormat();
  334. drawFormat1.Alignment = StringAlignment.Center;
  335. drawFormat1.LineAlignment = StringAlignment.Center;
  336. StringFormat drawFormat3 = new StringFormat();//注的字体
  337. drawFormat3.Alignment = StringAlignment.Near;
  338. drawFormat3.LineAlignment = StringAlignment.Near;
  339. StringFormat drawFormat5 = new StringFormat();//注的字体
  340. drawFormat5.Alignment = StringAlignment.Center;
  341. drawFormat5.LineAlignment = StringAlignment.Near;
  342. StringFormat drawFormat2 = new StringFormat();
  343. drawFormat2.Alignment = StringAlignment.Near;
  344. drawFormat2.LineAlignment = StringAlignment.Center;
  345. StringFormat drawFormat4 = new StringFormat();//
  346. drawFormat4.Alignment = StringAlignment.Far;
  347. drawFormat4.LineAlignment = StringAlignment.Far;
  348. //-----------------------标题
  349. /*
  350. Rectangle rec = new Rectangle(oX + xPos[1], oY + yPos[0], xPos[4] - xPos[1], yPos[1] - yPos[0]);
  351. e.Graphics.DrawString("九钢集团有限责任公司", headFont, Brushes.Black, rec, drawFormat1);
  352. rec = new Rectangle(oX + xPos[1], oY + yPos[1], xPos[4] - xPos[1], yPos[2] - yPos[1]);
  353. e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
  354. e.Graphics.DrawImage(img, oX + xPos[0], oY + yPos[0], xPos[1] - xPos[0], 40);
  355. //*/
  356. //*
  357. Rectangle rec = new Rectangle(oX + xPos[0], oY + yPos[0], xPos[4] - xPos[0], yPos[1] - yPos[0]);
  358. e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
  359. rec = new Rectangle(oX + xPos[0], oY + yPos[1], xPos[4] - xPos[0], yPos[2] - yPos[1]);
  360. e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
  361. //e.Graphics.DrawString("凌字311-005", txtFont2, Brushes.Black, rec, drawFormat4);
  362. //*/
  363. //-----------------------------
  364. //-----------------------正文
  365. rec.X = xPos[0] + oX; //35
  366. rec.Y = yPos[2] + oY;
  367. rec.Width = xPos[1] - xPos[0];
  368. rec.Height = 20;
  369. e.Graphics.DrawString("流水号", txtFont, Brushes.Black, rec, drawFormat1); //35
  370. rec.X = xPos[1] + oX;
  371. rec.Y = yPos[2] + oY;
  372. rec.Width = xPos[4] - xPos[1];
  373. rec.Height = 20;
  374. e.Graphics.DrawString(first.actualNo, txtFont, Brushes.Black, rec, drawFormat1); //流水号值
  375. rec.X = xPos[0] + oX;
  376. rec.Y = yPos[3] + oY;
  377. rec.Width = xPos[1] - xPos[0];
  378. rec.Height = 20;
  379. e.Graphics.DrawString("预报编号", txtFont, Brushes.Black, rec, drawFormat1);
  380. rec.X = xPos[1] + oX;
  381. rec.Y = yPos[3] + oY;
  382. rec.Width = xPos[4] - xPos[1];
  383. rec.Height = 20;
  384. e.Graphics.DrawString(first.predictionNo, txtFont, Brushes.Black, rec, drawFormat1); //预报编号值
  385. rec.X = xPos[0] + oX;
  386. rec.Y = yPos[4] + oY;
  387. rec.Width = xPos[1] - xPos[0];
  388. rec.Height = 20;
  389. e.Graphics.DrawString("车号", txtFont, Brushes.Black, rec, drawFormat1);
  390. rec.X = xPos[1] + oX;
  391. rec.Y = yPos[4] + oY;
  392. rec.Width = xPos[4] - xPos[1];
  393. rec.Height = 20;
  394. e.Graphics.DrawString(first.carNo, txtFont, Brushes.Black, rec, drawFormat1); //车号
  395. rec.X = xPos[0] + oX;
  396. rec.Y = yPos[5] + oY;
  397. rec.Width = xPos[1] - xPos[0];
  398. rec.Height = 20;
  399. e.Graphics.DrawString("物资名称", txtFont, Brushes.Black, rec, drawFormat1);
  400. rec.X = xPos[1] + oX;
  401. rec.Y = yPos[5] + oY;
  402. rec.Width = xPos[4] - xPos[1];
  403. rec.Height = 20;
  404. e.Graphics.DrawString(first.matterName, txtFont, Brushes.Black, rec, drawFormat1); //物资名称
  405. rec.X = xPos[0] + oX;
  406. rec.Y = yPos[6] + oY;
  407. rec.Width = xPos[1] - xPos[0];
  408. rec.Height = 20;
  409. e.Graphics.DrawString("检斤类型", txtFont, Brushes.Black, rec, drawFormat1);
  410. rec.X = xPos[1] + oX;
  411. rec.Y = yPos[6] + oY;
  412. rec.Width = xPos[4] - xPos[1];
  413. rec.Height = 20;
  414. e.Graphics.DrawString(first.meterTypeName, txtFont, Brushes.Black, rec, drawFormat1); //检斤类型值
  415. rec.X = xPos[0] + oX;
  416. rec.Y = yPos[7] + oY;
  417. rec.Width = xPos[1] - xPos[0];
  418. rec.Height = 20;
  419. e.Graphics.DrawString("来源", txtFont, Brushes.Black, rec, drawFormat1);
  420. rec.X = xPos[1] + oX;
  421. rec.Y = yPos[7] + oY;
  422. rec.Width = xPos[4] - xPos[1];
  423. rec.Height = 20;
  424. e.Graphics.DrawString(first.forwardingUnitName, txtFont2, Brushes.Black, rec, drawFormat1); //来源值
  425. rec.X = xPos[0] + oX;
  426. rec.Y = yPos[8] + oY;
  427. rec.Width = xPos[1] - xPos[0];
  428. rec.Height = 20;
  429. e.Graphics.DrawString("去向", txtFont, Brushes.Black, rec, drawFormat1);
  430. rec.X = xPos[1] + oX;
  431. rec.Y = yPos[8] + oY;
  432. rec.Width = xPos[4] - xPos[1];
  433. rec.Height = 20;
  434. e.Graphics.DrawString(first.receivingUintName, txtFont2, Brushes.Black, rec, drawFormat1); //去向值
  435. rec.X = xPos[0] + oX;
  436. rec.Y = yPos[9] + oY;
  437. rec.Width = xPos[1] - xPos[0];
  438. rec.Height = 20;
  439. e.Graphics.DrawString("毛重时间", txtFont, Brushes.Black, rec, drawFormat1);
  440. rec.X = xPos[1] + oX;
  441. rec.Y = yPos[9] + oY;
  442. rec.Width = xPos[4] - xPos[1];
  443. rec.Height = 20;
  444. e.Graphics.DrawString(first.grossTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont, Brushes.Black, rec, drawFormat1); //一次计量时间值
  445. rec.X = xPos[0] + oX;
  446. rec.Y = yPos[10] + oY;
  447. rec.Width = xPos[1] - xPos[0];
  448. rec.Height = 20;
  449. e.Graphics.DrawString("皮重时间", txtFont, Brushes.Black, rec, drawFormat1);
  450. rec.X = xPos[1] + oX;
  451. rec.Y = yPos[10] + oY;
  452. rec.Width = xPos[4] - xPos[1];
  453. rec.Height = 20;
  454. e.Graphics.DrawString(first.tareTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont, Brushes.Black, rec, drawFormat1); //二次计量时间值
  455. rec.X = xPos[0] + oX;
  456. rec.Y = yPos[11] + oY;
  457. rec.Width = xPos[1] - xPos[0];
  458. rec.Height = 20;
  459. e.Graphics.DrawString("毛重(t)", txtFont, Brushes.Black, rec, drawFormat1);
  460. rec.X = xPos[1] + oX;
  461. rec.Y = yPos[11] + oY;
  462. rec.Width = xPos[2] - xPos[1];
  463. rec.Height = 20;
  464. e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //毛重值
  465. rec.X = xPos[2] + oX;
  466. rec.Y = yPos[11] + oY;
  467. rec.Width = xPos[3] - xPos[2];
  468. rec.Height = 20;
  469. e.Graphics.DrawString("附加重量", txtFont, Brushes.Black, rec, drawFormat1);
  470. rec.X = xPos[3] + oX;
  471. rec.Y = yPos[11] + oY;
  472. rec.Width = xPos[4] - xPos[3];
  473. rec.Height = 20;
  474. e.Graphics.DrawString(((first.grossWeight.Value - first.tareWeight.Value - first.netWeight.Value) / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1);
  475. rec.X = xPos[0] + oX;
  476. rec.Y = yPos[12] + oY;
  477. rec.Width = xPos[1] - xPos[0];
  478. rec.Height = 20;
  479. e.Graphics.DrawString("皮重(t)", txtFont, Brushes.Black, rec, drawFormat1);
  480. rec.X = xPos[1] + oX;
  481. rec.Y = yPos[12] + oY;
  482. rec.Width = xPos[2] - xPos[1];
  483. rec.Height = 20;
  484. e.Graphics.DrawString((first.tareWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //皮重值
  485. rec.X = xPos[2] + oX;
  486. rec.Y = yPos[12] + oY;
  487. rec.Width = xPos[3] - xPos[2];
  488. rec.Height = 20;
  489. e.Graphics.DrawString("净重(t)", txtFont, Brushes.Black, rec, drawFormat1);
  490. rec.X = xPos[3] + oX;
  491. rec.Y = yPos[12] + oY;
  492. rec.Width = xPos[4] - xPos[3];
  493. rec.Height = 20;
  494. e.Graphics.DrawString((first.netWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //净重值
  495. rec.X = xPos[0] + oX;
  496. rec.Y = yPos[13] + oY;
  497. rec.Width = xPos[1] - xPos[0];
  498. rec.Height = 20;
  499. e.Graphics.DrawString("规格", txtFont, Brushes.Black, rec, drawFormat1);
  500. rec.X = xPos[1] + oX;
  501. rec.Y = yPos[13] + oY;
  502. rec.Width = xPos[4] - xPos[1];
  503. rec.Height = 20;
  504. e.Graphics.DrawString(first.specName, txtFont, Brushes.Black, rec, drawFormat1);
  505. //*/
  506. rec.X = xPos[0] + oX;
  507. rec.Y = yPos[14] + oY;
  508. rec.Width = xPos[4] - xPos[0];
  509. rec.Height = 20;
  510. e.Graphics.DrawString("注:本小票不作为结算凭证,请注意保管!", txtFont1, Brushes.Black, rec, drawFormat3); //注意
  511. rec.X = xPos[0] + oX;
  512. rec.Y = yPos[15] + oY;
  513. rec.Width = xPos[4] - xPos[0];
  514. rec.Height = 20;
  515. e.Graphics.DrawString("打票时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtFont1, Brushes.Black, rec, drawFormat3);//注意//Now.ToString("yyyy-MM-dd HH:mm:ss")
  516. e.Graphics.DrawImage(img, 180, 2 + yPos[16], xPos[1] - xPos[0], 40);
  517. //打印横线
  518. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[4] + oX, yPos[2] + oY);
  519. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[3] + oY, xPos[4] + oX, yPos[3] + oY);
  520. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[4] + oY, xPos[4] + oX, yPos[4] + oY);
  521. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[5] + oY, xPos[4] + oX, yPos[5] + oY);
  522. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[6] + oY, xPos[4] + oX, yPos[6] + oY);
  523. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[7] + oY, xPos[4] + oX, yPos[7] + oY);
  524. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[8] + oY, xPos[4] + oX, yPos[8] + oY);
  525. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[9] + oY, xPos[4] + oX, yPos[9] + oY);
  526. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[10] + oY, xPos[4] + oX, yPos[10] + oY);
  527. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[11] + oY, xPos[4] + oX, yPos[11] + oY);
  528. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[12] + oY, xPos[4] + oX, yPos[12] + oY);
  529. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[13] + oY, xPos[4] + oX, yPos[13] + oY);
  530. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[14] + oY, xPos[4] + oX, yPos[14] + oY);
  531. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[15] + oY, xPos[4] + oX, yPos[15] + oY);
  532. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[16] + oY, xPos[4] + oX, yPos[16] + oY);
  533. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[17] + oY, xPos[4] + oX, yPos[17] + oY);
  534. //打印竖线
  535. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[0] + oX, yPos[17] + oY);
  536. e.Graphics.DrawLine(blackPen, xPos[1] + oX, yPos[2] + oY, xPos[1] + oX, yPos[14] + oY);
  537. e.Graphics.DrawLine(blackPen, xPos[2] + oX, yPos[11] + oY, xPos[2] + oX, yPos[13] + oY);
  538. e.Graphics.DrawLine(blackPen, xPos[3] + oX, yPos[11] + oY, xPos[3] + oX, yPos[13] + oY);
  539. e.Graphics.DrawLine(blackPen, xPos[4] + oX, yPos[2] + oY, xPos[4] + oX, yPos[17] + oY);
  540. PrintNum(PbCache.sportInfo.baseSpotNo);
  541. }
  542. catch (Exception exp)
  543. {
  544. WriteLog("结净计量打印异常!" + exp.Message);
  545. }
  546. }
  547. /// <summary>
  548. /// 过磅打印
  549. /// </summary>
  550. /// <param name="e"></param>
  551. /// <param name="_strCarNo"></param>
  552. public void PrintWgtPage(System.Drawing.Printing.PrintPageEventArgs e, MeterWorkCarActual first, string strCode)
  553. {
  554. try
  555. {
  556. Image img = qr.rtImgQRCode(strCode);
  557. int oX = 0, oY = -2; //偏移量
  558. int[] xPos = { 0, 65, 125, 205, 265 };
  559. int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 360, 380, 400, 420, 440, 460 };
  560. //int[] xPos = { 0, 65, 110, 170, 220 };
  561. //int[] yPos = { 0, 20, 40, 60, 80, 100, 120, 160, 180, 220, 240, 260, 280, 300, 320, 350, 390, 410, 430, 450, 470, 490 };
  562. Font headFont = new Font("Arial", 10);
  563. Font txtFont = new Font("Arial", 9);
  564. Font txtFont1 = new Font("Arial", 8);//注的字体
  565. Font MemoFont = new Font("Arial", 12);
  566. Font txtFont2 = new Font("Arial", 7);
  567. Pen blackPen = new Pen(Color.Black, 2);
  568. StringFormat drawFormat1 = new StringFormat();
  569. drawFormat1.Alignment = StringAlignment.Center;
  570. drawFormat1.LineAlignment = StringAlignment.Center;
  571. StringFormat drawFormat3 = new StringFormat();//注的字体
  572. drawFormat3.Alignment = StringAlignment.Near;
  573. drawFormat3.LineAlignment = StringAlignment.Near;
  574. StringFormat drawFormat5 = new StringFormat();//注的字体
  575. drawFormat5.Alignment = StringAlignment.Center;
  576. drawFormat5.LineAlignment = StringAlignment.Near;
  577. StringFormat drawFormat2 = new StringFormat();
  578. drawFormat2.Alignment = StringAlignment.Near;
  579. drawFormat2.LineAlignment = StringAlignment.Center;
  580. StringFormat drawFormat4 = new StringFormat();//
  581. drawFormat4.Alignment = StringAlignment.Far;
  582. drawFormat4.LineAlignment = StringAlignment.Far;
  583. //-----------------------标题
  584. Rectangle rec = new Rectangle(oX + xPos[1], oY + yPos[0], xPos[4] - xPos[1], yPos[1] - yPos[0]);
  585. e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
  586. rec = new Rectangle(oX + xPos[1], oY + yPos[1], xPos[4] - xPos[1], yPos[2] - yPos[1]);
  587. e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
  588. e.Graphics.DrawImage(img, oX + xPos[0], oY + yPos[0], xPos[1] - xPos[0], 40);
  589. /*
  590. Rectangle rec = new Rectangle(oX + xPos[0], oY + yPos[0], xPos[4] - xPos[0], yPos[1] - yPos[0]);
  591. e.Graphics.DrawString("九钢集团股份有限公司", headFont, Brushes.Black, rec, drawFormat1);
  592. rec = new Rectangle(oX + xPos[0], oY + yPos[1], xPos[4] - xPos[0], yPos[2] - yPos[1]);
  593. e.Graphics.DrawString("检斤小票", headFont, Brushes.Black, rec, drawFormat1);
  594. //e.Graphics.DrawString("凌字311-005", txtFont2, Brushes.Black, rec, drawFormat4);
  595. //*/
  596. //-----------------------------
  597. //-----------------------正文
  598. rec.X = xPos[0] + oX; //35
  599. rec.Y = yPos[2] + oY;
  600. rec.Width = xPos[1] - xPos[0];
  601. rec.Height = 20;
  602. e.Graphics.DrawString("流水号", txtFont, Brushes.Black, rec, drawFormat1); //35
  603. rec.X = xPos[1] + oX;
  604. rec.Y = yPos[2] + oY;
  605. rec.Width = xPos[4] - xPos[1];
  606. rec.Height = 20;
  607. e.Graphics.DrawString(first.actualNo, txtFont, Brushes.Black, rec, drawFormat1); //流水号值
  608. rec.X = xPos[0] + oX;
  609. rec.Y = yPos[3] + oY;
  610. rec.Width = xPos[1] - xPos[0];
  611. rec.Height = 20;
  612. e.Graphics.DrawString("预报编号", txtFont, Brushes.Black, rec, drawFormat1);
  613. rec.X = xPos[1] + oX;
  614. rec.Y = yPos[3] + oY;
  615. rec.Width = xPos[4] - xPos[1];
  616. rec.Height = 20;
  617. e.Graphics.DrawString(first.predictionNo, txtFont, Brushes.Black, rec, drawFormat1); //预报编号值
  618. rec.X = xPos[0] + oX;
  619. rec.Y = yPos[4] + oY;
  620. rec.Width = xPos[1] - xPos[0];
  621. rec.Height = 20;
  622. e.Graphics.DrawString("车号", txtFont, Brushes.Black, rec, drawFormat1);
  623. rec.X = xPos[1] + oX;
  624. rec.Y = yPos[4] + oY;
  625. rec.Width = xPos[4] - xPos[1];
  626. rec.Height = 20;
  627. e.Graphics.DrawString(first.carNo, txtFont, Brushes.Black, rec, drawFormat1); //车号
  628. rec.X = xPos[0] + oX;
  629. rec.Y = yPos[5] + oY;
  630. rec.Width = xPos[1] - xPos[0];
  631. rec.Height = 20;
  632. e.Graphics.DrawString("物资名称", txtFont, Brushes.Black, rec, drawFormat1);
  633. rec.X = xPos[1] + oX;
  634. rec.Y = yPos[5] + oY;
  635. rec.Width = xPos[4] - xPos[1];
  636. rec.Height = 20;
  637. e.Graphics.DrawString(first.matterName, txtFont, Brushes.Black, rec, drawFormat1); //物资名称
  638. rec.X = xPos[0] + oX;
  639. rec.Y = yPos[6] + oY;
  640. rec.Width = xPos[1] - xPos[0];
  641. rec.Height = 20;
  642. e.Graphics.DrawString("检斤类型", txtFont, Brushes.Black, rec, drawFormat1);
  643. rec.X = xPos[1] + oX;
  644. rec.Y = yPos[6] + oY;
  645. rec.Width = xPos[4] - xPos[1];
  646. rec.Height = 20;
  647. e.Graphics.DrawString(first.meterTypeName, txtFont, Brushes.Black, rec, drawFormat1); //检斤类型值
  648. rec.X = xPos[0] + oX;
  649. rec.Y = yPos[7] + oY;
  650. rec.Width = xPos[1] - xPos[0];
  651. rec.Height = 20;
  652. e.Graphics.DrawString("来源", txtFont, Brushes.Black, rec, drawFormat1);
  653. rec.X = xPos[1] + oX;
  654. rec.Y = yPos[7] + oY;
  655. rec.Width = xPos[4] - xPos[1];
  656. rec.Height = 20;
  657. e.Graphics.DrawString(first.forwardingUnitName, txtFont2, Brushes.Black, rec, drawFormat1); //来源值
  658. rec.X = xPos[0] + oX;
  659. rec.Y = yPos[8] + oY;
  660. rec.Width = xPos[1] - xPos[0];
  661. rec.Height = 20;
  662. e.Graphics.DrawString("去向", txtFont, Brushes.Black, rec, drawFormat1);
  663. rec.X = xPos[1] + oX;
  664. rec.Y = yPos[8] + oY;
  665. rec.Width = xPos[4] - xPos[1];
  666. rec.Height = 20;
  667. e.Graphics.DrawString(first.receivingUintName, txtFont2, Brushes.Black, rec, drawFormat1); //去向值
  668. rec.X = xPos[0] + oX;
  669. rec.Y = yPos[9] + oY;
  670. rec.Width = xPos[1] - xPos[0];
  671. rec.Height = 20;
  672. e.Graphics.DrawString("计量类型", txtFont, Brushes.Black, rec, drawFormat1);
  673. rec.X = xPos[1] + oX;
  674. rec.Y = yPos[9] + oY;
  675. rec.Width = xPos[4] - xPos[1];
  676. rec.Height = 20;
  677. e.Graphics.DrawString(first.meterTypeNo == "0" ? "毛重" : "皮重", txtFont, Brushes.Black, rec, drawFormat1); //计量类型
  678. rec.X = xPos[0] + oX;
  679. rec.Y = yPos[10] + oY;
  680. rec.Width = xPos[1] - xPos[0];
  681. rec.Height = 20;
  682. e.Graphics.DrawString("计量时间", txtFont, Brushes.Black, rec, drawFormat1);
  683. rec.X = xPos[1] + oX;
  684. rec.Y = yPos[10] + oY;
  685. rec.Width = xPos[4] - xPos[1];
  686. rec.Height = 20;
  687. e.Graphics.DrawString(first.grossTime.Value.ToString("yyyy/MM/dd HH:mm"), txtFont, Brushes.Black, rec, drawFormat1); //计量时间
  688. rec.X = xPos[0] + oX;
  689. rec.Y = yPos[11] + oY;
  690. rec.Width = xPos[1] - xPos[0];
  691. rec.Height = 20;
  692. e.Graphics.DrawString("重量(t)", txtFont, Brushes.Black, rec, drawFormat1);
  693. rec.X = xPos[1] + oX;
  694. rec.Y = yPos[11] + oY;
  695. rec.Width = xPos[2] - xPos[1];
  696. rec.Height = 20;
  697. e.Graphics.DrawString((first.grossWeight.Value / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1); //毛重值
  698. rec.X = xPos[2] + oX;
  699. rec.Y = yPos[11] + oY;
  700. rec.Width = xPos[3] - xPos[2];
  701. rec.Height = 20;
  702. e.Graphics.DrawString("附加重量", txtFont, Brushes.Black, rec, drawFormat1);
  703. rec.X = xPos[3] + oX;
  704. rec.Y = yPos[11] + oY;
  705. rec.Width = xPos[4] - xPos[3];
  706. rec.Height = 20;
  707. e.Graphics.DrawString(((string.IsNullOrEmpty(first.valueFlag)?0:Convert.ToInt32(first.valueFlag)) / 1000) + "", txtFont, Brushes.Black, rec, drawFormat1);
  708. rec.X = xPos[0] + oX;
  709. rec.Y = yPos[12] + oY;
  710. rec.Width = xPos[1] - xPos[0];
  711. rec.Height = 20;
  712. e.Graphics.DrawString("规格", txtFont, Brushes.Black, rec, drawFormat1);
  713. rec.X = xPos[1] + oX;
  714. rec.Y = yPos[12] + oY;
  715. rec.Width = xPos[4] - xPos[1];
  716. rec.Height = 20;
  717. e.Graphics.DrawString(first.specName, txtFont, Brushes.Black, rec, drawFormat1);
  718. //*/
  719. rec.X = xPos[0] + oX;
  720. rec.Y = yPos[13] + oY;
  721. rec.Width = xPos[4] - xPos[0];
  722. rec.Height = 20;
  723. e.Graphics.DrawString("注:本小票不作为结算凭证,请注意保管!", txtFont1, Brushes.Black, rec, drawFormat3); //注意
  724. rec.X = xPos[0] + oX;
  725. rec.Y = yPos[14] + oY;
  726. rec.Width = xPos[4] - xPos[0];
  727. rec.Height = 20;
  728. e.Graphics.DrawString("打票时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), txtFont1, Brushes.Black, rec, drawFormat3);//注意//Now.ToString("yyyy-MM-dd HH:mm:ss")
  729. e.Graphics.DrawImage(img, 180, 2 + yPos[15], xPos[1] - xPos[0], 40);
  730. //打印横线
  731. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[4] + oX, yPos[2] + oY);
  732. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[3] + oY, xPos[4] + oX, yPos[3] + oY);
  733. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[4] + oY, xPos[4] + oX, yPos[4] + oY);
  734. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[5] + oY, xPos[4] + oX, yPos[5] + oY);
  735. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[6] + oY, xPos[4] + oX, yPos[6] + oY);
  736. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[7] + oY, xPos[4] + oX, yPos[7] + oY);
  737. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[8] + oY, xPos[4] + oX, yPos[8] + oY);
  738. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[9] + oY, xPos[4] + oX, yPos[9] + oY);
  739. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[10] + oY, xPos[4] + oX, yPos[10] + oY);
  740. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[11] + oY, xPos[4] + oX, yPos[11] + oY);
  741. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[12] + oY, xPos[4] + oX, yPos[12] + oY);
  742. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[13] + oY, xPos[4] + oX, yPos[13] + oY);
  743. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[14] + oY, xPos[4] + oX, yPos[14] + oY);
  744. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[15] + oY, xPos[4] + oX, yPos[15] + oY);
  745. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[16] + oY, xPos[4] + oX, yPos[16] + oY);
  746. //打印竖线
  747. e.Graphics.DrawLine(blackPen, xPos[0] + oX, yPos[2] + oY, xPos[0] + oX, yPos[16] + oY);
  748. e.Graphics.DrawLine(blackPen, xPos[1] + oX, yPos[2] + oY, xPos[1] + oX, yPos[12] + oY);
  749. e.Graphics.DrawLine(blackPen, xPos[2] + oX, yPos[11] + oY, xPos[2] + oX, yPos[12] + oY);
  750. e.Graphics.DrawLine(blackPen, xPos[3] + oX, yPos[11] + oY, xPos[3] + oX, yPos[12] + oY);
  751. e.Graphics.DrawLine(blackPen, xPos[4] + oX, yPos[2] + oY, xPos[4] + oX, yPos[16] + oY);
  752. PrintNum(PbCache.sportInfo.baseSpotNo);
  753. }
  754. catch (Exception exp)
  755. {
  756. WriteLog("一次计量打印异常!" + exp.Message);
  757. }
  758. }
  759. private void WriteLog(string str)
  760. {
  761. string m_szRunPath;
  762. m_szRunPath = System.Environment.CurrentDirectory;
  763. if (System.IO.Directory.Exists(m_szRunPath + "\\log") == false)
  764. {
  765. System.IO.Directory.CreateDirectory(m_szRunPath + "\\log");
  766. }
  767. string strDate = System.DateTime.Now.ToString("yyyyMMdd");
  768. string strPathFile = m_szRunPath + "\\log\\" + strDate;
  769. if (!Directory.Exists(strPathFile))//如果不存在就创建file文件夹
  770. {
  771. Directory.CreateDirectory(strPathFile);
  772. }
  773. System.IO.TextWriter tw = new System.IO.StreamWriter(strPathFile + "\\打印_" + strDate + ".log", true);
  774. tw.WriteLine(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
  775. tw.WriteLine(str);
  776. tw.WriteLine("\r\n");
  777. tw.Close();
  778. }
  779. }
  780. }