Sfoglia il codice sorgente

Attempted fix for DBnull error on printing by comparing number of actual downloaded vouchers to DeliveredQuantity

Brett Credo 8 anni fa
parent
commit
a19ee70644

+ 3 - 3
BulkPrinting/BulkPrinting/BatchForm.Designer.cs

@@ -29,7 +29,7 @@
29 29
         private void InitializeComponent()
30 30
         {
31 31
             this.components = new System.ComponentModel.Container();
32
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
32
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
33 33
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BatchForm));
34 34
             this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
35 35
             this.pnlSplitGrids = new System.Windows.Forms.Panel();
@@ -304,8 +304,8 @@
304 304
             this.dgvBatches.AllowUserToAddRows = false;
305 305
             this.dgvBatches.AllowUserToDeleteRows = false;
306 306
             this.dgvBatches.AllowUserToResizeRows = false;
307
-            dataGridViewCellStyle2.BackColor = System.Drawing.Color.Azure;
308
-            this.dgvBatches.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2;
307
+            dataGridViewCellStyle1.BackColor = System.Drawing.Color.Azure;
308
+            this.dgvBatches.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1;
309 309
             this.dgvBatches.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
310 310
             | System.Windows.Forms.AnchorStyles.Left) 
311 311
             | System.Windows.Forms.AnchorStyles.Right)));

+ 12 - 0
BulkPrinting/BulkPrinting/BatchForm.cs

@@ -300,6 +300,18 @@ namespace BulkPrinting
300 300
                 MessageBox.Show("A print dialog is already open for this batch","Cannot open print dialog",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
301 301
                 return;
302 302
             }
303
+
304
+            int DeliveredVoucherCount = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["DeliveredQuantity"].Index].Value;
305
+            string Sql = "SELECT COUNT(*) FROM Voucher WHERE BatchId=@id";
306
+            SQLiteCommand Command = new SQLiteCommand(Sql, Globals.DBConnection);
307
+            Command.Parameters.Add(new SQLiteParameter("@id", BatchID));
308
+            int DownloadedVoucherCount = Convert.ToInt32(Command.ExecuteScalar());
309
+            if (DownloadedVoucherCount < DeliveredVoucherCount) {
310
+                MessageBox.Show(string.Format("Batch {0} has not finished downloading.\nDownloaded {1} of {2} vouchers in batch.",BatchID,DownloadedVoucherCount,DeliveredVoucherCount), "Cannot open print dialog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
311
+                return;
312
+            }
313
+
314
+
303 315
             this.BeginInvoke((Action)delegate {
304 316
                 PrintForm PrintFormInstance = new PrintForm();
305 317
                 Globals.OpenBatches.Add(BatchID);