Nav apraksta

BatchForm.cs 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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.IO;
  11. using System.Net;
  12. using Newtonsoft.Json;
  13. using Newtonsoft.Json.Serialization;
  14. using System.Data.SQLite;
  15. using System.Threading;
  16. using System.Globalization;
  17. namespace BulkPrinting
  18. {
  19. public partial class BatchForm : ObservedForm
  20. {
  21. Thread LoadingThread;
  22. public BatchForm()
  23. {
  24. InitializeComponent();
  25. }
  26. private class BatchEvent
  27. {
  28. public int PrintCount=0;
  29. public int ReprintCount=0;
  30. public int ExportCount=0;
  31. }
  32. public void PopulateGrid()
  33. {
  34. Dictionary<int, BatchEvent> BatchEvents = new Dictionary<int, BatchEvent>();
  35. string Sql = "Select COUNT(v.BatchId) AS Total, v.BatchId,l.EventType,l.Retry FROM Voucher v LEFT JOIN Logs l on v.Id = l.VoucherId WHERE l.EventType in (@printevent,@exportevent) GROUP BY v.BatchId,l.EventType,l.Retry ORDER BY BatchId";
  36. SQLiteCommand Command = new SQLiteCommand(Sql, Globals.DBConnection);
  37. Command.Parameters.Add(new SQLiteParameter("@printevent", VendorEvent.VendorEventType.PrintVoucher));
  38. Command.Parameters.Add(new SQLiteParameter("@exportevent", VendorEvent.VendorEventType.ExportVoucher));
  39. using (SQLiteDataReader read = Command.ExecuteReader())
  40. {
  41. while (read.Read())
  42. {
  43. int BatchId = int.Parse(read["BatchId"].ToString());
  44. if (!BatchEvents.ContainsKey(BatchId))
  45. {
  46. BatchEvents.Add(BatchId, new BatchEvent());
  47. }
  48. if (read["EventType"].ToString() == "6")
  49. {
  50. if (read["Retry"].ToString() == "True")
  51. {
  52. BatchEvents[BatchId].ReprintCount += int.Parse(read["Total"].ToString());
  53. }
  54. else
  55. {
  56. BatchEvents[BatchId].PrintCount += int.Parse(read["Total"].ToString());
  57. }
  58. }
  59. else if (read["EventType"].ToString() == "8")
  60. {
  61. BatchEvents[BatchId].ExportCount += int.Parse(read["Total"].ToString());
  62. }
  63. }
  64. }
  65. bool CanOrder = Utility.CheckUserAccess(Utility.UserPermissions.BulkOrder);
  66. bool CanExport = Utility.CheckUserAccess(Utility.UserPermissions.BulkExport);
  67. dgvBatches.Rows.Clear();
  68. dgvBatches.Columns.Clear();
  69. dgvBatches.Columns.Add("Id", "ID");
  70. dgvBatches.Columns.Add("OrderDate", "Order Date");
  71. if (CanOrder) dgvBatches.Columns.Add("OrderReference", "Order Reference");
  72. dgvBatches.Columns.Add("NetworkName", "Network Name");
  73. dgvBatches.Columns.Add("ProductDescription", "Product Description");
  74. dgvBatches.Columns.Add("VoucherType", "Voucher Type");
  75. dgvBatches.Columns.Add("FaceValue", "Face Value");
  76. if (CanOrder) dgvBatches.Columns.Add("RequestedQuantity", "Quantity Ordered");
  77. dgvBatches.Columns.Add("DeliveredQuantity", "Quantity Delivered");
  78. if (CanOrder) dgvBatches.Columns.Add("ReadyForDownload", "Batch Ready for Download");
  79. dgvBatches.Columns.Add("PrintedQuantity", "Quantity Printed");
  80. if (CanExport) dgvBatches.Columns.Add("Exported", "Exported Batch");
  81. Sql = "Select Id,OrderDate,OrderReference,NetworkName,ProductDescription,VoucherType,FaceValue,RequestedQuantity,DeliveredQuantity,ReadyForDownload From Batch WHERE OrderDate BETWEEN @startdate AND @enddate";
  82. SQLiteCommand comm = new SQLiteCommand(Sql, Globals.DBConnection);
  83. CultureInfo IVC = CultureInfo.InvariantCulture;
  84. comm.Parameters.Add(new SQLiteParameter("@startdate", dtpFilterStartDate.Value.Date.ToString("yyyy-MM-dd 00:00:00", IVC)));
  85. comm.Parameters.Add(new SQLiteParameter("@enddate", dtpFilterEndDate.Value.Date.ToString("yyyy-MM-dd 23:59:59", IVC)));
  86. lblLoading.Hide();
  87. using (SQLiteDataReader read = comm.ExecuteReader())
  88. {
  89. while (read.Read())
  90. {
  91. int BatchId = int.Parse(read["Id"].ToString());
  92. if (!BatchEvents.ContainsKey(BatchId))
  93. { //For batches with no events
  94. BatchEvents.Add(BatchId, new BatchEvent());
  95. }
  96. int DeliveredQuantity = int.Parse(read["DeliveredQuantity"].ToString());
  97. if (rdoFilterPrinted.Checked)
  98. {
  99. if (BatchEvents[BatchId].PrintCount == 0)
  100. {
  101. continue;
  102. }
  103. }
  104. if (rdoFilterUnprinted.Checked) {
  105. if (BatchEvents[BatchId].PrintCount >= DeliveredQuantity)
  106. {
  107. continue;
  108. }
  109. }
  110. if (rdoFilterReprinted.Checked) {
  111. if (BatchEvents[BatchId].ReprintCount == 0)
  112. {
  113. continue;
  114. }
  115. }
  116. if (rdoFilterExported.Checked)
  117. {
  118. if (BatchEvents[BatchId].ExportCount == 0)
  119. {
  120. continue;
  121. }
  122. }
  123. else {
  124. if (BatchEvents[BatchId].ExportCount > 0)
  125. {
  126. continue;
  127. }
  128. }
  129. var BatchRow = new object[] {
  130. BatchId,
  131. read["OrderDate"],
  132. read["OrderReference"],
  133. read["NetworkName"].ToString(),
  134. read["ProductDescription"].ToString(),
  135. Enum.Parse(typeof(Vouchertype), read["VoucherType"].ToString()).ToString(),
  136. "R" +((decimal)read["FaceValue"]).ToString("0.##")};
  137. if (CanOrder)
  138. BatchRow = BatchRow.Concat(new[] { read["RequestedQuantity"] }).ToArray();
  139. BatchRow = BatchRow.Concat(new[] { read["DeliveredQuantity"] }).ToArray();
  140. if (CanOrder)
  141. BatchRow = BatchRow.Concat(new[] { ((bool)read["ReadyForDownload"] == true ? "Yes" : "No") }).ToArray();
  142. BatchRow = BatchRow.Concat(new[] { (object)BatchEvents[BatchId].PrintCount }).ToArray();
  143. if (CanExport)
  144. BatchRow = BatchRow.Concat(new[] { (BatchEvents[BatchId].ExportCount >0?"Exported":"") }).ToArray();
  145. dgvBatches.Rows.Add(BatchRow);
  146. }
  147. dgvBatches.Sort(dgvBatches.Columns["OrderDate"], ListSortDirection.Descending);
  148. }
  149. }
  150. private void BatchForm_Load(object sender, EventArgs e)
  151. {
  152. List<Button> LeftButtonList = new List<Button>();
  153. List<Button> RightButtonList = new List<Button>();
  154. LeftButtonList.Add(this.btnLogout);
  155. LeftButtonList.Add(this.btnOrderReport);
  156. LeftButtonList.Add(this.btnOrder);
  157. LeftButtonList.Add(this.btnPrint);
  158. LeftButtonList.Add(this.btnExport);
  159. RightButtonList.Add(this.btnViewPINs);
  160. RightButtonList.Add(this.btnReExport);
  161. RightButtonList.Add(this.btnReprint);
  162. foreach (Button b in LeftButtonList) {
  163. b.Hide();
  164. }
  165. foreach (Button b in RightButtonList) {
  166. b.Hide();
  167. }
  168. if (Globals.SessionMode == SessionModes.Online)
  169. {
  170. if (!Utility.CheckUserAccess(Utility.UserPermissions.BulkOrder))
  171. LeftButtonList.Remove(this.btnOrder);
  172. if (!Utility.CheckUserAccess(Utility.UserPermissions.CanPrintOnline))
  173. LeftButtonList.Remove(this.btnPrint);
  174. if (!Utility.CheckUserAccess(Utility.UserPermissions.CanReprintOnline)) {
  175. RightButtonList.Remove(this.btnReprint);
  176. rdoFilterReprinted.Hide();
  177. }
  178. }
  179. else if (Globals.SessionMode == SessionModes.Offline)
  180. {
  181. LeftButtonList.Remove(this.btnOrder);
  182. if (!Utility.CheckUserAccess(Utility.UserPermissions.CanPrintOffline))
  183. LeftButtonList.Remove(this.btnPrint);
  184. if (!Utility.CheckUserAccess(Utility.UserPermissions.CanReprintOffline)) {
  185. RightButtonList.Remove(this.btnReprint);
  186. rdoFilterReprinted.Hide();
  187. }
  188. }
  189. if (!Utility.CheckUserAccess(Utility.UserPermissions.BulkExport)) {
  190. LeftButtonList.Remove(this.btnExport);
  191. RightButtonList.Remove(this.btnReExport);
  192. rdoFilterExported.Hide();
  193. }
  194. if (!Utility.CheckUserAccess(Utility.UserPermissions.BulkViewPins))
  195. RightButtonList.Remove(this.btnViewPINs);
  196. int ButtonX = 12;
  197. foreach (Button b in LeftButtonList)
  198. {
  199. b.Location = new Point(ButtonX, 0);
  200. b.Show();
  201. ButtonX += 106;
  202. }
  203. ButtonX = pnlSplitGrids.Width - 378;
  204. RightButtonList.Reverse();
  205. foreach (Button b in RightButtonList)
  206. {
  207. b.Location = new Point(ButtonX, 0);
  208. b.Show();
  209. ButtonX -= 106;
  210. }
  211. lblLoading.Show();
  212. dtpFilterStartDate.Value = DateTime.Now.AddMonths(-3);
  213. Globals.OpenBatches = new List<int>();
  214. LoadingThread = new Thread(() =>
  215. {
  216. Invoke(new Action(() =>
  217. {
  218. this.Enabled = false;
  219. PopulateGrid();
  220. this.Enabled = true;
  221. }));
  222. if (Globals.SessionMode == SessionModes.Online)
  223. {
  224. Utility.SyncAllBatches();
  225. }
  226. Invoke(new Action(() =>
  227. {
  228. PopulateGrid();
  229. }));
  230. });
  231. LoadingThread.Start();
  232. Utility.InitialiseUserLimits();
  233. }
  234. private void btnOrder_Click(object sender, EventArgs e)
  235. {
  236. OrderForm orderform = new OrderForm();
  237. orderform.SourceForm = this;
  238. orderform.Show();
  239. }
  240. private void btnPrint_Click(object sender, EventArgs e)
  241. {
  242. if (dgvBatches.SelectedRows.Count == 0)
  243. {
  244. MessageBox.Show("Please choose a batch to print.", "No batch selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  245. return;
  246. }
  247. if ((string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["Exported"].Index].Value != "")
  248. {
  249. MessageBox.Show("This batch has been exported previously. Exported batches cannot be printed.", "Cannot print batch", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  250. return;
  251. }
  252. if (Utility.CheckUserAccess(Utility.UserPermissions.BulkOrder)) { //Only check for undownloaded vouchers if the user is able to see them
  253. if ((string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["ReadyForDownload"].Index].Value == "No") {
  254. MessageBox.Show("This batch is not ready to downloaded and cannot be printed.", "Cannot print batch", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  255. return;
  256. }
  257. }
  258. int BatchID = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["Id"].Index].Value;
  259. if (Globals.OpenBatches.Contains(BatchID)) {
  260. MessageBox.Show("A print dialog is already open for this batch","Cannot open print dialog",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
  261. return;
  262. }
  263. this.BeginInvoke((Action)delegate {
  264. PrintForm PrintFormInstance = new PrintForm();
  265. Globals.OpenBatches.Add(BatchID);
  266. int TotalVouchers = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["DeliveredQuantity"].Index].Value;
  267. int VouchersPrinted = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["PrintedQuantity"].Index].Value;
  268. PrintFormInstance.PrintDescription=(string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["ProductDescription"].Index].Value;
  269. PrintFormInstance.BatchOrderDate=(DateTime)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["OrderDate"].Index].Value;
  270. PrintFormInstance.UnprintedVouchers= TotalVouchers-VouchersPrinted;
  271. PrintFormInstance.TotalVouchers=TotalVouchers;
  272. PrintFormInstance.FaceValue=(string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["FaceValue"].Index].Value;
  273. PrintFormInstance.VoucherTypeName=(string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["VoucherType"].Index].Value;
  274. PrintFormInstance.BatchID=BatchID;
  275. PrintFormInstance.NetworkName = (string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["NetworkName"].Index].Value;
  276. PrintFormInstance.Show();
  277. });
  278. }
  279. private void btnLogout_Click(object sender, EventArgs e)
  280. {
  281. this.Close();
  282. }
  283. private void pnlSplitGrids_Paint(object sender, PaintEventArgs e)
  284. {
  285. }
  286. private void BatchForm_FormClosing(object sender, FormClosingEventArgs e)
  287. {
  288. if (Globals.OpenBatches.Count > 0) {
  289. MessageBox.Show("There are printing jobs in progress - pelase wait for them to complete before logging out.", "Busy printing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  290. e.Cancel = true;
  291. return;
  292. }
  293. if (LoadingThread.IsAlive)
  294. {
  295. LoadingThread.Abort();
  296. }
  297. Utility.Logout();
  298. }
  299. private void LogoutTimer_Tick(object sender, EventArgs e)
  300. {
  301. Utility.Logout();
  302. }
  303. public void ResetTimer()
  304. {
  305. LogoutTimer.Stop();
  306. LogoutTimer.Start();
  307. }
  308. private void btnReExport_Click(object sender, EventArgs e)
  309. {
  310. MessageBox.Show("Please be aware that this function is used for exporting vouchers that have already been exported previously. Use this function with caution.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
  311. ExportForm exportform = new ExportForm(ExportForm.ExportMode.Reexport);
  312. exportform.Show();
  313. }
  314. private void dtpFilterStartDate_CloseUp(object sender, EventArgs e)
  315. {
  316. PopulateGrid();
  317. }
  318. private void dtpFilterEndDate_CloseUp(object sender, EventArgs e)
  319. {
  320. PopulateGrid();
  321. }
  322. private void btnExport_Click(object sender, EventArgs e)
  323. {
  324. ExportForm exportform = new ExportForm(ExportForm.ExportMode.Export);
  325. exportform.Show();
  326. }
  327. private void dgvBatches_CellContentClick(object sender, DataGridViewCellEventArgs e)
  328. {
  329. }
  330. private void rdoFilterUnprinted_CheckedChanged(object sender, EventArgs e)
  331. {
  332. if (rdoFilterUnprinted.Checked)
  333. {
  334. PopulateGrid();
  335. btnPrint.Enabled = true;
  336. btnReprint.Enabled = false;
  337. }
  338. }
  339. private void rdoFilterPrinted_CheckedChanged(object sender, EventArgs e)
  340. {
  341. if (rdoFilterPrinted.Checked)
  342. {
  343. PopulateGrid();
  344. btnPrint.Enabled = false;
  345. btnReprint.Enabled = true;
  346. }
  347. }
  348. private void rdoFilterReprinted_CheckedChanged(object sender, EventArgs e)
  349. {
  350. if (rdoFilterReprinted.Checked)
  351. {
  352. PopulateGrid();
  353. btnPrint.Enabled = false;
  354. btnReprint.Enabled = true;
  355. }
  356. }
  357. private void rdoFilterExported_CheckedChanged(object sender, EventArgs e)
  358. {
  359. if (rdoFilterExported.Checked)
  360. {
  361. PopulateGrid();
  362. btnPrint.Enabled = false;
  363. btnReprint.Enabled = false;
  364. }
  365. }
  366. private void btnOrderReport_Click(object sender, EventArgs e)
  367. {
  368. OrderReport OrderReportForm = new OrderReport();
  369. OrderReportForm.Show();
  370. }
  371. private void btnReprint_Click(object sender, EventArgs e)
  372. {
  373. if (dgvBatches.SelectedRows.Count == 0) {
  374. MessageBox.Show("Please choose a batch to reprint.", "No batch selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  375. return;
  376. }
  377. MessageBox.Show("Please be aware that this function is used for exporting vouchers that have already been exported previously. Use this function with caution.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Stop);
  378. int BatchID = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["Id"].Index].Value;
  379. if ((string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["Exported"].Index].Value != "")
  380. {
  381. MessageBox.Show("This batch has been exported previously. Exported batches cannot be printed.", "Cannot print batch", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  382. return;
  383. }
  384. SQLiteCommand Command = new SQLiteCommand("SELECT COUNT(*) FROM Voucher v LEFT JOIN Logs l ON v.Id = l.VoucherId AND l.EventType = @eventtype WHERE l.VoucherId IS NOT NULL AND v.BatchId=@batchid AND Retry=0", Globals.DBConnection);
  385. Command.Parameters.Add(new SQLiteParameter("@batchid", BatchID));
  386. Command.Parameters.Add(new SQLiteParameter("@eventtype", VendorEvent.VendorEventType.PrintVoucher));
  387. int PrintCount = int.Parse(Command.ExecuteScalar().ToString());
  388. if (PrintCount == 0) {
  389. MessageBox.Show("You can only use the Reprint feature for vouchers that have already been printed. Please choose a batch with previously printed vouchers.", "Cannot reprint batch", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  390. return;
  391. }
  392. if (Utility.CheckUserAccess(Utility.UserPermissions.BulkOrder))
  393. { //Only check for undownloaded vouchers if the user is able to see them
  394. if ((string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["ReadyForDownload"].Index].Value == "No")
  395. {
  396. MessageBox.Show("This batch is not ready to downloaded and cannot be printed.", "Cannot print batch", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  397. return;
  398. }
  399. }
  400. if (Globals.OpenBatches.Contains(BatchID))
  401. {
  402. MessageBox.Show("A print dialog is already open for this batch", "Cannot open print dialog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  403. return;
  404. }
  405. this.BeginInvoke((Action)delegate {
  406. ReprintForm PrintFormInstance = new ReprintForm();
  407. Globals.OpenBatches.Add(BatchID);
  408. int TotalVouchers = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["DeliveredQuantity"].Index].Value;
  409. int VouchersPrinted = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["PrintedQuantity"].Index].Value;
  410. PrintFormInstance.PrintDescription = (string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["ProductDescription"].Index].Value;
  411. PrintFormInstance.BatchOrderDate = (DateTime)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["OrderDate"].Index].Value;
  412. PrintFormInstance.UnprintedVouchers = TotalVouchers - VouchersPrinted;
  413. PrintFormInstance.TotalVouchers = TotalVouchers;
  414. PrintFormInstance.FaceValue = (string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["FaceValue"].Index].Value;
  415. PrintFormInstance.VoucherTypeName = (string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["VoucherType"].Index].Value;
  416. PrintFormInstance.BatchID = BatchID;
  417. PrintFormInstance.NetworkName = (string)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["NetworkName"].Index].Value;
  418. PrintFormInstance.Show();
  419. });
  420. }
  421. private void btnViewPINs_Click(object sender, EventArgs e)
  422. {
  423. VoucherForm ViewPINs = new VoucherForm();
  424. if (dgvBatches.SelectedRows.Count == 0)
  425. {
  426. ViewPINs.BatchID = 0;
  427. }
  428. else
  429. {
  430. ViewPINs.BatchID = (int)dgvBatches.SelectedRows[0].Cells[dgvBatches.Columns["Id"].Index].Value;
  431. }
  432. ViewPINs.Show();
  433. }
  434. private void btnLogout_Paint(object sender, PaintEventArgs e)
  435. {
  436. Button b = sender as Button;
  437. if (!b.Enabled)
  438. {
  439. e.Graphics.Clear(Color.Gray);
  440. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  441. }
  442. }
  443. private void btnOrderReport_Paint(object sender, PaintEventArgs e)
  444. {
  445. Button b = sender as Button;
  446. if (!b.Enabled)
  447. {
  448. e.Graphics.Clear(Color.Gray);
  449. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  450. }
  451. }
  452. private void btnOrder_Paint(object sender, PaintEventArgs e)
  453. {
  454. Button b = sender as Button;
  455. if (!b.Enabled)
  456. {
  457. e.Graphics.Clear(Color.Gray);
  458. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  459. }
  460. }
  461. private void btnPrint_Paint(object sender, PaintEventArgs e)
  462. {
  463. Button b = sender as Button;
  464. if (!b.Enabled)
  465. {
  466. e.Graphics.Clear(Color.Gray);
  467. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  468. }
  469. }
  470. private void btnExport_Paint(object sender, PaintEventArgs e)
  471. {
  472. Button b = sender as Button;
  473. if (!b.Enabled)
  474. {
  475. e.Graphics.Clear(Color.Gray);
  476. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  477. }
  478. }
  479. private void btnViewPINs_Paint(object sender, PaintEventArgs e)
  480. {
  481. Button b = sender as Button;
  482. if (!b.Enabled)
  483. {
  484. e.Graphics.Clear(Color.Gray);
  485. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  486. }
  487. }
  488. private void btnReExport_Paint(object sender, PaintEventArgs e)
  489. {
  490. Button b = sender as Button;
  491. if (!b.Enabled)
  492. {
  493. e.Graphics.Clear(Color.Gray);
  494. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  495. }
  496. }
  497. private void btnReprint_Paint(object sender, PaintEventArgs e)
  498. {
  499. Button b = sender as Button;
  500. if (!b.Enabled)
  501. {
  502. e.Graphics.Clear(Color.Gray);
  503. e.Graphics.DrawImage(b.BackgroundImage, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);
  504. }
  505. }
  506. }
  507. }