在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → c#写的多页打印源码(支持导入excel数据)

c#写的多页打印源码(支持导入excel数据)

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:1.31M
  • 下载次数:121
  • 浏览次数:734
  • 发布时间:2016-04-05
  • 实例类别:C#语言基础
  • 发 布 人:1040888787
  • 文件格式:.rar
  • 所需积分:2
 相关标签: C# 源码 打印 多页

实例介绍

【实例简介】

c#写的多页打印源码

【实例截图】

【核心代码】

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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using RTQPrint.Code;
using System.IO;
using ThoughtWorks.QRCode.Codec;
using System.Drawing.Printing;
 
namespace RTQPrint
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();       
        }
        private string asc_code = string.Empty;//ASC代码
        private string asc_name = string.Empty;//ASC名称
        private string temp_Path = string.Empty;
        private void MainForm_Load(object sender, EventArgs e)
        {
            cmb_state.SelectedIndex =0;
            Bind();
            SetState();
            GetAsc();
            if (string.IsNullOrEmpty(asc_code))
            {
                SetASCForm fasc = new SetASCForm();
                fasc.Flag = true;
                fasc.Owner = this;
                fasc.ShowDialog();
            }
        }
        public void GetAsc()
        {
            asc_code = AppSettings.GetAppSettingValue("ASC");
            asc_name = AppSettings.GetAppSettingValue("Name");
            txt_asc_code.Text = asc_code;
            txt_asc_name.Text = asc_name;
        }
        private void SetState()
        {
            for (int i = 0; i < dataGridView1.RowCount; i  )
            {
                string flag=dataGridView1.Rows[i].Cells["Column17"].Value.ToString();
                if (string.IsNullOrEmpty(flag))
                {
                     
                    dataGridView1.Rows[i].Cells["Column17"].Value = "未打印";
                }
                else
                {
                    dataGridView1.Rows[i].Cells["Column17"].Value = "已打印";
                    dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.RosyBrown;
                    
                }
 
                string week_id = dataGridView1.Rows[i].Cells["week_id"].EditedFormattedValue.ToString();//索赔周次
                string work_id = dataGridView1.Rows[i].Cells["work_id"].EditedFormattedValue.ToString();//索赔工单号
                string bank_id = dataGridView1.Rows[i].Cells["bank_id"].EditedFormattedValue.ToString();//行号
                string vin = dataGridView1.Rows[i].Cells["vin"].EditedFormattedValue.ToString();//VIN码
                string exception_fit_id = dataGridView1.Rows[i].Cells["exception_fit_id"].EditedFormattedValue.ToString();//配件代码
                if (string.IsNullOrEmpty(week_id))
                {
                    dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                else if (string.IsNullOrEmpty(exception_fit_id))
                {
                    dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                else if (string.IsNullOrEmpty(work_id))
                {
                    dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                else if (string.IsNullOrEmpty(bank_id))
                {
                    dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                else if (string.IsNullOrEmpty(vin))
                {
                    dataGridView1.Rows[i].DefaultCellStyle.BackColor = Color.Red;
                }
                 
 
            }
            dataGridView1.ClearSelection();
        }
        private void btn_Excel_Click(object sender, EventArgs e)
        {
            try
            {
                openFileDialog1.Filter = "Excel File(*.xls)|*.xls";
                if (openFileDialog1.ShowDialog()==DialogResult.OK)
                {
 
                    InsertPictureToExcel ipt = new InsertPictureToExcel();
                    ipt.Open(openFileDialog1.FileName);
                    ipt.Insert("标记");
                    ipt.SaveFile(openFileDialog1.FileName);
                    ipt.Close();
                    ipt.Dispose();
                    DataTable dt = WareHouse.SelectAll(openFileDialog1.FileName);
                    QueryBind(dt);
                    AppSettings.SetConnectionStringsValue("Path", openFileDialog1.FileName);
 
                    temp_Path = openFileDialog1.FileName;
                    SetState();
 
                }
                 
            }
            catch (Exception ex)
            {
                MessageBox.Show("导入失败!请检查Excel格式!" ex.Message);
            }
        }
        private void Bind()
        {
            try
            {
                string path = AppSettings.GetConnectionStringsValue("Path");
                
                if (!string.IsNullOrEmpty(path))
                {
                    if (File.Exists(path))
                    {
                        temp_Path = path;
                        DataTable dt = WareHouse.SelectAll(path);
                        
                        QueryBind(dt);
                    }
                    else
                    {
 
                    }
                   
                }
            }
            catch (Exception ex)
            {
                AppSettings.SetConnectionStringsValue("Path","");
                MessageBox.Show("程序出错!" ex.Message);
            }
        }
        private void QueryBind(DataTable dt)
        {
            for (int i = 0; i< dt.Rows.Count; i  )
            {
                string flag=dt.Rows[i]["标记"].ToString();
                if (!string.IsNullOrEmpty(flag))
                {
                    dt.Rows[i].Delete();
                }
            }
            dataGridView1.DataSource = dt;
      
        }
        private void btn_Query_Click(object sender, EventArgs e)
        {
            try
            {
                //if (dataGridView1.Rows.Count > 0)
                //{
                    string week_id = txt_week_id.Text.Trim();
                    string work_id = txt_work_id.Text.Trim();
                    string bank_id = txt_bank_id.Text.Trim();
                    string vin = txt_win.Text.Trim();
                    string fitting_code = txt_operate_code.Text.Trim();
                    string flag = cmb_state.Text.Trim();
                    DataTable dt = WareHouse.Select(week_id, work_id, bank_id, vin, fitting_code, flag, temp_Path);
                    if (flag == "未打印")
                    {
                        QueryBind(dt);
                    }
                    else
                    {
                        dataGridView1.DataSource = dt.DefaultView;
                    }
                    SetState();
               // }
                 
            }
            catch (Exception ex)
            {
                MessageBox.Show("查询失败!请检查Excel格式!"   ex.Message);
            }
        }
        private bool IsHasPrint()
        {
            bool flag = false;
            foreach (DataGridViewRow dgdr in dataGridView1.Rows)
            {
                if (dgdr.Cells["SelectColumn12"].EditedFormattedValue.ToString() == "True")
                {
                    flag = true;
                    break;
                }
            }
            return flag;
        }
 
        private void btn_Print_Click(object sender, EventArgs e)
        {
            try
            {
                string path = AppSettings.GetConnectionStringsValue("Path");
                if (dataGridView1.Rows.Count > 0)
                {
                    if (IsHasPrint())
                    {
                        printDialog1.Document = printDocument1;
                        DialogResult dr = printDialog1.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            printDocument1.Print();
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择要打印的标签!");
                    }
                }
                else
                {
                    MessageBox.Show("请先导入数据!然后选择打印!");
                }
 
            }
            catch (InvalidPrinterException ex)
            {
                MessageBox.Show("打印机异常!请检查打印机!" ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show("删除失败!"   ex.Message);
            }
        }
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0 && e.ColumnIndex != -1)
            {
                txt_operate_miaoshu.Text = dataGridView1.Rows[e.RowIndex].Cells["Column12"].Value.ToString();
                txt_operate_deal.Text = dataGridView1.Rows[e.RowIndex].Cells["Column14"].Value.ToString();
                txt_operate_reason.Text = dataGridView1.Rows[e.RowIndex].Cells["exception_reason"].Value.ToString();
            }
        }
 
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                saveFileDialog1.Filter = "Excel File(*.xls)|*.xls";
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string path = AppSettings.GetConnectionStringsValue("Path");
                    File.Copy(path, saveFileDialog1.FileName);
                    AppSettings.SetConnectionStringsValue("Path","");
                    dataGridView1.DataSource = null;
                    temp_Path = "";
                    MessageBox.Show("备份成功!");
 
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("备份失败!" ex.Message);
            }
        }
 
        private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (e.ColumnIndex!= 0)
            {
                e.Cancel = true;
            }
        }
 
        private void btn_setAsc_Click(object sender, EventArgs e)
        {
            SetASCForm fasc = new SetASCForm();
            fasc.Flag = false;
            fasc.Owner = this;
            fasc.ShowDialog();
        }
        
        private Image GetImage(string temp_asc_code,string week_id,string work_id,string bank_id,string vin,string exception_fit_id)
        {
            //生成二维码
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
            qrCodeEncoder.QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE;
            qrCodeEncoder.QRCodeScale = 2;
            qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
            qrCodeEncoder.QRCodeVersion = 4;
            string data = temp_asc_code   week_id   work_id   bank_id   vin   exception_fit_id;
            return qrCodeEncoder.Encode(data);
        }
        
 
        //打印列表
        List<TRQInfo> printlists = new List<TRQInfo>();
        private void PrintDescriptionInfo(System.Drawing.Printing.PrintPageEventArgs e,int row_number)
        {
            switch (row_number)
            {
                case 2:
                case 3:
                case 4:
                case 5:
                    e.Graphics.DrawString("请及时将索赔标签系在更换下的相应的故障件", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 390); //390
                    e.Graphics.DrawString("上。并详细描述故障原因及位置,如描述原因", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 410);
                    e.Graphics.DrawString("与实际故障不一致,上海汽车将对该索赔执行", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 430);
                    e.Graphics.DrawString("抵扣,敬请注意。", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 450);
                    break;
                default:
                    e.Graphics.DrawString("请及时将索赔标签系在更换下的相应的故障件", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 390); //390
                    e.Graphics.DrawString("上。并详细描述故障原因及位置,如描述原因", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 410);
                    e.Graphics.DrawString("与实际故障不一致,上海汽车将对该索赔执行", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 430);
                    e.Graphics.DrawString("抵扣,敬请注意。", new Font("楷体", 8, FontStyle.Regular), Brushes.Black, 10, 450);
                    break;
            }
 
        }
        /// <summary>
        ///  字符 字节 截取字符串
        /// </summary>
        /// <param name="str">要截取的字符串</param>
        /// <param name="start">开始截取位置</param>
        /// <param name="length">截取的字符串长度</param>
        /// <param name="end">要截取长度的字节个数-1</param>
        /// <param name="nextend">要截取长度的字节个数</param>
        /// <param name="total_length">字符串总长度</param>
        /// <returns></returns>
        public static string Substring(string str, int start, int length, int end, int nextend, int total_length)
        {
            string temp = string.Empty;
            int temp_length = 0;
            int number = 0;
            if ((start   length) <= total_length)
            {
                do
                {
                    temp = str.Substring(start, length);
                    number = System.Text.Encoding.GetEncoding("GB2312").GetByteCount(temp);
                    length  ;
                    temp_length = start   length;
 
                } while (number != nextend && number != end && temp_length <= total_length);
            }
            else
            {
                temp = str.Substring(start, total_length - start);
            }
            return temp;
        }
        private int page_number = 0;
        private int i = 0;
        //打印
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
 
            page_number = printlists.Count-1;//打印的页数
 
            //ASC名称  第一行
            e.Graphics.DrawString("ASC名称: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 15);
            e.Graphics.DrawString(printlists[i].Asc_name, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 90, 15);
            //ASC代码  第二行
            e.Graphics.DrawString("ASC代码: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 35);
            e.Graphics.DrawString(printlists[i].Asc_id, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 90, 35);
            //二维条码
            e.Graphics.DrawImage(printlists[i].ImgRTQ, 170, 32, 80, 80);
            //索赔工单号    第三行
            e.Graphics.DrawString("索赔工单号: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 55);
            e.Graphics.DrawString(printlists[i].Work_id, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 100, 55);
 
            //索赔周次      第四行
            e.Graphics.DrawString("索赔周次: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 75);
            e.Graphics.DrawString(printlists[i].Week_id, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 90, 75);
            //操作代码      第五行
            e.Graphics.DrawString("操作代码: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 95);
            e.Graphics.DrawString(printlists[i].Operater_code, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 90, 95);
 
            //车型  行号  第六行
            e.Graphics.DrawString("车型: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 120);
            e.Graphics.DrawString(printlists[i].Car_model, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 60, 120);
 
            //里程数        第七行
            e.Graphics.DrawString("里程数: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 140);
            e.Graphics.DrawString(printlists[i].Card_km, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 80, 140);
 
            e.Graphics.DrawString("故障件数量: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 170, 140);
            e.Graphics.DrawString(printlists[i].Exception_number, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 250, 140);
            //车辆识别号  第八行
            e.Graphics.DrawString("车辆识别号: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 160);
            e.Graphics.DrawString(printlists[i].Vin, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 110, 160);
 
            //故障零件号  行号  第九行
            e.Graphics.DrawString("故障零件号: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 180);
            e.Graphics.DrawString(printlists[i].Exception_fit_number, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 105, 180);
            e.Graphics.DrawString("行号: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 210, 180);
            e.Graphics.DrawString(printlists[i].Bank_id, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 245, 180);
 
            //故障代码  主要配件 第十行
            e.Graphics.DrawString("故障代码: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 200);
            e.Graphics.DrawString(printlists[i].Exception_code, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 100, 200);
 
            e.Graphics.DrawString("主要配件: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 150, 200);
            e.Graphics.DrawString(printlists[i].Zhuyao_fit, new Font("Arial", 20, FontStyle.Regular), Brushes.Black, 220, 195);
            //故障名称 第十一行
            e.Graphics.DrawString("故障名称: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 230);
            string temp_exception_name = printlists[i].Exception_name;
            int exception_name_length = temp_exception_name.Length;
 
            string excepton_info1 = Substring(temp_exception_name, 0, 11, 21, 22, exception_name_length);
            e.Graphics.DrawString(excepton_info1, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 95, 230);
 
            string excepton_info2 = Substring(temp_exception_name, excepton_info1.Length, 17, 33, 34, exception_name_length);
            e.Graphics.DrawString(excepton_info2, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 25, 250);
 
            string temp_exception_reason = printlists[i].Exception_reason;
            int exception_reason_length = temp_exception_reason.Length;
            e.Graphics.DrawString("故障原因及位置: ", new Font("Arial", 9, FontStyle.Bold), Brushes.Black, 25, 280);
            string reason_one = Substring(temp_exception_reason, 0, 9, 17, 18, exception_reason_length);
            e.Graphics.DrawString(reason_one, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 140, 280);
 
            string reason_two = Substring(temp_exception_reason, reason_one.Length, 17, 33, 34, exception_reason_length);
            e.Graphics.DrawString(reason_two, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 25, 300);
 
            string reason_three = Substring(temp_exception_reason, reason_one.Length   reason_two.Length, 17, 33, 34, exception_reason_length);
            e.Graphics.DrawString(reason_three, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 25, 320);
 
            string reason_four = Substring(temp_exception_reason, reason_one.Length   reason_two.Length   reason_three.Length, 17, 33, 34, exception_reason_length);
            e.Graphics.DrawString(reason_four, new Font("Arial", 9, FontStyle.Regular), Brushes.Black, 25, 340);
            PrintDescriptionInfo(e, 2);
            if (i != page_number)
            {
                e.HasMorePages = true;
                i  ;
                return;
            }
            i = 0;
            page_number = 0;
            e.HasMorePages = false;
        }
        //全选
        private void btn_SelectAll_Click(object sender, EventArgs e)
        {
            if (dataGridView1.RowCount > 0)
            {
                foreach (DataGridViewRow dgdr in dataGridView1.Rows)
                {
                    dgdr.Cells["SelectColumn12"].Value = true;
                }
            }
        }
 
        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow dgdr in dataGridView1.Rows)
            {
                dgdr.Cells["SelectColumn12"].Value =false;
            }
        }
 
        private void btn_Exit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
 
        private void printDocument1_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            try
            {
 
                string path = AppSettings.GetConnectionStringsValue("Path");
                if (dataGridView1.Rows.Count > 0)
                {
                    if (IsHasPrint())
                    {
 
                        foreach (DataGridViewRow dgdr in dataGridView1.Rows)
                        {
 
                            if (dgdr.Cells["SelectColumn12"].EditedFormattedValue.ToString() == "True")
                            {
                                TRQInfo trqinfo = new TRQInfo();
 
                                trqinfo.Asc_name = asc_name;
                                trqinfo.Asc_id = asc_code;
 
                                trqinfo.Week_id = dgdr.Cells["week_id"].EditedFormattedValue.ToString();//索赔周次
                                trqinfo.Work_id = dgdr.Cells["work_id"].EditedFormattedValue.ToString();//索赔工单号
                                trqinfo.Bank_id = dgdr.Cells["bank_id"].EditedFormattedValue.ToString();//行号
                                trqinfo.Vin = dgdr.Cells["vin"].EditedFormattedValue.ToString();//VIN码
                                trqinfo.Exception_fit_number = dgdr.Cells["exception_fit_id"].EditedFormattedValue.ToString();//故障零件号
 
                                trqinfo.Operater_code = dgdr.Cells["operate_code"].EditedFormattedValue.ToString();//操作代码
                                trqinfo.Card_km = dgdr.Cells["card_km"].EditedFormattedValue.ToString();//里程数
                                trqinfo.Car_model = dgdr.Cells["card_mode"].EditedFormattedValue.ToString();//车型
 
                                trqinfo.Exception_code= dgdr.Cells["exception_code"].EditedFormattedValue.ToString();//故障代码
                                trqinfo.Exception_number = dgdr.Cells["exception_fit_number"].EditedFormattedValue.ToString();//故障件数量
                                trqinfo.Exception_name = dgdr.Cells["exception_name"].EditedFormattedValue.ToString();//故障名称
                                trqinfo.Exception_reason = dgdr.Cells["exception_reason"].EditedFormattedValue.ToString();//故障原因
                                trqinfo.Zhuyao_fit = dgdr.Cells["zhuyaopeijian"].EditedFormattedValue.ToString();//主要配件
                                trqinfo.ImgRTQ = GetImage(trqinfo.Asc_id, trqinfo.Week_id, trqinfo.Work_id, trqinfo.Bank_id, trqinfo.Vin, trqinfo.Exception_fit_number);
                                string temp_exception_fit_number = dgdr.Cells["exception_fit_number"].EditedFormattedValue.ToString();
                                int temp_number = Convert.ToInt32(temp_exception_fit_number);
                                for (int i = 0; i < temp_number; i  )
                                {
                                    printlists.Add(trqinfo);
                                }
                                WareHouse.Update(trqinfo.Week_id,trqinfo.Work_id,trqinfo.Bank_id,trqinfo.Vin,trqinfo.Exception_fit_number, "Y", temp_Path);
                                dgdr.Cells["Column17"].Value = "已打印";
                                dgdr.DefaultCellStyle.BackColor = Color.RosyBrown;
                                dgdr.Cells["SelectColumn12"].Value = false;
                                
                            }
                        }
 
                    }
                    else
                    {
                        MessageBox.Show("请选择要打印的标签!");
                    }
                }
                else
                {
                    MessageBox.Show("请先导入数据!然后选择打印!");
                }
 
            }
            catch (Exception ex)
            {
                MessageBox.Show("删除失败!"   ex.Message);
            }
        }
 
        private void printDocument1_EndPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            printlists.Clear();
        }
    }
}

标签: C# 源码 打印 多页

实例下载地址

c#写的多页打印源码(支持导入excel数据)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警