YxyyWvPrint.cs
25.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
using CsbrHcgClient.Common;
using CsbrHcgClient.Models;
using CsbrHcgClient.Models.SAP.Entity;
using CsbrHcgClient.Models.SAP.Model.Input;
using CsbrHcgClient.Models.SAP.Model.Output;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using System.Windows.Forms;
using System.IO;
using Microsoft.Reporting.WinForms;
using System.Drawing.Printing;
using System.Drawing.Imaging;
using System.Configuration;
using System.Drawing;
namespace CsbrHcgClient
{
public partial class YxyyWvPrint : Form
{
public YxyyWvPrint()
{
InitializeComponent();
this.dgv_Detail.AutoGenerateColumns = false;
this.dgv_Detailed.AutoGenerateColumns = false;
this.dataGridGoods.AutoGenerateColumns = false;
}
private WvControl wvControl = new WvControl();
PrintHelper printHelper = new PrintHelper();
private DataTable printedInfoTable = new DataTable();
DataTable tableWvDetail = new DataTable();
/// <summary>
/// 查询SAP采购订单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSelect_Click(object sender, EventArgs e)
{
try
{
#region 验证
if (String.IsNullOrEmpty(txtmeddeptguid.Text))
{
MessageBox.Show("请输入工厂信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (String.IsNullOrEmpty(txtmedstoreguid.Text))
{
MessageBox.Show("请输入接收库存地点信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (String.IsNullOrEmpty(txtsupplierno.Text))
{
MessageBox.Show("请输入供应商信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
#endregion
#region 获取SAP数据
PrintLabelModel inModel = new PrintLabelModel();
inModel.I_WERKS = txtmeddeptguid.Text;
inModel.I_LGORT = txtmedstoreguid.Text.ToUpper();
inModel.I_LIFNR = txtsupplierno.Text.ToUpper();
if (chekkostl.Checked)
{
inModel.P_KOSTL = "X";
}
if (checkelikz.Checked)
{
inModel.P_ELIKZ = "X";
}
if (!String.IsNullOrEmpty(txtbillNo.Text))
{
List<LrCgpz> lrCgpzList = new List<LrCgpz>();
LrCgpz lrCgpz = new LrCgpz();
lrCgpz.SIGN = "I";
lrCgpz.OPTION = "EQ";
lrCgpz.LOW = txtbillNo.Text;
lrCgpzList.Add(lrCgpz);
inModel.lrCgpzs = lrCgpzList;//采购订单号
}
string url = ConfigurationManager.AppSettings["SapUrl"] + "sap/printLable";
JavaScriptSerializer js = new JavaScriptSerializer();
string questJson = js.Serialize(inModel);
string result = ApiTransfer.HttpApi(url, questJson, "POST");
#endregion
PrintLabelExportModel returnModel = JsonConvert.DeserializeObject<PrintLabelExportModel>(result);
if (returnModel.E_MTYPE != "S")
{
MessageBox.Show(returnModel.E_MSG, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//PrintLabelLtItem item1 = new PrintLabelLtItem();
//item1.EBELN = "111";
//item1.MATNR = "c111";
//item1.MAKTX = "骨订1";
//PrintLabelLtItem item2 = new PrintLabelLtItem();
//item2.EBELN = "222";
//item2.MATNR = "c222";
//item2.MAKTX = "骨订2";
//PrintLabelLtItem item3 = new PrintLabelLtItem();
//item3.EBELN = "333";
//item3.MATNR = "c333";
//item3.MAKTX = "骨订3";
//采购单明细数据
List<PrintLabelLtItem> PrintLabelLtItems = returnModel.ltItems;
//List<PrintLabelLtItem> PrintLabelLtItems = new List<PrintLabelLtItem>();
//PrintLabelLtItems.Add(item1);
//PrintLabelLtItems.Add(item2);
//PrintLabelLtItems.Add(item3);
//List<SpdWv> spdWvList = new List<SpdWv>();
//int intRow = 1;
//判断商品是否存在,不存在则插入到商品表中
SaveGoods(PrintLabelLtItems, txtmeddeptguid.Text, txtmedstoreguid.Text);
YxyyChangeWvDetail wvDetail = new YxyyChangeWvDetail(tableWvDetail, txtmeddeptguid.Text, txtmedstoreguid.Text, txtsupplierno.Text);
wvDetail.Show();
//foreach (IGrouping<string, PrintLabelLtItem> group in PrintLabelLtItems.GroupBy(x => x.EBELN))
//{
// PrintLabelLtItem item = PrintLabelLtItems.Where(x => x.EBELN == group.Key).First();
// SpdWv wv = new SpdWv();
// wv.IntRow = intRow.ToString();
// wv.BillNo = item.EBELN;
// wv.SupplierGUID = item.LIFNR;
// wv.MedDeptGuid = txtmeddeptguid.Text;
// wv.MedStoreGuid = txtmedstoreguid.Text;
// wv.Link = "查看详情";
// spdWvList.Add(wv);
// intRow++;
//}
//dgv_Detail.DataSource = spdWvList;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
/// <summary>
/// 保存商品
/// </summary>
/// <param name="PrintLabelLtItems"></param>
/// <param name="MedDeptGuid"></param>
/// <param name="MedStoreGuid"></param>
public void SaveGoods(List<PrintLabelLtItem> PrintLabelLtItems, String MedDeptGuid, String MedStoreGuid)
{
if (tableWvDetail.Columns.Count <= 0)
{
tableWvDetail.Columns.Add("EBELN", typeof(string));//采购凭证号
tableWvDetail.Columns.Add("EBELP", typeof(string));//采购凭证的项目编号
tableWvDetail.Columns.Add("MATNR", typeof(string));//物料号
tableWvDetail.Columns.Add("MAKTX", typeof(string));//物料描述
tableWvDetail.Columns.Add("LIFNR", typeof(string));//供应商或债权人的帐号
tableWvDetail.Columns.Add("LIFN2", typeof(string));//其它供应商参考
tableWvDetail.Columns.Add("MENG1", typeof(string));//待收货数量
tableWvDetail.Columns.Add("MEIN1", typeof(string));//订单单位
tableWvDetail.Columns.Add("MSEH1", typeof(string));//订单单位描述
tableWvDetail.Columns.Add("ELIKZ", typeof(string));//"交货已完成"标识
tableWvDetail.Columns.Add("AFNAM", typeof(string));//需求者/请求者姓名
tableWvDetail.Columns.Add("PSTYP", typeof(string));//采购凭证中的项目类别
tableWvDetail.Columns.Add("PTEXT", typeof(string));//项目类别文本
tableWvDetail.Columns.Add("XCHPF", typeof(string));//批次管理需求的标识
tableWvDetail.Columns.Add("BWTTY", typeof(string));//评估类别
tableWvDetail.Columns.Add("MENGE", typeof(string));//采购数量
tableWvDetail.Columns.Add("MEINS", typeof(string));//基本计量单位
tableWvDetail.Columns.Add("MSEHL", typeof(string));//基本计量单位文本
tableWvDetail.Columns.Add("isCheck", typeof(bool));
tableWvDetail.Columns.Add("intRow", typeof(string));
tableWvDetail.Columns.Add("Lot", typeof(string));
tableWvDetail.Columns.Add("ExpireDate", typeof(string));
tableWvDetail.Columns.Add("PrintDate", typeof(string));
tableWvDetail.Columns.Add("PrintCount", typeof(string));
tableWvDetail.Columns.Add("hasRfidPrintCount", typeof(string));
tableWvDetail.Columns.Add("IsZR", typeof(string));
tableWvDetail.Columns.Add("IsRK", typeof(string));
tableWvDetail.Columns.Add("BarCode", typeof(string));
tableWvDetail.Columns.Add("RfidCode", typeof(string));
tableWvDetail.Columns.Add("WvDetailGuid", typeof(string));
tableWvDetail.Columns.Add("Link", typeof(string));
}
foreach (PrintLabelLtItem item in PrintLabelLtItems)
{
tableWvDetail.Rows.Add(item.EBELN, int.Parse(item.EBELP), item.MATNR, item.MAKTX, item.LIFNR, item.LIFN2, item.MENG1, item.MEIN1, item.MSEH1, item.ELIKZ, item.AFNAM, item.PSTYP, item.PTEXT, item.XCHPF, item.BWTTY, item.MENGE, item.MEINS, item.MSEHL);
DataTable dtGoods = wvControl.GetGoods(item.MATNR);
if (dtGoods !=null && dtGoods.Rows.Count > 0)
{
continue;
}
#region 获取SAP数据
GetMaterialDataModel goodModl = new GetMaterialDataModel();
goodModl.I_WERKS= MedDeptGuid;
goodModl.I_MATNR= item.MATNR;
string url = ConfigurationManager.AppSettings["SapUrl"] + "sap/getMaterialData";
JavaScriptSerializer js = new JavaScriptSerializer();
string questJson = js.Serialize(goodModl);
string result = ApiTransfer.HttpApi(url, questJson, "POST");
#endregion
GetMaterialDataExportModel returnModel = JsonConvert.DeserializeObject<GetMaterialDataExportModel>(result);
if (returnModel.E_MTYPE != "S")
{
MessageBox.Show(returnModel.E_MSG, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
continue;
}
//商品资料数据
List<GetMaterialDataLtItem> goodItems = returnModel.ltItems;
#region 保存商品资料
HisGoods hisGoods = new HisGoods();
hisGoods.Guid = goodItems.First().MATNR;
hisGoods.GoodsCode=goodItems.First().MATNR;
hisGoods.GoodsName=goodItems.First().MAKTX;
hisGoods.BizState="Y";
hisGoods.UnitStyle=goodItems.First().MEINS;
hisGoods.GoodsCate=goodItems.First().MTART;
hisGoods.Memo=goodItems.First().BISMT;
hisGoods.Productionaddress=goodItems.First().LGORT;
hisGoods.Model=goodItems.First().MBRSH;
hisGoods.Isrk="1";
hisGoods.Iszr="1";
hisGoods.Depotguid=goodItems.First().WERKS;
hisGoods.Depotname=goodItems.First().WERKS;
hisGoods.Producer = " ";
hisGoods.GoodsSpec = " ";
int res = wvControl.AddGoods(hisGoods);
#endregion
}
}
private void dgv_Detail_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
{
return;
}
if (dgv_Detail.Columns[e.ColumnIndex].Name == "colLink")
{
SpdWv dr = dgv_Detail.Rows[e.RowIndex].DataBoundItem as SpdWv;//微软提供的唯一的转换DataRow
string strkostl = string.Empty;
if (chekkostl.Checked)
{
strkostl = "X";
}
string strelikz = string.Empty;
if (checkelikz.Checked)
{
strelikz = "X";
}
YxyyWvDetail wvDetail = new YxyyWvDetail(txtmeddeptguid.Text, txtmedstoreguid.Text, dr.SupplierGUID, dr.BillNo, strkostl,strelikz);
wvDetail.Show();
}
}
/// <summary>
/// 查询已打印标签
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnHasSelect_Click(object sender, EventArgs e)
{
try
{
printedInfoTable = wvControl.GetWvScend(txtHasBillNo.Text, txtGoodInfo.Text, txtBarCode.Text, txtLot.Text);
if (printedInfoTable == null || printedInfoTable.Rows.Count <= 0)
{
MessageBox.Show("未查询到相关数据", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
this.dgv_Detailed.DataSource = printedInfoTable;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
/// <summary>
/// 重新打印标签
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dgv_Detailed_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
{
return;
}
//RFID标签打印
if (dgv_Detailed.Columns[e.ColumnIndex].Name == "Print1")
{
DataTable dd = printedInfoTable.Clone();//赋值结构
DataRow dr = dd.NewRow();
dr = (dgv_Detailed.Rows[e.RowIndex].DataBoundItem as DataRowView).Row;//微软提供的唯一的转换DataRow
try
{
printHelper.RePrint_Yxyy(dr);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//普通标签打印
if (dgv_Detailed.Columns[e.ColumnIndex].Name == "Print2")
{
DataTable dd = printedInfoTable.Clone();//赋值结构
DataRow dr = dd.NewRow();
dr = (dgv_Detailed.Rows[e.RowIndex].DataBoundItem as DataRowView).Row;//微软提供的唯一的转换DataRow
try
{
PrintPt(dr);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
#region 普通标签打印
public void PrintPt(DataRow drPrint)
{
#region 打印参数赋值
#region 数据结构
DataTable dt = new DataTable("dt");
DataColumn dc1 = new DataColumn("MAKTX", Type.GetType("System.String"));//物料描述
DataColumn dc2 = new DataColumn("MATNR", Type.GetType("System.String"));//物料号
DataColumn dc3 = new DataColumn("ExpireDate", Type.GetType("System.String"));//有效期
DataColumn dc4 = new DataColumn("Lot", Type.GetType("System.String"));//批号
DataColumn dc5 = new DataColumn("BarCode", Type.GetType("System.String"));//追溯码
DataColumn dc6 = new DataColumn("PrintDate", Type.GetType("System.String"));//打印日期
DataColumn dc7 = new DataColumn("EBELN", Type.GetType("System.String"));//采购订单号
DataColumn dc8 = new DataColumn("ImgBarCode", Type.GetType("System.String"));//二维码
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
dt.Columns.Add(dc6);
dt.Columns.Add(dc7);
dt.Columns.Add(dc8);
#endregion
DataRow drAdd = dt.NewRow();
drAdd["MATNR"] = drPrint["GoodsCode"].ToString();//物料号
drAdd["MAKTX"] = drPrint["GoodsName"].ToString();//物料描述
drAdd["EBELN"] = drPrint["BillNo"].ToString();//采购订单号
drAdd["Lot"] = drPrint["Lot"].ToString();//批号
drAdd["ExpireDate"] = Convert.ToDateTime(drPrint["ExpireDate"].ToString()).ToString("yyyy-MM-dd");//有效期
drAdd["PrintDate"] = "(" + DateTime.Now.ToString("yyyyMMdd") + ")";//打印日期
//条码格式 : 物料号|结算供应商|供货供应商|批次@有效期|采购订单号|一物一码ID
drAdd["BarCode"] = drPrint["BarCode"].ToString();//追溯码
//二维码打印,把追溯码生成的文件流放进去可以转换出来BASE64的图片格式,然后附加到数据源,打印机可以直接打印。
var img = ImgToBase64String(BarcodeHelper.Generate1(drPrint["BarCode"].ToString(), 300, 300));
drAdd["ImgBarCode"] = img;//追溯码
dt.Rows.Add(drAdd);
#endregion
ReportDataSource rds = new ReportDataSource("DataSet1", dt);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.ReportPath = "RDLC/YxyyReport1.rdlc";
reportViewer1.LocalReport.DataSources.Add(rds);
PrintStream(reportViewer1.LocalReport);
}
/// <summary>
/// 声明一个Stream对象的列表用来保存报表的输出数据,LocalReport对象的Render方法会将报表按页输出为多个Stream对象。
/// </summary>
private IList<Stream> m_streams;
private bool isLandSapces = false;
private int m_currentPageIndex;
/// <summary>
/// 为Report.rdlc创建本地报告加载数据,输出报告到.emf文件,并打印,同时释放资源
/// </summary>
/// <param name="rv">参数:ReportViewer.LocalReport</param>
public void PrintStream(LocalReport rvDoc)
{
//获取LocalReport中的报表页面方向
isLandSapces = rvDoc.GetDefaultPageSettings().IsLandscape;
Export(rvDoc);
PrintSetting();
Dispose();
}
/// <summary>
/// 用来提供Stream对象的函数,用于LocalReport对象的Render方法的第三个参数。
/// </summary>
/// <param name="name"></param>
/// <param name="fileNameExtension"></param>
/// <param name="encoding"></param>
/// <param name="mimeType"></param>
/// <param name="willSeek"></param>
/// <returns></returns>
private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
//如果需要将报表输出的数据保存为文件,请使用FileStream对象。
Stream stream = new MemoryStream();
m_streams.Add(stream);
return stream;
}
private void Export(LocalReport report)
{
string deviceInfo =
@"<DeviceInfo>
<OutputFormat>EMF</OutputFormat>
</DeviceInfo>";
//string deviceInfo = "<DeviceInfo>" +
// " <OutputFormat>EMF</OutputFormat>" +
// " <PageWidth>" + pgWidth + "cm</PageWidth>" +
// " <PageHeight>" + pgHeight + "cm</PageHeight>" +
// " <MarginTop>" + mgTop + "cm</MarginTop>" +
// " <MarginLeft>" + mgLeft + "cm</MarginLeft>" +
// " <MarginRight>" + mgRight + "cm</MarginRight>" +
// " <MarginBottom>" + mgBottom + "cm</MarginBottom>" +
// "</DeviceInfo>";
Warning[] warnings;
m_streams = new List<Stream>();
//将报表的内容按照deviceInfo指定的格式输出到CreateStream函数提供的Stream中。
report.Render("Image", deviceInfo, CreateStream, out warnings);
foreach (Stream stream in m_streams)
stream.Position = 0;
}
private void PrintSetting()
{
if (m_streams == null || m_streams.Count == 0)
throw new Exception("错误:没有检测到打印数据流");
//声明PrintDocument对象用于数据的打印
PrintDocument printDoc = new PrintDocument();
//获取配置文件的清单打印机名称
System.Configuration.AppSettingsReader appSettings = new System.Configuration.AppSettingsReader();
printDoc.PrinterSettings.PrinterName = ConfigurationManager.AppSettings["PrintName"];
//printDoc.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
printDoc.DefaultPageSettings.PaperSize = new PaperSize("Custom", 196, 118);
printDoc.PrintController = new System.Drawing.Printing.StandardPrintController();//指定打印机不显示页码
//判断指定的打印机是否可用
if (!printDoc.PrinterSettings.IsValid)
{
throw new Exception("错误:找不到打印机");
}
else
{
//设置打印机方向遵从报表方向
printDoc.DefaultPageSettings.Landscape = false;
//声明PrintDocument对象的PrintPage事件,具体的打印操作需要在这个事件中处理。
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
m_currentPageIndex = 0;
//显示打印预览
//PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
//printPreviewDialog.Document = printDoc;
//DialogResult result = printPreviewDialog.ShowDialog();
//设置打印机打印份数
printDoc.PrinterSettings.Copies = 1;
//执行打印操作,Print方法将触发PrintPage事件。
printDoc.Print();
}
}
/// <summary>
/// 处理程序PrintPageEvents
/// </summary>
/// <param name="sender"></param>
///// <param name="ev"></param>
private void PrintPage(object sender, PrintPageEventArgs ev)
{
//Metafile对象用来保存EMF或WMF格式的图形,
//我们在前面将报表的内容输出为EMF图形格式的数据流。
Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);
ev.PageSettings.Margins.Bottom = 0;
ev.PageSettings.Margins.Left = 0;
ev.PageSettings.Margins.Right = 0;
ev.PageSettings.Margins.Top = 0;
//ev.PageSettings.PaperSize.Height = 118;
//ev.PageSettings.PaperSize.Width = 196;
//调整打印机区域的边距
System.Drawing.Rectangle adjustedRect = new System.Drawing.Rectangle(
ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
ev.PageBounds.Width,
ev.PageBounds.Height);
//绘制一个白色背景的报告
//ev.Graphics.FillRectangle(Brushes.White, adjustedRect);
//获取报告内容
//这里的Graphics对象实际指向了打印机
ev.Graphics.DrawImage(pageImage, adjustedRect);
//ev.Graphics.DrawImage(pageImage, ev.PageBounds, 0, 0, ev.PageBounds.Width, ev.PageBounds.Height, System.Drawing.GraphicsUnit.Millimeter);
//// 准备下一个页,已确定操作尚未结束
//m_currentPageIndex++;
////设置是否需要继续打印
//ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
}
public void Dispose()
{
if (m_streams != null)
{
foreach (Stream stream in m_streams)
stream.Close();
m_streams = null;
}
}
public static string ImgToBase64String(Bitmap bmp)
{
try
{
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
return Convert.ToBase64String(arr);
}
catch (Exception ex)
{
return null;
}
}
#endregion
private void btnGoodSelect_Click(object sender, EventArgs e)
{
DataTable dtGoods = wvControl.GetGoodsList(txtGoodCode.Text,txtGoodName.Text,cheIsRk.Checked, ConfigurationManager.AppSettings["DepotGuid"]);
this.dataGridGoods.DataSource = dtGoods;
}
private void dataGridGoods_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//RFID标签打印
if (dataGridGoods.Columns[e.ColumnIndex].Name == "colGoodSave")
{
DataRow dr = (dataGridGoods.Rows[e.RowIndex].DataBoundItem as DataRowView).Row;//微软提供的唯一的转换DataRow
try
{
string strIsRK = "1";
string strIsZR = "1";
strIsRK = dr["IsRK"].ToString();
strIsZR = dr["IsZR"].ToString();
wvControl.UpdateGoods(dr["GUID"].ToString(), strIsRK, strIsZR);
MessageBox.Show("保存成功!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
}