|
|
|
|
|
|
82
|
{
|
82
|
{
|
|
83
|
int SelectedRangeStart = 0;
|
83
|
int SelectedRangeStart = 0;
|
|
84
|
int SelectedRangeEnd = 0;
|
84
|
int SelectedRangeEnd = 0;
|
|
|
|
85
|
+ int SelectedBatchID = -1;
|
|
85
|
|
86
|
|
|
86
|
decimal VoucherCount;
|
87
|
decimal VoucherCount;
|
|
87
|
|
88
|
|
|
|
|
|
|
|
103
|
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
|
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
|
return;
|
105
|
return;
|
|
105
|
}
|
106
|
}
|
|
|
|
107
|
+ SelectedBatchID = BatchID;
|
|
106
|
SelectedRangeStart = (int)numFirstSeqNum.Value;
|
108
|
SelectedRangeStart = (int)numFirstSeqNum.Value;
|
|
107
|
SelectedRangeEnd = (int)numLastSeqNum.Value;
|
109
|
SelectedRangeEnd = (int)numLastSeqNum.Value;
|
|
108
|
}
|
110
|
}
|
|
|
|
|
|
|
120
|
return;
|
122
|
return;
|
|
121
|
}
|
123
|
}
|
|
122
|
|
124
|
|
|
|
|
125
|
+ SelectedBatchID = BatchID;
|
|
123
|
SelectedRangeStart = ((int)numFirstPageNum.Value - 1) * 20 + MinSeqNo;
|
126
|
SelectedRangeStart = ((int)numFirstPageNum.Value - 1) * 20 + MinSeqNo;
|
|
124
|
SelectedRangeEnd = (int)numLastPageNum.Value * 20 + MinSeqNo - 1;
|
127
|
SelectedRangeEnd = (int)numLastPageNum.Value * 20 + MinSeqNo - 1;
|
|
125
|
if (SelectedRangeEnd > MaxSeqNo)
|
128
|
if (SelectedRangeEnd > MaxSeqNo)
|
|
|
|
|
|
|
128
|
}
|
131
|
}
|
|
129
|
}
|
132
|
}
|
|
130
|
else if (rdoSerial.Checked) {
|
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
|
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);
|
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
|
return;
|
149
|
return;
|
|
138
|
}
|
150
|
}
|
|
|
|
|
|
|
184
|
{
|
196
|
{
|
|
185
|
PrintAlignmentDialog printdialog = new PrintAlignmentDialog();
|
197
|
PrintAlignmentDialog printdialog = new PrintAlignmentDialog();
|
|
186
|
printdialog.PrintDescription = PrintDescription;
|
198
|
printdialog.PrintDescription = PrintDescription;
|
|
187
|
- printdialog.BatchID = BatchID;
|
|
|
|
|
|
199
|
+ printdialog.BatchID = SelectedBatchID;
|
|
188
|
printdialog.BatchOrderDate = BatchOrderDate;
|
200
|
printdialog.BatchOrderDate = BatchOrderDate;
|
|
189
|
printdialog.FaceValue = FaceValue;
|
201
|
printdialog.FaceValue = FaceValue;
|
|
190
|
printdialog.VoucherTypeName = VoucherTypeName;
|
202
|
printdialog.VoucherTypeName = VoucherTypeName;
|
|
191
|
printdialog.NetworkName = NetworkName;
|
203
|
printdialog.NetworkName = NetworkName;
|
|
192
|
printdialog.NumVouchers = null;
|
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
|
printdialog.Show();
|
207
|
printdialog.Show();
|
|
196
|
this.Close();
|
208
|
this.Close();
|
|
197
|
}
|
209
|
}
|