You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.8 KiB

  1. using HKLib.Dto;
  2. using HKLib.Interfaces;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using BPA.Helper;
  13. namespace HKCardManager.UserPages
  14. {
  15. public partial class CancellationPage : UserControl
  16. {
  17. public CancellationPage()
  18. {
  19. InitializeComponent();
  20. //this.SizeChanged += CancellationPage_SizeChanged;
  21. }
  22. //private void CancellationPage_SizeChanged(object? sender, EventArgs e)
  23. //{
  24. // panel1.Left = (this.Width - panel1.Width) / 2;
  25. // panel1.Top = (this.Height - panel1.Height) / 2;
  26. //}
  27. private void button2_Click(object sender, EventArgs e)
  28. {
  29. string name = textBox1.Text.Trim();
  30. if (string.IsNullOrEmpty(name))
  31. {
  32. MessageLogNotify.GetInstance.ShowWarning("请输入用户名");
  33. return;
  34. }
  35. string TagName = this.Tag.ToString();
  36. if (string.IsNullOrEmpty(TagName))
  37. {
  38. MessageLogNotify.GetInstance.ShowError("功能名称为空,操作失败,请重试");
  39. }
  40. else
  41. {
  42. int status = 0;
  43. if (TagName == "销户") status = 3;
  44. else if (TagName == "挂失") status = 2;
  45. else if (TagName == "解挂") status = 1;
  46. Task.Factory.StartNew(() =>
  47. {
  48. this.Invoke(() => { button2.Enabled = false; });
  49. var temp = Global.UserListDtos.FirstOrDefault(p => p.UserName == name);
  50. if (temp != null)
  51. {
  52. if (!string.IsNullOrEmpty(temp.CardNum))
  53. {
  54. var res = HKLibHelper.CardStutasChange(new CardStutasDto()
  55. {
  56. keywrod = name,
  57. Stutas = status
  58. });
  59. if (res) MessageLogNotify.GetInstance.Show($"用户 {TagName} 成功");
  60. else MessageLogNotify.GetInstance.ShowError($"用户 {TagName} 失败,请检查名称是否正常");
  61. }
  62. else
  63. {
  64. MessageLogNotify.GetInstance.ShowError("该用户未注册卡号");
  65. }
  66. }
  67. else
  68. {
  69. MessageLogNotify.GetInstance.ShowError("该用户不存在");
  70. }
  71. this.Invoke(() => { button2.Enabled = true; });
  72. });
  73. }
  74. }
  75. }
  76. }