浏览代码

Fix reprinting by page range and serial number.

Brett Credo 8 年之前
父节点
当前提交
3256615005
共有 2 个文件被更改,包括 21 次插入9 次删除
  1. 1 1
      BulkPrinting/BulkPrinting/Properties/AssemblyInfo.cs
  2. 20 8
      BulkPrinting/BulkPrinting/ReprintForm.cs

+ 1 - 1
BulkPrinting/BulkPrinting/Properties/AssemblyInfo.cs

@@ -33,4 +33,4 @@ using System.Runtime.InteropServices;
33 33
 // by using the '*' as shown below:
34 34
 // [assembly: AssemblyVersion("1.0.*")]
35 35
 [assembly: AssemblyVersion("1.0.*")]
36
-[assembly: AssemblyFileVersion("1.6")]
36
+[assembly: AssemblyFileVersion("1.7")]

+ 20 - 8
BulkPrinting/BulkPrinting/ReprintForm.cs

@@ -82,6 +82,7 @@ namespace BulkPrinting
82 82
         {
83 83
             int SelectedRangeStart = 0;
84 84
             int SelectedRangeEnd = 0;
85
+            int SelectedBatchID = -1;
85 86
 
86 87
             decimal VoucherCount;
87 88
 
@@ -103,6 +104,7 @@ namespace BulkPrinting
103 104
                     MessageBox.Show("You have a final sequence number higher than the available vouchers to print. Please reduce the last sequence number to equal to or below the total number of vouchers.", "Cannot print that many vouchers", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
104 105
                     return;
105 106
                 }
107
+                SelectedBatchID = BatchID;
106 108
                 SelectedRangeStart = (int)numFirstSeqNum.Value;
107 109
                 SelectedRangeEnd = (int)numLastSeqNum.Value;
108 110
             }
@@ -120,6 +122,7 @@ namespace BulkPrinting
120 122
                     return;
121 123
                 }
122 124
 
125
+                SelectedBatchID = BatchID;
123 126
                 SelectedRangeStart = ((int)numFirstPageNum.Value - 1) * 20 + MinSeqNo;
124 127
                 SelectedRangeEnd = (int)numLastPageNum.Value * 20 + MinSeqNo - 1;
125 128
                 if (SelectedRangeEnd > MaxSeqNo)
@@ -128,11 +131,20 @@ namespace BulkPrinting
128 131
                 }
129 132
             }
130 133
             else if (rdoSerial.Checked) {
131
-                int PrintCount = int.Parse(Globals.DB.ExecuteScalar(
132
-                    "SELECT Count(*) FROM Logs l left join Voucher v on l.VoucherId=v.id WHERE v.Serial=@serialnum and l.EventType=@eventtype and Retry=0",
133
-                    new SQLiteParameter("@serialnum", txtSerialNum.Text),
134
-                    new SQLiteParameter("@eventtype", VendorEvent.VendorEventType.PrintVoucher)).ToString());
135
-                if (PrintCount == 0) {
134
+                using (var command = Globals.DB.CreateCommand("SELECT * FROM Voucher WHERE Serial=@Serial AND PrintCount>0",
135
+                    new SQLiteParameter("@Serial", txtSerialNum.Text)))
136
+                {
137
+                    using (var reader = command.ExecuteReader())
138
+                    {
139
+                        if (reader.Read())
140
+                        {
141
+                            SelectedBatchID = (int)reader["BatchID"];
142
+                            SelectedRangeStart = (int)reader["SequenceNumber"];
143
+                            SelectedRangeEnd = SelectedRangeStart;
144
+                        }
145
+                    }
146
+                }
147
+                if (SelectedBatchID < 0) {
136 148
                     MessageBox.Show("No voucher with that serial number was found to have been printed. Please provide a previously printed voucher number or use the 'Print' function to print new vouchers.", "Cannot find printed voucher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
137 149
                     return;
138 150
                 }
@@ -184,14 +196,14 @@ namespace BulkPrinting
184 196
             {
185 197
                 PrintAlignmentDialog printdialog = new PrintAlignmentDialog();
186 198
                 printdialog.PrintDescription = PrintDescription;
187
-                printdialog.BatchID = BatchID;
199
+                printdialog.BatchID = SelectedBatchID;
188 200
                 printdialog.BatchOrderDate = BatchOrderDate;
189 201
                 printdialog.FaceValue = FaceValue;
190 202
                 printdialog.VoucherTypeName = VoucherTypeName;
191 203
                 printdialog.NetworkName = NetworkName;
192 204
                 printdialog.NumVouchers = null;
193
-                printdialog.FirstSeqNo = (int)numFirstSeqNum.Value;
194
-                printdialog.LastSeqNo = (int)numLastSeqNum.Value;
205
+                printdialog.FirstSeqNo = SelectedRangeStart;
206
+                printdialog.LastSeqNo = SelectedRangeEnd;
195 207
                 printdialog.Show();
196 208
                 this.Close();
197 209
             }