/* print packing slip button clicks that print the packing slip for the order item(s) */ private void printPackingSlipButton_Click(object sender, EventArgs e) { // get all cancel index and print the packing slip that are not cancelled int[] cancelIndex = GetCancelIndex(); switch (CHANNEL) { case "Sears": // ths case if the order is from sears try { SearsPackingSlip.CreatePackingSlip(searsValues, cancelIndex, true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; case "Shop.ca": // the case if the order is from shop.ca try { ShopCaPackingSlip.CreatePackingSlip(shopCaValues, cancelIndex, true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; case "Giant Tiger": // the case if the order is from giant tiger try { GiantTigerPackingSlip.CreatePackingSlip(giantTigerValues, cancelIndex, true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; } }
/* print button click that export the checked items' packing slip */ private void printButton_Click(object sender, EventArgs e) { // error check -> the case if the user has not select any of the order to print if (listview.CheckedItems.Count < 1) { MessageBox.Show("Please select the order you want to export the packing slip", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // fields for message string message = "Packing Slip have successfully exported to"; bool[] channel = { false, false, false }; // [0] sears, [1] shop.ca, [2] giant tiger foreach (Order order in from ListViewItem item in listview.CheckedItems select new Order { Source = item.SubItems[0].Text, TransactionId = item.SubItems[4].Text }) { switch (order.Source) { case "Sears": { // the case if it is sears order try { SearsPackingSlip.CreatePackingSlip(sears.GenerateValue(order.TransactionId), new int[0], false); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } channel[0] = true; } break; case "Shop.ca": { // the case if it is shop.ca order try { ShopCaPackingSlip.CreatePackingSlip(shopCa.GenerateValue(order.TransactionId), new int[0], false); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } channel[1] = true; } break; case "Giant Tiger": { // the case if it is giant tiger order try { GiantTigerPackingSlip.CreatePackingSlip(giantTiger.GenerateValue(order.TransactionId), new int[0], false); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } channel[2] = true; } break; } } // create message if (channel[0]) { message += '\n' + SearsPackingSlip.SavePath; } if (channel[1]) { message += '\n' + ShopCaPackingSlip.SavePath; } if (channel[2]) { message += '\n' + GiantTigerPackingSlip.SavePath; } MessageBox.Show(message, "Congratulation"); }