소스 검색

Optimised check for unprinted vouchers in range on Reprint next button
Changed printing to send one large job instead of one job per row

Brett Credo 8 년 전
부모
커밋
313356600e
2개의 변경된 파일13개의 추가작업 그리고 4개의 파일을 삭제
  1. 10 1
      BulkPrinting/BulkPrinting/ReprintForm.cs
  2. 3 3
      BulkPrinting/BulkPrinting/Utility.cs

+ 10 - 1
BulkPrinting/BulkPrinting/ReprintForm.cs

@@ -113,8 +113,17 @@ namespace BulkPrinting
113 113
 
114 114
             VoucherCount = SelectedRangeEnd - SelectedRangeStart + 1;
115 115
             decimal VoucherFaceValue = (decimal)Command.ExecuteScalar();
116
-            int UnprintedVouchersInRange = Utility.GetNumberOfUnprintedVouchersInRange((int)numFirstSeqNum.Value, (int)numLastSeqNum.Value, BatchID);
117 116
 
117
+            string countsql = "SELECT COUNT(v.ID) FROM Voucher v LEFT JOIN Logs l ON v.Id=l.VoucherId AND l.EventType=@event WHERE v.BatchId=@batchid AND v.SequenceNumber BETWEEN @startseq AND @endseq AND l.id IS NULL";
118
+            SQLiteCommand NewCommand = new SQLiteCommand(countsql, Globals.DBConnection);
119
+
120
+            NewCommand.Parameters.AddWithValue("@event", (int) VendorEvent.VendorEventType.PrintVoucher);
121
+            NewCommand.Parameters.AddWithValue("@batchid", BatchID);
122
+            NewCommand.Parameters.AddWithValue("@startseq", SelectedRangeStart);
123
+            NewCommand.Parameters.AddWithValue("@endseq", SelectedRangeEnd);
124
+
125
+            var result = Command.ExecuteScalar();//Utility.GetNumberOfUnprintedVouchersInRange((int)numFirstSeqNum.Value, (int)numLastSeqNum.Value, BatchID);
126
+            int UnprintedVouchersInRange = int.Parse(result.ToString());
118 127
             decimal PrintedVoucherValue = (VoucherCount - UnprintedVouchersInRange) * VoucherFaceValue;
119 128
             decimal UnprintedVoucherValue = UnprintedVouchersInRange * VoucherFaceValue;
120 129
 

+ 3 - 3
BulkPrinting/BulkPrinting/Utility.cs

@@ -422,6 +422,8 @@ namespace BulkPrinting
422 422
 
423 423
             using (SQLiteDataReader read = Command.ExecuteReader())
424 424
             {
425
+                int JobID = Globals.MaxPrinter.Open("Vouchers");
426
+                if (JobID == 0) return;
425 427
                 while (read.Read())
426 428
                 {
427 429
                     VoucherCount++;
@@ -475,10 +477,7 @@ namespace BulkPrinting
475 477
                             PrintRow += (Column == 2 ? " " : "") + IndividualVoucher.Description.PadRight(30, ' ');
476 478
                         }
477 479
                         PrintRow = PrintRow.TrimEnd() + "\r\n\n\n\n\n\n\n\n\n\n\n";
478
-                        int JobID = Globals.MaxPrinter.Open("Vouchers");
479
-                        if (JobID == 0) return;
480 480
                         Globals.MaxPrinter.Print(PrintRow);
481
-                        Globals.MaxPrinter.Close();
482 481
                         foreach (PrintVoucher PrintedVoucher in VoucherRow)
483 482
                         {
484 483
                             var ExportEvent = new EventLog();
@@ -499,6 +498,7 @@ namespace BulkPrinting
499 498
                     }
500 499
                     TotalCount++;
501 500
                 }
501
+                Globals.MaxPrinter.Close();
502 502
             }
503 503
             Utility.LogBulkEvents(LogEvents);
504 504
         }