Nenhuma descrição

PrintForm.cs 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SQLite;
  11. namespace BulkPrinting
  12. {
  13. public partial class PrintForm : Form
  14. {
  15. public PrintForm()
  16. {
  17. InitializeComponent();
  18. }
  19. public string PrintDescription;
  20. public DateTime BatchOrderDate;
  21. public int UnprintedVouchers;
  22. public int TotalVouchers;
  23. public string FaceValue;
  24. public string VoucherTypeName;
  25. public string NetworkName;
  26. public int BatchID;
  27. private Boolean CanReprintThisSession;
  28. private void PrintForm_Load(object sender, EventArgs e)
  29. {
  30. CanReprintThisSession =
  31. ((Globals.SessionMode == SessionModes.Online &&
  32. Utility.CheckUserAccess(Utility.UserPermissions.CanReprintOnline)) ||
  33. (Globals.SessionMode == SessionModes.Offline &&
  34. Utility.CheckUserAccess(Utility.UserPermissions.CanReprintOffline)));
  35. lblPrintDescription.Text = PrintDescription;
  36. lblBatchNumber.Text = BatchID.ToString();
  37. lblBatchOrderDate.Text = BatchOrderDate.Date.ToString("dd/MM/yyyy");
  38. lblUnprintedVouchers.Text = UnprintedVouchers.ToString();
  39. lblTotalVouchers.Text = TotalVouchers.ToString();
  40. lblFaceValue.Text = FaceValue;
  41. lblVoucherType.Text = VoucherTypeName;
  42. lblNetwork.Text = NetworkName;
  43. numNumVouchers.Maximum = UnprintedVouchers;
  44. }
  45. private void btnCancel_Click(object sender, EventArgs e)
  46. {
  47. Globals.OpenBatches.Remove(BatchID);
  48. this.Close();
  49. }
  50. private void btnNext_Click(object sender, EventArgs e)
  51. {
  52. decimal VoucherCount;
  53. if (numNumVouchers.Value < 1)
  54. {
  55. MessageBox.Show("Please select a valid number of vouchers to print", "Invalid print value", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  56. return;
  57. }
  58. if (numNumVouchers.Value > UnprintedVouchers)
  59. {
  60. if (CanReprintThisSession)
  61. {
  62. MessageBox.Show("You have selected more vouchers than are available to print. If you wish to reprint vouchers that have already been printed, please select the 'Print Voucher Range' option and type in the starting and ending voucher sequence numbers to print that range.", "Cannot print that many vouchers", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  63. return;
  64. }
  65. else
  66. {
  67. MessageBox.Show("You have selected more vouchers than are available to print.", "Cannot print that many vouchers", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  68. return;
  69. }
  70. }
  71. string Sql = "SELECT FaceValue FROM Batch WHERE Id = @id";
  72. SQLiteCommand Command = new SQLiteCommand(Sql, Globals.DBConnection);
  73. Command.Parameters.Add(new SQLiteParameter("@id", BatchID));
  74. VoucherCount = numNumVouchers.Value;
  75. decimal TotalVoucherValue = VoucherCount * (decimal)Command.ExecuteScalar();
  76. if (Globals.SessionMode == SessionModes.Online)
  77. {
  78. if (!Utility.IsValueWithinRemainingUserLimit(UserLimits.UserLimitTypes.OnlinePrint, TotalVoucherValue))
  79. {
  80. MessageBox.Show("You have selected more vouchers than your permissions allow you to print today.", "Cannot print that many vouchers", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  81. return;
  82. }
  83. }
  84. if (Globals.SessionMode == SessionModes.Offline)
  85. {
  86. if (!Utility.IsValueWithinRemainingUserLimit(UserLimits.UserLimitTypes.OfflinePrint, TotalVoucherValue))
  87. {
  88. MessageBox.Show("You have selected more vouchers than your permissions allow you to print today.", "Cannot print that many vouchers", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  89. return;
  90. }
  91. }
  92. if (Globals.MaxPrinter.ChoosePrinter())
  93. {
  94. PrintAlignmentDialog printdialog = new PrintAlignmentDialog();
  95. printdialog.PrintDescription = PrintDescription;
  96. printdialog.BatchID = BatchID;
  97. printdialog.BatchOrderDate = BatchOrderDate;
  98. printdialog.FaceValue = FaceValue;
  99. printdialog.VoucherTypeName = VoucherTypeName;
  100. printdialog.NetworkName = NetworkName;
  101. printdialog.NumVouchers = (int)numNumVouchers.Value;
  102. printdialog.FirstSeqNo = null;
  103. printdialog.LastSeqNo = null;
  104. printdialog.Show();
  105. this.Close();
  106. }
  107. }
  108. private void lblPrintDescription_Click(object sender, EventArgs e)
  109. {
  110. }
  111. }
  112. }